dolibarr 24.0.0-beta
linesalesrepresentative.tpl.php
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
30// Protection to avoid direct call of template
31if (empty($conf) || !is_object($conf)) {
32 print "Error, template page can't be called as URL";
33 exit(1);
34}
35
36print '<!-- linesalesrepresentative.tpl.php -->';
37
38// Sale representative
39print '<tr><td>';
40print '<table class="nobordernopadding centpercent"><tr><td>';
41print $langs->trans('SalesRepresentatives');
42print '</td>';
43if ($action != 'editsalesrepresentatives' && $user->hasRight('societe', 'creer')) {
44 print '<td class="right">';
45 print '<a class="editfielda reposition" href="' . dolBuildUrl($_SERVER["PHP_SELF"], ['action' => 'editsalesrepresentatives', 'socid' => $object->id], true) . '">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
46 print '</td>';
47}
48print '</tr></table>';
49print '</td><td>';
50
51if ($action == 'editsalesrepresentatives') {
52 print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
53 print '<input type="hidden" name="action" value="set_salesrepresentatives" />';
54 print '<input type="hidden" name="token" value="'.newToken().'" />';
55 print '<input type="hidden" name="socid" value="'.$object->id.'" />';
56 $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 'default', 0, 0, '', 0, '', '', 0, 1);
57
58 $arrayselected = GETPOST('commercial', 'array');
59 if (empty($arrayselected)) {
60 $arrayselected = $object->getSalesRepresentatives($user, 1);
61 }
62 print $form->multiselectarray('commercial', $userlist, $arrayselected, 0, 0, '', 0, "90%");
63 print '<input type="submit" class="button valignmiddle smallpaddingimp" value="'.$langs->trans("Modify").'" />';
64 print '</form>';
65} else {
66 $listsalesrepresentatives = $object->getSalesRepresentatives($user);
67
68 $nbofsalesrepresentative = is_array($listsalesrepresentatives) ? count($listsalesrepresentatives) : 0;
69 if ($nbofsalesrepresentative > 0) {
70 $userstatic = new User($db);
71 foreach ($listsalesrepresentatives as $val) {
72 $userstatic->id = $val['id'];
73 $userstatic->login = $val['login'];
74 $userstatic->lastname = $val['lastname'];
75 $userstatic->firstname = $val['firstname'];
76 $userstatic->status = $val['statut'];
77 $userstatic->photo = $val['photo'];
78 $userstatic->email = $val['email'];
79 $userstatic->office_phone = $val['office_phone'];
80 $userstatic->user_mobile = $val['user_mobile'];
81 $userstatic->job = $val['job'];
82 $userstatic->entity = $val['entity'];
83 $userstatic->gender = $val['gender'];
84 print $userstatic->getNomUrl(-1, '', 0, 0, ($nbofsalesrepresentative > 1 ? 16 : (empty($conf->dol_optimize_smallscreen) ? 24 : 20)));
85 print ' ';
86 }
87 } else {
88 //print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
89 }
90 print '</td></tr>';
91}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage Dolibarr users.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.