Fix bad management of second level approvement
This commit is contained in:
parent
e37fc87cd5
commit
84ee18a11b
@ -695,7 +695,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
// Do we have to change status now ? (If double approval is required and first approval, we keep status to 1 = validated)
|
||||
$movetoapprovestatus=true;
|
||||
|
||||
$comment='';
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql.= " SET ref='".$this->db->escape($num)."',";
|
||||
if (empty($secondlevel)) // standard or first level approval
|
||||
@ -704,7 +705,11 @@ class CommandeFournisseur extends CommonOrder
|
||||
$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($this->user_approve_id2)) $movetoapprovestatus=false; // second level approval not done
|
||||
if (empty($this->user_approve_id2))
|
||||
{
|
||||
$movetoapprovestatus=false; // second level approval not done
|
||||
$comment=' (first level)';
|
||||
}
|
||||
}
|
||||
}
|
||||
else // request a second level approval
|
||||
@ -712,6 +717,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " date_approve2='".$this->db->idate($now)."',";
|
||||
$sql.= " fk_user_approve2 = ".$user->id;
|
||||
if (empty($this->user_approve_id)) $movetoapprovestatus=false; // first level approval not done
|
||||
$comment=' (second level)';
|
||||
}
|
||||
// If double approval is required and first approval, we keep status to 1 = validated
|
||||
if ($movetoapprovestatus) $sql.= ", fk_statut = 2";
|
||||
@ -721,7 +727,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$this->log($user, 2, time()); // Statut 2
|
||||
$this->log($user, 2, time(), $comment); // Statut 2
|
||||
|
||||
if (! empty($conf->global->SUPPLIER_ORDER_AUTOADD_USER_CONTACT))
|
||||
{
|
||||
|
||||
@ -2696,10 +2696,24 @@ elseif (! empty($object->id))
|
||||
// Reopen
|
||||
if (in_array($object->statut, array(2)))
|
||||
{
|
||||
if ($user->rights->fournisseur->commande->commander)
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Disapprove").'</a>';
|
||||
}
|
||||
$buttonshown=0;
|
||||
if (! $buttonshown && $user->rights->fournisseur->commande->approuver)
|
||||
{
|
||||
if (empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY)
|
||||
|| (! empty($conf->global->SUPPLIER_ORDER_REOPEN_BY_APPROVER_ONLY) && $user->id == $object->user_approve_id))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Disapprove").'</a>';
|
||||
$buttonshown++;
|
||||
}
|
||||
}
|
||||
if (! $buttonshown && $user->rights->fournisseur->commande->approve2 && ! empty($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL))
|
||||
{
|
||||
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))
|
||||
{
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Disapprove").'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (in_array($object->statut, array(3, 5, 6, 7, 9)))
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user