diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 5910f77a819..43230d8f9b0 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -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 /* @@ -152,7 +166,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) { @@ -165,7 +179,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 @@ -189,10 +203,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) @@ -223,7 +234,7 @@ if (empty($reshook)) } } - 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) @@ -231,7 +242,7 @@ if (empty($reshook)) } // Create supplier proposal - elseif ($action == 'add' && $user->rights->supplier_proposal->creer) + elseif ($action == 'add' && $usercancreate) { $object->socid = $socid; $object->fetch_thirdparty(); @@ -460,7 +471,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); @@ -468,7 +479,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); @@ -476,7 +487,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'; @@ -499,12 +510,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); @@ -522,7 +533,7 @@ if (empty($reshook)) } } - 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"]); @@ -534,7 +545,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; @@ -845,7 +856,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 @@ -1013,46 +1024,46 @@ if (empty($reshook)) } } - 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) { + elseif ($action == 'setremisepercent' && $usercancreate) { $result = $object->set_remise_percent($user, $_POST['remise_percent']); } - elseif ($action == 'setremiseabsolue' && $user->rights->supplier_proposal->creer) { + elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); } // 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'))); } @@ -1480,8 +1491,8 @@ if ($action == 'create') $morehtmlref = '
| '; print $langs->trans('BankAccount'); print ' | '; - if ($action != 'editbankaccount' && $user->rights->supplier_proposal->creer) + if ($action != 'editbankaccount' && $usercancreate) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).' | '; print '