Merge pull request #13679 from TobiasSekan/cleanupUserRightsSupplierProposalCard
Cleanup user rights on supplier proposal card
This commit is contained in:
commit
79c2d96375
@ -96,9 +96,23 @@ if ($id > 0 || !empty($ref)) {
|
||||
dol_print_error('', $object->error);
|
||||
}
|
||||
|
||||
$permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->supplier_proposal->creer; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoedit = $user->rights->supplier_proposal->creer; // Used by the include of actions_lineupdown.inc.php
|
||||
// Common permissions
|
||||
$usercanread = $user->rights->supplier_proposal->lire;
|
||||
$usercancreate = $user->rights->supplier_proposal->creer;
|
||||
$usercandelete = $user->rights->supplier_proposal->supprimer;
|
||||
|
||||
// Advanced permissions
|
||||
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)));
|
||||
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance);
|
||||
|
||||
// Additional area permissions
|
||||
$usercanclose = $user->rights->supplier_proposal->cloturer;
|
||||
$usercancreateorder = $user->rights->fournisseur->commande->creer;
|
||||
|
||||
// Permissions for includes
|
||||
$permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php
|
||||
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
|
||||
|
||||
|
||||
/*
|
||||
@ -148,7 +162,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Delete askprice
|
||||
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->supplier_proposal->supprimer)
|
||||
elseif ($action == 'confirm_delete' && $confirm == 'yes' && $usercandelete)
|
||||
{
|
||||
$result = $object->delete($user);
|
||||
if ($result > 0) {
|
||||
@ -161,7 +175,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Remove line
|
||||
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->supplier_proposal->creer)
|
||||
elseif ($action == 'confirm_deleteline' && $confirm == 'yes' && $usercancreate)
|
||||
{
|
||||
$result = $object->deleteline($lineid);
|
||||
// reorder lines
|
||||
@ -185,10 +199,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Validation
|
||||
elseif ($action == 'confirm_validate' && $confirm == 'yes' &&
|
||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer))
|
||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)))
|
||||
)
|
||||
elseif ($action == 'confirm_validate' && $confirm == 'yes' && $usercanvalidate)
|
||||
{
|
||||
$result = $object->valid($user);
|
||||
if ($result >= 0)
|
||||
@ -217,15 +228,14 @@ if (empty($reshook))
|
||||
if (count($object->errors) > 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||
else setEventMessages($langs->trans($object->error), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'setdate_livraison' && $user->rights->supplier_proposal->creer)
|
||||
{
|
||||
} elseif ($action == 'setdate_livraison' && $usercancreate) {
|
||||
$result = $object->set_date_livraison($user, dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']));
|
||||
if ($result < 0)
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
|
||||
// Create supplier proposal
|
||||
elseif ($action == 'add' && $user->rights->supplier_proposal->creer)
|
||||
elseif ($action == 'add' && $usercancreate)
|
||||
{
|
||||
$object->socid = $socid;
|
||||
$object->fetch_thirdparty();
|
||||
@ -449,7 +459,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Reopen proposal
|
||||
elseif ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) {
|
||||
elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) {
|
||||
// prevent browser refresh from reopening proposal several times
|
||||
if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) {
|
||||
$object->reopen($user, SupplierProposal::STATUS_VALIDATED);
|
||||
@ -457,7 +467,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Close proposal
|
||||
elseif ($action == 'close' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) {
|
||||
elseif ($action == 'close' && $usercanclose && !GETPOST('cancel', 'alpha')) {
|
||||
// prevent browser refresh from reopening proposal several times
|
||||
if ($object->statut == SupplierProposal::STATUS_SIGNED) {
|
||||
$object->setStatut(SupplierProposal::STATUS_CLOSE);
|
||||
@ -465,7 +475,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Set accepted/refused
|
||||
elseif ($action == 'setstatut' && $user->rights->supplier_proposal->cloturer && !GETPOST('cancel', 'alpha')) {
|
||||
elseif ($action == 'setstatut' && $usercanclose && !GETPOST('cancel', 'alpha')) {
|
||||
if (!GETPOST('statut')) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("CloseAs")), null, 'errors');
|
||||
$action = 'statut';
|
||||
@ -488,12 +498,12 @@ if (empty($reshook))
|
||||
|
||||
// Actions to build doc
|
||||
$upload_dir = $conf->supplier_proposal->dir_output;
|
||||
$permissiontoadd = $user->rights->supplier_proposal->creer;
|
||||
$permissiontoadd = $usercancreate;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
|
||||
|
||||
// Go back to draft
|
||||
if ($action == 'modif' && $user->rights->supplier_proposal->creer)
|
||||
if ($action == 'modif' && $usercancreate)
|
||||
{
|
||||
$object->setDraft($user);
|
||||
|
||||
@ -509,7 +519,7 @@ if (empty($reshook))
|
||||
$ret = $object->fetch($id); // Reload to get new records
|
||||
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
}
|
||||
} elseif ($action == "setabsolutediscount" && $user->rights->supplier_proposal->creer) {
|
||||
} elseif ($action == "setabsolutediscount" && $usercancreate) {
|
||||
if ($_POST["remise_id"]) {
|
||||
if ($object->id > 0) {
|
||||
$result = $object->insert_discount($_POST["remise_id"]);
|
||||
@ -521,7 +531,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Add a product line
|
||||
if ($action == 'addline' && $user->rights->supplier_proposal->creer)
|
||||
if ($action == 'addline' && $usercancreate)
|
||||
{
|
||||
$langs->load('errors');
|
||||
$error = 0;
|
||||
@ -822,7 +832,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Mise a jour d'une ligne dans la demande de prix
|
||||
elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('save') == $langs->trans("Save")) {
|
||||
elseif ($action == 'updateline' && $usercancreate && GETPOST('save') == $langs->trans("Save")) {
|
||||
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
|
||||
|
||||
// Define info_bits
|
||||
@ -988,42 +998,42 @@ if (empty($reshook))
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'updateline' && $user->rights->supplier_proposal->creer && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
|
||||
} elseif ($action == 'updateline' && $usercancreate && GETPOST('cancel', 'alpha') == $langs->trans('Cancel')) {
|
||||
header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition
|
||||
exit();
|
||||
}
|
||||
|
||||
// Set project
|
||||
elseif ($action == 'classin' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'classin' && $usercancreate) {
|
||||
$object->setProject(GETPOST('projectid'), 'int');
|
||||
}
|
||||
|
||||
// Delivery delay
|
||||
elseif ($action == 'setavailability' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'setavailability' && $usercancreate) {
|
||||
$result = $object->availability($_POST['availability_id']);
|
||||
}
|
||||
|
||||
// Terms of payments
|
||||
elseif ($action == 'setconditions' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'setconditions' && $usercancreate) {
|
||||
$result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
|
||||
} elseif ($action == 'setremisepercent' && $user->rights->supplier_proposal->creer) {
|
||||
$result = $object->set_remise_percent($user, $_POST['remise_percent']);
|
||||
} elseif ($action == 'setremiseabsolue' && $user->rights->supplier_proposal->creer) {
|
||||
$result = $object->set_remise_absolue($user, $_POST['remise_absolue']);
|
||||
} elseif ($action == 'setremisepercent' && $usercancreate) {
|
||||
$result = $object->set_remise_percent($user, GETPOST('remise_percent', 'alpha'));
|
||||
} elseif ($action == 'setremiseabsolue' && $usercancreate) {
|
||||
$result = $object->set_remise_absolue($user, GETPOST('remise_absolue', 'alpha'));
|
||||
}
|
||||
|
||||
// Payment mode
|
||||
elseif ($action == 'setmode' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'setmode' && $usercancreate) {
|
||||
$result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int'));
|
||||
}
|
||||
|
||||
// Multicurrency Code
|
||||
elseif ($action == 'setmulticurrencycode' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'setmulticurrencycode' && $usercancreate) {
|
||||
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
|
||||
}
|
||||
|
||||
// Multicurrency rate
|
||||
elseif ($action == 'setmulticurrencyrate' && $user->rights->supplier_proposal->creer) {
|
||||
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
|
||||
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
|
||||
} elseif ($action == 'update_extras') {
|
||||
$object->oldcopy = dol_clone($object);
|
||||
@ -1447,8 +1457,8 @@ if ($action == 'create')
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Ref supplier
|
||||
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', 0, 1);
|
||||
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->fournisseur->commande->creer, 'string', '', null, null, '', 1);
|
||||
//$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', 0, 1);
|
||||
//$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $usercancreateorder, 'string', '', null, null, '', 1);
|
||||
// Thirdparty
|
||||
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
|
||||
if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/supplier_proposal/list.php?socid='.$object->thirdparty->id.'&search_societe='.urlencode($object->thirdparty->name).'">'.$langs->trans("OtherProposals").'</a>)';
|
||||
@ -1457,7 +1467,7 @@ if ($action == 'create')
|
||||
{
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($user->rights->supplier_proposal->creer)
|
||||
if ($usercancreate)
|
||||
{
|
||||
if ($action != 'classify') {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||
@ -1647,7 +1657,7 @@ if ($action == 'create')
|
||||
print '<table width="100%" class="nobordernopadding"><tr><td>';
|
||||
print $langs->trans('BankAccount');
|
||||
print '</td>';
|
||||
if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer)
|
||||
if ($action != 'editbankaccount' && $usercancreate)
|
||||
print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
@ -1776,7 +1786,7 @@ if ($action == 'create')
|
||||
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, $dateSelector);
|
||||
|
||||
// Form to add new line
|
||||
if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer)
|
||||
if ($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate)
|
||||
{
|
||||
if ($action != 'editline')
|
||||
{
|
||||
@ -1837,22 +1847,20 @@ if ($action == 'create')
|
||||
if ($action != 'statut' && $action != 'editline')
|
||||
{
|
||||
// Validate
|
||||
if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 &&
|
||||
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->creer))
|
||||
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->supplier_proposal->validate_advance)))
|
||||
) {
|
||||
if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 && $usercanvalidate)
|
||||
{
|
||||
if (count($object->lines) > 0)
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a></div>';
|
||||
// else print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans('Validate').'</a>';
|
||||
}
|
||||
|
||||
// Edit
|
||||
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->creer) {
|
||||
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $usercancreate) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a></div>';
|
||||
}
|
||||
|
||||
// ReOpen
|
||||
if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $user->rights->supplier_proposal->cloturer) {
|
||||
if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $usercanclose) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"';
|
||||
print '>'.$langs->trans('ReOpen').'</a></div>';
|
||||
}
|
||||
@ -1860,7 +1868,7 @@ if ($action == 'create')
|
||||
// Send
|
||||
if (empty($user->socid)) {
|
||||
if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) {
|
||||
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) {
|
||||
if ($usercansend) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
|
||||
} else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans('SendMail').'</a></div>';
|
||||
}
|
||||
@ -1868,30 +1876,30 @@ if ($action == 'create')
|
||||
|
||||
// Create an order
|
||||
if (!empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) {
|
||||
if ($user->rights->fournisseur->commande->creer) {
|
||||
if ($usercancreateorder) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("AddOrder").'</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Set accepted/refused
|
||||
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->cloturer) {
|
||||
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $usercanclose) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=statut'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused').'"';
|
||||
print '>'.$langs->trans('SetAcceptedRefused').'</a></div>';
|
||||
}
|
||||
|
||||
// Close
|
||||
if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) {
|
||||
if ($object->statut == SupplierProposal::STATUS_SIGNED && $usercanclose) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close').'"';
|
||||
print '>'.$langs->trans('Close').'</a></div>';
|
||||
}
|
||||
|
||||
// Clone
|
||||
if ($user->rights->supplier_proposal->creer) {
|
||||
if ($usercancreate) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object='.$object->element.'">'.$langs->trans("ToClone").'</a></div>';
|
||||
}
|
||||
|
||||
// Delete
|
||||
if (($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) {
|
||||
if (($object->statut == SupplierProposal::STATUS_DRAFT && $usercancreate) || $usercandelete) {
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete"';
|
||||
print '>'.$langs->trans('Delete').'</a></div>';
|
||||
}
|
||||
@ -1911,8 +1919,8 @@ if ($action == 'create')
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
$filedir = $conf->supplier_proposal->dir_output."/".dol_sanitizeFileName($object->ref);
|
||||
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
|
||||
$genallowed = $user->rights->supplier_proposal->lire;
|
||||
$delallowed = $user->rights->supplier_proposal->creer;
|
||||
$genallowed = $usercanread;
|
||||
$delallowed = $usercancreate;
|
||||
|
||||
print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user