diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 87718a7def1..431b1d2f9bf 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -68,6 +68,29 @@ class ActionsCardCommon { $this->tpl[$key] = $value; } + + if ($action == 'create') + { + if ($conf->use_javascript_ajax) + { + $this->tpl['ajax_selecttype'] = "\n".''."\n"; + } + } if ($action == 'create' || $action == 'edit') { @@ -97,19 +120,6 @@ class ActionsCardCommon // We verified if the tag prefix is used if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); - // Load object modCodeFournisseur - $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; - if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; - if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') - { - $module = substr($module, 0, dol_strlen($module)-4); - } - require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); - $modCodeFournisseur = new $module; - $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto; - // We verified if the tag prefix is used - if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed(); - // TODO create a function $this->tpl['select_customertype'] = ''; $this->tpl['select_customertype'].= 'object->client==2?' selected="selected"':'').'>'.$langs->trans('Prospect').''; @@ -124,18 +134,36 @@ class ActionsCardCommon $this->tpl['ismodifiable_customercode'] = $this->object->codeclient_modifiable(); $s=$modCodeClient->getToolTip($langs,$this->object,0); $this->tpl['help_customercode'] = $form->textwithpicto('',$s,1); - - // Supplier - $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1); - $this->tpl['suppliercode'] = $this->object->code_fournisseur; - if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1); - $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable(); - $s=$modCodeFournisseur->getToolTip($langs,$this->object,1); - $this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1); - - $this->object->LoadSupplierCateg(); - $this->tpl['suppliercategory'] = $this->object->SupplierCategories; - $this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1); + + if ($conf->fournisseur->enabled) + { + $this->tpl['supplier_enabled'] = 1; + + // Load object modCodeFournisseur + $module=$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; + if (! $module) $module=$conf->global->SOCIETE_CODECLIENT_ADDON; + if (substr($module, 0, 15) == 'mod_codeclient_' && substr($module, -3) == 'php') + { + $module = substr($module, 0, dol_strlen($module)-4); + } + require_once(DOL_DOCUMENT_ROOT ."/includes/modules/societe/".$module.".php"); + $modCodeFournisseur = new $module; + $this->tpl['auto_suppliercode'] = $modCodeFournisseur->code_auto; + // We verified if the tag prefix is used + if ($modCodeFournisseur->code_auto) $this->tpl['prefix_suppliercode'] = $modCodeFournisseur->verif_prefixIsUsed(); + + // Supplier + $this->tpl['yn_supplier'] = $form->selectyesno("fournisseur",$this->object->fournisseur,1); + $this->tpl['suppliercode'] = $this->object->code_fournisseur; + if ((!$this->object->code_fournisseur || $this->object->code_fournisseur == -1) && $modCodeFournisseur->code_auto) $this->tpl['suppliercode'] = $modCodeFournisseur->getNextValue($this->object,1); + $this->tpl['ismodifiable_suppliercode'] = $this->object->codefournisseur_modifiable(); + $s=$modCodeFournisseur->getToolTip($langs,$this->object,1); + $this->tpl['help_suppliercode'] = $form->textwithpicto('',$s,1); + + $this->object->LoadSupplierCateg(); + $this->tpl['suppliercategory'] = $this->object->SupplierCategories; + $this->tpl['select_suppliercategory'] = $form->selectarray("fournisseur_categorie",$this->object->SupplierCategories,$_POST["fournisseur_categorie"],1); + } // Zip $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->cp,'zipcode',array('town','selectpays_id','departement_id'),6); diff --git a/htdocs/societe/canvas/default/tpl/card_create.tpl.php b/htdocs/societe/canvas/default/tpl/card_create.tpl.php index bbc33ed39ca..384854cca58 100644 --- a/htdocs/societe/canvas/default/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/default/tpl/card_create.tpl.php @@ -22,23 +22,7 @@ use_javascript_ajax) { ?> - - +control->tpl['ajax_selecttype']; ?> trans("ThirdPartyType") ?>: > @@ -83,6 +67,7 @@ jQuery(document).ready(function () { +control->tpl['supplier_enabled']) { ?> trans('Supplier'); ?> control->tpl['yn_supplier']; ?> @@ -97,9 +82,7 @@ jQuery(document).ready(function () { -control->tpl['fournisseur']) { - if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?> +control->tpl['suppliercategory']) > 0) { ?> trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?> diff --git a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php index a6db140a9b6..31e15c2f591 100644 --- a/htdocs/societe/canvas/individual/tpl/card_create.tpl.php +++ b/htdocs/societe/canvas/individual/tpl/card_create.tpl.php @@ -22,23 +22,7 @@ use_javascript_ajax) { ?> - - +control->tpl['ajax_selecttype']; ?> trans("ThirdPartyType") ?>: > @@ -95,6 +79,7 @@ jQuery(document).ready(function () { +control->tpl['supplier_enabled']) { ?> trans('Supplier'); ?> control->tpl['yn_supplier']; ?> @@ -109,9 +94,7 @@ jQuery(document).ready(function () { -control->tpl['fournisseur']) { - if (sizeof($this->control->tpl['suppliercategory']) > 0) { ?> +control->tpl['suppliercategory']) > 0) { ?> trans('SupplierCategory'); ?> control->tpl['select_suppliercategory']; ?>