diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 8fb590d61b4..a1727d770a4 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1245,7 +1245,7 @@ if ($id > 0) print ''; - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + if (! empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_CUSTOMER_CARD)) { // List of contacts show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 3cb683a0e9b..f616ca728b6 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -49,8 +49,8 @@ class Contact extends CommonObject */ public $fields=array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'), - 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Reference of object'), - 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1, 'comment'=>'Reference of object'), + 'lastname' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'firstname' =>array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>11, 'searchall'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>60), 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>61), diff --git a/htdocs/core/actions_changeselectedfields.inc.php b/htdocs/core/actions_changeselectedfields.inc.php index 11884f81224..6d39272f74e 100644 --- a/htdocs/core/actions_changeselectedfields.inc.php +++ b/htdocs/core/actions_changeselectedfields.inc.php @@ -33,14 +33,14 @@ if (GETPOST('formfilteraction') == 'listafterchangingselectedfields') $tabparam=array(); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - + if (GETPOST("selectedfields")) $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=GETPOST("selectedfields"); else $tabparam["MAIN_SELECTEDFIELDS_".$varpage]=''; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - + $result=dol_set_user_param($db, $conf, $user, $tabparam); - + //$action='list'; //var_dump($tabparam);exit; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index dd8081754d8..a1d051440c3 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -259,9 +259,6 @@ class Conf // Load translation object with current language if (empty($this->global->MAIN_LANG_DEFAULT)) $this->global->MAIN_LANG_DEFAULT="en_US"; - //if (! isset($this->global->MAIN_REPEATCONTACTONEACHTAB)) $this->global->MAIN_REPEATCONTACTONEACHTAB=1; - //if (! isset($this->global->MAIN_REPEATADDRESSONEACHTAB)) $this->global->MAIN_REPEATADDRESSONEACHTAB=1; - $rootfordata = DOL_DATA_ROOT; $rootforuser = DOL_DATA_ROOT; // If multicompany module is enabled, we redefine the root of data diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 9a750639182..357771f04d3 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1351,28 +1351,48 @@ class ExtraFields /** * Return HTML string to put an output field into a page * - * @param string $key Key of attribute - * @param string $value Value to show - * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) - * @return string Formated value + * @param string $key Key of attribute + * @param string $value Value to show + * @param string $moreparam To add more parameters on html input tag (only checkbox use html input for output rendering) + * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data + * @return string Formated value */ - function showOutputField($key,$value,$moreparam='') + function showOutputField($key, $value, $moreparam='', $extrafieldsobjectkey='') { global $conf,$langs; - $elementtype=$this->attribute_elementtype[$key]; // seems not used - $label=$this->attribute_label[$key]; - $type=$this->attribute_type[$key]; - $size=$this->attribute_size[$key]; - $default=$this->attribute_default[$key]; - $computed=$this->attribute_computed[$key]; - $unique=$this->attribute_unique[$key]; - $required=$this->attribute_required[$key]; - $param=$this->attribute_param[$key]; - $perms=$this->attribute_perms[$key]; - $langfile=$this->attribute_langfile[$key]; - $list=$this->attribute_list[$key]; - $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + if (! empty($extrafieldsobjectkey)) + { + $elementtype=$this->attributes[$extrafieldsobjectkey]['elementtype'][$key]; // seems not used + $label=$this->attributes[$extrafieldsobjectkey]['label'][$key]; + $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + $size=$this->attributes[$extrafieldsobjectkey]['size'][$key]; + $default=$this->attributes[$extrafieldsobjectkey]['default'][$key]; + $computed=$this->attributes[$extrafieldsobjectkey]['computed'][$key]; + $unique=$this->attributes[$extrafieldsobjectkey]['unique'][$key]; + $required=$this->attributes[$extrafieldsobjectkey]['required'][$key]; + $param=$this->attributes[$extrafieldsobjectkey]['param'][$key]; + $perms=$this->attributes[$extrafieldsobjectkey]['perms'][$key]; + $langfile=$this->attributes[$extrafieldsobjectkey]['langfile'][$key]; + $list=$this->attributes[$extrafieldsobjectkey]['list'][$key]; + $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } + else + { + $elementtype=$this->attribute_elementtype[$key]; // seems not used + $label=$this->attribute_label[$key]; + $type=$this->attribute_type[$key]; + $size=$this->attribute_size[$key]; + $default=$this->attribute_default[$key]; + $computed=$this->attribute_computed[$key]; + $unique=$this->attribute_unique[$key]; + $required=$this->attribute_required[$key]; + $param=$this->attribute_param[$key]; + $perms=$this->attribute_perms[$key]; + $langfile=$this->attribute_langfile[$key]; + $list=$this->attribute_list[$key]; + $hidden=(($list == 0) ? 1 : 0); // If zero, we are sure it is hidden, otherwise we show. If it depends on mode (view/create/edit form or list, this must be filtered by caller) + } if ($hidden) return ''; // This is a protection. If field is hidden, we should just not call this method. @@ -1600,6 +1620,7 @@ class ExtraFields elseif ($type == 'link') { $out=''; + // only if something to display (perf) if ($value) { @@ -1648,14 +1669,16 @@ class ExtraFields /** * Return tag to describe alignement to use for this extrafield * - * @param string $key Key of attribute - * @return string Formated value + * @param string $key Key of attribute + * @param string $extrafieldsobjectkey If defined, use the new method to get extrafields data + * @return string Formated value */ - function getAlignFlag($key) + function getAlignFlag($key, $extrafieldsobjectkey='') { global $conf,$langs; - $type=$this->attribute_type[$key]; + if (! empty($extrafieldsobjectkey)) $type=$this->attributes[$extrafieldsobjectkey]['type'][$key]; + else $type=$this->attribute_type[$key]; $align=''; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 48914ebd69f..0c62c190992 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -640,7 +640,6 @@ function isInEEC($object) function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelink=0, $morehtmlright='') { global $user; - global $bc; $i = -1 ; @@ -768,10 +767,10 @@ function show_projects($conf, $langs, $db, $object, $backtopage='', $nocreatelin */ function show_contacts($conf,$langs,$db,$object,$backtopage='') { - global $user,$conf; - global $bc; + global $user,$conf,$extrafields,$hookmanager; + global $contextpage; - $form= new Form($db); + $form = new Form($db); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -782,24 +781,67 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') $search_addressphone = GETPOST("search_addressphone",'alpha'); if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="p.lastname"; + if (! $sortfield) $sortfield="t.lastname"; + if (! empty($conf->clicktodial->enabled)) + { + $user->fetch_clicktodial(); // lecture des infos de clicktodial du user + } + + + $contactstatic = new Contact($db); + + $extralabels=$extrafields->fetch_name_optionals_label($contactstatic->table_element); + + $contactstatic->fields=array( + 'name' =>array('type'=>'varchar(128)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1), + 'poste' =>array('type'=>'varchar(128)', 'label'=>'PostOfFunction', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>20), + 'address' =>array('type'=>'varchar(128)', 'label'=>'Address', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>30), + 'statut' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>40, 'arrayofkeyval'=>array(0=>$contactstatic->LibStatut(0,1), 1=>$contactstatic->LibStatut(1,1))), + ); + + // Definition of fields for list + $arrayfields=array( + 't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID?1:0), 'position'=>1), + 't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10), + 't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20), + 't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30), + 't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>40, 'align'=>'center'), + ); + // Extra fields + if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) + { + foreach($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) + { + if (! empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$contactstatic->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$contactstatic->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$contactstatic->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$contactstatic->table_element]['list'][$key])!=3 && $extrafields->attributes[$contactstatic->table_element]['perms'][$key])); + } + } + + // Initialize array of search criterias + $search=array(); + foreach($contactstatic->fields as $key => $val) + { + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); + } + + + // Purge search criteria if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { $search_status = ''; $search_name = ''; $search_addressphone = ''; $search_array_options=array(); + + foreach($contactstatic->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; } - $i=-1; - - $contactstatic = new Contact($db); - - if (! empty($conf->clicktodial->enabled)) - { - $user->fetch_clicktodial(); // lecture des infos de clicktodial - } + $contactstatic->fields = dol_sort_array($contactstatic->fields, 'position'); + $arrayfields = dol_sort_array($arrayfields, 'position'); $buttoncreate=''; if ($user->rights->societe->contact->creer) @@ -815,25 +857,30 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='') print load_fiche_titre($title, $buttoncreate,''); print '