From 5126786d60b27e6590bfac02c616539e8d25f05a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Aug 2016 15:46:31 +0200 Subject: [PATCH] NEW Add option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED --- htdocs/admin/supplier_order.php | 16 ++++++++-------- htdocs/core/modules/modFournisseur.class.php | 4 ++-- .../fourn/class/fournisseur.commande.class.php | 8 ++++---- htdocs/fourn/commande/card.php | 8 ++++---- htdocs/langs/en_US/admin.lang | 2 ++ htdocs/langs/en_US/suppliers.lang | 1 - 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 50eb9c9a322..b19831502f9 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -169,11 +169,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','alpha'); + $doubleapproval = GETPOST('SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED','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); + $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'; @@ -189,7 +189,7 @@ else if ($action == 'set_SUPPLIER_ORDER_OTHER') $newmodule->rights[$r][4] = 'commande'; $newmodule->rights[$r][5] = 'approve2'; - if ($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) + if ($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { $newmodule->insert_permissions(1); } @@ -474,18 +474,18 @@ print ''.$langs->trans("Value").''; print ' '; print "\n"; $var=false; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) -{ +//if ($conf->global->MAIN_FEATURES_LEVEL > 0) +//{ print ''; - print $langs->trans("UseDoubleApproval").'
'; + print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'
'; print $langs->trans("IfSetToYesDontForgetPermission"); print ''; - print ''; + print ''; print ''; print ''; print "\n"; $var=!$var; -} +//} print ''; print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')
'; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 794b6cb50ff..7d5d6752281 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -261,7 +261,7 @@ class modFournisseur extends DolibarrModules $this->rights[$r][4] = 'commande'; $this->rights[$r][5] = 'export'; - if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)) + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { $r++; $this->rights[$r][0] = 1190; @@ -449,7 +449,7 @@ class modFournisseur extends DolibarrModules $this->export_permission[$r]=array(array("fournisseur","commande","export")); $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.date_approve'=>'DateApprove','f.date_approve2'=>'DateApprove2','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'ua1.login'=>'ApprovedBy','ua2.login'=>'ApprovedBy2','fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef','p.label'=>'ProductLabel','project.rowid'=>'ProjectId','project.ref'=>'ProjectRef','project.title'=>'ProjectLabel'); - if (empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)) + if (empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { unset($this->export_fields_array['f.date_approve2']); unset($this->export_fields_array['ua2.login']); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 29670e28dc8..54241a36eee 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -71,7 +71,7 @@ class CommandeFournisseur extends CommonOrder public $date; public $date_valid; public $date_approve; - public $date_approve2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set + public $date_approve2; // Used when SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set public $date_commande; /** @@ -101,7 +101,7 @@ class CommandeFournisseur extends CommonOrder public $user_author_id; public $user_valid_id; public $user_approve_id; - public $user_approve_id2; // Used when SUPPLIER_ORDER_DOUBLE_APPROVAL is set + public $user_approve_id2; // Used when SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set //Incoterms public $fk_incoterms; @@ -718,7 +718,7 @@ class CommandeFournisseur extends CommonOrder * * @param User $user Object user * @param int $idwarehouse Id of warhouse for stock change - * @param int $secondlevel 0=Standard approval, 1=Second level approval (used when option SUPPLIER_ORDER_DOUBLE_APPROVAL is set) + * @param int $secondlevel 0=Standard approval, 1=Second level approval (used when option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) * @return int <0 if KO, >0 if OK */ public function approve($user, $idwarehouse=0, $secondlevel=0) @@ -761,7 +761,7 @@ 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) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if (empty($this->user_approve_id2)) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 500b240fa16..a316aaf0f6a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2659,7 +2659,7 @@ elseif (! empty($object->id)) { if ($user->rights->fournisseur->commande->approuver) { - 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)) + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED && ! empty($object->user_approve_id)) { print ''.$langs->trans("ApproveOrder").''; } @@ -2674,8 +2674,8 @@ elseif (! empty($object->id)) } } - // Second approval (if option SUPPLIER_ORDER_DOUBLE_APPROVAL is set) - if (! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL) + // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED is set) + if (! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $object->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if ($object->statut == 1) { @@ -2732,7 +2732,7 @@ elseif (! empty($object->id)) $buttonshown++; } } - if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL)) + if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED)) { if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2)) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index df79240c4b4..6ce618f5bbd 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -390,6 +390,8 @@ EnableAndSetupModuleCron=If you want to have this recurring invoice beeing gener ModuleCompanyCodeAquarium=Return an accountancy code built by:
%s followed by third party supplier code for a supplier accountancy code,
%s followed by third party customer code for a customer accountancy code. ModuleCompanyCodePanicum=Return an empty accountancy code. ModuleCompanyCodeDigitaria=Accountancy code depends on third party code. The code is composed of the character "C" in the first position followed by the first 5 characters of the third party code. +Use3StepsApproval=By default, Purchase Orders need to be created and approved by 2 different users (one step/user to validate and one step/user to approve. Note that if user has both permission to create and approve, one step/user will be enough). You can ask with this option to introduce an third step/user approval, if amount is higher than a dedicated value (so 3 steps will be necessary: 1 validation, 2=first approval and 3=second approval). Set this to 0 if only one approval is required, set it to a very low value (0.1) if second approval is always required. +UseDoubleApproval=Use a 3 steps approval when amount (without tax) is higher than... # Modules Module0Name=Users & groups diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index abacb3d7660..6e554c6545e 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -36,7 +36,6 @@ 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 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) SupplierReputation=Supplier reputation DoNotOrderThisProductToThisSupplier=Do not order NotTheGoodQualitySupplier=Wrong quality