mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix trouble with product id = -1
This commit is contained in:
parent
5853aa4c1e
commit
f6efe51032
|
|
@ -263,6 +263,7 @@ if ($conf->facture->enabled) {
|
|||
print '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
|
||||
print '<td>';
|
||||
$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 '</td>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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").",";
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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).",";
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 .= '<option value="0" selected>'.($textifempty ? $textifempty : ' ').'</option>';
|
||||
$out .= '<option value="-1" selected>'.($textifempty ? $textifempty : ' ').'</option>';
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
|
|
|
|||
|
|
@ -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").',';
|
||||
|
|
|
|||
|
|
@ -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 .= '<option value="-1">'.($empty_label ? $empty_label : ' ').'</option>';
|
||||
}
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -356,14 +356,14 @@ print '<div class="inline-block valignmiddle" style="padding-right: 20px;">';
|
|||
print '<span class="fieldrequired">'.$langs->trans('Date').'</span> '.$form->selectDate(($date ? $date : -1), 'date');
|
||||
|
||||
print ' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
|
||||
print img_picto('', 'product').' ';
|
||||
print $langs->trans('Product').'</span> ';
|
||||
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 '</span> ';
|
||||
print $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, $langs->trans('Product'), 0, 'maxwidth300', 0, '', null, 1);
|
||||
|
||||
print ' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
|
||||
print img_picto('', 'stock').' ';
|
||||
print $langs->trans('Warehouse').'</span> ';
|
||||
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 '</span> ';
|
||||
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 '</div>';
|
||||
|
||||
$parameters = array();
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user