diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index b725f05ccc2..c7e4f538103 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -774,12 +774,13 @@ if (empty($reshook)) $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) $tva_npr=0; + // Price unique per product $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; - // On defini prix unitaire + // If price per segment if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->thirdparty->price_level) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; @@ -792,6 +793,7 @@ if (empty($reshook)) if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } + // If price per customer elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; @@ -814,6 +816,37 @@ if (empty($reshook)) } } } + // If price per quantity + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { + if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity + { + // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. + $pqp = GETPOST('pbq','int'); + + // Search price into product_price_by_qty from $prod->id + foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + { + if ($priceforthequantityarray['rowid'] != $pqp) continue; + // We found the price + if ($priceforthequantityarray['price_base_type'] == 'HT') + { + $pu_ht = $priceforthequantityarray['unitprice']; + } + else + { + $pu_ttc = $priceforthequantityarray['unitprice']; + } + // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. + break; + } + } + } + // If price per quantity and customer + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES)) + { + // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level + } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b93def7d263..29134010dd6 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -735,7 +735,7 @@ if (empty($reshook)) $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; - // multiprix + // If price per segment if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; @@ -748,6 +748,7 @@ if (empty($reshook)) if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level]; } } + // If price per customer elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; @@ -775,6 +776,37 @@ if (empty($reshook)) setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } } + // If price per quantity + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { + if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity + { + // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. + $pqp = GETPOST('pbq','int'); + + // Search price into product_price_by_qty from $prod->id + foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + { + if ($priceforthequantityarray['rowid'] != $pqp) continue; + // We found the price + if ($priceforthequantityarray['price_base_type'] == 'HT') + { + $pu_ht = $priceforthequantityarray['unitprice']; + } + else + { + $pu_ttc = $priceforthequantityarray['unitprice']; + } + // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. + break; + } + } + } + // If price per quantity and customer + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES)) + { + // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level + } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 6cddffd3b7a..5207ca83b91 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1643,7 +1643,7 @@ if (empty($reshook)) $price_min = $prod->price_min; $price_base_type = $prod->price_base_type; - // We define price for product + // If price per segment if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level)) { $pu_ht = $prod->multiprices[$object->thirdparty->price_level]; @@ -1657,6 +1657,7 @@ if (empty($reshook)) if (empty($tva_tx)) $tva_npr=0; } } + // If price per customer elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php'; @@ -1678,6 +1679,37 @@ if (empty($reshook)) } } } + // If price per quantity + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) + { + if ($prod->prices_by_qty[0]) // yes, this product has some prices per quantity + { + // Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp']. + $pqp = GETPOST('pbq','int'); + + // Search price into product_price_by_qty from $prod->id + foreach($prod->prices_by_qty_list[0] as $priceforthequantityarray) + { + if ($priceforthequantityarray['rowid'] != $pqp) continue; + // We found the price + if ($priceforthequantityarray['price_base_type'] == 'HT') + { + $pu_ht = $priceforthequantityarray['unitprice']; + } + else + { + $pu_ttc = $priceforthequantityarray['unitprice']; + } + // Note: the remise_percent or price by qty is used to set data on form, so we will use value from POST. + break; + } + } + } + // If price per quantity and customer + elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY&PRODUIT_MULTIPRICES)) + { + // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level + } $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));