Merge pull request #18960 from vincentjdc/project-edit-fordid-supplier-order
Add an option to forbid changing the project of a supplier order
This commit is contained in:
commit
507d5962ab
@ -149,7 +149,7 @@ if ($action == 'updateMask') {
|
||||
|
||||
$res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
|
||||
$res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED", $doubleapproval, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
|
||||
// TODO We add/delete permission here until permission can have a condition on a global var
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php';
|
||||
$newmodule = new modFournisseur($db);
|
||||
|
||||
@ -144,6 +144,12 @@ $permissiondellink = $usercancreate; // Used by the include of actions_dellink.i
|
||||
$permissiontoedit = $usercancreate; // Used by the include of actions_lineupdown.inc.php
|
||||
$permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php
|
||||
|
||||
// Project permission
|
||||
$caneditproject = false;
|
||||
if (!empty($conf->projet->enabled)) {
|
||||
$caneditproject = empty($conf->global->SUPPLIER_ORDER_FORBID_EDIT_PROJECT) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && preg_match('/^[\(]?PROV/i', $object->ref));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -239,7 +245,7 @@ if (empty($reshook)) {
|
||||
}
|
||||
|
||||
// Set project
|
||||
if ($action == 'classin' && $usercancreate) {
|
||||
if ($action == 'classin' && $usercancreate && $caneditproject) {
|
||||
$result = $object->setProject($projectid);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -1988,7 +1994,7 @@ if ($action == 'create') {
|
||||
$langs->load("projects");
|
||||
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
|
||||
if ($usercancreate) {
|
||||
if ($action != 'classify') {
|
||||
if ($action != 'classify' && $caneditproject) {
|
||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||
}
|
||||
if ($action == 'classify') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user