diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index ee4d05231ee..1fbabc01462 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1063,6 +1063,39 @@ else $("#TypeName").html(document.formsoc.LastName.value); document.formsoc.private.value=1; }); + + init_customer_categ(); + $("#customerprospect").change(function() { + init_customer_categ(); + }); + function init_customer_categ() { + console.log("is customer or prospect = "+jQuery("#customerprospect").val()); + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').')) + { + jQuery(".visibleifcustomer").hide(); + } + else + { + jQuery(".visibleifcustomer").show(); + } + } + + init_supplier_categ(); + $("#fournisseur").change(function() { + init_supplier_categ(); + }); + function init_supplier_categ() { + console.log("is supplier = "+jQuery("#fournisseur").val()); + if (jQuery("#fournisseur").val() == 0) + { + jQuery(".visibleifsupplier").hide(); + } + else + { + jQuery(".visibleifsupplier").show(); + } + } + $("#selectcountry_id").change(function() { document.formsoc.action.value="create"; document.formsoc.submit(); @@ -1421,22 +1454,20 @@ else $langs->load('categories'); // Customer - if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); - print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, - null, "90%"); - print ""; - } + //if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { + print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, 'parent', null, null, 1); + print $form->multiselectarray('custcats', $cate_arbo, GETPOST('custcats', 'array'), null, null, null, null, "90%"); + print ""; + //} // Supplier - if ($object->fournisseur) { - print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); - print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, - null, "90%"); - print ""; - } + //if ($object->fournisseur) { + print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, 'parent', null, null, 1); + print $form->multiselectarray('suppcats', $cate_arbo, GETPOST('suppcats', 'array'), null, null, null, null, "90%"); + print ""; + //} } // Multicurrency @@ -1488,11 +1519,6 @@ else } elseif ($action == 'edit') { - /* - * Edition - */ - - //print load_fiche_titre($langs->trans("EditCompany")); if ($socid) @@ -1612,8 +1638,10 @@ else $sub2=0; }else{$sub2=1;} - print "\n".''."\n"; + init_customer_categ(); + $("#customerprospect").change(function() { + init_customer_categ(); + }); + function init_customer_categ() { + console.log("is customer or prospect = "+jQuery("#customerprospect").val()); + if (jQuery("#customerprospect").val() == 0 && (jQuery("#fournisseur").val() == 0 || '.(empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER)?'1':'0').')) + { + jQuery(".visibleifcustomer").hide(); + } + else + { + jQuery(".visibleifcustomer").show(); + } + } + init_supplier_categ(); + $("#fournisseur").change(function() { + init_supplier_categ(); + }); + function init_supplier_categ() { + console.log("is supplier = "+jQuery("#fournisseur").val()); + if (jQuery("#fournisseur").val() == 0) + { + jQuery(".visibleifsupplier").hide(); + } + else + { + jQuery(".visibleifsupplier").show(); + } + }; - if ($conf->use_javascript_ajax) - { - print "\n".''."\n"; } @@ -2022,34 +2075,30 @@ else if (! empty($conf->categorie->enabled) && ! empty($user->rights->categorie->lire)) { // Customer - if ($object->prospect || $object->client || (! $object->fournisseur && ! empty($conf->global->THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER))) { - print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; - print ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); - $c = new Categorie($db); - $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); - $arrayselected=array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); - print ""; + print '' . fieldLabel('CustomersCategoriesShort', 'custcats') . ''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_CUSTOMER); + $arrayselected=array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; } + print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print ""; // Supplier - if ($object->fournisseur) { - print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; - print ''; - $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); - $c = new Categorie($db); - $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); - $arrayselected=array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; - } - print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); - print ""; + print '' . fieldLabel('SuppliersCategoriesShort', 'suppcats') . ''; + print ''; + $cate_arbo = $form->select_all_categories(Categorie::TYPE_SUPPLIER, null, null, null, null, 1); + $c = new Categorie($db); + $cats = $c->containing($object->id, Categorie::TYPE_SUPPLIER); + $arrayselected=array(); + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; } + print $form->multiselectarray('suppcats', $cate_arbo, $arrayselected, '', 0, '', 0, '90%'); + print ""; } // Multicurrency