NEW Add option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED

This commit is contained in:
Laurent Destailleur 2016-08-04 15:46:31 +02:00
parent d688681605
commit 5126786d60
6 changed files with 20 additions and 19 deletions

View File

@ -169,11 +169,11 @@ else if ($action == 'addcat')
else if ($action == 'set_SUPPLIER_ORDER_OTHER') else if ($action == 'set_SUPPLIER_ORDER_OTHER')
{ {
$freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string $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 ); $doubleapproval = price2num($doubleapproval );
$res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); $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 // 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'; 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][4] = 'commande';
$newmodule->rights[$r][5] = 'approve2'; $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); $newmodule->insert_permissions(1);
} }
@ -474,18 +474,18 @@ print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
print '<td width="80">&nbsp;</td>'; print '<td width="80">&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$var=false; $var=false;
if ($conf->global->MAIN_FEATURES_LEVEL > 0) //if ($conf->global->MAIN_FEATURES_LEVEL > 0)
{ //{
print '<tr '.$bc[$var].'><td>'; print '<tr '.$bc[$var].'><td>';
print $langs->trans("UseDoubleApproval").'<br>'; print $form->textwithpicto($langs->trans("UseDoubleApproval"), $langs->trans("Use3StepsApproval"), 1, 'help').'<br>';
print $langs->trans("IfSetToYesDontForgetPermission"); print $langs->trans("IfSetToYesDontForgetPermission");
print '</td><td>'; print '</td><td>';
print '<input type="text" size="3" name="SUPPLIER_ORDER_DOUBLE_APPROVAL" value="'.$conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL.'">'; print '<input type="text" size="3" name="SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED" value="'.$conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED.'">';
print '</td><td align="right">'; print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n"; print "</td></tr>\n";
$var=!$var; $var=!$var;
} //}
print '<tr '.$bc[$var].'><td colspan="2">'; print '<tr '.$bc[$var].'><td colspan="2">';
print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>'; print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';

View File

@ -261,7 +261,7 @@ class modFournisseur extends DolibarrModules
$this->rights[$r][4] = 'commande'; $this->rights[$r][4] = 'commande';
$this->rights[$r][5] = 'export'; $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++; $r++;
$this->rights[$r][0] = 1190; $this->rights[$r][0] = 1190;
@ -449,7 +449,7 @@ class modFournisseur extends DolibarrModules
$this->export_permission[$r]=array(array("fournisseur","commande","export")); $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', $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'); '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['f.date_approve2']);
unset($this->export_fields_array['ua2.login']); unset($this->export_fields_array['ua2.login']);

View File

@ -71,7 +71,7 @@ class CommandeFournisseur extends CommonOrder
public $date; public $date;
public $date_valid; public $date_valid;
public $date_approve; 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; public $date_commande;
/** /**
@ -101,7 +101,7 @@ class CommandeFournisseur extends CommonOrder
public $user_author_id; public $user_author_id;
public $user_valid_id; public $user_valid_id;
public $user_approve_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 //Incoterms
public $fk_incoterms; public $fk_incoterms;
@ -718,7 +718,7 @@ class CommandeFournisseur extends CommonOrder
* *
* @param User $user Object user * @param User $user Object user
* @param int $idwarehouse Id of warhouse for stock change * @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 * @return int <0 if KO, >0 if OK
*/ */
public function approve($user, $idwarehouse=0, $secondlevel=0) public function approve($user, $idwarehouse=0, $secondlevel=0)
@ -761,7 +761,7 @@ class CommandeFournisseur extends CommonOrder
{ {
$sql.= " date_approve='".$this->db->idate($now)."',"; $sql.= " date_approve='".$this->db->idate($now)."',";
$sql.= " fk_user_approve = ".$user->id; $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)) if (empty($this->user_approve_id2))
{ {

View File

@ -2659,7 +2659,7 @@ elseif (! empty($object->id))
{ {
if ($user->rights->fournisseur->commande->approuver) 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 '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>'; print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>';
} }
@ -2674,8 +2674,8 @@ elseif (! empty($object->id))
} }
} }
// Second approval (if option SUPPLIER_ORDER_DOUBLE_APPROVAL is set) // Second approval (if option SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED 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) 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) if ($object->statut == 1)
{ {
@ -2732,7 +2732,7 @@ elseif (! empty($object->id))
$buttonshown++; $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) 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)) || (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER2_ONLY) && $user->id == $object->user_approve_id2))

View File

@ -390,6 +390,8 @@ EnableAndSetupModuleCron=If you want to have this recurring invoice beeing gener
ModuleCompanyCodeAquarium=Return an accountancy code built by:<br>%s followed by third party supplier code for a supplier accountancy code,<br>%s followed by third party customer code for a customer accountancy code. ModuleCompanyCodeAquarium=Return an accountancy code built by:<br>%s followed by third party supplier code for a supplier accountancy code,<br>%s followed by third party customer code for a customer accountancy code.
ModuleCompanyCodePanicum=Return an empty 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. 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 # Modules
Module0Name=Users & groups Module0Name=Users & groups

View File

@ -36,7 +36,6 @@ ListOfSupplierOrders=List of supplier orders
MenuOrdersSupplierToBill=Supplier orders to invoice MenuOrdersSupplierToBill=Supplier orders to invoice
NbDaysToDelivery=Delivery delay in days NbDaysToDelivery=Delivery delay in days
DescNbDaysToDelivery=The biggest deliver delay of the products from this order 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 SupplierReputation=Supplier reputation
DoNotOrderThisProductToThisSupplier=Do not order DoNotOrderThisProductToThisSupplier=Do not order
NotTheGoodQualitySupplier=Wrong quality NotTheGoodQualitySupplier=Wrong quality