Skip to content

Commit

Permalink
Fix Option for second level approbation was visible when it should
Browse files Browse the repository at this point in the history
not.
  • Loading branch information
eldy committed Jul 29, 2015
1 parent c058437 commit fcc6ce8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 30 deletions.
21 changes: 3 additions & 18 deletions htdocs/admin/supplier_order.php
Expand Up @@ -168,19 +168,11 @@
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';
Expand Down Expand Up @@ -486,18 +478,11 @@
print $langs->trans("UseDoubleApproval").'<br>';
print $langs->trans("IfSetToYesDontForgetPermission");
print '</td><td>';
print $form->selectyesno('SUPPLIER_ORDER_DOUBLE_APPROVAL', $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL, 1);
print '<input type="text" size="3" name="SUPPLIER_ORDER_DOUBLE_APPROVAL" value="'.$conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL.'">';
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
$var=!$var;
/*print '<tr '.$bc[$var].'><td>';
print $langs->trans("GroupOfUserForSecondApproval").'</td><td>';
print $form->select_dolgroups($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP,'SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP', 1);
print '</td><td align="right">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print "</td></tr>\n";
$var=!$var;*/
}

print '<tr '.$bc[$var].'><td colspan="2">';
Expand Down
5 changes: 4 additions & 1 deletion htdocs/fourn/class/fournisseur.commande.class.php
Expand Up @@ -703,7 +703,10 @@ function approve($user, $idwarehouse=0, $secondlevel=0)
{
$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
{
Expand Down
23 changes: 13 additions & 10 deletions htdocs/fourn/commande/card.php
Expand Up @@ -2629,7 +2629,7 @@
{
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 '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("FirstApprovalAlreadyDone")).'">'.$langs->trans("ApproveOrder").'</a>';
}
Expand All @@ -2645,23 +2645,26 @@
}

// 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 '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>';
if (! empty($object->user_approve_id2))
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("SecondApprovalAlreadyDone")).'">'.$langs->trans("Approve2Order").'</a>';
}
else
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>';
}
}
else
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=approve2">'.$langs->trans("Approve2Order").'</a>';
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Approve2Order").'</a>';
}
}
else
{
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans("Approve2Order").'</a>';
}
}

// Refuse
Expand Down
2 changes: 1 addition & 1 deletion htdocs/langs/en_US/suppliers.lang
Expand Up @@ -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)
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)

0 comments on commit fcc6ce8

Please sign in to comment.