diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7096f5a3b32..9eaf5ab79d1 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -283,6 +283,9 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ $arrayfields['s.price_level'] = array('label'=>"PriceLevel", 'position'=>30, 'checked'=>0); } +// Add non object fields to fields for list +$arrayfields['sales.representative'] = array('label'=>$langs->trans("SalesRepresentatives"), 'checked'=>1, 'position'=>12); + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -1272,6 +1275,11 @@ if (!empty($arrayfields['s.address']['checked'])) { print ''; print ''; } +// Sales representatives +if (!empty($arrayfields['sales.representative']['checked'])) { + print ''; + print ''; +} // Zip if (!empty($arrayfields['s.zip']['checked'])) { print ''; @@ -1516,6 +1524,10 @@ if (!empty($arrayfields['s.address']['checked'])) { print_liste_field_titre($arrayfields['s.address']['label'], $_SERVER['PHP_SELF'], 's.address', '', $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; } +if (!empty($arrayfields['sales.representative']['checked'])) { + print_liste_field_titre($arrayfields['sales.representative']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); + $totalarray['nbfield']++; +} if (!empty($arrayfields['s.zip']['checked'])) { print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], "s.zip", "", $param, '', $sortfield, $sortorder); $totalarray['nbfield']++; @@ -1787,6 +1799,44 @@ while ($i < $imaxinloop) { $totalarray['nbfield']++; } } + // Sales Representative + if (!empty($arrayfields['sales.representative']['checked'])) { + print ''; + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + } + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } // Zip if (!empty($arrayfields['s.zip']['checked'])) { print "".dol_escape_htmltag($companystatic->zip)."\n";