NEW: Add management of date begin/end and discount for a customer price (Code)
This commit is contained in:
parent
fbac78e6f8
commit
7ba21bd23d
17 changed files with 406 additions and 126 deletions
|
|
@ -1169,20 +1169,26 @@ if (empty($reshook)) {
|
|||
if ($result) {
|
||||
// If there is some prices specific to the customer
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
/*$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$price_min_ttc = price($custprice_line->price_min_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
/*$tva_tx = ($custprice_line->default_vat_code ? $custprice_line->tva_tx.' ('.$custprice_line->default_vat_code.' )' : $custprice_line->tva_tx);
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$custprice_line->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1227,19 +1233,25 @@ if (empty($reshook)) {
|
|||
if ($result) {
|
||||
// If there is some prices specific to the customer
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
/*$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$price_min_ttc = price($custprice_line->price_min_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
/*$tva_tx = ($custprice_line->default_vat_code ? $custprice_line->tva_tx.' ('.$custprice_line->default_vat_code.' )' : $custprice_line->tva_tx);
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$custprice_line->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
} elseif (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY')) {
|
||||
|
|
|
|||
|
|
@ -1541,10 +1541,17 @@ class Propal extends CommonObject
|
|||
if ($result) {
|
||||
// If there is some prices specific to the customer
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx);
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$tva_tx = ($custprice_line->default_vat_code ? $custprice_line->tva_tx . ' (' . $custprice_line->default_vat_code . ' )' : $custprice_line->tva_tx);
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
|
||||
}
|
||||
$remise_percent = $custprice_line->remise_percent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -877,19 +877,25 @@ if (empty($reshook)) {
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result >= 0) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', (string) $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$price_min_ttc = price($custprice_line->price_min_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
$tva_tx = $custprice_line->tva_tx;
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', (string)$tva_tx)) {
|
||||
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -938,18 +944,24 @@ if (empty($reshook)) {
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result >= 0) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$price_min_ttc = price($custprice_line->price_min_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
$tva_tx = $custprice_line->tva_tx;
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -567,16 +567,22 @@ if (empty($reshook)) {
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||
/*$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$price_min_ttc = price($custprice_line->price_min_ttc);
|
||||
/*$tva_tx = $custprice_line->tva_tx;
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$custprice_line->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2995,8 +2995,8 @@ class Form
|
|||
//Price by customer
|
||||
if ((getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($socid)) {
|
||||
$sql .= ', pcp.rowid as idprodcustprice, pcp.price as custprice, pcp.price_ttc as custprice_ttc,';
|
||||
$sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx, pcp.default_vat_code as custdefault_vat_code, pcp.ref_customer as custref';
|
||||
$selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref";
|
||||
$sql .= ' pcp.price_base_type as custprice_base_type, pcp.tva_tx as custtva_tx, pcp.default_vat_code as custdefault_vat_code, pcp.ref_customer as custref, pcp.remise_percent as custremise_percent';
|
||||
$selectFields .= ", idprodcustprice, custprice, custprice_ttc, custprice_base_type, custtva_tx, custdefault_vat_code, custref, custremise_percent";
|
||||
}
|
||||
// Units
|
||||
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
|
||||
|
|
@ -3047,7 +3047,20 @@ class Form
|
|||
|
||||
//Price by customer
|
||||
if ((getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($socid)) {
|
||||
$sql .= " LEFT JOIN " . $this->db->prefix() . "product_customer_price as pcp ON pcp.fk_soc=" . ((int) $socid) . " AND pcp.fk_product=p.rowid";
|
||||
$now = dol_now();
|
||||
$sql .= " LEFT JOIN (";
|
||||
$sql .= " SELECT pcp1.*";
|
||||
$sql .= " FROM " . $this->db->prefix() . "product_customer_price AS pcp1";
|
||||
$sql .= " LEFT JOIN (";
|
||||
$sql .= " SELECT fk_soc, fk_product, MIN(date_begin) AS date_begin";
|
||||
$sql .= " FROM " . $this->db->prefix() . "product_customer_price";
|
||||
$sql .= " WHERE fk_soc = " . ((int) $socid);
|
||||
$sql .= " AND date_begin <= '" . $this->db->idate($now) . "'";
|
||||
$sql .= " AND (date_end IS NULL OR '" . $this->db->idate($now) . "' <= date_end)";
|
||||
$sql .= " GROUP BY fk_soc, fk_product";
|
||||
$sql .= " ) AS pcp2 ON pcp1.fk_soc = pcp2.fk_soc AND pcp1.fk_product = pcp2.fk_product AND pcp1.date_begin = pcp2.date_begin";
|
||||
$sql .= " WHERE pcp2.fk_soc IS NOT NULL";
|
||||
$sql .= " ) AS pcp ON pcp.fk_soc = " . ((int) $socid) . " AND pcp.fk_product = p.rowid";
|
||||
}
|
||||
// Units
|
||||
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
|
||||
|
|
@ -3588,6 +3601,7 @@ class Form
|
|||
$outpricebasetype = $objp->custprice_base_type;
|
||||
$outtva_tx = $objp->custtva_tx;
|
||||
$outdefault_vat_code = $objp->custdefault_vat_code;
|
||||
$outdiscount = $objp->custremise_percent;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1747,9 +1747,18 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
|
|||
$nbCustomerPrices = $productCustomerPriceStatic->fetchAll('', '', 1, 0, $filter);
|
||||
|
||||
if ($nbCustomerPrices > 0) {
|
||||
$productCustomerPrice = $productCustomerPriceStatic->lines[0];
|
||||
$productCustomerPrice = null;
|
||||
if (count($productCustomerPriceStatic->lines) > 0) {
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($productCustomerPriceStatic->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$productCustomerPrice = $custprice_line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($productCustomerPrice->ref_customer)) {
|
||||
if (isset($productCustomerPrice) && !empty($productCustomerPrice->ref_customer)) {
|
||||
switch ($conf->global->PRODUIT_CUSTOMER_PRICES_PDF_REF_MODE) {
|
||||
case 1:
|
||||
$ref_prodserv = $productCustomerPrice->ref_customer;
|
||||
|
|
|
|||
|
|
@ -380,11 +380,14 @@ class modProduct extends DolibarrModules
|
|||
$this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref", 'p.label' => "Label",
|
||||
's.nom' => 'ThirdParty',
|
||||
's.code_client' => 'CodeClient',
|
||||
'pr.date_begin' => "AppliedPricesFrom",
|
||||
'pr.date_end' => "AppliedPricesTo",
|
||||
'pr.price_base_type' => "PriceBase",
|
||||
'pr.price' => "PriceUnitPriceHT", 'pr.price_ttc' => "PriceUnitPriceTTC",
|
||||
'pr.price_min' => "MinPriceUnitPriceHT", 'pr.price_min_ttc' => "MinPriceUnitPriceTTC",
|
||||
'pr.tva_tx' => 'PriceVATRate',
|
||||
'pr.default_vat_code' => 'PriceVATCode',
|
||||
'pr.remise_percent' => 'Discount',
|
||||
'pr.datec' => 'DateCreation');
|
||||
if (is_object($mysoc) && $usenpr) {
|
||||
$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
|
|
@ -392,11 +395,14 @@ class modProduct extends DolibarrModules
|
|||
$this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product", 'p.label' => "Label",
|
||||
's.nom' => 'company',
|
||||
's.code_client' => 'company',
|
||||
'pr.date_begin' => "product",
|
||||
'pr.date_end' => "product",
|
||||
'pr.price_base_type' => "product", 'pr.price' => "product",
|
||||
'pr.price_ttc' => "product",
|
||||
'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
|
||||
'pr.tva_tx' => 'product',
|
||||
'pr.default_vat_code' => 'product',
|
||||
'pr.remise_percent' => 'product',
|
||||
'pr.recuperableonly' => 'product',
|
||||
'pr.datec' => "product");
|
||||
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
|
|
|
|||
|
|
@ -327,22 +327,28 @@ class modService extends DolibarrModules
|
|||
$this->export_permission[$r] = array(array("service", "export"));
|
||||
$this->export_fields_array[$r] = array('p.rowid' => "Id", 'p.ref' => "Ref",
|
||||
's.nom' => 'ThirdParty',
|
||||
'pr.date_begin' => "AppliedPricesFrom",
|
||||
'pr.date_end' => "AppliedPricesTo",
|
||||
'pr.price_base_type' => "PriceBase",
|
||||
'pr.price' => "PriceUnitPriceHT", 'pr.price_ttc' => "PriceUnitPriceTTC",
|
||||
'pr.price_min' => "MinPriceUnitPriceHT", 'pr.price_min_ttc' => "MinPriceUnitPriceTTC",
|
||||
'pr.tva_tx' => 'PriceVATRate',
|
||||
'pr.default_vat_code' => 'PriceVATCode',
|
||||
'pr.remise_percent' => 'Discount',
|
||||
'pr.datec' => 'DateCreation');
|
||||
if (is_object($mysoc) && $usenpr) {
|
||||
$this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
|
||||
}
|
||||
$this->export_entities_array[$r] = array('p.rowid' => "product", 'p.ref' => "product",
|
||||
's.nom' => 'company',
|
||||
'pr.date_begin' => "product",
|
||||
'pr.date_end' => "product",
|
||||
'pr.price_base_type' => "product", 'pr.price' => "product",
|
||||
'pr.price_ttc' => "product",
|
||||
'pr.price_min' => "product", 'pr.price_min_ttc' => "product",
|
||||
'pr.tva_tx' => 'product',
|
||||
'pr.default_vat_code' => 'product',
|
||||
'pr.remise_percent' => 'product',
|
||||
'pr.recuperableonly' => 'product',
|
||||
'pr.datec' => "product");
|
||||
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
|
|
|
|||
|
|
@ -938,6 +938,13 @@ if (!empty($usemargins) && $user->hasRight('margins', 'creer')) {
|
|||
$('#tva_tx option[value="'+stringforvatrateselection+'"]').prop('selected', true);
|
||||
|
||||
<?php
|
||||
// Price by customer
|
||||
if ((getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) && !empty($object->socid)) {
|
||||
?>
|
||||
$("#remise_percent").val(data.discount);
|
||||
<?php
|
||||
}
|
||||
|
||||
if (getDolGlobalInt('PRODUIT_AUTOFILL_DESC') == 1) {
|
||||
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) { ?>
|
||||
var proddesc = data.desc_trans;
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ UpdateVAT=Update VAT
|
|||
UpdateDefaultPrice=Update default price
|
||||
UpdateLevelPrices=Update prices for each level
|
||||
AppliedPricesFrom=Applied from
|
||||
AppliedPricesTo=Applied to
|
||||
SellingPrice=Selling price
|
||||
SellingPriceHT=Selling price (excl. tax)
|
||||
SellingPriceTTC=Selling price (inc. tax)
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ UpdateVAT=Mettre à jour la TVA
|
|||
UpdateDefaultPrice=Modifier prix par défaut
|
||||
UpdateLevelPrices=Modifier prix pour chaque niveau
|
||||
AppliedPricesFrom=Pratiqués à partir du
|
||||
AppliedPricesTo=Pratiqués jusqu'au
|
||||
SellingPrice=Prix de vente
|
||||
SellingPriceHT=Prix de vente HT
|
||||
SellingPriceTTC=Prix de vente TTC
|
||||
|
|
|
|||
|
|
@ -220,13 +220,20 @@ if ($action == 'fetch' && !empty($id)) {
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$found = true;
|
||||
$outprice_ht = price($prodcustprice->lines[0]->price);
|
||||
$outprice_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$outpricebasetype = $prodcustprice->lines[0]->price_base_type;
|
||||
$outtva_tx_formated = price($prodcustprice->lines[0]->tva_tx);
|
||||
$outtva_tx = price2num($prodcustprice->lines[0]->tva_tx);
|
||||
$outdefault_vat_code = $prodcustprice->lines[0]->default_vat_code;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$found = true;
|
||||
$outprice_ht = price($custprice_line->price);
|
||||
$outprice_ttc = price($custprice_line->price_ttc);
|
||||
$outpricebasetype = $custprice_line->price_base_type;
|
||||
$outtva_tx_formated = price($custprice_line->tva_tx);
|
||||
$outtva_tx = price2num($custprice_line->tva_tx);
|
||||
$outdefault_vat_code = $custprice_line->default_vat_code;
|
||||
$outdiscount = $custprice_line->remise_percent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1156,10 +1156,16 @@ if (empty($reshook)) {
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines [0]->price);
|
||||
$pu_ttc = price($prodcustprice->lines [0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines [0]->price_base_type;
|
||||
$tva_tx = $prodcustprice->lines [0]->tva_tx;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
$tva_tx = $custprice_line->tva_tx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2354,18 +2354,24 @@ class Product extends CommonObject
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pricebycustomerexist = true;
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
$tva_tx = $custprice_line->tva_tx;
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2415,17 +2421,23 @@ class Product extends CommonObject
|
|||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
if (count($prodcustprice->lines) > 0) {
|
||||
$pu_ht = price($prodcustprice->lines[0]->price);
|
||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||
$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
|
||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
||||
$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||
}
|
||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
$date_now = (int) floor(dol_now() / 86400) * 86400; // date without hours
|
||||
foreach ($prodcustprice->lines as $k => $custprice_line) {
|
||||
if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
|
||||
$pu_ht = price($custprice_line->price);
|
||||
$price_min = price($custprice_line->price_min);
|
||||
$pu_ttc = price($custprice_line->price_ttc);
|
||||
$price_base_type = $custprice_line->price_base_type;
|
||||
$tva_tx = $custprice_line->tva_tx;
|
||||
if ($custprice_line->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||
$tva_tx .= ' (' . $custprice_line->default_vat_code . ')';
|
||||
}
|
||||
$tva_npr = $custprice_line->recuperableonly;
|
||||
if (empty($tva_tx)) {
|
||||
$tva_npr = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ class ProductCustomerPrice extends CommonObject
|
|||
'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'visible' => 4, 'position' => 10, 'notnull' => 1, 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'comment' => "Reference of object", 'showoncombobox' => 1, 'noteditable' => 1),
|
||||
'fk_product' => array('type' => 'integer:Product:product/class/product.class.php:0', 'label' => 'Product', 'enabled' => '$conf->product->enabled', 'visible' => 1, 'position' => 35, 'notnull' => 1, 'index' => 1, 'comment' => "Product to produce", 'css' => 'maxwidth300', 'csslist' => 'tdoverflowmax100', 'picto' => 'product'),
|
||||
'ref_customer' => array('type' => 'varchar(128)', 'label' => 'RefCustomer', 'enabled' => 1, 'visible' => 4, 'position' => 10, 'notnull' => 1,),
|
||||
'datec' => array('type' => 'datetime', 'label' => 'AppliedPricesFrom', 'enabled' => 1, 'visible' => 1, 'position' => 500, 'notnull' => 1,),
|
||||
'date_begin' => array('type' => 'date', 'label' => 'AppliedPricesFrom', 'enabled' => 1, 'visible' => 1, 'position' => 500, 'notnull' => 1,),
|
||||
'date_end' => array('type' => 'date', 'label' => 'AppliedPricesTo', 'enabled' => 1, 'visible' => 1, 'position' => 501, 'notnull' => 1,),
|
||||
'price_base_type' => array('type' => 'varchar(255)', 'label' => 'PriceBase', 'enabled' => 1, 'visible' => 1, 'position' => 11, 'notnull' => -1, 'comment' => 'Price Base Type'),
|
||||
'tva_tx' => array('type' => 'decimal(20,6)', 'label' => 'VAT', 'enabled' => 1, 'visible' => 1, 'position' => 12, 'notnull' => -1, 'comment' => 'TVA Tax Rate'),
|
||||
'price' => array('type' => 'decimal(20,6)', 'label' => 'HT', 'enabled' => 1, 'visible' => 1, 'position' => 8, 'notnull' => -1, 'comment' => 'Price HT'),
|
||||
|
|
@ -46,6 +47,7 @@ class ProductCustomerPrice extends CommonObject
|
|||
'price_min' => array('type' => 'decimal(20,6)', 'label' => 'MinPriceHT', 'enabled' => 1, 'visible' => 1, 'position' => 9, 'notnull' => -1, 'comment' => 'Minimum Price'),
|
||||
'price_min_ttc' => array('type' => 'decimal(20,6)', 'label' => 'MinPriceTTC', 'enabled' => 1, 'visible' => 1, 'position' => 10, 'notnull' => -1, 'comment' => 'Minimum Price TTC'),
|
||||
'price_label' => array('type' => 'varchar(255)', 'label' => 'PriceLabel', 'enabled' => 1, 'visible' => 1, 'position' => 20, 'notnull' => -1, 'comment' => 'Price Label'),
|
||||
'remise_percent' => array('type' => 'decimal(20,6)', 'label' => 'Discount', 'enabled' => 1, 'visible' => 1, 'position' => 30, 'notnull' => -1, 'comment' => 'Discount'),
|
||||
'fk_user' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'visible' => 1, 'position' => 510, 'notnull' => 1, 'foreignkey' => 'user.rowid', 'csslist' => 'tdoverflowmax100'),
|
||||
);
|
||||
|
||||
|
|
@ -136,6 +138,18 @@ class ProductCustomerPrice extends CommonObject
|
|||
* @var string
|
||||
*/
|
||||
public $price_label;
|
||||
/**
|
||||
* @var float|string|''
|
||||
*/
|
||||
public $remise_percent;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $date_begin = '';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $date_end = '';
|
||||
|
||||
/**
|
||||
* @var int User ID
|
||||
|
|
@ -212,6 +226,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
if (isset($this->localtax2_tx)) {
|
||||
$this->localtax2_tx = trim($this->localtax2_tx);
|
||||
}
|
||||
if (empty($this->remise_percent) || !is_numeric($this->remise_percent)) {
|
||||
$this->remise_percent = 0;
|
||||
}
|
||||
if (isset($this->fk_user)) {
|
||||
$this->fk_user = (int) $this->fk_user;
|
||||
}
|
||||
|
|
@ -257,6 +274,8 @@ class ProductCustomerPrice extends CommonObject
|
|||
}
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".$this->db->prefix()."product_customer_price(";
|
||||
$sql .= "entity,";
|
||||
|
|
@ -276,12 +295,15 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= "localtax1_tx,";
|
||||
$sql .= "localtax2_type,";
|
||||
$sql .= "localtax2_tx,";
|
||||
$sql .= "remise_percent,";
|
||||
$sql .= "date_begin,";
|
||||
$sql .= "date_end,";
|
||||
$sql .= "fk_user,";
|
||||
$sql .= "price_label,";
|
||||
$sql .= "import_key";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= " ".((int) $conf->entity).",";
|
||||
$sql .= " '".$this->db->idate(dol_now())."',";
|
||||
$sql .= " '".$this->db->idate($now)."',";
|
||||
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : ((int) $this->fk_product)).",";
|
||||
$sql .= " ".(!isset($this->fk_soc) ? 'NULL' : ((int) $this->fk_soc)).",";
|
||||
$sql .= " ".(!isset($this->ref_customer) ? 'NULL' : "'".$this->db->escape($this->ref_customer)."'").",";
|
||||
|
|
@ -297,6 +319,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " ".(!isset($this->localtax1_tx) ? 'NULL' : (empty($this->localtax1_tx) ? 0 : $this->localtax1_tx)).",";
|
||||
$sql .= " ".(empty($this->localtax2_type) ? "'0'" : "'".$this->db->escape($this->localtax2_type)."'").",";
|
||||
$sql .= " ".(!isset($this->localtax2_tx) ? 'NULL' : (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx)).",";
|
||||
$sql .= " ".(empty($this->remise_percent) ? '0' : "'".$this->db->escape(price2num($this->remise_percent))."'").",";
|
||||
$sql .= " '".$this->db->idate(empty($this->date_begin) ? $now : $this->date_begin)."',";
|
||||
$sql .= " ".(empty($this->date_end) ? 'NULL' : "'".$this->db->idate($this->date_end)."'").",";
|
||||
$sql .= " ".((int) $user->id).",";
|
||||
$sql .= " ".(!isset($this->price_label) ? 'NULL' : "'".$this->db->escape($this->price_label)."'").",";
|
||||
$sql .= " ".(!isset($this->import_key) ? 'NULL' : "'".$this->db->escape($this->import_key)."'");
|
||||
|
|
@ -371,6 +396,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " t.recuperableonly,";
|
||||
$sql .= " t.localtax1_tx,";
|
||||
$sql .= " t.localtax2_tx,";
|
||||
$sql .= " t.remise_percent,";
|
||||
$sql .= " t.date_begin,";
|
||||
$sql .= " t.date_end,";
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.price_label,";
|
||||
$sql .= " t.import_key";
|
||||
|
|
@ -401,6 +429,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$this->recuperableonly = $obj->recuperableonly;
|
||||
$this->localtax1_tx = $obj->localtax1_tx;
|
||||
$this->localtax2_tx = $obj->localtax2_tx;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$this->date_begin = $this->db->jdate($obj->date_begin);
|
||||
$this->date_end = $this->db->jdate($obj->date_end);
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->price_label = $obj->price_label;
|
||||
$this->import_key = $obj->import_key;
|
||||
|
|
@ -433,7 +464,7 @@ class ProductCustomerPrice extends CommonObject
|
|||
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '')
|
||||
{
|
||||
if (empty($sortfield)) {
|
||||
$sortfield = "t.rowid";
|
||||
$sortfield = "t.date_begin";
|
||||
}
|
||||
if (empty($sortorder)) {
|
||||
$sortorder = "DESC";
|
||||
|
|
@ -459,6 +490,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " t.localtax2_tx,";
|
||||
$sql .= " t.localtax1_type,";
|
||||
$sql .= " t.localtax2_type,";
|
||||
$sql .= " t.remise_percent,";
|
||||
$sql .= " t.date_begin,";
|
||||
$sql .= " t.date_end,";
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.price_label,";
|
||||
$sql .= " t.import_key,";
|
||||
|
|
@ -482,7 +516,7 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
|
||||
} elseif ($key == 'prod.ref' || $key == 'prod.label') {
|
||||
$sql .= " AND ".$this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
|
||||
} elseif ($key == 't.price' || $key == 't.price_ttc') {
|
||||
} elseif ($key == 't.price' || $key == 't.price_ttc' || $key == 't.remise_percent') {
|
||||
$sql .= " AND ".$this->db->sanitize($key)." = ".((float) price2num($value));
|
||||
} else {
|
||||
$sql .= " AND ".$this->db->sanitize($key)." = ".((int) $value);
|
||||
|
|
@ -536,6 +570,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$line->localtax2_tx = $obj->localtax2_tx;
|
||||
$line->localtax1_type = $obj->localtax1_type;
|
||||
$line->localtax2_type = $obj->localtax2_type;
|
||||
$line->remise_percent = $obj->remise_percent;
|
||||
$line->date_begin = $this->db->jdate($obj->date_begin);
|
||||
$line->date_end = $this->db->jdate($obj->date_end);
|
||||
$line->fk_user = $obj->fk_user;
|
||||
$line->price_label = $obj->price_label;
|
||||
$line->import_key = $obj->import_key;
|
||||
|
|
@ -565,10 +602,10 @@ class ProductCustomerPrice extends CommonObject
|
|||
*/
|
||||
public function fetchAllLog($sortorder, $sortfield, $limit, $offset, $filter = array())
|
||||
{
|
||||
if (!empty($sortfield)) {
|
||||
$sortfield = "t.rowid";
|
||||
if (empty($sortfield)) {
|
||||
$sortfield = "t.date_begin";
|
||||
}
|
||||
if (!empty($sortorder)) {
|
||||
if (empty($sortorder)) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
|
||||
|
|
@ -589,6 +626,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " t.recuperableonly,";
|
||||
$sql .= " t.localtax1_tx,";
|
||||
$sql .= " t.localtax2_tx,";
|
||||
$sql .= " t.remise_percent,";
|
||||
$sql .= " t.date_begin,";
|
||||
$sql .= " t.date_end,";
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.price_label,";
|
||||
$sql .= " t.import_key,";
|
||||
|
|
@ -645,6 +685,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$line->recuperableonly = $obj->recuperableonly;
|
||||
$line->localtax1_tx = $obj->localtax1_tx;
|
||||
$line->localtax2_tx = $obj->localtax2_tx;
|
||||
$line->remise_percent = $obj->remise_percent;
|
||||
$line->date_begin = $this->db->jdate($obj->date_begin);
|
||||
$line->date_end = $this->db->jdate($obj->date_end);
|
||||
$line->fk_user = $obj->fk_user;
|
||||
$line->price_label = $obj->price_label;
|
||||
$line->import_key = $obj->import_key;
|
||||
|
|
@ -716,6 +759,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
if (isset($this->localtax2_tx)) {
|
||||
$this->localtax2_tx = trim((string) $this->localtax2_tx);
|
||||
}
|
||||
if (empty($this->remise_percent) || !is_numeric($this->remise_percent)) {
|
||||
$this->remise_percent = 0;
|
||||
}
|
||||
if (isset($this->fk_user)) {
|
||||
$this->fk_user = (int) $this->fk_user;
|
||||
}
|
||||
|
|
@ -782,6 +828,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= "localtax2_tx,";
|
||||
$sql .= "localtax1_type,";
|
||||
$sql .= "localtax2_type,";
|
||||
$sql .= "remise_percent,";
|
||||
$sql .= "date_begin,";
|
||||
$sql .= "date_end,";
|
||||
$sql .= "fk_user,";
|
||||
$sql .= "price_label,";
|
||||
$sql .= "import_key";
|
||||
|
|
@ -806,6 +855,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " t.localtax2_tx,";
|
||||
$sql .= " t.localtax1_type,";
|
||||
$sql .= " t.localtax2_type,";
|
||||
$sql .= " t.remise_percent,";
|
||||
$sql .= " t.date_begin,";
|
||||
$sql .= " t.date_end,";
|
||||
$sql .= " t.fk_user,";
|
||||
$sql .= " t.price_label,";
|
||||
$sql .= " t.import_key";
|
||||
|
|
@ -821,11 +873,13 @@ class ProductCustomerPrice extends CommonObject
|
|||
$this->errors [] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".$this->db->prefix()."product_customer_price SET";
|
||||
|
||||
$sql .= " entity=".((int) $conf->entity).",";
|
||||
$sql .= " datec='".$this->db->idate(dol_now())."',";
|
||||
$sql .= " datec='".$this->db->idate($now)."',";
|
||||
$sql .= " tms=".(dol_strlen((string) $this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
|
||||
$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
|
||||
$sql .= " fk_soc=".(isset($this->fk_soc) ? $this->fk_soc : "null").",";
|
||||
|
|
@ -842,6 +896,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$sql .= " localtax2_tx=".(isset($this->localtax2_tx) ? (empty($this->localtax2_tx) ? 0 : $this->localtax2_tx) : "null").",";
|
||||
$sql .= " localtax1_type=".(!empty($this->localtax1_type) ? "'".$this->db->escape($this->localtax1_type)."'" : "'0'").",";
|
||||
$sql .= " localtax2_type=".(!empty($this->localtax2_type) ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'").",";
|
||||
$sql .= " remise_percent=".(isset($this->remise_percent) ? price2num($this->remise_percent) : "null").",";
|
||||
$sql .= " date_begin='".$this->db->idate(!empty($this->date_begin) ? $this->date_begin : $now)."',";
|
||||
$sql .= " date_end=".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").",";
|
||||
$sql .= " fk_user=".((int) $user->id).",";
|
||||
$sql .= " price_label=".(isset($this->price_label) ? "'".$this->db->escape($this->price_label)."'" : "null").",";
|
||||
$sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null");
|
||||
|
|
@ -939,6 +996,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$prodsocpriceupd->tva_tx = $this->tva_tx;
|
||||
$prodsocpriceupd->recuperableonly = $this->recuperableonly;
|
||||
$prodsocpriceupd->price_label = $this->price_label;
|
||||
$prodsocpriceupd->remise_percent = $this->remise_percent;
|
||||
$prodsocpriceupd->date_begin = $this->date_begin;
|
||||
$prodsocpriceupd->date_end = $this->date_end;
|
||||
|
||||
$resultupd = $prodsocpriceupd->update($user, 0, $forceupdateaffiliate);
|
||||
if ($resultupd < 0) {
|
||||
|
|
@ -958,6 +1018,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$prodsocpricenew->tva_tx = $this->tva_tx;
|
||||
$prodsocpricenew->recuperableonly = $this->recuperableonly;
|
||||
$prodsocpricenew->price_label = $this->price_label;
|
||||
$prodsocpricenew->remise_percent = $this->remise_percent;
|
||||
$prodsocpricenew->date_begin = $this->date_begin;
|
||||
$prodsocpricenew->date_end = $this->date_end;
|
||||
|
||||
$resultupd = $prodsocpricenew->create($user, 0, $forceupdateaffiliate);
|
||||
if ($resultupd < 0) {
|
||||
|
|
@ -1102,6 +1165,9 @@ class ProductCustomerPrice extends CommonObject
|
|||
$this->recuperableonly = '';
|
||||
$this->localtax1_tx = '';
|
||||
$this->localtax2_tx = '';
|
||||
$this->remise_percent = '';
|
||||
$this->date_begin = '';
|
||||
$this->date_end = '';
|
||||
$this->fk_user = 0;
|
||||
$this->price_label = '';
|
||||
$this->import_key = '';
|
||||
|
|
@ -1185,6 +1251,18 @@ class PriceByCustomerLine extends CommonObjectLine
|
|||
* @var float
|
||||
*/
|
||||
public $localtax2_tx;
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
public $remise_percent;
|
||||
/**
|
||||
* @var string|int
|
||||
*/
|
||||
public $date_begin = '';
|
||||
/**
|
||||
* @var string|int
|
||||
*/
|
||||
public $date_end = '';
|
||||
|
||||
/**
|
||||
* @var int User ID
|
||||
|
|
|
|||
|
|
@ -754,6 +754,9 @@ if (empty($reshook)) {
|
|||
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
|
||||
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
|
||||
$prodcustprice->price_label = GETPOST("price_label", 'alpha');
|
||||
$prodcustprice->remise_percent = price2num(GETPOST("remise_percent"));
|
||||
$prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
$prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
|
||||
$extralabels = $extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
|
||||
|
|
@ -906,6 +909,9 @@ if (empty($reshook)) {
|
|||
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
|
||||
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
|
||||
$prodcustprice->price_label = GETPOST("price_label", 'alpha');
|
||||
$prodcustprice->remise_percent = price2num(GETPOST("remise_percent"));
|
||||
$prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
$prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
|
||||
$extralabels = $extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$extrafield_values = $extrafields->getOptionalsFromPost("product_customer_price");
|
||||
|
|
@ -2002,10 +2008,10 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
$sortorder = "ASC,ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "soc.nom";
|
||||
$sortfield = "soc.nom,t.date_begin";
|
||||
}
|
||||
|
||||
// Build filter to display only concerned lines
|
||||
|
|
@ -2042,6 +2048,18 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<tr><td>' . $langs->trans('RefCustomer') . '</td>';
|
||||
print '<td><input name="ref_customer" size="12"></td></tr>';
|
||||
|
||||
// Applied Prices From
|
||||
$date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
|
||||
print $form->selectDate(!empty($date_begin) ? $date_begin : dol_now(), "date_begin", 0, 0, 1, "date_begin");
|
||||
print '</td></tr>';
|
||||
|
||||
// Applied Prices To
|
||||
$date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
|
||||
print $form->selectDate($date_end, "date_end", 0, 0, 1, "date_end");
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DefaultTaxRate").'</td><td>';
|
||||
print $form->load_tva("tva_tx", $object->default_vat_code ? $object->tva_tx.' ('.$object->default_vat_code.')' : $object->tva_tx, $mysoc, null, $object->id, $object->tva_npr, $object->type, false, 1);
|
||||
|
|
@ -2090,6 +2108,12 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Discount
|
||||
$remise_percent = price2num(GETPOST("remise_percent"));
|
||||
print '<tr><td>'.$langs->trans("Discount").'</td><td>';
|
||||
print '<input name="remise_percent" size="10" value="'.price($remise_percent).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Extrafields
|
||||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
|
||||
|
|
@ -2159,6 +2183,16 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<tr><td>' . $langs->trans('RefCustomer') . '</td>';
|
||||
print '<td><input name="ref_customer" size="12" value="' . dol_escape_htmltag($prodcustprice->ref_customer) . '"></td></tr>';
|
||||
|
||||
// Applied Prices From
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
|
||||
print $form->selectDate($prodcustprice->date_begin, "date_begin", 0, 0, 1, "date_begin");
|
||||
print '</td></tr>';
|
||||
|
||||
// Applied Prices To
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
|
||||
print $form->selectDate($prodcustprice->date_end, "date_end", 0, 0, 1, "date_end");
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("DefaultTaxRate").'</td><td>';
|
||||
print $form->load_tva("tva_tx", $prodcustprice->default_vat_code ? $prodcustprice->tva_tx.' ('.$prodcustprice->default_vat_code.')' : $prodcustprice->tva_tx, $mysoc, null, $object->id, $prodcustprice->recuperableonly, $object->type, false, 1);
|
||||
|
|
@ -2201,8 +2235,6 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
}
|
||||
print '</tr>';
|
||||
|
||||
|
||||
|
||||
// Price Label
|
||||
print '<tr><td>';
|
||||
print $langs->trans('PriceLabel');
|
||||
|
|
@ -2211,6 +2243,11 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Discount
|
||||
print '<tr><td>'.$langs->trans("Discount").'</td><td>';
|
||||
print '<input name="remise_percent" size="10" value="'.price($prodcustprice->remise_percent).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Extrafields
|
||||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
|
||||
|
|
@ -2280,6 +2317,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
// List of all log of prices by customers
|
||||
print '<!-- list of all log of prices per customer -->'."\n";
|
||||
|
||||
$sortfield = 't.datec';
|
||||
$filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) GETPOSTINT('socid'));
|
||||
|
||||
// Count total nb of records
|
||||
|
|
@ -2318,6 +2356,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td>'.$langs->trans("ThirdParty").'</td>';
|
||||
print '<td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesTo").'</td>';
|
||||
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
||||
print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>';
|
||||
print '<td class="right">'.$langs->trans("HT").'</td>';
|
||||
|
|
@ -2328,8 +2367,9 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
||||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
||||
print '<td class="right">'.$langs->trans("PriceLabel").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Discount").'</td>';
|
||||
print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td>'.$langs->trans("DateCreation").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($prodcustprice->lines as $line) {
|
||||
|
|
@ -2361,7 +2401,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
|
||||
print '<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1)."</td>";
|
||||
print '<td>'.$line->ref_customer.'</td>';
|
||||
print "<td>".dol_print_date($line->datec, "dayhour", 'tzuserrel')."</td>";
|
||||
print "<td>".dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
|
||||
print "<td>".dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
|
||||
print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
|
||||
print '<td class="right">';
|
||||
|
||||
|
|
@ -2393,6 +2434,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.price($line->price_min).'</td>';
|
||||
print '<td class="right">'.price($line->price_min_ttc).'</td>';
|
||||
print '<td class="right">'.$line->price_label.'</td>';
|
||||
print '<td class="right">'.price($line->remise_percent).'</td>';
|
||||
|
||||
// User
|
||||
$userstatic = new User($db);
|
||||
|
|
@ -2401,6 +2443,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print $userstatic->getNomUrl(1, '', 0, 0, 24, 0, 'login');
|
||||
//print $userstatic->getLoginUrl(1);
|
||||
print '</td>';
|
||||
print "<td>".dol_print_date($line->datec, "dayhour", 'tzuserrel')."</td>";
|
||||
print '</tr>';
|
||||
}
|
||||
print "</table>";
|
||||
|
|
@ -2440,9 +2483,9 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$custom_price_extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
|
||||
if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
|
||||
$colspan = 10;
|
||||
} else {
|
||||
$colspan = 11;
|
||||
} else {
|
||||
$colspan = 12;
|
||||
}
|
||||
if ($mysoc->localtax1_assuj == "1" || $mysoc->localtax2_assuj == "1") {
|
||||
$colspan++;
|
||||
|
|
@ -2466,6 +2509,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td>'.$langs->trans("ThirdParty").'</td>';
|
||||
print '<td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesTo").'</td>';
|
||||
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
||||
print '<td class="right">'.$langs->trans("DefaultTaxRate").'</td>';
|
||||
print '<td class="right">'.$langs->trans("HT").'</td>';
|
||||
|
|
@ -2476,6 +2520,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
||||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
||||
print '<td class="right">'.$langs->trans("PriceLabel").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Discount").'</td>';
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
if ($extrafields->attributes["product_customer_price"] && array_key_exists('label', $extrafields->attributes["product_customer_price"])) {
|
||||
|
|
@ -2522,7 +2567,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
if (!getDolGlobalString('PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES')) {
|
||||
print '<!-- PRODUIT_CUSTOMER_PRICES_AND_MULTIPRICES -->'."\n";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td colspan="3">' . $langs->trans('Default') . '</td>';
|
||||
print '<td colspan="4">' . $langs->trans('Default') . '</td>';
|
||||
|
||||
print '<td class="center">'.$langs->trans($object->price_base_type)."</td>";
|
||||
|
||||
|
|
@ -2560,6 +2605,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.price($object->price_min_ttc).'</td>';
|
||||
print '<td class="right">'.$object->price_label.'</td>';
|
||||
print '<td class="right"></td>';
|
||||
print '<td class="right"></td>';
|
||||
if (!empty($extralabels)) {
|
||||
foreach ($extralabels as $key) {
|
||||
// Show field if not hidden
|
||||
|
|
@ -2612,7 +2658,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
|
||||
print '<td class="tdoverflowmax125">'.$staticsoc->getNomUrl(1)."</td>";
|
||||
print '<td>'.dol_escape_htmltag($line->ref_customer).'</td>';
|
||||
print "<td>".dol_print_date($line->datec, "dayhour", 'tzuserrel')."</td>";
|
||||
print "<td>".dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
|
||||
print "<td>".dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
|
||||
print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
|
||||
// VAT Rate
|
||||
print '<td class="right">';
|
||||
|
|
@ -2646,6 +2693,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.price($line->price_min).'</td>';
|
||||
print '<td class="right">'.price($line->price_min_ttc).'</td>';
|
||||
print '<td class="right">'.$line->price_label.'</td>';
|
||||
print '<td class="right">'.price($line->remise_percent).'</td>';
|
||||
|
||||
// Extrafields
|
||||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
|
|
|
|||
|
|
@ -115,6 +115,9 @@ if (empty($reshook)) {
|
|||
$prodcustprice->price = price2num(GETPOST("price"), 'MU');
|
||||
$prodcustprice->price_min = price2num(GETPOST("price_min"), 'MU');
|
||||
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
|
||||
$prodcustprice->remise_percent = price2num(GETPOST("remise_percent"));
|
||||
$prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
$prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
|
||||
$tva_tx_txt = GETPOST('tva_tx', 'alpha'); // tva_tx can be '8.5' or '8.5*' or '8.5 (XXX)' or '8.5* (XXX)'
|
||||
|
||||
|
|
@ -213,6 +216,9 @@ if (empty($reshook)) {
|
|||
$prodcustprice->price_base_type = GETPOST("price_base_type", 'alpha');
|
||||
$prodcustprice->tva_tx = str_replace('*', '', GETPOST("tva_tx"));
|
||||
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
|
||||
$prodcustprice->remise_percent = price2num(GETPOST("remise_percent"));
|
||||
$prodcustprice->date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
$prodcustprice->date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
|
||||
$result = $prodcustprice->update($user, 0, $update_child_soc);
|
||||
if ($result > 0) {
|
||||
|
|
@ -323,10 +329,10 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
$sortorder = "ASC,ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "soc.nom";
|
||||
$sortfield = "soc.nom,t.date_begin";
|
||||
}
|
||||
|
||||
// Build filter to display only related lines
|
||||
|
|
@ -376,6 +382,18 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td><input name="ref_customer" size="12"></td></tr>';
|
||||
|
||||
// Applied Prices From
|
||||
$date_begin = dol_mktime(0, 0, 0, GETPOST('date_beginmonth', 'int'), GETPOST('date_beginday', 'int'), GETPOST('date_beginyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server;
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
|
||||
print $form->selectDate(!empty($date_begin) ? $date_begin : dol_now(), "date_begin", 0, 0, 1, "date_begin");
|
||||
print '</td></tr>';
|
||||
|
||||
// Applied Prices To
|
||||
$date_end = dol_mktime(0, 0, 0, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
|
||||
print $form->selectDate($date_end, "date_end", 0, 0, 1, "date_end");
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $form->load_tva("tva_tx", GETPOST("tva_tx", "alpha"), $mysoc, null, $object->id, 0, '', false, 1);
|
||||
|
|
@ -405,6 +423,12 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td><input name="price_min" size="10" value="'.GETPOSTINT('price_min').'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Discount
|
||||
$remise_percent = price2num(GETPOST("remise_percent"));
|
||||
print '<tr><td>'.$langs->trans("Discount").'</td><td>';
|
||||
print '<input name="remise_percent" size="10" value="'.price($remise_percent).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Update all child soc
|
||||
print '<tr><td width="15%">';
|
||||
print $langs->trans('ForceUpdateChildPriceSoc');
|
||||
|
|
@ -469,6 +493,16 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<tr><td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td><input name="ref_customer" size="12" value="'.dol_escape_htmltag($prodcustprice->ref_customer).'"></td></tr>';
|
||||
|
||||
// Applied Prices From
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesFrom").'</td><td>';
|
||||
print $form->selectDate($prodcustprice->date_begin, "date_begin", 0, 0, 1, "date_begin");
|
||||
print '</td></tr>';
|
||||
|
||||
// Applied Prices To
|
||||
print '<tr><td>'.$langs->trans("AppliedPricesTo").'</td><td>';
|
||||
print $form->selectDate($prodcustprice->date_end, "date_end", 0, 0, 1, "date_end");
|
||||
print '</td></tr>';
|
||||
|
||||
// VAT
|
||||
print '<tr><td>'.$langs->trans("VATRate").'</td><td>';
|
||||
print $form->load_tva("tva_tx", $prodcustprice->tva_tx, $mysoc, null, $staticprod->id, $prodcustprice->recuperableonly);
|
||||
|
|
@ -507,6 +541,11 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Discount
|
||||
print '<tr><td>'.$langs->trans("Discount").'</td><td>';
|
||||
print '<input name="remise_percent" size="10" value="'.price($prodcustprice->remise_percent).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Extrafields
|
||||
$extrafields->fetch_name_optionals_label("product_customer_price");
|
||||
$extralabels = !empty($extrafields->attributes["product_customer_price"]['label']) ? $extrafields->attributes["product_customer_price"]['label'] : '';
|
||||
|
|
@ -577,6 +616,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<br>';
|
||||
print '<!-- showlog_customer_price -->'."\n";
|
||||
|
||||
$sortfield = 't.datec';
|
||||
$filter = array(
|
||||
't.fk_product' => (string) GETPOSTINT('prodid'),
|
||||
't.fk_soc' => (string) $socid
|
||||
|
|
@ -609,14 +649,16 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td>'.$langs->trans("Product").'</td>';
|
||||
print '<td>'.$langs->trans('RefCustomer').'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesFrom").'</td>';
|
||||
print '<td>'.$langs->trans("AppliedPricesTo").'</td>';
|
||||
print '<td class="center">'.$langs->trans("PriceBase").'</td>';
|
||||
print '<td class="right">'.$langs->trans("VAT").'</td>';
|
||||
print '<td class="right">'.$langs->trans("HT").'</td>';
|
||||
print '<td class="right">'.$langs->trans("TTC").'</td>';
|
||||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("HT").'</td>';
|
||||
print '<td class="right">'.$langs->trans("MinPrice").' '.$langs->trans("TTC").'</td>';
|
||||
print '<td class="right">'.$langs->trans("Discount").'</td>';
|
||||
print '<td class="right">'.$langs->trans("ChangedBy").'</td>';
|
||||
print '<td></td>';
|
||||
print '<td>'.$langs->trans("DateCreation").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($prodcustprice->lines as $line) {
|
||||
|
|
@ -630,7 +672,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
|
||||
print "<td>".$staticprod->getNomUrl(1)."</td>";
|
||||
print '<td>'.$line->ref_customer.'</td>';
|
||||
print "<td>".dol_print_date($line->datec, "dayhour")."</td>";
|
||||
print "<td>".dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
|
||||
print "<td>".dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
|
||||
|
||||
print '<td class="center">'.$langs->trans($line->price_base_type)."</td>";
|
||||
print '<td class="right">'.vatrate($line->tva_tx, true, $line->recuperableonly)."</td>";
|
||||
|
|
@ -638,12 +681,13 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="right">'.price($line->price_ttc)."</td>";
|
||||
print '<td class="right">'.price($line->price_min).'</td>';
|
||||
print '<td class="right">'.price($line->price_min_ttc).'</td>';
|
||||
print '<td class="right">'.price($line->remise_percent).'</td>';
|
||||
|
||||
// User
|
||||
print '<td class="right">';
|
||||
print $userstatic->getNomUrl(-1);
|
||||
print '</td>';
|
||||
print '<td></td>';
|
||||
print "<td>".dol_print_date($line->datec, "dayhour", 'tzuserrel')."</td>";
|
||||
}
|
||||
print "</table>";
|
||||
} else {
|
||||
|
|
@ -786,12 +830,14 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price" value="'.$search_price.'"></td>';
|
||||
print '<td class="liste_titre left"><input type="text" class="flat width75" name="search_price_ttc" value="'.$search_price_ttc.'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
if (!empty($extralabels)) {
|
||||
foreach ($extralabels as $key) {
|
||||
print '<td class="right"></td>';
|
||||
|
|
@ -818,7 +864,8 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="left">'.$staticprod->getNomUrl(1)."</td>";
|
||||
print '<td class="left">'.$staticprod->label."</td>";
|
||||
print '<td class="left">'.$line->ref_customer.'</td>';
|
||||
print '<td class="left">'.dol_print_date($line->datec, "dayhour")."</td>";
|
||||
print '<td class="left">'.dol_print_date($line->date_begin, "day", 'tzuserrel')."</td>";
|
||||
print '<td class="left">'.dol_print_date($line->date_end, "day", 'tzuserrel')."</td>";
|
||||
print '<td class="left">'.$langs->trans($line->price_base_type)."</td>";
|
||||
print '<td class="left">'.vatrate($line->tva_tx.($line->default_vat_code ? ' ('.$line->default_vat_code.')' : ''), true, $line->recuperableonly)."</td>";
|
||||
print '<td class="left">'.price($line->price)."</td>";
|
||||
|
|
@ -826,6 +873,7 @@ if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') || getDolGlobalString('PRODUIT
|
|||
print '<td class="left">'.price($line->price_min).'</td>';
|
||||
print '<td class="left">'.price($line->price_min_ttc).'</td>';
|
||||
print '<td class="left">'.$line->price_label.'</td>';
|
||||
print '<td class="left">'.price($line->remise_percent).'</td>';
|
||||
// User
|
||||
print '<td class="left">';
|
||||
print $userstatic->getNomUrl(-1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue