diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 87d46ea10b0..4b39b2381f7 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -168,19 +168,11 @@ else if ($action == 'addcat') else if ($action == 'set_SUPPLIER_ORDER_OTHER') { $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string - $doubleapproval = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL'); - //$doubleapprovalgroup = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') > 0 ? GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') : ''; + $doubleapproval = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL','alpha'); + $doubleapproval = price2num($doubleapproval ); $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL",$doubleapproval,'chaine',0,'',$conf->entity); - /*if (isset($_POST["SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP"])) - { - $res3 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP",$doubleapprovalgroup,'chaine',0,'',$conf->entity); - } - else - { - $res3=1; - }*/ // 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'; @@ -486,18 +478,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) print $langs->trans("UseDoubleApproval").'
'; print $langs->trans("IfSetToYesDontForgetPermission"); print ''; - print $form->selectyesno('SUPPLIER_ORDER_DOUBLE_APPROVAL', $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL, 1); + print ''; print ''; print ''; print "\n"; $var=!$var; - /*print ''; - print $langs->trans("GroupOfUserForSecondApproval").''; - print $form->select_dolgroups($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP,'SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP', 1); - print ''; - print ''; - print "\n"; - $var=!$var;*/ } print ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6628aeb19d7..9bd341e357c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -703,7 +703,10 @@ class CommandeFournisseur extends CommonOrder { $sql.= " date_approve='".$this->db->idate($now)."',"; $sql.= " fk_user_approve = ".$user->id; - if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)) $movetoapprovestatus=false; + if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) + { + if (empty($this->user_approve_id2)) $movetoapprovestatus=false; // second level approval not done + } } else // request a second level approval { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index a348ad93396..9ca609c154c 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2629,7 +2629,7 @@ elseif (! empty($object->id)) { if ($user->rights->fournisseur->commande->approuver) { - if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && ! empty($object->user_approve_id)) + if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL && ! empty($object->user_approve_id)) { print ''.$langs->trans("ApproveOrder").''; } @@ -2645,23 +2645,26 @@ elseif (! empty($object->id)) } // Second approval (if option SUPPLIER_ORDER_DOUBLE_APPROVAL is set) - if ($object->statut == 1) + if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) { - if ($user->rights->fournisseur->commande->approve2) + if ($object->statut == 1) { - if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && ! empty($object->user_approve_id2)) + if ($user->rights->fournisseur->commande->approve2) { - print ''.$langs->trans("Approve2Order").''; + if (! empty($object->user_approve_id2)) + { + print ''.$langs->trans("Approve2Order").''; + } + else + { + print ''.$langs->trans("Approve2Order").''; + } } else { - print ''.$langs->trans("Approve2Order").''; + print ''.$langs->trans("Approve2Order").''; } } - else - { - print ''.$langs->trans("Approve2Order").''; - } } // Refuse diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 39b3ee8c3d9..85b01c6c25a 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -43,4 +43,4 @@ ListOfSupplierOrders=List of supplier orders MenuOrdersSupplierToBill=Supplier orders to invoice NbDaysToDelivery=Delivery delay in days DescNbDaysToDelivery=The biggest deliver delay of the products from this order -UseDoubleApproval=Use double approval (the second approval can be done by any user with the dedicated permission) \ No newline at end of file +UseDoubleApproval=Use double approval when amount (without tax) is higher than (The second approval can be done by any user with the dedicated permission. Set to 0 for no double approval) \ No newline at end of file