diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 7d9059fc9c1..d65a744398f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -190,6 +190,13 @@ if (empty($reshook)) if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } + // Set sales representatives + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) + { + $object->fetch($id); + $result = $object->setSalesRep(GETPOST('commercial', 'array')); + } + if ($action == 'update_extras') { $object->fetch($id); diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index c22aab4cfd1..354b29eabed 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -839,6 +839,13 @@ if (empty($reshook)) $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); } + // Set sales representatives + if ($action == 'set_salesrepresentatives' && $user->rights->societe->creer) + { + $object->fetch($socid); + $result = $object->setSalesRep(GETPOST('commercial', 'array')); + } + $id = $socid; $object->fetch($socid); diff --git a/htdocs/societe/tpl/linesalesrepresentative.tpl.php b/htdocs/societe/tpl/linesalesrepresentative.tpl.php index 8ee338fba44..5b9078e6b76 100644 --- a/htdocs/societe/tpl/linesalesrepresentative.tpl.php +++ b/htdocs/societe/tpl/linesalesrepresentative.tpl.php @@ -23,30 +23,48 @@ if (empty($conf) || !is_object($conf)) } // Sale representative -print ''; +print ''; +print ''; -print ''; +} +print '
'; print $langs->trans('SalesRepresentatives'); print ''; +if ($action != 'editsalesrepresentatives' && $user->rights->societe->creer) { + print ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; + print '
'; +print ''; -$listsalesrepresentatives = $object->getSalesRepresentatives($user); -$nbofsalesrepresentative = count($listsalesrepresentatives); -if ($nbofsalesrepresentative > 0) -{ - $userstatic = new User($db); - foreach ($listsalesrepresentatives as $val) - { - $userstatic->id = $val['id']; - $userstatic->login = $val['login']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->statut = $val['statut']; - $userstatic->photo = $val['photo']; - $userstatic->email = $val['email']; - $userstatic->phone = $val['phone']; - $userstatic->job = $val['job']; - $userstatic->entity = $val['entity']; - print $userstatic->getNomUrl(-1); - print ' '; - } -} else print ''.$langs->trans("NoSalesRepresentativeAffected").''; -print ''; +if ($action == 'editsalesrepresentatives') { + print '
'; + print ''; + print ''; + print ''; + $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1); + $arrayselected = GETPOST('commercial', 'array'); + if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1); + print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%"); + print ''; + print '
'; +} else { + $listsalesrepresentatives = $object->getSalesRepresentatives($user); + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->login = $val['login']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->statut = $val['statut']; + $userstatic->photo = $val['photo']; + $userstatic->email = $val['email']; + $userstatic->phone = $val['phone']; + $userstatic->job = $val['job']; + $userstatic->entity = $val['entity']; + print $userstatic->getNomUrl(-1); + print ' '; + } + } else print '' . $langs->trans("NoSalesRepresentativeAffected") . ''; + print ''; +}