diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index eee4d529751..f74f9d777e8 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -436,7 +436,7 @@ if ($object->id > 0)
// Multiprice level
- if (! empty($conf->global->PRODUIT_MULTIPRICES))
+ if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
print '
';
print '
';
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 80db1bf7efc..83e90677566 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -848,7 +848,28 @@ if (empty($reshook))
// If price per quantity and customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
- // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level
+ if ($prod->prices_by_qty[$object->thirdparty->price_level]) // 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[$object->thirdparty->price_level] 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;
+ }
+ }
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 57b98d1a29a..6d4fafa51ac 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -798,7 +798,27 @@ if (empty($reshook))
// If price per quantity and customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
- // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level
+ if ($prod->prices_by_qty[$object->thirdparty->price_level]) // 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[$object->thirdparty->price_level] 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;
+ }
+ }
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
@@ -1019,8 +1039,8 @@ if (empty($reshook))
$type = $product->type;
$price_min = $product->price_min;
- if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
- $price_min = $product->multiprices_min [$object->thirdparty->price_level];
+ if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($object->thirdparty->price_level))
+ $price_min = $product->multiprices_min[$object->thirdparty->price_level];
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 476319fcdea..d441bae6d49 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -1807,7 +1807,28 @@ if (empty($reshook))
// If price per quantity and customer
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
- // TODO Same than PRODUIT_CUSTOMER_PRICES_BY_QTY but using $object->thirdparty->price_level
+ if ($prod->prices_by_qty[$object->thirdparty->price_level]) // 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[$object->thirdparty->price_level] 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;
+ }
+ }
}
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
@@ -2074,7 +2095,7 @@ if (empty($reshook))
$type = $product->type;
$price_min = $product->price_min;
- if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
+ if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && ! empty($object->thirdparty->price_level))
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 642fe099593..b97f0da6499 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -1943,7 +1943,7 @@ class Form
$selectFields.= ", label_translated";
}
// Price by quantity
- if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
$sql.= ", (SELECT pp.rowid FROM ".MAIN_DB_PREFIX."product_price as pp WHERE pp.fk_product = p.rowid";
if ($price_level >= 1 && !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $sql.= " AND price_level=".$price_level;
@@ -2064,7 +2064,7 @@ class Form
$optJson = array();
$objp = $this->db->fetch_object($result);
- if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1)
+ if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !empty($objp->price_by_qty) && $objp->price_by_qty == 1)
{ // Price by quantity will return many prices for the same product
$sql = "SELECT rowid, quantity, price, unitprice, remise_percent, remise, price_base_type";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
@@ -2213,7 +2213,8 @@ class Form
$found=0;
// Multiprice
- if (empty($hidepriceinlabel) && $price_level >= 1 && $conf->global->PRODUIT_MULTIPRICES) // If we need a particular price level (from 1 to 6)
+ // If we need a particular price level (from 1 to 6)
+ if (empty($hidepriceinlabel) && $price_level >= 1 && (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)))
{
$sql = "SELECT price, price_ttc, price_base_type, tva_tx";
$sql.= " FROM ".MAIN_DB_PREFIX."product_price";
@@ -2254,7 +2255,7 @@ class Form
}
// Price by quantity
- if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY))
+ if (empty($hidepriceinlabel) && !empty($objp->quantity) && $objp->quantity >= 1 && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)))
{
$found = 1;
$outqty=$objp->quantity;
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 78ef6c2f1c3..fba96096dc7 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -478,6 +478,24 @@ class FormFile
$modellist=ModelePDFProductBatch::liste_modeles($this->db);
}
}
+ elseif ($modulepart == 'stock')
+ {
+ if (is_array($genallowed)) $modellist=$genallowed;
+ else
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.php';
+ $modellist=ModelePDFStock::liste_modeles($this->db);
+ }
+ }
+ elseif ($modulepart == 'movement')
+ {
+ if (is_array($genallowed)) $modellist=$genallowed;
+ else
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
+ $modellist=ModelePDFMovement::liste_modeles($this->db);
+ }
+ }
elseif ($modulepart == 'export')
{
if (is_array($genallowed)) $modellist=$genallowed;
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 06f129299e4..7606f272f5b 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -301,18 +301,14 @@ class pdf_einstein extends ModelePDFCommandes
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
- $tab_height = 130-$top_shift;
- $tab_height_newpage = 150;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
// Incoterm
- $height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
@@ -323,8 +319,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
- $tab_top = $nexY+6;
- $height_incoterms += 4;
+ $tab_top = $nexY+6+$height_incoterms;
}
}
@@ -343,14 +338,14 @@ class pdf_einstein extends ModelePDFCommandes
}
if ($notetoshow)
{
+ $tab_top -= 2;
+
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $tab_top = 88 + $height_incoterms;
-
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -358,12 +353,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
index aed6a7f8205..e1a7640ec62 100644
--- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php
+++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php
@@ -213,16 +213,14 @@ class pdf_strato extends ModelePDFContract
$tab_top = 90;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
- $tab_height = 130;
- $tab_height_newpage = 150;
// Affiche notes
if (! empty($object->note_public))
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -230,12 +228,7 @@ class pdf_strato extends ModelePDFContract
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 2afdd21c82f..f3bc84533ca 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -366,18 +366,14 @@ class pdf_crabe extends ModelePDFFactures
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
- $tab_height = 130-$top_shift;
- $tab_height_newpage = 150;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
// Incoterm
- $height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
@@ -388,8 +384,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
- $tab_top = $nexY+6;
- $height_incoterms += 4;
+ $tab_top = $nexY+6+$height_incoterms;
}
}
@@ -408,14 +403,14 @@ class pdf_crabe extends ModelePDFFactures
}
if ($notetoshow)
{
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $tab_top -= 2;
+
+ $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $tab_top = 88 + $height_incoterms;
-
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -423,12 +418,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 51de90f3c7c..758a11cf439 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -339,18 +339,14 @@ class pdf_azur extends ModelePDFPropales
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
- $tab_height = 130-$top_shift;
- $tab_height_newpage = 150;
- if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
// Incoterm
- $height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
@@ -361,8 +357,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
- $tab_top = $nexY+6;
- $height_incoterms += 4;
+ $tab_top = $nexY+6+$height_incoterms;
}
}
@@ -389,14 +384,14 @@ class pdf_azur extends ModelePDFPropales
}
if ($notetoshow)
{
+ $tab_top -= 2;
+
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $tab_top = 88 + $height_incoterms;
-
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -404,12 +399,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index 6eb9f136a27..2ddff657b3d 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -260,24 +260,21 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
- $tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
- $tab_height = 130;
- $tab_height_newpage = 150;
+ $tab_top = 90+$top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
// Incoterm
- $height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
@@ -288,18 +285,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
- $tab_top = $nexY+6;
- $height_incoterms += 4;
+ $tab_top = $nexY+6+$height_incoterms;
}
}
// Affiche notes
if (! empty($object->note_public))
{
- $tab_top = 88 + $height_incoterms;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -307,12 +303,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
@@ -1082,8 +1073,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$posy+=1;
$pdf->SetTextColor(0,0,60);
+ $top_shift = 0;
// Show list of linked objects
+ $current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY())
+ {
+ $top_shift = $pdf->getY() - $current_y;
+ }
if ($showaddress)
{
@@ -1100,7 +1097,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
@@ -1152,7 +1149,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
// Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
@@ -1175,6 +1172,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
+
+ return $top_shift;
}
/**
diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
index 6947d67fb16..3de234821e1 100644
--- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
+++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php
@@ -310,24 +310,21 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
- $tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
- $tab_height = 130;
- $tab_height_newpage = 150;
+ $tab_top = 90+$top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
// Incoterm
- $height_incoterms = 0;
if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
{
- $tab_top = 88;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
@@ -338,18 +335,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
- $tab_top = $nexY+6;
- $height_incoterms += 4;
+ $tab_top = $nexY+6+$height_incoterms;
}
}
// Affiche notes
if (! empty($object->note_public))
{
- $tab_top = 88 + $height_incoterms;
+ $tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($object->note_public), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -357,13 +353,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
$tab_top = $nexY+6;
}
- else
- {
- $height_note=0;
- }
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
@@ -1207,8 +1198,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$posy+=1;
$pdf->SetTextColor(0,0,60);
+ $top_shift = 0;
// Show list of linked objects
+ $current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY())
+ {
+ $top_shift = $pdf->getY() - $current_y;
+ }
if ($showaddress)
{
@@ -1225,7 +1222,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
@@ -1277,7 +1274,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
@@ -1300,6 +1297,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetXY($posx+2,$posy);
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
}
+
+ return $top_shift;
}
/**
diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
index 227a4258918..67306bc1fd8 100644
--- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
+++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
@@ -340,15 +340,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
- $this->_pagehead($pdf, $object, 1, $outputlangs);
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
- $tab_top = 90;
- $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
- $tab_height = 130;
- $tab_height_newpage = 150;
+ $tab_top = 90+$top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
@@ -365,14 +363,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
if ($notetoshow)
{
- $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
+ $tab_top -= 2;
+
+ $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $tab_top = 88;
-
$pdf->SetFont('','', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($notetoshow), 0, 1);
$nexY = $pdf->GetY();
$height_note=$nexY-$tab_top;
@@ -380,12 +378,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
- $tab_height = $tab_height - $height_note;
- $tab_top = $nexY+6;
- }
- else
- {
- $height_note=0;
+ $tab_top = $nexY+6+$height_note;
}
$iniY = $tab_top + 7;
@@ -1339,8 +1332,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
$posy+=2;
+ $top_shift = 0;
// Show list of linked objects
+ $current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY())
+ {
+ $top_shift = $pdf->getY() - $current_y;
+ }
if ($showaddress)
{
@@ -1358,7 +1357,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->marge_gauche;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
$hautcadre=40;
@@ -1412,7 +1411,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
// Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
- $posy=42;
+ $posy=42+$top_shift;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
@@ -1435,6 +1434,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
}
$pdf->SetTextColor(0,0,0);
+ return $top_shift;
}
/**
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index 3ff76dd1f82..63f10296212 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -541,7 +541,7 @@ print '
'."\n";
*/
$rowspan = 4;
-if (! empty($conf->global->PRODUIT_MULTIPRICES)) $rowspan++;
+if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $rowspan++;
if (empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) $rowspan++;
if (! empty($conf->global->MAIN_MULTILANGS)) $rowspan++;
@@ -553,7 +553,7 @@ $current_rule = 'PRODUCT_PRICE_UNIQ';
if (!empty($conf->global->PRODUIT_MULTIPRICES)) $current_rule='PRODUIT_MULTIPRICES';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) $current_rule='PRODUIT_CUSTOMER_PRICES_BY_QTY';
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $current_rule='PRODUIT_CUSTOMER_PRICES';
-if ((!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) && (!empty($conf->global->PRODUIT_MULTIPRICES))) $current_rule='PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
+if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) $current_rule='PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES';
print $form->selectarray("princingrule",$select_pricing_rules,$current_rule);
if ( empty($conf->multicompany->enabled))
{
@@ -566,7 +566,7 @@ print '';
// multiprix nombre de prix a proposer
-if (! empty($conf->global->PRODUIT_MULTIPRICES))
+if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
print '
';
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 2f035c6dc68..353b53f698b 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -1665,7 +1665,7 @@ class Product extends CommonObject
// If multiprices are enabled, then we check if the current product is subject to price autogeneration
// Price will be modified ONLY when the first one is the one that is being modified
- if (!empty($conf->global->PRODUIT_MULTIPRICES) && !$ignore_autogen && $this->price_autogen && ($level == 1))
+ if ((!empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && !$ignore_autogen && $this->price_autogen && ($level == 1))
{
return $this->generateMultiprices($user, $newprice, $newpricebase, $newvat, $newnpr, $newpbq);
}
@@ -2088,7 +2088,71 @@ class Product extends CommonObject
}
else if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // prices per customer and quantity
{
- // Not yet implemented
+ for ($i=1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
+ {
+ $sql = "SELECT price, price_ttc, price_min, price_min_ttc,";
+ $sql.= " price_base_type, tva_tx, default_vat_code, tosell, price_by_qty, rowid, recuperableonly";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_price";
+ $sql.= " WHERE entity IN (".getEntity('productprice').")";
+ $sql.= " AND price_level=".$i;
+ $sql.= " AND fk_product = ".$this->id;
+ $sql.= " ORDER BY date_price DESC, rowid DESC";
+ $sql.= " LIMIT 1";
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $result = $this->db->fetch_array($resql);
+
+ $this->multiprices[$i]=$result["price"];
+ $this->multiprices_ttc[$i]=$result["price_ttc"];
+ $this->multiprices_min[$i]=$result["price_min"];
+ $this->multiprices_min_ttc[$i]=$result["price_min_ttc"];
+ $this->multiprices_base_type[$i]=$result["price_base_type"];
+ // Next two fields are used only if PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on
+ $this->multiprices_tva_tx[$i]=$result["tva_tx"]; // TODO Add ' ('.$result['default_vat_code'].')'
+ $this->multiprices_recuperableonly[$i]=$result["recuperableonly"];
+
+ // Price by quantity
+ $this->prices_by_qty[$i]=$result["price_by_qty"];
+ $this->prices_by_qty_id[$i]=$result["rowid"];
+ // Récuperation de la liste des prix selon qty si flag positionné
+ if ($this->prices_by_qty[$i] == 1)
+ {
+ $sql = "SELECT rowid, price, unitprice, quantity, remise_percent, remise, price_base_type";
+ $sql.= " FROM ".MAIN_DB_PREFIX."product_price_by_qty";
+ $sql.= " WHERE fk_product_price = ".$this->prices_by_qty_id[$i];
+ $sql.= " ORDER BY quantity ASC";
+ $resultat=array();
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ $ii=0;
+ while ($result= $this->db->fetch_array($resql)) {
+ $resultat[$ii]=array();
+ $resultat[$ii]["rowid"]=$result["rowid"];
+ $resultat[$ii]["price"]= $result["price"];
+ $resultat[$ii]["unitprice"]= $result["unitprice"];
+ $resultat[$ii]["quantity"]= $result["quantity"];
+ $resultat[$ii]["remise_percent"]= $result["remise_percent"];
+ $resultat[$ii]["remise"]= $result["remise"]; // deprecated
+ $resultat[$ii]["price_base_type"]= $result["price_base_type"];
+ $ii++;
+ }
+ $this->prices_by_qty_list[$i]=$resultat;
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
}
if (!empty($conf->dynamicprices->enabled) && !empty($this->fk_price_expression) && empty($ignore_expression))
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index bb7f0a5d6bd..ad73b57d76f 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -72,7 +72,7 @@ if ($id > 0 || ! empty($ref))
}
// Clean param
-if (! empty($conf->global->PRODUIT_MULTIPRICES) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
+if ((! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) && empty($conf->global->PRODUIT_MULTIPRICES_LIMIT)) $conf->global->PRODUIT_MULTIPRICES_LIMIT = 5;
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('productpricecard','globalcard'));
@@ -202,7 +202,7 @@ if (empty($reshook))
}
// Multiprices
- if (! $error && ! empty($conf->global->PRODUIT_MULTIPRICES)) {
+ if (! $error && (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) {
$newprice = GETPOST('price', 'array');
$newprice_min = GETPOST('price_min', 'array');
@@ -717,7 +717,7 @@ print '';
print '
';
// Price per customer segment/level
-if (! empty($conf->global->PRODUIT_MULTIPRICES))
+if (! empty($conf->global->PRODUIT_MULTIPRICES) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))
{
// Price and min price are variable (depends on level of company).
if (! empty($socid))
@@ -880,10 +880,11 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print '';
// Price by quantity
- if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // TODO Fix the form included into a tr instead of a td
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // TODO Fix the form included into a tr instead of a td
{
print '
';
@@ -935,9 +936,9 @@ if (! empty($conf->global->PRODUIT_MULTIPRICES))
print ''; // id in product_price
print '
';
print '
';
- print '
' . $object->price_base_type . '
';
- // print '
';
- print '
%
';
+ print '
' . $object->price_base_type . '
';
+ print '
';
+ print '
%
';
print '
';
print '
';
print '';
@@ -991,7 +992,7 @@ else
print '';
// Price by quantity
- if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) // TODO Fix the form inside tr instead of td
+ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || ! empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) // TODO Fix the form inside tr instead of td
{
print '