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 '<tr class="oddeven"><td>'.$langs->trans("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS").'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
$selected = (empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) ? '' : $conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
|
$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);
|
$form->select_produits($selected, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', '', 0);
|
||||||
print '</td>';
|
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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
|
||||||
$error++;
|
$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_ht = 0;
|
||||||
$pu_ttc = 0;
|
$pu_ttc = 0;
|
||||||
$price_min = 0;
|
$price_min = 0;
|
||||||
@ -885,7 +885,7 @@ if (empty($reshook)) {
|
|||||||
// Ecrase $desc par celui du produit
|
// Ecrase $desc par celui du produit
|
||||||
// Ecrase $tva_tx par celui du produit
|
// Ecrase $tva_tx par celui du produit
|
||||||
// Replaces $fk_unit with the product unit
|
// Replaces $fk_unit with the product unit
|
||||||
if (!empty($idprod)) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$prod->fetch($idprod);
|
$prod->fetch($idprod);
|
||||||
|
|
||||||
|
|||||||
@ -605,7 +605,7 @@ class Propal extends CommonObject
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$product_type = $type;
|
$product_type = $type;
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
$result = $product->fetch($fk_product);
|
$result = $product->fetch($fk_product);
|
||||||
$product_type = $product->type;
|
$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');
|
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -661,7 +661,7 @@ if (empty($reshook)) {
|
|||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
|
||||||
$error++;
|
$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
|
// 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_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'));
|
$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 $desc par celui du produit
|
||||||
// Ecrase $tva_tx par celui du produit
|
// Ecrase $tva_tx par celui du produit
|
||||||
// Ecrase $base_price_type 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 = new Product($db);
|
||||||
$prod->fetch($idprod);
|
$prod->fetch($idprod);
|
||||||
|
|
||||||
|
|||||||
@ -1518,7 +1518,7 @@ class Commande extends CommonOrder
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$product_type = $type;
|
$product_type = $type;
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
$result = $product->fetch($fk_product);
|
$result = $product->fetch($fk_product);
|
||||||
$product_type = $product->type;
|
$product_type = $product->type;
|
||||||
@ -4389,7 +4389,7 @@ class OrderLine extends CommonOrderLine
|
|||||||
$sql .= " '".price2num($this->localtax2_tx)."',";
|
$sql .= " '".price2num($this->localtax2_tx)."',";
|
||||||
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
||||||
$sql .= " '".$this->db->escape($this->localtax2_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 .= " '".$this->db->escape($this->product_type)."',";
|
||||||
$sql .= " '".price2num($this->remise_percent)."',";
|
$sql .= " '".price2num($this->remise_percent)."',";
|
||||||
$sql .= " ".(price2num($this->subprice) !== '' ?price2num($this->subprice) : "null").",";
|
$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');
|
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ if (empty($reshook)) {
|
|||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -473,7 +473,7 @@ if (empty($reshook)) {
|
|||||||
$error++;
|
$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);
|
$ret = $object->fetch($id);
|
||||||
if ($ret < 0) {
|
if ($ret < 0) {
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
@ -495,7 +495,7 @@ if (empty($reshook)) {
|
|||||||
// Ecrase $tva_tx par celui du produit
|
// Ecrase $tva_tx par celui du produit
|
||||||
// Ecrase $base_price_type par celui du produit
|
// Ecrase $base_price_type par celui du produit
|
||||||
// Replaces $fk_unit with the product's
|
// Replaces $fk_unit with the product's
|
||||||
if (!empty($idprod)) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$prod->fetch($idprod);
|
$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');
|
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
@ -2010,11 +2010,11 @@ if (empty($reshook)) {
|
|||||||
$error++;
|
$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');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||||
$error++;
|
$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)) {
|
if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
if ($object->type == $object::TYPE_DEPOSIT) {
|
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);
|
$ret = $object->fetch($id);
|
||||||
if ($ret < 0) {
|
if ($ret < 0) {
|
||||||
dol_print_error($db, $object->error);
|
dol_print_error($db, $object->error);
|
||||||
@ -2079,7 +2079,7 @@ if (empty($reshook)) {
|
|||||||
// Ecrase $tva_tx par celui du produit
|
// Ecrase $tva_tx par celui du produit
|
||||||
// Ecrase $base_price_type par celui du produit
|
// Ecrase $base_price_type par celui du produit
|
||||||
// Replaces $fk_unit with the product's
|
// Replaces $fk_unit with the product's
|
||||||
if (!empty($idprod)) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
$prod->fetch($idprod);
|
$prod->fetch($idprod);
|
||||||
|
|
||||||
|
|||||||
@ -3213,7 +3213,7 @@ class Facture extends CommonInvoice
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$product_type = $type;
|
$product_type = $type;
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
$result = $product->fetch($fk_product);
|
$result = $product->fetch($fk_product);
|
||||||
$product_type = $product->type;
|
$product_type = $product->type;
|
||||||
@ -5342,7 +5342,7 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
$this->error = 'ErrorProductTypeMustBe0orMore';
|
$this->error = 'ErrorProductTypeMustBe0orMore';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!empty($this->fk_product)) {
|
if (!empty($this->fk_product) && $this->fk_product > 0) {
|
||||||
// Check product exists
|
// Check product exists
|
||||||
$result = Product::isExistingObject('product', $this->fk_product);
|
$result = Product::isExistingObject('product', $this->fk_product);
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
@ -5377,7 +5377,7 @@ class FactureLigne extends CommonInvoiceLine
|
|||||||
$sql .= " ".price2num($this->localtax2_tx).",";
|
$sql .= " ".price2num($this->localtax2_tx).",";
|
||||||
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
||||||
$sql .= " '".$this->db->escape($this->localtax2_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 .= " ".((int) $this->product_type).",";
|
||||||
$sql .= " ".price2num($this->remise_percent).",";
|
$sql .= " ".price2num($this->remise_percent).",";
|
||||||
$sql .= " ".price2num($this->subprice).",";
|
$sql .= " ".price2num($this->subprice).",";
|
||||||
|
|||||||
@ -386,7 +386,7 @@ if (empty($reshook)) {
|
|||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7717,7 +7717,7 @@ abstract class CommonObject
|
|||||||
$buyPrice = $unitPrice * (1 - $discountPercent / 100);
|
$buyPrice = $unitPrice * (1 - $discountPercent / 100);
|
||||||
} else {
|
} else {
|
||||||
// Get cost price for margin calculation
|
// 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') {
|
if (isset($conf->global->MARGIN_TYPE) && $conf->global->MARGIN_TYPE == 'costprice') {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
$product = new Product($this->db);
|
$product = new Product($this->db);
|
||||||
|
|||||||
@ -2176,7 +2176,7 @@ class Form
|
|||||||
*
|
*
|
||||||
* @param int $selected Preselected products
|
* @param int $selected Preselected products
|
||||||
* @param string $htmlname Name of HTML select field (must be unique in page).
|
* @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 $limit Limit on number of returned lines
|
||||||
* @param int $price_level Level of price to show
|
* @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
|
* @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) {
|
if ($showempty) {
|
||||||
$out .= '<option value="0" selected>'.($textifempty ? $textifempty : ' ').'</option>';
|
$out .= '<option value="-1" selected>'.($textifempty ? $textifempty : ' ').'</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|||||||
@ -3550,7 +3550,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|||||||
$this->error = 'ErrorProductTypeMustBe0orMore';
|
$this->error = 'ErrorProductTypeMustBe0orMore';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!empty($this->fk_product)) {
|
if (!empty($this->fk_product) && $this->fk_product > 0) {
|
||||||
// Check product exists
|
// Check product exists
|
||||||
$result = Product::isExistingObject('product', $this->fk_product);
|
$result = Product::isExistingObject('product', $this->fk_product);
|
||||||
if ($result <= 0) {
|
if ($result <= 0) {
|
||||||
@ -3583,7 +3583,7 @@ class SupplierInvoiceLine extends CommonObjectLine
|
|||||||
$sql .= " ".price2num($this->localtax2_tx).",";
|
$sql .= " ".price2num($this->localtax2_tx).",";
|
||||||
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
|
||||||
$sql .= " '".$this->db->escape($this->localtax2_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 .= " ".((int) $this->product_type).",";
|
||||||
$sql .= " ".price2num($this->remise_percent).",";
|
$sql .= " ".price2num($this->remise_percent).",";
|
||||||
$sql .= ' '.(! empty($this->fk_remise_except) ? ((int) $this->fk_remise_except) : "null").',';
|
$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";
|
$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)) {
|
if (!empty($batch)) {
|
||||||
$sql .= ", pb.qty as stock";
|
$sql .= ", pb.qty as stock";
|
||||||
} else {
|
} else {
|
||||||
@ -104,7 +104,7 @@ class FormProduct
|
|||||||
}
|
}
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
|
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_entrepot = e.rowid";
|
$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);
|
$sql .= " AND ps.fk_product = ".((int) $fk_product);
|
||||||
if (!empty($batch)) {
|
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)."'";
|
$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
|
// minimum stock
|
||||||
if ($stockMin !== false) {
|
if ($stockMin !== false) {
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
if (!empty($batch)) {
|
if (!empty($batch)) {
|
||||||
$sql .= " AND pb.qty > ".$this->db->escape($stockMin);
|
$sql .= " AND pb.qty > ".((float) $stockMin);
|
||||||
} else {
|
} else {
|
||||||
$sql .= " AND ps.reel > ".$this->db->escape($stockMin);
|
$sql .= " AND ps.reel > ".((float) $stockMin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ class FormProduct
|
|||||||
|
|
||||||
// minimum stock
|
// minimum stock
|
||||||
if ($stockMin !== false) {
|
if ($stockMin !== false) {
|
||||||
$sql .= " HAVING sum(ps.reel) > ".$this->db->escape($stockMin);
|
$sql .= " HAVING sum(ps.reel) > ".((float) $stockMin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sql .= " ORDER BY ".$orderBy;
|
$sql .= " ORDER BY ".$orderBy;
|
||||||
@ -234,7 +234,7 @@ class FormProduct
|
|||||||
if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
|
if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) {
|
||||||
$filterstatus = '';
|
$filterstatus = '';
|
||||||
}
|
}
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$this->cache_warehouses = array();
|
$this->cache_warehouses = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,8 +549,8 @@ class FormProduct
|
|||||||
$out = '';
|
$out = '';
|
||||||
$productIdArray = array();
|
$productIdArray = array();
|
||||||
if (!is_array($objectLines) || !count($objectLines)) {
|
if (!is_array($objectLines) || !count($objectLines)) {
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray[] = $fk_product;
|
$productIdArray[] = (int) $fk_product;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
foreach ($objectLines as $line) {
|
foreach ($objectLines as $line) {
|
||||||
@ -572,8 +572,8 @@ class FormProduct
|
|||||||
if ($empty) {
|
if ($empty) {
|
||||||
$out .= '<option value="-1">'.($empty_label ? $empty_label : ' ').'</option>';
|
$out .= '<option value="-1">'.($empty_label ? $empty_label : ' ').'</option>';
|
||||||
}
|
}
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$productIdArray = array($fk_product); // only show lot stock for product
|
$productIdArray = array((int) $fk_product); // only show lot stock for product
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->cache_lot as $key => $value) {
|
foreach ($this->cache_lot as $key => $value) {
|
||||||
$productIdArray[] = $key;
|
$productIdArray[] = $key;
|
||||||
|
|||||||
@ -280,10 +280,10 @@ class ProductStockEntrepot extends CommonObject
|
|||||||
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($fk_product)) {
|
if (!empty($fk_product) && $fk_product > 0) {
|
||||||
$sql .= ' AND fk_product = '.$fk_product;
|
$sql .= ' AND fk_product = '.((int) $fk_product);
|
||||||
} elseif (!empty($fk_entrepot)) {
|
} elseif (!empty($fk_entrepot) && $fk_entrepot > 0) {
|
||||||
$sql .= ' AND fk_entrepot = '.$fk_entrepot;
|
$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
|
// "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="fieldrequired">'.$langs->trans('Date').'</span> '.$form->selectDate(($date ? $date : -1), 'date');
|
||||||
|
|
||||||
print ' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
|
print ' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
|
||||||
print img_picto('', 'product').' ';
|
print img_picto('', 'product', 'class="pictofiwedwidth"').' ';
|
||||||
print $langs->trans('Product').'</span> ';
|
print '</span> ';
|
||||||
print $form->select_produits($productid, 'productid', '', 0, 0, -1, 2, '', 0, array(), 0, '1', 0, 'maxwidth300', 0, '', null, 1);
|
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 ' <span class="clearbothonsmartphone marginleftonly paddingleftonly marginrightonly paddingrightonly"> </span> ';
|
||||||
print img_picto('', 'stock').' ';
|
print img_picto('', 'stock', 'class="pictofiwedwidth"');
|
||||||
print $langs->trans('Warehouse').'</span> ';
|
print '</span> ';
|
||||||
print $formproduct->selectWarehouses((GETPOSTISSET('fk_warehouse') ? $fk_warehouse : 'ifone'), 'fk_warehouse', '', 1, 0, 0, '', 0, 0, null, '', null, 1, false, 'e.ref');
|
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>';
|
print '</div>';
|
||||||
|
|
||||||
$parameters = array();
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPrice")), null, 'errors');
|
||||||
$error++;
|
$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');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -587,7 +587,7 @@ class SupplierProposal extends CommonObject
|
|||||||
$this->line->date_end = $date_end;
|
$this->line->date_end = $date_end;
|
||||||
|
|
||||||
// infos marge
|
// 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
|
// When fk_fournprice is 0, we take the lowest buying price
|
||||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||||
$productFournisseur = new ProductFournisseur($this->db);
|
$productFournisseur = new ProductFournisseur($this->db);
|
||||||
@ -777,7 +777,7 @@ class SupplierProposal extends CommonObject
|
|||||||
$this->line->fk_unit = $fk_unit;
|
$this->line->fk_unit = $fk_unit;
|
||||||
|
|
||||||
// infos marge
|
// 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
|
// by external module, take lowest buying price
|
||||||
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
|
||||||
$productFournisseur = new ProductFournisseur($this->db);
|
$productFournisseur = new ProductFournisseur($this->db);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user