Fix edition of margins in recurring invoices
This commit is contained in:
parent
83c369cc0f
commit
c3732f2b7a
@ -1943,7 +1943,7 @@ if (empty($reshook))
|
|||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
// Define output language
|
// Define output language and generate document
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
@ -2055,7 +2055,7 @@ if (empty($reshook))
|
|||||||
$line->fetch(GETPOST('lineid'));
|
$line->fetch(GETPOST('lineid'));
|
||||||
$percent = $line->get_prev_progress($object->id);
|
$percent = $line->get_prev_progress($object->id);
|
||||||
|
|
||||||
if($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref>0)
|
if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref>0)
|
||||||
{
|
{
|
||||||
// in case of situation credit note
|
// in case of situation credit note
|
||||||
if(GETPOST('progress') >= 0 )
|
if(GETPOST('progress') >= 0 )
|
||||||
@ -2147,7 +2147,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'),
|
$result = $object->updateline(GETPOST('lineid'), $description, $pu_ht, $qty, GETPOST('remise_percent'),
|
||||||
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
|
$date_start, $date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $type,
|
||||||
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'),
|
GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('progress'),
|
||||||
$_POST['units'], $pu_ht_devise);
|
$_POST['units'], $pu_ht_devise);
|
||||||
|
|||||||
@ -527,7 +527,7 @@ class FactureRec extends CommonInvoice
|
|||||||
|
|
||||||
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
|
||||||
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
|
||||||
$sql.= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc,';
|
$sql.= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,';
|
||||||
//$sql.= ' l.situation_percent, l.fk_prev_id,';
|
//$sql.= ' l.situation_percent, l.fk_prev_id,';
|
||||||
//$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
|
//$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
|
||||||
$sql.= ' l.rang, l.special_code,';
|
$sql.= ' l.rang, l.special_code,';
|
||||||
@ -583,6 +583,11 @@ class FactureRec extends CommonInvoice
|
|||||||
$line->total_tva = $objp->total_tva;
|
$line->total_tva = $objp->total_tva;
|
||||||
$line->total_ttc = $objp->total_ttc;
|
$line->total_ttc = $objp->total_ttc;
|
||||||
$line->code_ventilation = $objp->fk_code_ventilation;
|
$line->code_ventilation = $objp->fk_code_ventilation;
|
||||||
|
$line->fk_fournprice = $objp->fk_fournprice;
|
||||||
|
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht);
|
||||||
|
$line->pa_ht = $marginInfos[0];
|
||||||
|
$line->marge_tx = $marginInfos[1];
|
||||||
|
$line->marque_tx = $marginInfos[2];
|
||||||
$line->rang = $objp->rang;
|
$line->rang = $objp->rang;
|
||||||
$line->special_code = $objp->special_code;
|
$line->special_code = $objp->special_code;
|
||||||
$line->fk_unit = $objp->fk_unit;
|
$line->fk_unit = $objp->fk_unit;
|
||||||
@ -695,15 +700,17 @@ class FactureRec extends CommonInvoice
|
|||||||
* @param double $pu_ht_devise Unit price in currency
|
* @param double $pu_ht_devise Unit price in currency
|
||||||
* @param int $date_start_fill 1=Flag to fill start date when generating invoice
|
* @param int $date_start_fill 1=Flag to fill start date when generating invoice
|
||||||
* @param int $date_end_fill 1=Flag to fill end date when generating invoice
|
* @param int $date_end_fill 1=Flag to fill end date when generating invoice
|
||||||
|
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
|
||||||
|
* @param int $pa_ht Buying price of line (to calculate margin) or ''
|
||||||
* @return int <0 if KO, Id of line if OK
|
* @return int <0 if KO, Id of line if OK
|
||||||
*/
|
*/
|
||||||
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0)
|
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
|
|
||||||
$facid=$this->id;
|
$facid=$this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise,date_start_fill=$date_start_fill,date_end_fill=$date_end_fill", LOG_DEBUG);
|
dol_syslog(get_class($this)."::addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva,txlocaltax1=$txlocaltax1,txlocaltax2=$txlocaltax2,fk_product=$fk_product,remise_percent=$remise_percent,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type,fk_unit=$fk_unit,pu_ht_devise=$pu_ht_devise,date_start_fill=$date_start_fill,date_end_fill=$date_end_fill,pa_ht=$pa_ht", LOG_DEBUG);
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
@ -795,6 +802,8 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql.= ", total_ttc";
|
$sql.= ", total_ttc";
|
||||||
$sql.= ", date_start_fill";
|
$sql.= ", date_start_fill";
|
||||||
$sql.= ", date_end_fill";
|
$sql.= ", date_end_fill";
|
||||||
|
$sql.= ", fk_product_fournisseur_price";
|
||||||
|
$sql.= ", buy_price_ht";
|
||||||
$sql.= ", info_bits";
|
$sql.= ", info_bits";
|
||||||
$sql.= ", rang";
|
$sql.= ", rang";
|
||||||
$sql.= ", special_code";
|
$sql.= ", special_code";
|
||||||
@ -824,6 +833,8 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql.= ", ".price2num($total_ttc);
|
$sql.= ", ".price2num($total_ttc);
|
||||||
$sql.= ", ".(int) $date_start_fill;
|
$sql.= ", ".(int) $date_start_fill;
|
||||||
$sql.= ", ".(int) $date_end_fill;
|
$sql.= ", ".(int) $date_end_fill;
|
||||||
|
$sql.= ", ".($fk_fournprice > 0 ? $fk_fournprice : 'null');
|
||||||
|
$sql.= ", ".($pa_ht ? price2num($pa_ht) : 0);
|
||||||
$sql.= ", ".$info_bits;
|
$sql.= ", ".$info_bits;
|
||||||
$sql.= ", ".$rang;
|
$sql.= ", ".$rang;
|
||||||
$sql.= ", ".$special_code;
|
$sql.= ", ".$special_code;
|
||||||
@ -877,9 +888,11 @@ class FactureRec extends CommonInvoice
|
|||||||
* @param int $notrigger disable line update trigger
|
* @param int $notrigger disable line update trigger
|
||||||
* @param int $date_start_fill 1=Flag to fill start date when generating invoice
|
* @param int $date_start_fill 1=Flag to fill start date when generating invoice
|
||||||
* @param int $date_end_fill 1=Flag to fill end date when generating invoice
|
* @param int $date_end_fill 1=Flag to fill end date when generating invoice
|
||||||
|
* @param int $fk_fournprice Id of origin supplier price
|
||||||
|
* @param int $pa_ht Price (without tax) of product when it was bought
|
||||||
* @return int <0 if KO, Id of line if OK
|
* @return int <0 if KO, Id of line if OK
|
||||||
*/
|
*/
|
||||||
public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0)
|
public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0)
|
||||||
{
|
{
|
||||||
global $mysoc;
|
global $mysoc;
|
||||||
|
|
||||||
@ -894,16 +907,6 @@ class FactureRec extends CommonInvoice
|
|||||||
// Check parameters
|
// Check parameters
|
||||||
if ($type < 0) return -1;
|
if ($type < 0) return -1;
|
||||||
|
|
||||||
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
|
||||||
|
|
||||||
// Clean vat code
|
|
||||||
$vat_src_code='';
|
|
||||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
|
||||||
{
|
|
||||||
$vat_src_code = $reg[1];
|
|
||||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->brouillon)
|
if ($this->brouillon)
|
||||||
{
|
{
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
@ -932,10 +935,20 @@ class FactureRec extends CommonInvoice
|
|||||||
$pu=$pu_ttc;
|
$pu=$pu_ttc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcul du total TTC et de la TVA pour la ligne a partir de
|
// Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
|
||||||
// qty, pu, remise_percent et txtva
|
|
||||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||||
|
|
||||||
|
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||||
|
|
||||||
|
// Clean vat code
|
||||||
|
$vat_src_code='';
|
||||||
|
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||||
|
{
|
||||||
|
$vat_src_code = $reg[1];
|
||||||
|
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||||
|
}
|
||||||
|
|
||||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
|
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
|
||||||
|
|
||||||
$total_ht = $tabprice[0];
|
$total_ht = $tabprice[0];
|
||||||
@ -984,6 +997,8 @@ class FactureRec extends CommonInvoice
|
|||||||
$sql.= ", total_ttc='".price2num($total_ttc)."'";
|
$sql.= ", total_ttc='".price2num($total_ttc)."'";
|
||||||
$sql.= ", date_start_fill=".((int) $date_start_fill);
|
$sql.= ", date_start_fill=".((int) $date_start_fill);
|
||||||
$sql.= ", date_end_fill=".((int) $date_end_fill);
|
$sql.= ", date_end_fill=".((int) $date_end_fill);
|
||||||
|
$sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null');
|
||||||
|
$sql.= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0);
|
||||||
$sql.= ", info_bits=".$info_bits;
|
$sql.= ", info_bits=".$info_bits;
|
||||||
$sql.= ", rang=".$rang;
|
$sql.= ", rang=".$rang;
|
||||||
$sql.= ", special_code=".$special_code;
|
$sql.= ", special_code=".$special_code;
|
||||||
|
|||||||
@ -100,6 +100,20 @@ $permissionnote = $user->rights->facture->creer; // Used by the include of actio
|
|||||||
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
|
$permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php
|
||||||
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
|
$permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php
|
||||||
|
|
||||||
|
$usercanread = $user->rights->facture->lire;
|
||||||
|
$usercancreate = $user->rights->facture->creer;
|
||||||
|
$usercanissuepayment = $user->rights->facture->paiement;
|
||||||
|
$usercandelete = $user->rights->facture->supprimer;
|
||||||
|
$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->validate)));
|
||||||
|
$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->send);
|
||||||
|
$usercanreopen = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->facture->invoice_advance->reopen);
|
||||||
|
$usercanunvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($usercancreate)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->facture->invoice_advance->unvalidate)));
|
||||||
|
|
||||||
|
$usercanproductignorepricemin = ((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS));
|
||||||
|
$usercancreatemargin = $user->rights->margins->creer;
|
||||||
|
$usercanreadallmargin = $user->rights->margins->liretous;
|
||||||
|
$usercancreatewithdrarequest = $user->rights->prelevement->bons->creer;
|
||||||
|
|
||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
|
|
||||||
@ -435,10 +449,12 @@ if (empty($reshook))
|
|||||||
$predef='';
|
$predef='';
|
||||||
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
|
||||||
$price_ht = GETPOST('price_ht');
|
$price_ht = GETPOST('price_ht');
|
||||||
if (GETPOST('prod_entry_mode') == 'free')
|
$price_ht_devise = GETPOST('multicurrency_price_ht');
|
||||||
|
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
|
||||||
|
if ($prod_entry_mode == 'free')
|
||||||
{
|
{
|
||||||
$idprod=0;
|
$idprod=0;
|
||||||
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
|
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -466,11 +482,11 @@ if (empty($reshook))
|
|||||||
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) {
|
if ($prod_entry_mode == 'free' && empty($idprod) && GETPOST('type') < 0) {
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
if ($prod_entry_mode == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not ''
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
@ -479,7 +495,7 @@ if (empty($reshook))
|
|||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) {
|
if ($prod_entry_mode == 'free' && empty($idprod) && empty($product_desc)) {
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), null, 'errors');
|
||||||
$error ++;
|
$error ++;
|
||||||
}
|
}
|
||||||
@ -524,48 +540,17 @@ if (empty($reshook))
|
|||||||
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
|
||||||
if (empty($tva_tx)) $tva_npr=0;
|
if (empty($tva_tx)) $tva_npr=0;
|
||||||
|
|
||||||
$pu_ht = $prod->price;
|
// Search the correct price into loaded array product_price_by_qty using id of array retrieved into POST['pqp'].
|
||||||
$pu_ttc = $prod->price_ttc;
|
$pqp = (GETPOST('pbq', 'int') ? GETPOST('pbq', 'int') : 0);
|
||||||
$price_min = $prod->price_min;
|
|
||||||
$price_base_type = $prod->price_base_type;
|
|
||||||
|
|
||||||
// We define price for product
|
$datapriceofproduct = $prod->getSellPrice($mysoc, $object->thirdparty, $pqp);
|
||||||
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
|
|
||||||
{
|
|
||||||
$pu_ht = $prod->multiprices[$object->thirdparty->price_level];
|
|
||||||
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
|
|
||||||
$price_min = $prod->multiprices_min[$object->thirdparty->price_level];
|
|
||||||
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
|
|
||||||
if (! empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) // using this option is a bug. kept for backward compatibility
|
|
||||||
{
|
|
||||||
if (isset($prod->multiprices_tva_tx[$object->thirdparty->price_level])) $tva_tx=$prod->multiprices_tva_tx[$object->thirdparty->price_level];
|
|
||||||
if (isset($prod->multiprices_recuperableonly[$object->thirdparty->price_level])) $tva_npr=$prod->multiprices_recuperableonly[$object->thirdparty->price_level];
|
|
||||||
if (empty($tva_tx)) $tva_npr=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
|
|
||||||
{
|
|
||||||
include_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
|
|
||||||
|
|
||||||
$prodcustprice = new Productcustomerprice($db);
|
$pu_ht = $datapriceofproduct['pu_ht'];
|
||||||
|
$pu_ttc = $datapriceofproduct['pu_ttc'];
|
||||||
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
|
$price_min = $datapriceofproduct['price_min'];
|
||||||
|
$price_base_type = $datapriceofproduct['price_base_type'];
|
||||||
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
|
$tva_tx = $datapriceofproduct['tva_tx'];
|
||||||
if ($result)
|
$tva_npr = $datapriceofproduct['tva_npr'];
|
||||||
{
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$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));
|
||||||
@ -620,12 +605,33 @@ if (empty($reshook))
|
|||||||
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
|
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
|
||||||
{
|
{
|
||||||
$tmptxt = '(';
|
$tmptxt = '(';
|
||||||
|
// Define output language
|
||||||
|
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang = '';
|
||||||
|
if (empty($newlang) && GETPOST('lang_id', 'alpha'))
|
||||||
|
$newlang = GETPOST('lang_id', 'alpha');
|
||||||
|
if (empty($newlang))
|
||||||
|
$newlang = $object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang)) {
|
||||||
|
$outputlangs = new Translate("", $conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
$outputlangs->load('products');
|
||||||
|
}
|
||||||
|
if (! empty($prod->customcode))
|
||||||
|
$tmptxt .= $outputlangs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
|
||||||
|
if (! empty($prod->customcode) && ! empty($prod->country_code))
|
||||||
|
$tmptxt .= ' - ';
|
||||||
|
if (! empty($prod->country_code))
|
||||||
|
$tmptxt .= $outputlangs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $outputlangs, 0);
|
||||||
|
} else {
|
||||||
if (! empty($prod->customcode))
|
if (! empty($prod->customcode))
|
||||||
$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
|
$tmptxt .= $langs->transnoentitiesnoconv("CustomCode") . ': ' . $prod->customcode;
|
||||||
if (! empty($prod->customcode) && ! empty($prod->country_code))
|
if (! empty($prod->customcode) && ! empty($prod->country_code))
|
||||||
$tmptxt .= ' - ';
|
$tmptxt .= ' - ';
|
||||||
if (! empty($prod->country_code))
|
if (! empty($prod->country_code))
|
||||||
$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
|
$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
|
||||||
|
}
|
||||||
$tmptxt .= ')';
|
$tmptxt .= ')';
|
||||||
$desc = dol_concatdesc($desc, $tmptxt);
|
$desc = dol_concatdesc($desc, $tmptxt);
|
||||||
}
|
}
|
||||||
@ -661,18 +667,18 @@ if (empty($reshook))
|
|||||||
if ($tva_npr)
|
if ($tva_npr)
|
||||||
$info_bits |= 0x01;
|
$info_bits |= 0x01;
|
||||||
|
|
||||||
if (((!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->produit->ignore_price_min_advance)) || empty($conf->global->MAIN_USE_ADVANCED_PERMS) )&& (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min))))
|
if ($usercanproductignorepricemin && (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($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');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Insert line
|
// Insert line
|
||||||
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill);
|
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit, 0, $date_start_fill, $date_end_fill, $fournprice, $buyingprice);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
// Define output language and generate document
|
||||||
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
|
||||||
{
|
{
|
||||||
// Define output language
|
// Define output language
|
||||||
@ -741,7 +747,7 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($action == 'updateline' && $user->rights->facture->creer && ! GETPOST('cancel', 'alpha'))
|
elseif ($action == 'updateline' && $usercancreate && ! GETPOST('cancel', 'alpha'))
|
||||||
{
|
{
|
||||||
if (! $object->fetch($id) > 0) dol_print_error($db);
|
if (! $object->fetch($id) > 0) dol_print_error($db);
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
@ -855,7 +861,7 @@ if (empty($reshook))
|
|||||||
// Update line
|
// Update line
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$result = $object->updateline(
|
$result = $object->updateline(
|
||||||
GETPOST('lineid'),
|
GETPOST('lineid'),
|
||||||
$description,
|
$description,
|
||||||
$pu_ht,
|
$pu_ht,
|
||||||
@ -877,7 +883,9 @@ $result = $object->updateline(
|
|||||||
$pu_ht_devise,
|
$pu_ht_devise,
|
||||||
0,
|
0,
|
||||||
$date_start_fill,
|
$date_start_fill,
|
||||||
$date_end_fill
|
$date_end_fill,
|
||||||
|
$fournprice,
|
||||||
|
$buyingprice
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
|
|||||||
@ -3913,7 +3913,7 @@ abstract class CommonObject
|
|||||||
|
|
||||||
// Define usemargins
|
// Define usemargins
|
||||||
$usemargins=0;
|
$usemargins=0;
|
||||||
if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element, array('facture','propal','commande'))) $usemargins=1;
|
if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element, array('facture','facturerec','propal','commande'))) $usemargins=1;
|
||||||
|
|
||||||
$num = count($this->lines);
|
$num = count($this->lines);
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,7 @@ if (empty($object) || ! is_object($object)) {
|
|||||||
|
|
||||||
|
|
||||||
$usemargins=0;
|
$usemargins=0;
|
||||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','propal','commande')))
|
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande')))
|
||||||
{
|
{
|
||||||
$usemargins=1;
|
$usemargins=1;
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ if (empty($senderissupplier)) $senderissupplier=0;
|
|||||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||||
|
|
||||||
|
|
||||||
// Define colspan for button Add
|
// Define colspan for the button 'Add'
|
||||||
$colspan = 3; // Columns: total ht + col edit + col delete
|
$colspan = 3; // Columns: total ht + col edit + col delete
|
||||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required
|
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan++;//Add column for Total (currency) if required
|
||||||
if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
if (in_array($object->element, array('propal','commande','order','facture','facturerec','invoice','supplier_proposal','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||||
|
|||||||
@ -40,7 +40,7 @@ if (empty($object) || ! is_object($object))
|
|||||||
|
|
||||||
|
|
||||||
$usemargins=0;
|
$usemargins=0;
|
||||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','propal','commande'))) $usemargins=1;
|
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande'))) $usemargins=1;
|
||||||
|
|
||||||
global $forceall, $senderissupplier, $inputalsopricewithtax;
|
global $forceall, $senderissupplier, $inputalsopricewithtax;
|
||||||
if (empty($dateSelector)) $dateSelector=0;
|
if (empty($dateSelector)) $dateSelector=0;
|
||||||
@ -49,11 +49,10 @@ if (empty($senderissupplier)) $senderissupplier=0;
|
|||||||
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
if (empty($inputalsopricewithtax)) $inputalsopricewithtax=0;
|
||||||
|
|
||||||
|
|
||||||
// Define colspan for button Add
|
// Define colspan for the button 'Add'
|
||||||
$colspan = 3; // Col total ht + col edit + col delete
|
$colspan = 3; // Col total ht + col edit + col delete
|
||||||
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
|
if (! empty($inputalsopricewithtax)) $colspan++; // We add 1 if col total ttc
|
||||||
if (in_array($object->element, array('propal','supplier_proposal','facture','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
if (in_array($object->element, array('propal','supplier_proposal','facture','facturerec','invoice','commande','order','order_supplier','invoice_supplier'))) $colspan++; // With this, there is a column move button
|
||||||
if (empty($user->rights->margins->creer)) $colspan++;
|
|
||||||
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2;
|
if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) $colspan+=2;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@ -252,7 +251,7 @@ $coldisplay=0;
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- colspan=4 for this td because it replace total_ht+3 td for buttons -->
|
<!-- colspan for this td because it replace total_ht+3 td for buttons+... -->
|
||||||
<td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay+=$colspan; ?>
|
<td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay+=$colspan; ?>
|
||||||
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
|
<input type="submit" class="button" id="savelinebutton" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
|
||||||
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
|
<input type="submit" class="button" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
|
||||||
|
|||||||
@ -48,7 +48,7 @@ if (empty($object) || ! is_object($object))
|
|||||||
global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
|
global $forceall, $senderissupplier, $inputalsopricewithtax, $outputalsopricetotalwithtax;
|
||||||
|
|
||||||
$usemargins=0;
|
$usemargins=0;
|
||||||
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','propal','commande'))) $usemargins=1;
|
if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($object->element, array('facture','facturerec','propal','commande'))) $usemargins=1;
|
||||||
|
|
||||||
if (empty($dateSelector)) $dateSelector=0;
|
if (empty($dateSelector)) $dateSelector=0;
|
||||||
if (empty($forceall)) $forceall=0;
|
if (empty($forceall)) $forceall=0;
|
||||||
@ -253,9 +253,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
|
|||||||
|
|
||||||
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
|
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
|
||||||
{
|
{
|
||||||
?>
|
if (!empty($user->rights->margins->creer)) { ?>
|
||||||
|
|
||||||
<?php if (!empty($user->rights->margins->creer)) { ?>
|
|
||||||
<td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
<td class="linecolmargin1 nowrap margininfos right"><?php $coldisplay++; ?><?php echo price($line->pa_ht); ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
|
<?php if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?>
|
||||||
@ -336,14 +334,14 @@ $domData .= ' data-product_type="'.$line->product_type.'"';
|
|||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<td <?php echo (($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"'); ?>><?php $coldisplay++; ?></td>
|
<td <?php echo (($conf->browser->layout != 'phone' && empty($disablemove)) ?' class="linecolmove tdlineupdown center"':' class="linecolmove center"'); ?>><?php $coldisplay++; ?></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
|
<td colspan="3"><?php $coldisplay=$coldisplay+3; ?></td>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
<?php if($action == 'selectlines'){ ?>
|
if($action == 'selectlines'){ ?>
|
||||||
<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
|
<td class="linecolcheck center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user