dolibarr  17.0.4
linesalesrepresentative.tpl.php
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 // Protection to avoid direct call of template
19 if (empty($conf) || !is_object($conf)) {
20  print "Error, template page can't be called as URL";
21  exit;
22 }
23 
24 print '<!-- linesalesrepresentative.tpl.php -->';
25 
26 // Sale representative
27 print '<tr><td>';
28 print '<table class="nobordernopadding" width="100%"><tr><td>';
29 print $langs->trans('SalesRepresentatives');
30 print '</td>';
31 if ($action != 'editsalesrepresentatives' && $user->hasRight('societe', 'creer')) {
32  print '<td class="right">';
33  print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editsalesrepresentatives&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
34  print '</td>';
35 }
36 print '</tr></table>';
37 print '</td><td colspan="3">';
38 
39 if ($action == 'editsalesrepresentatives') {
40  print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
41  print '<input type="hidden" name="action" value="set_salesrepresentatives" />';
42  print '<input type="hidden" name="token" value="'.newToken().'" />';
43  print '<input type="hidden" name="socid" value="'.$object->id.'" />';
44  $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1);
45  $arrayselected = GETPOST('commercial', 'array');
46  if (empty($arrayselected)) {
47  $arrayselected = $object->getSalesRepresentatives($user, 1);
48  }
49  print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%");
50  print '<input type="submit" class="button valignmiddle small" value="'.$langs->trans("Modify").'" />';
51  print '</form>';
52 } else {
53  $listsalesrepresentatives = $object->getSalesRepresentatives($user);
54  $nbofsalesrepresentative = count($listsalesrepresentatives);
55  if ($nbofsalesrepresentative > 0 && is_array($listsalesrepresentatives)) {
56  $userstatic = new User($db);
57  foreach ($listsalesrepresentatives as $val) {
58  $userstatic->id = $val['id'];
59  $userstatic->login = $val['login'];
60  $userstatic->lastname = $val['lastname'];
61  $userstatic->firstname = $val['firstname'];
62  $userstatic->statut = $val['statut'];
63  $userstatic->photo = $val['photo'];
64  $userstatic->email = $val['email'];
65  $userstatic->phone = $val['phone'];
66  $userstatic->job = $val['job'];
67  $userstatic->entity = $val['entity'];
68  $userstatic->gender = $val['gender'];
69  print $userstatic->getNomUrl(-1);
70  print ' ';
71  }
72  } else {
73  print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
74  }
75  print '</td></tr>';
76 }
Class to manage Dolibarr users.
Definition: user.class.php:47
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.