diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 8c8d79f7422..aec9e74dcb8 100755 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -134,7 +134,7 @@ abstract class CommonDocGenerator $object->state=getState($object->state_code,0); } - return array( + $array_thirdparty = array( 'company_name'=>$object->name, 'company_email'=>$object->email, 'company_phone'=>$object->phone, @@ -163,6 +163,25 @@ abstract class CommonDocGenerator 'company_idprof6'=>$object->idprof6, 'company_note'=>$object->note ); + + // Retrieve extrafields + if(is_array($object->array_options) && count($object->array_options)) + { + if(!class_exists('Extrafields')) + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $extralabels = $extrafields->fetch_name_optionals_label('company',true); + + foreach($extrafields->attribute_label as $key=>$label) + { + if($extrafields->attribute_type[$key] == 'price') + { + $object->array_options['options_'.$key] = price($object->array_options['options_'.$key]).' '.$outputlangs->getCurrencySymbol($conf->currency); + } + $array_thirdparty=array_merge($array_thirdparty,array('company_options_'.$key => $object->array_options['options_'.$key])); + } + } + return $array_thirdparty; } /** diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4f583a667f9..f72ddc8d6e2 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -44,6 +44,10 @@ class ExtraFields var $attribute_unique; // Array to store if attribute is required or not var $attribute_required; + // Array to store parameters of attribute (used in select type) + var $attribute_param; + // Int to store position of attribute + var $attribute_pos; var $error; var $errno; @@ -669,7 +673,7 @@ class ExtraFields */ function showOutputField($key,$value,$moreparam='') { - global $conf; + global $conf,$langs; $label=$this->attribute_label[$key]; $type=$this->attribute_type[$key]; diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index b471e19b473..a43179386de 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -47,9 +47,9 @@ DictionnarySetup= Dictionnaires Dictionnary= Dictionnaires DisableJavascript= Désactiver les fonctions Javascript et Ajax ConfirmAjax= Utiliser les popups de confirmation Ajax -UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. +UseSearchToSelectCompany= Utiliser un champ avec autocomplétion pour choisir un tiers (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de tiers (> 100 000), vous pouvez améliorer les performances en définissant la constante SOCIETE_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. ActivityStateToSelectCompany= Ajouter une option de filtrage lors des recherches pour afficher/masquer les tiers en exercice ou ayant cessés d'exercer -UseSearchToSelectContact= Utiliser un champ avec autocomplétion pour choisir un contact (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de produits ou services (> 100 000), vous pouvez améliorer les performances en définissant la constante CONTACT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. +UseSearchToSelectContact= Utiliser un champ avec autocomplétion pour choisir un contact (plutôt qu'une liste déroulante).

Notez que si vous avez un nombre important de contacts (> 100 000), vous pouvez améliorer les performances en définissant la constante CONTACT_DONOTSEARCH_ANYWHERE à 1 dans Configuration->Divers. La recherche sera alors limitée au début de la chaine. SearchFilter=Options des filtres de recherche NumberOfKeyToSearch=Nb carac. déclenchant recherche: %s ViewFullDateActions= Visualiser les dates des actions en entier dans la fiche tiers @@ -931,11 +931,11 @@ MAIN_PROXY_PORT=Port du serveur proxy mandataire MAIN_PROXY_USER=Login pour passer le serveur proxy mandataire MAIN_PROXY_PASS=Mot de passe pour passer le serveur proxy mandataire DefineHereComplementaryAttributes=Définissez ici la liste des attributs supplémentaires, non disponibles en standard, et que vous voulez voir gérer sur les %s. -ExtraFields=Attributs suplémentaires -ExtraFieldsThirdParties=Attributs suplémentaires (tiers) -ExtraFieldsContacts=Attributs suplémentaires (contacts/adresses) -ExtraFieldsMember=Attributs suplémentaires (adhérents) -ExtraFieldsMemberType=Attributs suplémentaires (type d'adhérents) +ExtraFields=Attributs supplémentaires +ExtraFieldsThirdParties=Attributs supplémentaires (tiers) +ExtraFieldsContacts=Attributs supplémentaires (contacts/adresses) +ExtraFieldsMember=Attributs supplémentaires (adhérents) +ExtraFieldsMemberType=Attributs supplémentaires (type d'adhérents) ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte. AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace SendingMailSetup=Configuration de l'envoi par mail @@ -973,7 +973,7 @@ NotificationsDesc= La fonction des notifications par emails permet d'envoyer aut ModelModules=Modèle de documents DocumentModelOdt=Genération depuis des modèles OpenDocument (Fichier .ODT OpenOffice, KOffice, TextEdit...) WatermarkOnDraft=Filigrane sur les documents brouillons -CompanyIdProfChecker=Id professionel unique +CompanyIdProfChecker=Id professionnel unique MustBeUnique=Doit être unique ? MustBeMandatory=Doit être obligatoire? Miscellanous=Divers diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0f5e7051010..7688eec0d66 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -139,6 +139,8 @@ class Societe extends CommonObject var $logo; var $logo_small; var $logo_mini; + + var $array_options; var $oldcopy; @@ -852,6 +854,19 @@ class Societe extends CommonObject $this->import_key = $obj->import_key; $result = 1; + + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label('company',true); + if (count($extralabels)>0) { + $this->array_options = array(); + } + foreach($extrafields->attribute_label as $key=>$label) + { + $this->array_options['options_'.$key]=$label; + } } else { diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index c1dd0c4c09d..cb62e16ab80 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -222,19 +222,20 @@ if (empty($reshook)) { $langs->load("errors"); $error++; $errors[] = $langs->transcountry('ProfId'.$i, $object->country_code)." ".$langs->trans("ErrorProdIdAlreadyExist", $vallabel); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } } $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); $error++; $errors[] = $langs->trans("ErrorProdIdIsMandatory", $langs->transcountry('ProfId'.$i, $object->country_code)); - $action = ($action=='add'?'create':'edit'); + $action = (($action=='add'||$action=='create')?'create':'edit'); } - } + } } if (! $error) @@ -712,8 +713,7 @@ else print "
\n"; } - - dol_htmloutput_errors($error,$errors); + dol_htmloutput_mesg(is_numeric($error)?'':$error, $errors, 'error'); print '
'; @@ -998,14 +998,25 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options["options_".$key])?$object->array_options["options_".$key]:'')); - print ''; + $colspan='0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''; + print ''; print $extrafields->showInputField($key,$value); - print ''."\n"; + print ''; + + if (($e % 2) == 1) print ''."\n"; + $e++; } } @@ -1426,23 +1437,38 @@ else print ''; print ''; } - // Other attributes $parameters=array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $old_pos=0; + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan = '3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - print ''."\n"; + $colspan = '0'; + } + print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; + print '>'.$label.''."\n"; + print ''; print $extrafields->showInputField($key,$value); - print "\n"; + print ""."\n"; + + if (($e % 2) == 1 ) + { + print "\n"; + } + $old_pos = $extrafields->attribute_pos[$key]; + $e++; } } - // Logo print ''; print ''.$langs->trans("Logo").''; @@ -1756,12 +1782,23 @@ else $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { + $e=0; foreach($extrafields->attribute_label as $key=>$label) { + $colspan='3'; $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:(isset($object->array_options['options_'.$key])?$object->array_options['options_'.$key]:'')); - print ''.$label.''; + if (($e % 2) == 0) + { + print ''; + $colspan='0'; + } + print ''.$label.''; + print ''; print $extrafields->showOutputField($key,$value); - print "\n"; + print ""; + + if (($e % 2) == 1) print ''; + $e++; } }