linesalesrepresentative.tpl.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. // Protection to avoid direct call of template
  18. if (empty($conf) || !is_object($conf)) {
  19. print "Error, template page can't be called as URL";
  20. exit;
  21. }
  22. print '<!-- linesalesrepresentative.tpl.php -->';
  23. // Sale representative
  24. print '<tr><td>';
  25. print '<table class="nobordernopadding" width="100%"><tr><td>';
  26. print $langs->trans('SalesRepresentatives');
  27. print '</td>';
  28. if ($action != 'editsalesrepresentatives' && $user->hasRight('societe', 'creer')) {
  29. print '<td class="right">';
  30. print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editsalesrepresentatives&token='.newToken().'&socid='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
  31. print '</td>';
  32. }
  33. print '</tr></table>';
  34. print '</td><td colspan="3">';
  35. if ($action == 'editsalesrepresentatives') {
  36. print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
  37. print '<input type="hidden" name="action" value="set_salesrepresentatives" />';
  38. print '<input type="hidden" name="token" value="'.newToken().'" />';
  39. print '<input type="hidden" name="socid" value="'.$object->id.'" />';
  40. $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1);
  41. $arrayselected = GETPOST('commercial', 'array');
  42. if (empty($arrayselected)) {
  43. $arrayselected = $object->getSalesRepresentatives($user, 1);
  44. }
  45. print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%");
  46. print '<input type="submit" class="button valignmiddle small" value="'.$langs->trans("Modify").'" />';
  47. print '</form>';
  48. } else {
  49. $listsalesrepresentatives = $object->getSalesRepresentatives($user);
  50. $nbofsalesrepresentative = count($listsalesrepresentatives);
  51. if ($nbofsalesrepresentative > 0 && is_array($listsalesrepresentatives)) {
  52. $userstatic = new User($db);
  53. foreach ($listsalesrepresentatives as $val) {
  54. $userstatic->id = $val['id'];
  55. $userstatic->login = $val['login'];
  56. $userstatic->lastname = $val['lastname'];
  57. $userstatic->firstname = $val['firstname'];
  58. $userstatic->statut = $val['statut'];
  59. $userstatic->photo = $val['photo'];
  60. $userstatic->email = $val['email'];
  61. $userstatic->phone = $val['phone'];
  62. $userstatic->job = $val['job'];
  63. $userstatic->entity = $val['entity'];
  64. $userstatic->gender = $val['gender'];
  65. print $userstatic->getNomUrl(-1);
  66. print ' ';
  67. }
  68. } else {
  69. print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>';
  70. }
  71. print '</td></tr>';
  72. }