diff --git a/ChangeLog b/ChangeLog index 57714680554..18f9fbe2dcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ For Users: NEW: Module Ticket is available as a stable module. NEW: Experimental module "Vendor receptions". NEW: Experimental module "BOM". +FIX: Disallow line start date to be after end date For Developers: NEW: Module DebugBar is available as a stable module. diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d585d7c9ab9..388433222e0 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -473,6 +473,12 @@ class Propal extends CommonObject // Check parameters if ($type < 0) return -1; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); @@ -666,7 +672,7 @@ class Propal extends CommonObject */ public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { - global $mysoc; + global $mysoc, $langs; dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); @@ -684,6 +690,12 @@ class Propal extends CommonObject if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag if (empty($type)) $type=0; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } if ($this->statut == self::STATUS_DRAFT) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 70c5b2d45f0..07b7a907150 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1367,6 +1367,12 @@ class Commande extends CommonOrder // Check parameters if ($type < 0) return -1; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); @@ -2932,7 +2938,6 @@ class Commande extends CommonOrder if ($this->statut == Propal::STATUS_DRAFT) { - $this->db->begin(); // Clean parameters if (empty($qty)) $qty=0; @@ -2942,6 +2947,12 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($remise_percent)) $remise_percent=0; if (empty($special_code) || $special_code == 3) $special_code=0; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $remise_percent=price2num($remise_percent); $qty=price2num($qty); @@ -2951,6 +2962,8 @@ class Commande extends CommonOrder $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); + + $this->db->begin(); // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8bf86599eb4..15d985db6bf 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2720,6 +2720,12 @@ class Facture extends CommonInvoice // Check parameters if ($type < 0) return -1; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); @@ -2923,6 +2929,12 @@ class Facture extends CommonInvoice return -3; } } + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f89ad5e7307..79fc66dfce8 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -1374,7 +1374,6 @@ class Contrat extends CommonObject if ($this->statut >= 0) { - $this->db->begin(); // Clean parameters $pu_ht=price2num($pu_ht); @@ -1394,7 +1393,7 @@ class Contrat extends CommonObject if (empty($txtva) || ! is_numeric($txtva)) $txtva=0; if (empty($txlocaltax1) || ! is_numeric($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2) || ! is_numeric($txlocaltax2)) $txlocaltax2=0; - + if ($price_base_type=='HT') { $pu=$pu_ht; @@ -1406,6 +1405,14 @@ class Contrat extends CommonObject // Check parameters if (empty($remise_percent)) $remise_percent=0; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } + + $this->db->begin(); $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); @@ -1596,6 +1603,12 @@ class Contrat extends CommonObject { $remise_percent=0; } + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx, $price_base_type, $info_bits"); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5f7789e72f5..3573484f7c7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -1543,6 +1543,11 @@ class CommandeFournisseur extends CommonOrder return -1; } if ($type < 0) return -1; + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); @@ -2470,7 +2475,7 @@ class CommandeFournisseur extends CommonOrder */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { - global $mysoc, $conf; + global $mysoc, $conf, $langs; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2478,8 +2483,6 @@ class CommandeFournisseur extends CommonOrder if ($this->brouillon) { - $this->db->begin(); - // Clean parameters if (empty($qty)) $qty=0; if (empty($info_bits)) $info_bits=0; @@ -2500,6 +2503,13 @@ class CommandeFournisseur extends CommonOrder // Check parameters if ($type < 0) return -1; + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } + + $this->db->begin(); // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index bf9241e0754..703b90cc831 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1616,6 +1616,12 @@ class FactureFournisseur extends CommonInvoice if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' } + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } $this->db->begin(); @@ -1837,7 +1843,7 @@ class FactureFournisseur extends CommonInvoice */ public function updateline($id, $desc, $pu, $vatrate, $txlocaltax1 = 0, $txlocaltax2 = 0, $qty = 1, $idproduct = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $remise_percent = 0, $notrigger = false, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { - global $mysoc; + global $mysoc, $langs; dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$notrigger,$date_start,$date_end,$fk_unit,$pu_ht_devise,$ref_supplier", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1849,6 +1855,12 @@ class FactureFournisseur extends CommonInvoice // Check parameters //if (! is_numeric($pu) || ! is_numeric($qty)) return -1; if ($type < 0) return -1; + + if ($date_start && $date_end && $date_start > $date_end) { + $langs->load("errors"); + $this->error=$langs->trans('ErrorStartDateGreaterEnd'); + return -1; + } // Clean parameters if (empty($vatrate)) $vatrate=0;