diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index 621873afc94..d03beec610e 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -263,6 +263,7 @@ if ($conf->facture->enabled) { print ''.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").''; print ''; $selected = (empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + print img_picto('', 'product', 'class="pictofixedwidth"'); $form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0); print ''; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 78d139bb764..ce1beacadf3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -843,16 +843,16 @@ if (empty($reshook)) { } } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; } @@ -871,7 +871,7 @@ if (empty($reshook)) { } } - if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { $pu_ht = 0; $pu_ttc = 0; $price_min = 0; @@ -885,7 +885,7 @@ if (empty($reshook)) { // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Replaces $fk_unit with the product unit - if (!empty($idprod)) { + if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); $prod->fetch($idprod); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 940e0156c7e..3bc30d7d729 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -605,7 +605,7 @@ class Propal extends CommonObject $this->db->begin(); $product_type = $type; - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 6d0badf6380..7908b54bf05 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -645,15 +645,15 @@ if (empty($reshook)) { } } - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } @@ -661,7 +661,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } @@ -680,7 +680,7 @@ if (empty($reshook)) { } } - if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { // Clean parameters $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); @@ -690,7 +690,7 @@ if (empty($reshook)) { // Ecrase $desc par celui du produit // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit - if (!empty($idprod)) { + if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); $prod->fetch($idprod); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index aa9897f9dc7..333d4e2ded6 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1518,7 +1518,7 @@ class Commande extends CommonOrder $this->db->begin(); $product_type = $type; - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; @@ -4389,7 +4389,7 @@ class OrderLine extends CommonOrderLine $sql .= " '".price2num($this->localtax2_tx)."',"; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").','; $sql .= " '".$this->db->escape($this->product_type)."',"; $sql .= " '".price2num($this->remise_percent)."',"; $sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").","; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index dd4042b9e34..affdd2e8991 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -447,15 +447,15 @@ if (empty($reshook)) { } } - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && (!($price_ht >= 0) || $price_ht == '')) { // Unit price can be 0 but not '' + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (!($price_ht >= 0) || $price_ht == '')) { // Unit price can be 0 but not '' setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; } @@ -463,7 +463,7 @@ if (empty($reshook)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors'); $error++; } @@ -473,7 +473,7 @@ if (empty($reshook)) { $error++; } - if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -495,7 +495,7 @@ if (empty($reshook)) { // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (!empty($idprod)) { + if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); $prod->fetch($idprod); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 00653473cba..507c4ac44c2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2000,7 +2000,7 @@ if (empty($reshook)) { } } - if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { + if ((empty($idprod) || $idprod < 0) && ($price_ht < 0) && ($qty < 0)) { setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors'); $error++; } @@ -2010,11 +2010,11 @@ if (empty($reshook)) { $error++; } } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if (($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' + if (($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { $langs->load("errors"); if ($object->type == $object::TYPE_DEPOSIT) { @@ -2057,7 +2057,7 @@ if (empty($reshook)) { } } - if (!$error && ($qty >= 0) && (!empty($product_desc) || !empty($idprod))) { + if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { $ret = $object->fetch($id); if ($ret < 0) { dol_print_error($db, $object->error); @@ -2079,7 +2079,7 @@ if (empty($reshook)) { // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's - if (!empty($idprod)) { + if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); $prod->fetch($idprod); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 735f2877184..9cbfb33e5bd 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3213,7 +3213,7 @@ class Facture extends CommonInvoice $this->db->begin(); $product_type = $type; - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { $product = new Product($this->db); $result = $product->fetch($fk_product); $product_type = $product->type; @@ -5342,7 +5342,7 @@ class FactureLigne extends CommonInvoiceLine $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (!empty($this->fk_product)) { + if (!empty($this->fk_product) && $this->fk_product > 0) { // Check product exists $result = Product::isExistingObject('product', $this->fk_product); if ($result <= 0) { @@ -5377,7 +5377,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").','; $sql .= " ".((int) $this->product_type).","; $sql .= " ".price2num($this->remise_percent).","; $sql .= " ".price2num($this->subprice).","; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 05c7436c22e..32edf9a1558 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -386,7 +386,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); $error++; } - if (GETPOST('prod_entry_mode', 'alpha') == 'free' && empty($idprod) && empty($product_desc)) { + if (GETPOST('prod_entry_mode', 'alpha') == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b38de413e9..64fdb956ab0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7717,7 +7717,7 @@ abstract class CommonObject $buyPrice = $unitPrice * (1 - $discountPercent / 100); } else { // Get cost price for margin calculation - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $product = new Product($this->db); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 0b1504d229a..83f66b204ee 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2176,7 +2176,7 @@ class Form * * @param int $selected Preselected products * @param string $htmlname Name of HTML select field (must be unique in page). - * @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param int $limit Limit on number of returned lines * @param int $price_level Level of price to show * @param int $status Sell status -1=Return all products, 0=Products not on sell, 1=Products on sell @@ -2604,7 +2604,7 @@ class Form } } if ($showempty) { - $out .= ''; + $out .= ''; } $i = 0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 3c6151ef349..7b5bbbc50c5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3550,7 +3550,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->error = 'ErrorProductTypeMustBe0orMore'; return -1; } - if (!empty($this->fk_product)) { + if (!empty($this->fk_product) && $this->fk_product > 0) { // Check product exists $result = Product::isExistingObject('product', $this->fk_product); if ($result <= 0) { @@ -3583,7 +3583,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= ' '.(!empty($this->fk_product) ? $this->fk_product : "null").','; + $sql .= ' '.((!empty($this->fk_product) && $this->fk_product > 0) ? $this->fk_product : "null").','; $sql .= " ".((int) $this->product_type).","; $sql .= " ".price2num($this->remise_percent).","; $sql .= ' '.(! empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").','; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 5f4f13056a3..5be93a9b9d1 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -93,7 +93,7 @@ class FormProduct } $sql = "SELECT e.rowid, e.ref as label, e.description, e.fk_parent"; - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { if (!empty($batch)) { $sql .= ", pb.qty as stock"; } else { @@ -104,7 +104,7 @@ class FormProduct } $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid"; - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { $sql .= " AND ps.fk_product = ".((int) $fk_product); if (!empty($batch)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$this->db->escape($batch)."'"; @@ -123,11 +123,11 @@ class FormProduct // minimum stock if ($stockMin !== false) { - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { if (!empty($batch)) { - $sql .= " AND pb.qty > ".$this->db->escape($stockMin); + $sql .= " AND pb.qty > ".((float) $stockMin); } else { - $sql .= " AND ps.reel > ".$this->db->escape($stockMin); + $sql .= " AND ps.reel > ".((float) $stockMin); } } } @@ -137,7 +137,7 @@ class FormProduct // minimum stock if ($stockMin !== false) { - $sql .= " HAVING sum(ps.reel) > ".$this->db->escape($stockMin); + $sql .= " HAVING sum(ps.reel) > ".((float) $stockMin); } } $sql .= " ORDER BY ".$orderBy; @@ -234,7 +234,7 @@ class FormProduct if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) { $filterstatus = ''; } - if (!empty($fk_product)) { + if (!empty($fk_product) && $fk_product > 0) { $this->cache_warehouses = array(); } @@ -549,8 +549,8 @@ class FormProduct $out = ''; $productIdArray = array(); if (!is_array($objectLines) || !count($objectLines)) { - if (!empty($fk_product)) { - $productIdArray[] = $fk_product; + if (!empty($fk_product) && $fk_product > 0) { + $productIdArray[] = (int) $fk_product; } } else { foreach ($objectLines as $line) { @@ -572,8 +572,8 @@ class FormProduct if ($empty) { $out .= ''; } - if (!empty($fk_product)) { - $productIdArray = array($fk_product); // only show lot stock for product + if (!empty($fk_product) && $fk_product > 0) { + $productIdArray = array((int) $fk_product); // only show lot stock for product } else { foreach ($this->cache_lot as $key => $value) { $productIdArray[] = $key; diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index aea8c3e1f14..d8138c7f149 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -280,10 +280,10 @@ class ProductStockEntrepot extends CommonObject $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); } - if (!empty($fk_product)) { - $sql .= ' AND fk_product = '.$fk_product; - } elseif (!empty($fk_entrepot)) { - $sql .= ' AND fk_entrepot = '.$fk_entrepot; + if (!empty($fk_product) && $fk_product > 0) { + $sql .= ' AND fk_product = '.((int) $fk_product); + } elseif (!empty($fk_entrepot) && $fk_entrepot > 0) { + $sql .= ' AND fk_entrepot = '.((int) $fk_entrepot); } // "elseif" used instead of "if" because getting list with specified fk_product and specified fk_entrepot would be the same as doing a fetch diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index d9cc186111f..4892004db72 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -356,14 +356,14 @@ print '
'; print ''.$langs->trans('Date').' '.$form->selectDate(($date ? $date : -1), 'date'); print '   '; -print img_picto('', 'product').' '; -print $langs->trans('Product').' '; -print $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300', 0, '', null, 1); +print img_picto('', 'product', 'class="pictofiwedwidth"').' '; +print ' '; +print $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, $langs->trans('Product'), 0, 'maxwidth300', 0, '', null, 1); print '   '; -print img_picto('', 'stock').' '; -print $langs->trans('Warehouse').' '; -print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1, 0, 0, '', 0, 0, null, '', null, 1, false, 'e.ref'); +print img_picto('', 'stock', 'class="pictofiwedwidth"'); +print ' '; +print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1, 0, 0, $langs->trans('Warehouse'), 0, 0, null, '', null, 1, false, 'e.ref'); print '
'; $parameters = array(); diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 633f0785fe1..5d22ea05684 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -552,16 +552,16 @@ if (empty($reshook)) { } } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('type') < 0) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && GETPOST('price_ht') === '' && GETPOST('price_ttc') === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) { + if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && empty($product_desc)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors'); $error++; } diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5906db24ee7..eb003cdab9e 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -587,7 +587,7 @@ class SupplierProposal extends CommonObject $this->line->date_end = $date_end; // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + if (!empty($fk_product) && $fk_product > 0 && empty($fk_fournprice) && empty($pa_ht)) { // When fk_fournprice is 0, we take the lowest buying price include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($this->db); @@ -777,7 +777,7 @@ class SupplierProposal extends CommonObject $this->line->fk_unit = $fk_unit; // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + if (!empty($fk_product) && $fk_product > 0 && empty($fk_fournprice) && empty($pa_ht)) { // by external module, take lowest buying price include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($this->db);