diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index c791a4a9b83..7685c715494 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -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)) { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 50bcefc36b2..d0d32cf237c 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2696,10 +2696,24 @@ elseif (! empty($object->id)) // Reopen if (in_array($object->statut, array(2))) { - if ($user->rights->fournisseur->commande->commander) - { - print ''.$langs->trans("Disapprove").''; - } + $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 ''.$langs->trans("Disapprove").''; + $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 ''.$langs->trans("Disapprove").''; + } + } } if (in_array($object->statut, array(3, 5, 6, 7, 9))) {