From c5201b95bb9c6f26a09a4dd8df65e1b420c5b4b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 16:12:03 +0100 Subject: [PATCH] FIX Must not be able to edit vat of all lines if not draft --- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 2 ++ htdocs/compta/facture/class/facture.class.php | 2 ++ htdocs/core/class/commonobject.class.php | 6 ++++++ htdocs/core/tpl/objectline_title.tpl.php | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 42ad4ac6af6..27dd6b2308e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -615,7 +615,7 @@ if (empty($reshook)) $result = $object->set_remise($user, GETPOST('remise_percent')); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha')) { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7ed6d5e7199..fae2fefefaa 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1824,6 +1824,8 @@ class Commande extends CommonOrder $this->project = null; // Clear if another value was already set by fetch_projet $this->statut = $obj->fk_statut; + $this->status = $obj->fk_statut; + $this->user_author_id = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->total_ht = $obj->total_ht; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f036145161d..1ce1ea84f93 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1594,6 +1594,8 @@ class Facture extends CommonInvoice $this->project = null; // Clear if another value was already set by fetch_projet $this->statut = $obj->fk_statut; + $this->status = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 23924814d04..9e6204bd364 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -221,6 +221,12 @@ abstract class CommonObject */ public $statut; + /** + * @var int The object's status + * @see setStatut() + */ + public $status; + /** * @var string * @see getFullAddress() diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index bfced08e5c8..8a7c38f8ada 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -65,6 +65,7 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA } else { print $langs->trans('VAT'); } + if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { global $mysoc;