diff --git a/htdocs/api/index.php b/htdocs/api/index.php
index b76ef49b65e..2862ba32b95 100644
--- a/htdocs/api/index.php
+++ b/htdocs/api/index.php
@@ -122,6 +122,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$conf->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 1;
+// In API context, we force the protection to avoid forging of criteria including bind SQL injection
+$conf->global->MAIN_DISALLOW_UNSECURED_SELECT_INTO_EXTRAFIELDS_FILTER = 1;
+
+
$url = $_SERVER['PHP_SELF'];
if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method'
$url = $_SERVER['PHP_SELF'].(empty($_SERVER['PATH_INFO']) ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']);
diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php
index 4c64456847d..fefc4ce41b6 100644
--- a/htdocs/fourn/class/fournisseur.facture-rec.class.php
+++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php
@@ -995,152 +995,146 @@ class FactureFournisseurRec extends CommonInvoice
return -1;
}
- if ($this->suspended == self::STATUS_NOTSUSPENDED) {
- $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+ $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
- // Clean vat code
- $reg = array();
- $vat_src_code = '';
- if (preg_match('/\((.*)\)/', (string) $txtva, $reg)) {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', (string) $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $reg = array();
+ $vat_src_code = '';
+ if (preg_match('/\((.*)\)/', (string) $txtva, $reg)) {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', (string) $txtva); // Remove code into vatrate.
+ }
- // Clean parameters
- $fk_product = empty($fk_product) ? 0 : $fk_product;
- $label = empty($label) ? '' : $label;
- $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
- $qty = price2num($qty);
- $pu_ht = price2num($pu_ht);
- $pu_ttc = price2num($pu_ttc);
- if (!preg_match('/\((.*)\)/', $txtva)) {
- $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
- }
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- $txtva = !empty($txtva) ? $txtva : 0;
- $txlocaltax1 = !empty($txlocaltax1) ? $txlocaltax1 : 0;
- $txlocaltax2 = !empty($txlocaltax2) ? $txlocaltax2 : 0;
- $info_bits = !empty($info_bits) ? $info_bits : 0;
- $info_bits = !empty($info_bits) ? $info_bits : 0;
- $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
+ // Clean parameters
+ $fk_product = empty($fk_product) ? 0 : $fk_product;
+ $label = empty($label) ? '' : $label;
+ $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
+ $qty = price2num($qty);
+ $pu_ht = price2num($pu_ht);
+ $pu_ttc = price2num($pu_ttc);
+ if (!preg_match('/\((.*)\)/', $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ $txtva = !empty($txtva) ? $txtva : 0;
+ $txlocaltax1 = !empty($txlocaltax1) ? $txlocaltax1 : 0;
+ $txlocaltax2 = !empty($txlocaltax2) ? $txlocaltax2 : 0;
+ $info_bits = !empty($info_bits) ? $info_bits : 0;
+ $info_bits = !empty($info_bits) ? $info_bits : 0;
+ $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
- // Calcul du total TTC et de la TVA pour la ligne a partir de qty, pu, remise_percent et txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // Calcul du total TTC et de la TVA pour la ligne a partir de qty, pu, remise_percent et txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
- $tabprice = calcul_price_total((float) $qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
+ $tabprice = calcul_price_total((float) $qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
- // MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
- $pu_ht_devise = $tabprice[19];
-
- $this->db->begin();
- $product_type = $type;
- if ($fk_product) {
- $product = new Product($this->db);
- $result = $product->fetch($fk_product);
- if ($result < 0) {
- return -1;
- }
- $product_type = $product->type;
- if (empty($label)) {
- $label = $product->label;
- }
- }
-
- $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec (';
- $sql .= 'fk_facture_fourn';
- $sql .= ', fk_product';
- $sql .= ', ref';
- $sql .= ', label';
- $sql .= ', description';
- $sql .= ', pu_ht';
- $sql .= ', pu_ttc';
- $sql .= ', qty';
- $sql .= ', remise_percent';
- $sql .= ', fk_remise_except';
- $sql .= ', vat_src_code';
- $sql .= ', tva_tx';
- $sql .= ', localtax1_tx';
- $sql .= ', localtax1_type';
- $sql .= ', localtax2_tx';
- $sql .= ', localtax2_type';
- $sql .= ', total_ht';
- $sql .= ', total_tva';
- $sql .= ', total_localtax1';
- $sql .= ', total_localtax2';
- $sql .= ', total_ttc';
- $sql .= ', product_type';
- $sql .= ', date_start';
- $sql .= ', date_end';
- $sql .= ', info_bits';
- $sql .= ', special_code';
- $sql .= ', rang';
- $sql .= ', fk_unit';
- $sql .= ', fk_user_author';
- $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
- $sql .= ') VALUES (';
- $sql .= ' ' . (int) $facid; // source supplier invoice id
- $sql .= ', ' . (!empty($fk_product) ? "'" . $this->db->escape((string) $fk_product) . "'" : 'null');
- $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null');
- $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null');
- $sql .= ", '" . $this->db->escape($desc) . "'";
- $sql .= ', ' . price2num($pu_ht);
- $sql .= ', ' . price2num($pu_ttc);
- $sql .= ', ' . price2num($qty);
- $sql .= ', ' . price2num($remise_percent);
- $sql .= ', null';
- $sql .= ", '" . $this->db->escape($vat_src_code) . "'";
- $sql .= ', ' . price2num($txtva);
- $sql .= ', ' . price2num($txlocaltax1);
- $sql .= ", '" . $this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '') . "'";
- $sql .= ', ' . price2num($txlocaltax2);
- $sql .= ", '" . $this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '') . "'";
- $sql .= ', ' . price2num($total_ht);
- $sql .= ', ' . price2num($total_tva);
- $sql .= ', ' . price2num($total_localtax1);
- $sql .= ', ' . price2num($total_localtax2);
- $sql .= ', ' . price2num($total_ttc);
- $sql .= ', ' . (int) $product_type;
- $sql .= ', ' . ($date_start > 0 ? (int) $date_start : 'NULL');
- $sql .= ', ' . ($date_end > 0 ? (int) $date_end : 'NULL');
- $sql .= ', ' . (int) $info_bits;
- $sql .= ', ' . (int) $special_code;
- $sql .= ', ' . (int) $rang;
- $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL');
- $sql .= ', ' . (int) $user->id;
- $sql .= ', ' . (int) $this->fk_multicurrency;
- $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'";
- $sql .= ', ' . price2num($pu_ht_devise, 'CU');
- $sql .= ', ' . price2num($multicurrency_total_ht, 'CT');
- $sql .= ', ' . price2num($multicurrency_total_tva, 'CT');
- $sql .= ', ' . price2num($multicurrency_total_ttc, 'CT');
- $sql .= ')';
-
- dol_syslog(get_class($this). '::addline', LOG_DEBUG);
- if ($this->db->query($sql)) {
- $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_det_rec');
- $this->update_price();
- $this->id = $facid;
- $this->db->commit();
- return $lineId;
- } else {
- $this->db->rollback();
- $this->error = $this->db->lasterror();
+ // MultiCurrency
+ $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
+ $pu_ht_devise = $tabprice[19];
+ $this->db->begin();
+ $product_type = $type;
+ if ($fk_product) {
+ $product = new Product($this->db);
+ $result = $product->fetch($fk_product);
+ if ($result < 0) {
return -1;
}
+ $product_type = $product->type;
+ if (empty($label)) {
+ $label = $product->label;
+ }
+ }
+
+ $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec (';
+ $sql .= 'fk_facture_fourn';
+ $sql .= ', fk_product';
+ $sql .= ', ref';
+ $sql .= ', label';
+ $sql .= ', description';
+ $sql .= ', pu_ht';
+ $sql .= ', pu_ttc';
+ $sql .= ', qty';
+ $sql .= ', remise_percent';
+ $sql .= ', fk_remise_except';
+ $sql .= ', vat_src_code';
+ $sql .= ', tva_tx';
+ $sql .= ', localtax1_tx';
+ $sql .= ', localtax1_type';
+ $sql .= ', localtax2_tx';
+ $sql .= ', localtax2_type';
+ $sql .= ', total_ht';
+ $sql .= ', total_tva';
+ $sql .= ', total_localtax1';
+ $sql .= ', total_localtax2';
+ $sql .= ', total_ttc';
+ $sql .= ', product_type';
+ $sql .= ', date_start';
+ $sql .= ', date_end';
+ $sql .= ', info_bits';
+ $sql .= ', special_code';
+ $sql .= ', rang';
+ $sql .= ', fk_unit';
+ $sql .= ', fk_user_author';
+ $sql .= ', fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
+ $sql .= ') VALUES (';
+ $sql .= ' ' . (int) $facid; // source supplier invoice id
+ $sql .= ', ' . (!empty($fk_product) ? ((int) $fk_product) : 'null');
+ $sql .= ', ' . (!empty($ref) ? "'" . $this->db->escape($ref) . "'" : 'null');
+ $sql .= ', ' . (!empty($label) ? "'" . $this->db->escape($label) . "'" : 'null');
+ $sql .= ", '" . $this->db->escape($desc) . "'";
+ $sql .= ', ' . price2num($pu_ht);
+ $sql .= ', ' . price2num($pu_ttc);
+ $sql .= ', ' . price2num($qty);
+ $sql .= ', ' . price2num($remise_percent);
+ $sql .= ', null';
+ $sql .= ", '" . $this->db->escape($vat_src_code) . "'";
+ $sql .= ', ' . price2num($txtva);
+ $sql .= ', ' . price2num($txlocaltax1);
+ $sql .= ", '" . $this->db->escape(isset($localtaxes_type[0]) ? $localtaxes_type[0] : '') . "'";
+ $sql .= ', ' . price2num($txlocaltax2);
+ $sql .= ", '" . $this->db->escape(isset($localtaxes_type[2]) ? $localtaxes_type[2] : '') . "'";
+ $sql .= ', ' . price2num($total_ht);
+ $sql .= ', ' . price2num($total_tva);
+ $sql .= ', ' . price2num($total_localtax1);
+ $sql .= ', ' . price2num($total_localtax2);
+ $sql .= ', ' . price2num($total_ttc);
+ $sql .= ', ' . (int) $product_type;
+ $sql .= ', ' . ($date_start > 0 ? (int) $date_start : 'NULL');
+ $sql .= ', ' . ($date_end > 0 ? (int) $date_end : 'NULL');
+ $sql .= ', ' . (int) $info_bits;
+ $sql .= ', ' . (int) $special_code;
+ $sql .= ', ' . (int) $rang;
+ $sql .= ', ' . ($fk_unit ? (int) $fk_unit : 'NULL');
+ $sql .= ', ' . (int) $user->id;
+ $sql .= ', ' . (int) $this->fk_multicurrency;
+ $sql .= ", '" . $this->db->escape($this->multicurrency_code) . "'";
+ $sql .= ', ' . price2num($pu_ht_devise, 'CU');
+ $sql .= ', ' . price2num($multicurrency_total_ht, 'CT');
+ $sql .= ', ' . price2num($multicurrency_total_tva, 'CT');
+ $sql .= ', ' . price2num($multicurrency_total_ttc, 'CT');
+ $sql .= ')';
+
+ dol_syslog(get_class($this). '::addline', LOG_DEBUG);
+ if ($this->db->query($sql)) {
+ $lineId = $this->db->last_insert_id(MAIN_DB_PREFIX. 'facture_fourn_det_rec');
+ $this->update_price();
+ $this->id = $facid;
+ $this->db->commit();
+ return $lineId;
} else {
- $this->error = 'Recurring Invoice is suspended. adding lines not allowed.';
+ $this->db->rollback();
+ $this->error = $this->db->lasterror();
return -1;
}
@@ -1187,113 +1181,110 @@ class FactureFournisseurRec extends CommonInvoice
return -1;
}
- if ($this->suspended == self::STATUS_SUSPENDED) {
- // Clean parameters
- $fk_product = empty($fk_product) ? 0 : $fk_product;
- $label = empty($label) ? '' : $label;
- $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
- $qty = price2num($qty);
- $info_bits = empty($info_bits) ? 0 : $info_bits;
- $pu_ht = price2num($pu_ht);
- $pu_ttc = price2num($pu_ttc);
- $pu_ht_devise = price2num($pu_ht_devise);
+ // Clean parameters
+ $fk_product = empty($fk_product) ? 0 : $fk_product;
+ $label = empty($label) ? '' : $label;
+ $remise_percent = empty($remise_percent) ? 0 : price2num($remise_percent);
+ $qty = price2num($qty);
+ $info_bits = empty($info_bits) ? 0 : $info_bits;
+ $pu_ht = price2num($pu_ht);
+ $pu_ttc = price2num($pu_ttc);
+ $pu_ht_devise = price2num($pu_ht_devise);
- if (!preg_match('/\((.*)\)/', (string) $txtva)) {
- $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
- }
-
- $txlocaltax1 = empty($txlocaltax1) ? 0 : price2num($txlocaltax1);
- $txlocaltax2 = empty($txlocaltax2) ? 0 : price2num($txlocaltax2);
- $this->multicurrency_total_ht = empty($this->multicurrency_total_ht) ? 0 : $this->multicurrency_total_ht;
- $this->multicurrency_total_tva = empty($this->multicurrency_total_tva) ? 0 : $this->multicurrency_total_tva;
- $this->multicurrency_total_ttc = empty($this->multicurrency_total_ttc) ? 0 : $this->multicurrency_total_ttc;
-
- $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
-
-
- // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
-
- $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
-
- // Clean vat code
- $vat_src_code = '';
- $reg = array();
- if (preg_match('/\((.*)\)/', $txtva, $reg)) {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
-
- $tabprice = calcul_price_total((float) $qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, (float) $pu_ht_devise);
-
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
- $pu_tva = $tabprice[4];
- $pu_ttc = $tabprice[5];
-
- // MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
- $pu_ht_devise = $tabprice[19];
-
- $product_type = $type;
- if ($fk_product) {
- $product = new Product($this->db);
- $result = $product->fetch($fk_product);
- $product_type = $product->type;
- }
-
- $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
- $sql .= ' fk_facture_fourn = ' . ((int) $facid);
- $sql .= ', fk_product = ' . ($fk_product > 0 ? ((int) $fk_product) : 'null');
- $sql .= ", ref = '" . $this->db->escape($ref) . "'";
- $sql .= ", label = '" . $this->db->escape($label) . "'";
- $sql .= ", description = '" . $this->db->escape($desc) . "'";
- $sql .= ', pu_ht = ' . price2num($pu_ht);
- $sql .= ', qty = ' . price2num($qty);
- $sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
- $sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
- $sql .= ', tva_tx = ' . price2num($txtva);
- $sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
- $sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
- $sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
- $sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
- $sql .= ", total_ht = '" . price2num($total_ht) . "'";
- $sql .= ", total_tva = '" . price2num($total_tva) . "'";
- $sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
- $sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
- $sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
- $sql .= ', product_type = ' . (int) $product_type;
- $sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
- $sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
- $sql .= ', info_bits = ' . (int) $info_bits;
- $sql .= ', special_code = ' . (int) $special_code;
- $sql .= ', rang = ' . (int) $rang;
- $sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
- $sql .= ', fk_user_modif = ' . (int) $user;
- $sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
- $sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
- $sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
- $sql .= ', multicurrency_total_ttc = '.price2num($multicurrency_total_ttc);
- $sql .= ' WHERE rowid = ' . (int) $rowid;
-
- dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
- if ($this->db->query($sql)) {
- $this->id = $facid;
- $this->update_price();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- return -1;
- }
+ if (!preg_match('/\((.*)\)/', (string) $txtva)) {
+ $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
+ }
+
+ $txlocaltax1 = empty($txlocaltax1) ? 0 : price2num($txlocaltax1);
+ $txlocaltax2 = empty($txlocaltax2) ? 0 : price2num($txlocaltax2);
+ $this->multicurrency_total_ht = empty($this->multicurrency_total_ht) ? 0 : $this->multicurrency_total_ht;
+ $this->multicurrency_total_tva = empty($this->multicurrency_total_tva) ? 0 : $this->multicurrency_total_tva;
+ $this->multicurrency_total_ttc = empty($this->multicurrency_total_ttc) ? 0 : $this->multicurrency_total_ttc;
+
+ $pu = $price_base_type == 'HT' ? $pu_ht : $pu_ttc;
+
+
+ // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+
+ $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
+
+ // Clean vat code
+ $vat_src_code = '';
+ $reg = array();
+ if (preg_match('/\((.*)\)/', $txtva, $reg)) {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
+
+ $tabprice = calcul_price_total((float) $qty, (float) $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, (float) $pu_ht_devise);
+
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
+ $pu_tva = $tabprice[4];
+ $pu_ttc = $tabprice[5];
+
+ // MultiCurrency
+ $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
+ $pu_ht_devise = $tabprice[19];
+
+ $product_type = $type;
+ if ($fk_product) {
+ $product = new Product($this->db);
+ $result = $product->fetch($fk_product);
+ $product_type = $product->type;
+ }
+
+ $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture_fourn_det_rec SET';
+ $sql .= ' fk_facture_fourn = ' . ((int) $facid);
+ $sql .= ', fk_product = ' . ($fk_product > 0 ? ((int) $fk_product) : 'null');
+ $sql .= ", ref = '" . $this->db->escape($ref) . "'";
+ $sql .= ", label = '" . $this->db->escape($label) . "'";
+ $sql .= ", description = '" . $this->db->escape($desc) . "'";
+ $sql .= ', pu_ht = ' . price2num($pu_ht);
+ $sql .= ', qty = ' . price2num($qty);
+ $sql .= ", remise_percent = '" . price2num($remise_percent) . "'";
+ $sql .= ", vat_src_code = '" . $this->db->escape($vat_src_code) . "'";
+ $sql .= ', tva_tx = ' . price2num($txtva);
+ $sql .= ', localtax1_tx = ' . (float) $txlocaltax1;
+ $sql .= ", localtax1_type = '" . $this->db->escape($localtaxes_type[0]) . "'";
+ $sql .= ', localtax2_tx = ' . (float) $txlocaltax2;
+ $sql .= ", localtax2_type = '" . $this->db->escape($localtaxes_type[2]) . "'";
+ $sql .= ", total_ht = '" . price2num($total_ht) . "'";
+ $sql .= ", total_tva = '" . price2num($total_tva) . "'";
+ $sql .= ", total_localtax1 = '" . price2num($total_localtax1) . "'";
+ $sql .= ", total_localtax2 = '" . price2num($total_localtax2) . "'";
+ $sql .= ", total_ttc = '" . price2num($total_ttc) . "'";
+ $sql .= ', product_type = ' . (int) $product_type;
+ $sql .= ', date_start = ' . (empty($date_start) ? 'NULL' : (int) $date_start);
+ $sql .= ', date_end = ' . (empty($date_end) ? 'NULL' : (int) $date_end);
+ $sql .= ', info_bits = ' . (int) $info_bits;
+ $sql .= ', special_code = ' . (int) $special_code;
+ $sql .= ', rang = ' . (int) $rang;
+ $sql .= ', fk_unit = ' . ($fk_unit ? "'" . $this->db->escape($fk_unit) . "'" : 'null');
+ $sql .= ', fk_user_modif = ' . (int) $user;
+ $sql .= ', multicurrency_subprice = '.price2num($pu_ht_devise);
+ $sql .= ', multicurrency_total_ht = '.price2num($multicurrency_total_ht);
+ $sql .= ', multicurrency_total_tva = '.price2num($multicurrency_total_tva);
+ $sql .= ', multicurrency_total_ttc = '.price2num($multicurrency_total_ttc);
+ $sql .= ' WHERE rowid = ' . (int) $rowid;
+
+ dol_syslog(get_class($this). '::updateline', LOG_DEBUG);
+ if ($this->db->query($sql)) {
+ $this->id = $facid;
+ $this->update_price();
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ return -1;
}
- return 0;
}
diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php
index e7a7db67e86..8a8f07bd019 100644
--- a/htdocs/install/upgrade2.php
+++ b/htdocs/install/upgrade2.php
@@ -4231,6 +4231,7 @@ function migrate_delete_old_files($db, $langs, $conf)
'/core/modules/modCommercial.class.php',
'/core/modules/modProduit.class.php',
'/core/modules/modSkype.class.php',
+ '/core/modules/modactivite.class.php', // A file from external module that should not be here
'/core/triggers/interface_modWebcalendar_Webcalsynchro.class.php',
'/core/triggers/interface_modCommande_Ecotax.class.php',
'/core/triggers/interface_modCommande_fraisport.class.php',
diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang
index fe41d4a5757..a55581fca8b 100644
--- a/htdocs/langs/en_US/mrp.lang
+++ b/htdocs/langs/en_US/mrp.lang
@@ -163,11 +163,13 @@ ConfirmMassChangeDateEndQuestion = Are you sure you want to modify the %s select
ModifyDateStart = New planned start date
ModifyDateEnd = New planned end date
ModifyMoDate = Date modification validated for %s
-ErrorEmptyChangeDate = Please define a date
ConfirmMassChangeDateEnd = Confirmation of mass modification of the planned end date
-ErrorModifyMoDateStart = You must choose a start date earlier than the current start date. %s
+ErrorEmptyChangeDate = Please define a date
+ErrorModifyMoDateStart = You must choose a start date earlier than the current end date. %s
ErrorModifyMoDateEnd = You must choose an end date later than the start date. %s
ErrorCancelMo=Error updating cancellation
ErrorModifyMoDate=Error updating date modification
+ErrorObjectMustNotBeFinishedToModifyDateEnd = Object %s must not be finished to modify the end date.
+ErrorObjectMustNotBeFinishedToModifyDateStart = Object %s must not be finished to modify the start date.
BOM_SUB_BOM=Use sub-boms
UseSearchToSelectBom=Wait until a key is pressed before loading content of Boms combo list.
This may improve performance if you have a large number of projects, but it is less convenient.
diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang
index 0adcfc2db4a..9bec8ed7b5a 100644
--- a/htdocs/langs/fr_FR/mrp.lang
+++ b/htdocs/langs/fr_FR/mrp.lang
@@ -165,9 +165,12 @@ ModifyDateEnd = Nouvelle date de fin prévue
ModifyMoDate = Modification de la date validée pour %s
ErrorEmptyChangeDate = Veuillez définir une date
ConfirmMassChangeDateEnd = Confirmation de la modification massive de la date de fin prévue
-ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de début actuelle. %s
+ErrorModifyMoDateStart = Vous devez choisir une date de début antérieure à la date de fin actuelle. %s
ErrorModifyMoDateEnd = Vous devez choisir une date de fin postérieure à la date de début. %s
ErrorCancelMo=Erreur lors de la mise à jour de l'annulation
ErrorModifyMoDate=Erreur lors de la mise à jour de la modification de la date
-BOM_SUB_BOM=Utilisez des sous-bombes
+BOM_SUB_BOM=Utilisez des sous-boms
UseSearchToSelectBom=Attendez qu'une touche soit enfoncée avant de charger le contenu de la liste combo Boms.
Cela peut améliorer les performances si vous avez un grand nombre de projets, mais c'est moins pratique.
+ErrorObjectMustNotBeFinishedToModifyDateEnd = L'objet %s ne doit pas être fabriqué pour modifier la date de fin.
+ErrorObjectMustNotBeFinishedToModifyDateStart = L'objet %s ne doit pas être fabriqué pour modifier la date de début.
+UseSearchToSelectBom=Attendre que vous ayez appuyé sur une touche avant de charger le contenu de la liste déroulante des nomenclatures (Cela peut augmenter les performances si vous avez un grand nombre de nomenclatures, mais cela est moins convivial)
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 663bf3333a5..e880063aa3c 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -795,7 +795,7 @@ class MyObject extends CommonObject
$datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref;
}
if (property_exists($this, 'label')) {
- $datas['ref'] = '
'.$langs->trans('Label').': '.$this->label;
+ $datas['label'] = '
'.$langs->trans('Label').': '.$this->label;
}
return $datas;
diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php
index 85a2446651b..7a43974790d 100644
--- a/htdocs/mrp/mo_list.php
+++ b/htdocs/mrp/mo_list.php
@@ -253,34 +253,37 @@ if (empty($reshook)) {
if (!empty($toselect)) {
foreach ($toselect as $key => $idMo) {
if ($objMo->fetch($idMo)) {
- if ($objMo->status == Mo::STATUS_DRAFT) {
- if (!empty($changeDate)) {
- if ($action == 'changedatestart_confirm') { // Test on permission not required
- if ($newDate < $objMo->date_end_planned) {
- $objMo->date_start_planned = $newDate;
- } else {
- setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
- break;
- }
- } elseif ($action == 'changedateend_confirm') { // Test on permission not required
- if ($newDate > $objMo->date_start_planned) {
- $objMo->date_end_planned = $newDate;
- } else {
- setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
- break;
- }
- }
- if ($objMo->update($user)) {
- setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
+ if (in_array($action, array('changedatestart_confirm', 'changedateend_confirm'), true) && $objMo->status == Mo::STATUS_PRODUCED) {
+ $errorKey = $action == 'changedatestart_confirm'
+ ? 'ErrorObjectMustNotBeFinishedToModifyDateStart'
+ : 'ErrorObjectMustNotBeFinishedToModifyDateEnd';
+ setEventMessages($langs->trans($errorKey, $objMo->ref), null, 'errors');
+ continue;
+ }
+ if (!empty($changeDate)) {
+ if ($action == 'changedatestart_confirm') { // Test on permission not required
+ if (empty($objMo->date_end_planned) || $newDate < $objMo->date_end_planned) {
+ $objMo->date_start_planned = $newDate;
} else {
- setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
+ setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors');
+ break;
}
+ } elseif ($action == 'changedateend_confirm') { // Test on permission not required
+ if ($newDate > $objMo->date_start_planned) {
+ $objMo->date_end_planned = $newDate;
+ } else {
+ setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors');
+ break;
+ }
+ }
+ if ($objMo->update($user)) {
+ setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs');
} else {
- setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
- break;
+ setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors');
}
} else {
- setEventMessages($langs->trans('ErrorObjectMustHaveStatusDraftToModifyDate', $objMo->ref), null, 'errors');
+ setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors');
+ break;
}
}
}