NEW can edit and set sales representatives directly on thirdparty card

This commit is contained in:
lvessiller 2020-06-26 12:20:53 +02:00
parent e4922f38ab
commit ad36447295
3 changed files with 56 additions and 24 deletions

View File

@ -190,6 +190,13 @@ if (empty($reshook))
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); 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') { if ($action == 'update_extras') {
$object->fetch($id); $object->fetch($id);

View File

@ -839,6 +839,13 @@ if (empty($reshook))
$result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); $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; $id = $socid;
$object->fetch($socid); $object->fetch($socid);

View File

@ -23,30 +23,48 @@ if (empty($conf) || !is_object($conf))
} }
// Sale representative // Sale representative
print '<tr><td class="titlefield">'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('SalesRepresentatives'); print $langs->trans('SalesRepresentatives');
print '</td>'; print '</td>';
print '<td>'; if ($action != 'editsalesrepresentatives' && $user->rights->societe->creer) {
print '<td class="right">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?action=editsalesrepresentatives&amp;socid=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
print '</td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
$listsalesrepresentatives = $object->getSalesRepresentatives($user); if ($action == 'editsalesrepresentatives') {
$nbofsalesrepresentative = count($listsalesrepresentatives); print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">';
if ($nbofsalesrepresentative > 0) print '<input type="hidden" name="action" value="set_salesrepresentatives" />';
{ print '<input type="hidden" name="token" value="' . newToken() . '" />';
$userstatic = new User($db); print '<input type="hidden" name="socid" value="' . $object->id . '" />';
foreach ($listsalesrepresentatives as $val) $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, '', 0, '', '', 0, 1);
{ $arrayselected = GETPOST('commercial', 'array');
$userstatic->id = $val['id']; if (empty($arrayselected)) $arrayselected = $object->getSalesRepresentatives($user, 1);
$userstatic->login = $val['login']; print $form->multiselectarray('commercial', $userlist, $arrayselected, null, null, null, null, "90%");
$userstatic->lastname = $val['lastname']; print '<input type="submit" class="button valignmiddle" value="' . $langs->trans("Modify") . '" />';
$userstatic->firstname = $val['firstname']; print '</form>';
$userstatic->statut = $val['statut']; } else {
$userstatic->photo = $val['photo']; $listsalesrepresentatives = $object->getSalesRepresentatives($user);
$userstatic->email = $val['email']; $nbofsalesrepresentative = count($listsalesrepresentatives);
$userstatic->phone = $val['phone']; if ($nbofsalesrepresentative > 0) {
$userstatic->job = $val['job']; $userstatic = new User($db);
$userstatic->entity = $val['entity']; foreach ($listsalesrepresentatives as $val) {
print $userstatic->getNomUrl(-1); $userstatic->id = $val['id'];
print ' '; $userstatic->login = $val['login'];
} $userstatic->lastname = $val['lastname'];
} else print '<span class="opacitymedium">'.$langs->trans("NoSalesRepresentativeAffected").'</span>'; $userstatic->firstname = $val['firstname'];
print '</td></tr>'; $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 '<span class="opacitymedium">' . $langs->trans("NoSalesRepresentativeAffected") . '</span>';
print '</td></tr>';
}