Add an option to forbird changing the project of a supplier order if validated or if in draft but already has a reference (not )

This commit is contained in:
Vincent Dieltiens 2021-10-12 15:15:09 +02:00
parent f3ea05b701
commit 8370973a9d
4 changed files with 19 additions and 2 deletions

View File

@ -149,6 +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);
$res3 = dolibarr_set_const($db, "FORBID_EDIT_PROJECT_ON_SUPPLIER_ORDER", GETPOST('FORBID_EDIT_PROJECT_ON_SUPPLIER_ORDER', 'int'), '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';
@ -532,6 +533,15 @@ if ($conf->reception->enabled) {
print "</td>\n";
print "</tr>\n";
// Option
print '<tr class="oddeven">';
print '<td>'.$langs->trans("SupplierOrderForbidProjectChange").'</td>';
print '<td class="center">'.$form->selectyesno('FORBID_EDIT_PROJECT_ON_SUPPLIER_ORDER', $conf->global->FORBID_EDIT_PROJECT_ON_SUPPLIER_ORDER, 1).'</td>';
print '<td class="center">';
print '<input type="submit" class="button button-edit" value="'.$langs->trans("Modify").'">';
print '</td>';
print '</tr>';
print '</table><br>';
print '</form>';

View File

@ -144,6 +144,11 @@ $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
if (!empty($conf->projet->enabled)) {
$caneditproject = empty($conf->global->FORBID_EDIT_PROJECT_ON_SUPPLIER_ORDER) || ($object->statut == CommandeFournisseur::STATUS_DRAFT && preg_match('/^[\(]?PROV/i', $object->ref));
}
/*
* Actions
@ -239,7 +244,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 +1993,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') {

View File

@ -1436,6 +1436,7 @@ OrdersNumberingModules=Orders numbering models
OrdersModelModule=Order documents models
FreeLegalTextOnOrders=Free text on orders
WatermarkOnDraftOrders=Watermark on draft orders (none if empty)
SupplierOrderForbidProjectChange=Forbid changing the project of a supplier order or a draft which already has a reference
ShippableOrderIconInList=Add an icon in Orders list which indicate if order is shippable
BANK_ASK_PAYMENT_BANK_DURING_ORDER=Ask for bank account destination of order
##### Interventions #####

View File

@ -1428,6 +1428,7 @@ OrdersNumberingModules=Modèles de numérotation des commandes
OrdersModelModule=Modèles de document des commandes
FreeLegalTextOnOrders=Mention complémentaire sur les commandes
WatermarkOnDraftOrders=Filigrane sur les brouillons de commandes (aucun si vide)
SupplierOrderForbidProjectChange=Interdire de modifier le projet d'une commande validée (ou en brouillon mais ayant déjà une référence)
ShippableOrderIconInList=Ajouter une icône dans la liste des commandes qui indique si la commande est expédiable.
BANK_ASK_PAYMENT_BANK_DURING_ORDER=Demander le compte bancaire cible durant la commande
##### Interventions #####