NEW VAT can be modified during add of line
This commit is contained in:
parent
2f2c710a33
commit
3769861a8a
@ -938,12 +938,12 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
|
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$tva_tx = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tva_tx = GETPOST('tva_tx', 'alpha');
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
|
||||||
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
|
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
|
||||||
if (empty($remise_percent)) {
|
if (empty($remise_percent)) {
|
||||||
@ -992,6 +992,8 @@ if (empty($reshook)) {
|
|||||||
if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
|
if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) {
|
||||||
$pu_ht = 0;
|
$pu_ht = 0;
|
||||||
$pu_ttc = 0;
|
$pu_ttc = 0;
|
||||||
|
$pu_ht_devise = 0;
|
||||||
|
$pu_ttc_devise = 0;
|
||||||
$price_min = 0;
|
$price_min = 0;
|
||||||
$price_min_ttc = 0;
|
$price_min_ttc = 0;
|
||||||
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
|
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
|
||||||
@ -1002,7 +1004,6 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Ecrase $pu par celui du produit
|
// Ecrase $pu par celui du produit
|
||||||
// Ecrase $desc par celui du produit
|
// Ecrase $desc par celui du produit
|
||||||
// Ecrase $tva_tx par celui du produit
|
|
||||||
// Replaces $fk_unit with the product unit
|
// Replaces $fk_unit with the product unit
|
||||||
if (!empty($idprod) && $idprod > 0) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
@ -1011,11 +1012,11 @@ if (empty($reshook)) {
|
|||||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||||
|
|
||||||
// Update if prices fields are defined
|
// Update if prices fields are defined
|
||||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
/*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||||
if (empty($tva_tx)) {
|
if (empty($tva_tx)) {
|
||||||
$tva_npr = 0;
|
$tva_npr = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// Price unique per product
|
// Price unique per product
|
||||||
$pu_ht = $prod->price;
|
$pu_ht = $prod->price;
|
||||||
@ -1056,14 +1057,14 @@ if (empty($reshook)) {
|
|||||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||||
$price_base_type = $prodcustprice->lines[0]->price_base_type;
|
$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);
|
/*$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)) {
|
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||||
}
|
}
|
||||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||||
if (empty($tva_tx)) {
|
if (empty($tva_tx)) {
|
||||||
$tva_npr = 0;
|
$tva_npr = 0;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
|
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) {
|
||||||
@ -1114,12 +1115,12 @@ if (empty($reshook)) {
|
|||||||
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
|
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
|
||||||
|
|
||||||
// Set unit price to use
|
// Set unit price to use
|
||||||
if (!empty($price_ht) || $price_ht === '0') {
|
if (!empty($price_ht) || (string) $price_ht === '0') {
|
||||||
$pu_ht = price2num($price_ht, 'MU');
|
$pu_ht = price2num($price_ht, 'MU');
|
||||||
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
|
$pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU');
|
||||||
} elseif (!empty($price_ttc) || $price_ttc === '0') {
|
} elseif (!empty($price_ttc) || (string) $price_ttc === '0') {
|
||||||
$pu_ttc = price2num($price_ttc, 'MU');
|
$pu_ttc = price2num($price_ttc, 'MU');
|
||||||
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
|
$pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU');
|
||||||
} elseif ($tmpvat != $tmpprodvat) {
|
} elseif ($tmpvat != $tmpprodvat) {
|
||||||
// Is this still used ?
|
// Is this still used ?
|
||||||
if ($price_base_type != 'HT') {
|
if ($price_base_type != 'HT') {
|
||||||
@ -1416,12 +1417,12 @@ if (empty($reshook)) {
|
|||||||
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
//var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit;
|
||||||
|
|
||||||
if ($usermustrespectpricemin) {
|
if ($usermustrespectpricemin) {
|
||||||
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) {
|
if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < price2num($price_min))) {
|
||||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
$action = 'editline';
|
$action = 'editline';
|
||||||
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) {
|
} elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc))) {
|
||||||
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
|
||||||
setEventMessages($mesg, null, 'errors');
|
setEventMessages($mesg, null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
@ -676,12 +676,11 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
|
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$tva_tx = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tva_tx = GETPOST('tva_tx', 'alpha');
|
||||||
|
|
||||||
// Prepare a price equivalent for minimum price check
|
// Prepare a price equivalent for minimum price check
|
||||||
$pu_equivalent = $pu_ht;
|
$pu_equivalent = $pu_ht;
|
||||||
@ -762,7 +761,6 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Ecrase $pu par celui du produit
|
// Ecrase $pu par celui du produit
|
||||||
// Ecrase $desc par celui du produit
|
// Ecrase $desc par celui du produit
|
||||||
// Ecrase $tva_tx par celui du produit
|
|
||||||
// Ecrase $base_price_type par celui du produit
|
// Ecrase $base_price_type par celui du produit
|
||||||
if (!empty($idprod) && $idprod > 0) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
$prod = new Product($db);
|
$prod = new Product($db);
|
||||||
@ -771,11 +769,11 @@ if (empty($reshook)) {
|
|||||||
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
|
||||||
|
|
||||||
// Update if prices fields are defined
|
// Update if prices fields are defined
|
||||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
/*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||||
if (empty($tva_tx)) {
|
if (empty($tva_tx)) {
|
||||||
$tva_npr = 0;
|
$tva_npr = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$pu_ht = $prod->price;
|
$pu_ht = $prod->price;
|
||||||
$pu_ttc = $prod->price_ttc;
|
$pu_ttc = $prod->price_ttc;
|
||||||
|
|||||||
@ -2038,12 +2038,12 @@ if (empty($reshook)) {
|
|||||||
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
|
||||||
if ($prod_entry_mode == 'free') {
|
if ($prod_entry_mode == 'free') {
|
||||||
$idprod = 0;
|
$idprod = 0;
|
||||||
$tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
|
|
||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
$tva_tx = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tva_tx = GETPOST('tva_tx', 'alpha');
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
|
||||||
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
|
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
|
||||||
if (empty($remise_percent)) {
|
if (empty($remise_percent)) {
|
||||||
@ -2137,7 +2137,6 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
// Ecrase $pu par celui du produit
|
// Ecrase $pu par celui du produit
|
||||||
// Ecrase $desc par celui du produit
|
// Ecrase $desc par celui du produit
|
||||||
// Ecrase $tva_tx par celui du produit
|
|
||||||
// Ecrase $base_price_type par celui du produit
|
// Ecrase $base_price_type par celui du produit
|
||||||
// Replaces $fk_unit with the product's
|
// Replaces $fk_unit with the product's
|
||||||
if (!empty($idprod) && $idprod > 0) {
|
if (!empty($idprod) && $idprod > 0) {
|
||||||
@ -2157,8 +2156,8 @@ if (empty($reshook)) {
|
|||||||
$price_min_ttc = $datapriceofproduct['price_min_ttc'];
|
$price_min_ttc = $datapriceofproduct['price_min_ttc'];
|
||||||
$price_base_type = $datapriceofproduct['price_base_type'];
|
$price_base_type = $datapriceofproduct['price_base_type'];
|
||||||
|
|
||||||
$tva_tx = $datapriceofproduct['tva_tx'];
|
//$tva_tx = $datapriceofproduct['tva_tx'];
|
||||||
$tva_npr = $datapriceofproduct['tva_npr'];
|
//$tva_npr = $datapriceofproduct['tva_npr'];
|
||||||
|
|
||||||
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
|
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
|
||||||
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
|
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
|
||||||
|
|||||||
@ -427,6 +427,7 @@ if (empty($reshook)) {
|
|||||||
} else {
|
} else {
|
||||||
$idprod = GETPOST('idprod', 'int');
|
$idprod = GETPOST('idprod', 'int');
|
||||||
}
|
}
|
||||||
|
|
||||||
$tva_tx = GETPOST('tva_tx', 'alpha');
|
$tva_tx = GETPOST('tva_tx', 'alpha');
|
||||||
|
|
||||||
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
|
||||||
@ -474,11 +475,11 @@ if (empty($reshook)) {
|
|||||||
$prod->fetch($idprod);
|
$prod->fetch($idprod);
|
||||||
|
|
||||||
// Update if prices fields are defined
|
// Update if prices fields are defined
|
||||||
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
/*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
|
||||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||||
if (empty($tva_tx)) {
|
if (empty($tva_tx)) {
|
||||||
$tva_npr = 0;
|
$tva_npr = 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$price_min = $prod->price_min;
|
$price_min = $prod->price_min;
|
||||||
$price_min_ttc = $prod->price_min_ttc;
|
$price_min_ttc = $prod->price_min_ttc;
|
||||||
@ -500,14 +501,14 @@ if (empty($reshook)) {
|
|||||||
if (count($prodcustprice->lines) > 0) {
|
if (count($prodcustprice->lines) > 0) {
|
||||||
$price_min = price($prodcustprice->lines[0]->price_min);
|
$price_min = price($prodcustprice->lines[0]->price_min);
|
||||||
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
$price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
|
||||||
$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
/*$tva_tx = $prodcustprice->lines[0]->tva_tx;
|
||||||
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
|
||||||
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
|
||||||
}
|
}
|
||||||
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
$tva_npr = $prodcustprice->lines[0]->recuperableonly;
|
||||||
if (empty($tva_tx)) {
|
if (empty($tva_tx)) {
|
||||||
$tva_npr = 0;
|
$tva_npr = 0;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -699,7 +700,7 @@ if (empty($reshook)) {
|
|||||||
$date_end_real_update = $objectline->date_end_real;
|
$date_end_real_update = $objectline->date_end_real;
|
||||||
}
|
}
|
||||||
|
|
||||||
$vat_rate = GETPOST('eltva_tx');
|
$vat_rate = GETPOST('eltva_tx', 'alpha');
|
||||||
// Define info_bits
|
// Define info_bits
|
||||||
$info_bits = 0;
|
$info_bits = 0;
|
||||||
if (preg_match('/\*/', $vat_rate)) {
|
if (preg_match('/\*/', $vat_rate)) {
|
||||||
|
|||||||
@ -2344,11 +2344,7 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// mode=1 means customers products
|
// mode=1 means customers products
|
||||||
$urloption = 'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
|
$urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&status_purchase='.$status_purchase.'&finished='.$finished.'&hidepriceinlabel='.$hidepriceinlabel.'&warehousestatus='.$warehouseStatus;
|
||||||
//Price by customer
|
|
||||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
|
||||||
$urloption .= '&socid='.$socid;
|
|
||||||
}
|
|
||||||
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
$out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
|
||||||
|
|
||||||
if (isModEnabled('variants') && is_array($selected_combinations)) {
|
if (isModEnabled('variants') && is_array($selected_combinations)) {
|
||||||
@ -3247,6 +3243,7 @@ class Form
|
|||||||
// mode=2 means suppliers products
|
// mode=2 means suppliers products
|
||||||
$urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
|
$urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
|
||||||
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
|
||||||
|
|
||||||
print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').'<input type="text" class="minwidth300" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.($placeholder ? ' placeholder="'.$placeholder.'"' : '').'>';
|
print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').'<input type="text" class="minwidth300" name="search_'.$htmlname.'" id="search_'.$htmlname.'" value="'.$selected_input_value.'"'.($placeholder ? ' placeholder="'.$placeholder.'"' : '').'>';
|
||||||
} else {
|
} else {
|
||||||
print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
|
print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', $status, 0, 0, $alsoproductwithnosupplierprice, $morecss, 0, $placeholder);
|
||||||
|
|||||||
@ -40,6 +40,7 @@ if (empty($object) || !is_object($object)) {
|
|||||||
print "Error: this template page cannot be called directly as an URL";
|
print "Error: this template page cannot be called directly as an URL";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$usemargins = 0;
|
$usemargins = 0;
|
||||||
if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
|
if (isModEnabled('margin') && !empty($object->element) && in_array($object->element, array('facture', 'facturerec', 'propal', 'commande'))) {
|
||||||
$usemargins = 1;
|
$usemargins = 1;
|
||||||
@ -48,6 +49,7 @@ if (!isset($dateSelector)) {
|
|||||||
global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
|
global $dateSelector; // Take global var only if not already defined into function calling (for example formAddObjectLine)
|
||||||
}
|
}
|
||||||
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
|
global $forceall, $forcetoshowtitlelines, $senderissupplier, $inputalsopricewithtax;
|
||||||
|
global $mysoc;
|
||||||
|
|
||||||
if (!isset($dateSelector)) {
|
if (!isset($dateSelector)) {
|
||||||
$dateSelector = 1; // For backward compatibility
|
$dateSelector = 1; // For backward compatibility
|
||||||
@ -776,6 +778,35 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
var stringforvatrateselection = tva_tx;
|
var stringforvatrateselection = tva_tx;
|
||||||
if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
|
if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') {
|
||||||
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
|
stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')';
|
||||||
|
<?php
|
||||||
|
// Special case for India
|
||||||
|
if (getDolGlobalString('MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA')) {
|
||||||
|
?>
|
||||||
|
console.log("MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA is on so we check if we need to autoswith the vat code");
|
||||||
|
console.log("mysoc->country_code=<?php echo $mysoc->country_code; ?> thirdparty->country_code=<?php echo $object->thirdparty->country_code; ?>");
|
||||||
|
new_default_vat_code = default_vat_code;
|
||||||
|
<?php
|
||||||
|
if ($mysoc->country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code == $object->thirdparty->state_code) {
|
||||||
|
// We are in India and states are same, we revert the vat code "I-x" into "CS-x"
|
||||||
|
?>
|
||||||
|
console.log("Countries are both IN and states are same, so we revert I into CS in default_vat_code="+default_vat_code);
|
||||||
|
new_default_vat_code = default_vat_code.replace(/^I\-/, 'C+S-');
|
||||||
|
<?php
|
||||||
|
} elseif ($mysoc->country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code != $object->thirdparty->state_code) {
|
||||||
|
// We are in India and states differs, we revert the vat code "CS-x" into "I-x"
|
||||||
|
?>
|
||||||
|
console.log("Countries are both IN and states differs, so we revert CS into I in default_vat_code="+default_vat_code);
|
||||||
|
new_default_vat_code = default_vat_code.replace(/^C\+S\-/, 'I-');
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
if (new_default_vat_code != default_vat_code && jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val()) {
|
||||||
|
console.log("We found en entry into VAT with new default_vat_code, we will use it");
|
||||||
|
stringforvatrateselection = jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val();
|
||||||
|
}
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
}
|
}
|
||||||
// Set vat rate if field is an input box
|
// Set vat rate if field is an input box
|
||||||
$('#tva_tx').val(tva_tx);
|
$('#tva_tx').val(tva_tx);
|
||||||
@ -1113,7 +1144,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Function to set fields from choice */
|
/* Function to set fields visibility after selecting a free product */
|
||||||
function setforfree() {
|
function setforfree() {
|
||||||
console.log("objectline_create.tpl::setforfree. We show most fields");
|
console.log("objectline_create.tpl::setforfree. We show most fields");
|
||||||
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
|
jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product
|
||||||
@ -1148,7 +1179,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
|
|||||||
jQuery("#multicurrency_price_ttc").val('').hide();
|
jQuery("#multicurrency_price_ttc").val('').hide();
|
||||||
jQuery("#title_up_ttc, #title_up_ttc_currency").hide();
|
jQuery("#title_up_ttc, #title_up_ttc_currency").hide();
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
jQuery("#tva_tx, #title_vat").hide();
|
/* jQuery("#tva_tx, #title_vat").hide(); */
|
||||||
/* jQuery("#title_fourn_ref").hide(); */
|
/* jQuery("#title_fourn_ref").hide(); */
|
||||||
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
|
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide();
|
||||||
jQuery("#buying_price").show();
|
jQuery("#buying_price").show();
|
||||||
|
|||||||
@ -103,11 +103,19 @@ if ($action == 'fetch' && !empty($id)) {
|
|||||||
|
|
||||||
$price_level = 1;
|
$price_level = 1;
|
||||||
if ($socid > 0) {
|
if ($socid > 0) {
|
||||||
|
$needchangeaccordingtothirdparty = 0;
|
||||||
|
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
|
||||||
|
$needchangeaccordingtothirdparty = 1;
|
||||||
|
}
|
||||||
|
if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
|
||||||
|
$needchangeaccordingtothirdparty = 1;
|
||||||
|
}
|
||||||
|
if ($needchangeaccordingtothirdparty) {
|
||||||
$thirdpartytemp = new Societe($db);
|
$thirdpartytemp = new Societe($db);
|
||||||
$thirdpartytemp->fetch($socid);
|
$thirdpartytemp->fetch($socid);
|
||||||
|
|
||||||
//Load translation description and label
|
//Load translation description and label according to thirdparty language
|
||||||
if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
if (getDolGlobalInt('MAIN_MULTILANGS') && getDolGlobalString('PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE')) {
|
||||||
$newlang = $thirdpartytemp->default_lang;
|
$newlang = $thirdpartytemp->default_lang;
|
||||||
|
|
||||||
if (!empty($newlang)) {
|
if (!empty($newlang)) {
|
||||||
@ -121,10 +129,12 @@ if ($action == 'fetch' && !empty($id)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) {
|
//Set price level according to thirdparty
|
||||||
|
if (getDolGlobalString('PRODUIT_MULTIPRICES') || getDolGlobalString('PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES')) {
|
||||||
$price_level = $thirdpartytemp->price_level;
|
$price_level = $thirdpartytemp->price_level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Price by qty
|
// Price by qty
|
||||||
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { // If we need a particular price related to qty
|
if (!empty($price_by_qty_rowid) && $price_by_qty_rowid >= 1 && (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES))) { // If we need a particular price related to qty
|
||||||
@ -185,7 +195,7 @@ if ($action == 'fetch' && !empty($id)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Price by customer
|
// Price by customer
|
||||||
if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES) && !empty($socid)) {
|
if (getDolGlobalString('PRODUIT_CUSTOMER_PRICES') && !empty($socid)) {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
|
||||||
|
|
||||||
$prodcustprice = new Productcustomerprice($db);
|
$prodcustprice = new Productcustomerprice($db);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user