Add column sales representative third party list (#26387)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Mohamed DAOUD 2023-10-30 02:59:52 +01:00 committed by GitHub
parent b8728b5d07
commit 636f9eaced
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 '<input class="flat searchstring maxwidth50imp" type="text" name="search_address" value="'.dol_escape_htmltag($search_address).'">';
print '</td>';
}
// Sales representatives
if (!empty($arrayfields['sales.representative']['checked'])) {
print '<td class="liste_titre">';
print '</td>';
}
// Zip
if (!empty($arrayfields['s.zip']['checked'])) {
print '<td class="liste_titre">';
@ -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 '<td class="nowraponall tdoverflowmax200">';
$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 '&nbsp;';
}
print '</td>';
if (!$i) {
$totalarray['nbfield']++;
}
}
// Zip
if (!empty($arrayfields['s.zip']['checked'])) {
print "<td>".dol_escape_htmltag($companystatic->zip)."</td>\n";