Implemented units for CommandeFournisseur and FactureFournisseur
This commit is contained in:
parent
270bca740c
commit
7be7a770c1
@ -452,7 +452,7 @@ if (empty($reshook))
|
||||
|
||||
$tva_tx=get_default_tva($mysoc, $object->thirdparty);
|
||||
|
||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options);
|
||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->fk_product, $lines[$i]->remise_percent, 'HT', 0, $lines[$i]->info_bits, $product_type, $lines[$i]->rang, $lines[$i]->special_code, $fk_parent_line, $lines[$i]->fk_fournprice, $lines[$i]->pa_ht, $label, $date_start, $date_end, $array_options, $lines[$i]->fk_unit);
|
||||
|
||||
if ($result > 0) {
|
||||
$lineid = $result;
|
||||
|
||||
@ -338,7 +338,9 @@ if ($action == 'add' && $user->rights->contrat->creer)
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht
|
||||
$lines[$i]->pa_ht,
|
||||
array(),
|
||||
$lines[$i]->fk_unit
|
||||
);
|
||||
|
||||
if ($result < 0)
|
||||
|
||||
@ -97,6 +97,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
$this->posxqty=145;
|
||||
$this->posxdiscount=162;
|
||||
$this->postotalht=174;
|
||||
|
||||
if($conf->global->PRODUCT_USE_UNITS) {
|
||||
$this->posxtva=99;
|
||||
$this->posxup=114;
|
||||
$this->posxqty=133;
|
||||
$this->posxunit=150;
|
||||
}
|
||||
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
|
||||
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
@ -237,7 +244,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
if (empty($this->atleastonediscount))
|
||||
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
|
||||
{
|
||||
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
|
||||
$this->posxtva+=($this->postotalht - $this->posxdiscount);
|
||||
@ -382,9 +389,30 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
$pdf->SetXY($this->posxup, $curY);
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, price($object->lines[$i]->pu_ht), 0, 'R', 0);
|
||||
|
||||
// Unit price before discount
|
||||
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxup, $curY);
|
||||
$pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0);
|
||||
|
||||
// Quantity
|
||||
$pdf->SetXY($this->posxqty, $curY);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $object->lines[$i]->qty, 0, 'R');
|
||||
// Enough for 6 chars
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
|
||||
}
|
||||
|
||||
// Unit
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
|
||||
$pdf->SetXY($this->posxunit, $curY);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
|
||||
}
|
||||
|
||||
// Discount on line
|
||||
$pdf->SetXY($this->posxdiscount, $curY);
|
||||
@ -790,7 +818,23 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->SetXY($this->posxqty-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
}
|
||||
}
|
||||
|
||||
if($conf->global->PRODUCT_USE_UNITS) {
|
||||
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
|
||||
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
|
||||
'C');
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
|
||||
|
||||
@ -103,11 +103,21 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
|
||||
// Defini position des colonnes
|
||||
$this->posxdesc=$this->marge_gauche+1;
|
||||
$this->posxtva=112;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
$this->posxdiscount=162;
|
||||
$this->postotalht=174;
|
||||
|
||||
if ($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$this->posxtva=99;
|
||||
$this->posxup=114;
|
||||
$this->posxqty=133;
|
||||
$this->posxunit=150;
|
||||
} else {
|
||||
$this->posxtva=112;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
}
|
||||
|
||||
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
|
||||
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
|
||||
if ($this->page_largeur < 210) // To work with US executive format
|
||||
@ -245,7 +255,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
$this->atleastonediscount++;
|
||||
}
|
||||
}
|
||||
if (empty($this->atleastonediscount))
|
||||
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
|
||||
{
|
||||
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
|
||||
$this->posxtva+=($this->postotalht - $this->posxdiscount);
|
||||
@ -392,7 +402,23 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
|
||||
// Quantity
|
||||
$pdf->SetXY($this->posxqty, $curY);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $object->lines[$i]->qty, 0, 'R');
|
||||
// Enough for 6 chars
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $object->lines[$i]->qty, 0, 'R');
|
||||
}
|
||||
|
||||
// Unit
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
|
||||
$pdf->SetXY($this->posxunit, $curY);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxunit-0.8, 4, $unit, 0, 'L');
|
||||
}
|
||||
|
||||
// Discount on line
|
||||
$pdf->SetXY($this->posxdiscount, $curY);
|
||||
@ -910,7 +936,23 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
if (empty($hidetop))
|
||||
{
|
||||
$pdf->SetXY($this->posxqty-1, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
if($conf->global->PRODUCT_USE_UNITS)
|
||||
{
|
||||
$pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
|
||||
}
|
||||
}
|
||||
|
||||
if($conf->global->PRODUCT_USE_UNITS) {
|
||||
$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
|
||||
if (empty($hidetop)) {
|
||||
$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
|
||||
$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
|
||||
'C');
|
||||
}
|
||||
}
|
||||
|
||||
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
|
||||
|
||||
@ -129,7 +129,6 @@ $coldisplay=-1; // We remove first td
|
||||
print '></td>';
|
||||
}
|
||||
?>
|
||||
|
||||
<td align="right"><?php $coldisplay++; ?>
|
||||
<?php if (($line->info_bits & 2) != 2) {
|
||||
// I comment this because it shows info even when not required
|
||||
|
||||
@ -247,6 +247,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " l.localtax1_tx, l. localtax2_tx, l.total_localtax1, l.total_localtax2,";
|
||||
$sql.= " l.total_ht, l.total_tva, l.total_ttc, l.special_code, l.fk_parent_line, l.rang,";
|
||||
$sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.description as product_desc,";
|
||||
$sql.= " l.fk_unit,";
|
||||
$sql.= " l.date_start, l.date_end";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
|
||||
@ -297,9 +298,10 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
$line->date_start = $this->db->jdate($objp->date_start);
|
||||
$line->date_end = $this->db->jdate($objp->date_end);
|
||||
$line->fk_unit = $objp->fk_unit;
|
||||
|
||||
$this->special_line = $objp->special_line;
|
||||
$this->fk_parent_line = $objp->fk_parent_line;
|
||||
$this->special_line = $objp->special_line;
|
||||
$this->fk_parent_line = $objp->fk_parent_line;
|
||||
|
||||
$this->rang = $objp->rang;
|
||||
|
||||
@ -1196,13 +1198,14 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param int $date_start Date start of service
|
||||
* @param int $date_end Date end of service
|
||||
* @param array $array_options extrafields array
|
||||
* @param int $fk_unit Id of the unit to use. Null to use the default one
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0)
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $fourn_ref='', $remise_percent=0.0, $price_base_type='HT', $pu_ttc=0.0, $type=0, $info_bits=0, $notrigger=false, $date_start=null, $date_end=null, $array_options=0, $fk_unit = null)
|
||||
{
|
||||
global $langs,$mysoc;
|
||||
|
||||
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2. $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type");
|
||||
dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2. $fk_product, $fk_prod_fourn_price, $fourn_ref, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit");
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
// Clean parameters
|
||||
@ -1305,7 +1308,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " (fk_commande, label, description, date_start, date_end,";
|
||||
$sql.= " fk_product, product_type,";
|
||||
$sql.= " qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice, ref,";
|
||||
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc";
|
||||
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_unit";
|
||||
$sql.= ")";
|
||||
$sql.= " VALUES (".$this->id.", '" . $this->db->escape($label) . "','" . $this->db->escape($desc) . "',";
|
||||
$sql.= " ".($date_start?"'".$this->db->idate($date_start)."'":"null").",";
|
||||
@ -1323,7 +1326,8 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= "'".price2num($total_tva)."',";
|
||||
$sql.= "'".price2num($total_localtax1)."',";
|
||||
$sql.= "'".price2num($total_localtax2)."',";
|
||||
$sql.= "'".price2num($total_ttc)."'";
|
||||
$sql.= "'".price2num($total_ttc)."',";
|
||||
$sql.= (!$fk_unit ? 'NULL' : $fk_unit);
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::addline", LOG_DEBUG);
|
||||
@ -1989,12 +1993,13 @@ class CommandeFournisseur extends CommonOrder
|
||||
* @param timestamp $date_start Date start of service
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_options extrafields array
|
||||
* @param int $fk_unit Id of the unit to use. Null to use the default one
|
||||
* @return int < 0 if error, > 0 if ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
|
||||
{
|
||||
global $mysoc;
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type");
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
if ($this->brouillon)
|
||||
@ -2061,6 +2066,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= ",total_localtax2='".price2num($total_localtax2)."'";
|
||||
$sql.= ",total_ttc='".price2num($total_ttc)."'";
|
||||
$sql.= ",product_type=".$type;
|
||||
$sql.= ",fk_unit=".(!$fk_unit ? 'NULL' : $fk_unit);
|
||||
$sql.= " WHERE rowid = ".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
|
||||
@ -2493,7 +2499,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc,';
|
||||
$sql.= ' cd.total_localtax1, cd.total_localtax2,';
|
||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc,';
|
||||
$sql.= ' cd.date_start, cd.date_end';
|
||||
$sql.= ' cd.date_start, cd.date_end, cd.fk_unit';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as cd';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||
$sql.= ' WHERE cd.rowid = '.$rowid;
|
||||
@ -2526,6 +2532,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
|
||||
|
||||
$this->date_start = $this->db->jdate($objp->date_start);
|
||||
$this->date_end = $this->db->jdate($objp->date_end);
|
||||
$this->fk_unit = $objp->fk_unit;
|
||||
|
||||
$this->db->free($result);
|
||||
return 1;
|
||||
|
||||
@ -480,7 +480,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
{
|
||||
$sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx';
|
||||
$sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 ';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line';
|
||||
$sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit';
|
||||
$sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid';
|
||||
@ -531,6 +531,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->lines[$i]->fk_parent_line = $obj->fk_parent_line;
|
||||
$this->lines[$i]->special_code = $obj->special_code;
|
||||
$this->lines[$i]->rang = $obj->rang;
|
||||
$this->lines[$i]->fk_unit = $obj->fk_unit;
|
||||
|
||||
$i++;
|
||||
}
|
||||
@ -1117,13 +1118,14 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param int $rang Position of line
|
||||
* @param int $notrigger Disable triggers
|
||||
* @param array $array_options extrafields array
|
||||
* @param int $fk_unit Id of the unit to use. Null to use the default one
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*
|
||||
* FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order.
|
||||
*/
|
||||
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0)
|
||||
function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit = null)
|
||||
{
|
||||
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
// Clean parameters
|
||||
@ -1158,7 +1160,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
{
|
||||
$idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det');
|
||||
|
||||
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options);
|
||||
$result=$this->updateline($idligne, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product, $price_base_type, $info_bits, $type, $remise_percent, true, '', '', $array_options, $fk_unit);
|
||||
if ($result > 0)
|
||||
{
|
||||
$this->rowid = $idligne;
|
||||
@ -1213,12 +1215,13 @@ class FactureFournisseur extends CommonInvoice
|
||||
* @param timestamp $date_start Date start of service
|
||||
* @param timestamp $date_end Date end of service
|
||||
* @param array $array_options extrafields array
|
||||
* @param int $fk_unit Id of the unit to use. Null to use the default one
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0)
|
||||
function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false, $date_start='', $date_end='', $array_options=0, $fk_unit = null)
|
||||
{
|
||||
global $mysoc;
|
||||
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent,$fk_unit", LOG_DEBUG);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
$pu = price2num($pu);
|
||||
@ -1288,6 +1291,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
else $sql.= ", fk_product = null";
|
||||
$sql.= ", product_type = ".$product_type;
|
||||
$sql.= ", info_bits = ".$info_bits;
|
||||
$sql .= ", fk_unit=".(!$fk_unit ? 'NULL' : $fk_unit);
|
||||
$sql.= " WHERE rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
|
||||
@ -1877,7 +1881,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
/**
|
||||
* Class to manage line invoices
|
||||
*/
|
||||
class SupplierInvoiceLine extends CommonInvoice
|
||||
class SupplierInvoiceLine extends CommonObjectLine
|
||||
{
|
||||
public $element='facture_fourn_det';
|
||||
public $table_element='facture_fourn_det';
|
||||
|
||||
@ -347,7 +347,8 @@ if (empty($reshook))
|
||||
'',
|
||||
$date_start,
|
||||
$date_end,
|
||||
$array_options
|
||||
$array_options,
|
||||
$productsupplier->fk_unit
|
||||
);
|
||||
}
|
||||
if ($idprod == -99 || $idprod == 0)
|
||||
@ -375,6 +376,12 @@ if (empty($reshook))
|
||||
$desc = $product_desc;
|
||||
$type = GETPOST('type');
|
||||
|
||||
$fk_unit= GETPOST('units', 'int');
|
||||
|
||||
if ($fk_unit <= 0) {
|
||||
$fk_unit = null;
|
||||
}
|
||||
|
||||
$tva_tx = price2num($tva_tx); // When vat is text input field
|
||||
|
||||
// Local Taxes
|
||||
@ -385,15 +392,16 @@ if (empty($reshook))
|
||||
{
|
||||
$price_base_type = 'HT';
|
||||
$ht = price2num(GETPOST('price_ht'));
|
||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, 0, $type,'','', $date_start, $date_end, $array_options);
|
||||
$ttc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ttc = price2num(GETPOST('price_ttc'));
|
||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
||||
$price_base_type = 'HT';
|
||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options);
|
||||
}
|
||||
|
||||
$result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, '', $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit);
|
||||
}
|
||||
|
||||
//print "xx".$tva_tx; exit;
|
||||
@ -513,7 +521,8 @@ if (empty($reshook))
|
||||
false,
|
||||
$date_start,
|
||||
$date_end,
|
||||
$array_options
|
||||
$array_options,
|
||||
$_POST['units']
|
||||
);
|
||||
unset($_POST['qty']);
|
||||
unset($_POST['type']);
|
||||
@ -525,6 +534,7 @@ if (empty($reshook))
|
||||
unset($_POST['tva_tx']);
|
||||
unset($_POST['date_start']);
|
||||
unset($_POST['date_end']);
|
||||
unset($_POST['units']);
|
||||
unset($localtax1_tx);
|
||||
unset($localtax2_tx);
|
||||
|
||||
@ -989,7 +999,9 @@ if (empty($reshook))
|
||||
'',
|
||||
'',
|
||||
null,
|
||||
null
|
||||
null,
|
||||
array(),
|
||||
$lines[$i]->fk_unit
|
||||
);
|
||||
|
||||
if ($result < 0) {
|
||||
|
||||
@ -207,7 +207,7 @@ if (($action == 'create' || $action == 'add') && empty($mesgs)) {
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
// FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example.
|
||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type);
|
||||
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->tva_tx, $lines[$i]->localtax1_tx, $lines[$i]->localtax2_tx, $lines[$i]->qty, $lines[$i]->fk_product, $lines[$i]->remise_percent, $date_start, $date_end, 0, $lines[$i]->info_bits, 'HT', $product_type, -1, false, 0, $lines[$i]->fk_unit);
|
||||
|
||||
if ($result > 0) {
|
||||
$lineid = $result;
|
||||
|
||||
@ -444,7 +444,8 @@ if (empty($reshook))
|
||||
$product_type,
|
||||
$lines[$i]->rang,
|
||||
1,
|
||||
$lines[$i]->array_options
|
||||
$lines[$i]->array_options,
|
||||
$lines[$i]->fk_unit
|
||||
);
|
||||
|
||||
if ($result < 0)
|
||||
@ -587,7 +588,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options);
|
||||
$result=$object->updateline(GETPOST('lineid'), $label, $up, $tva_tx, $localtax1_tx, $localtax2_tx, GETPOST('qty'), GETPOST('productid'), $price_base_type, 0, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $_POST['units']);
|
||||
if ($result >= 0)
|
||||
{
|
||||
unset($_POST['label']);
|
||||
@ -684,6 +685,7 @@ if (empty($reshook))
|
||||
$idprod=$productsupplier->get_buyprice(GETPOST('idprodfournprice'), $qty); // Just to see if a price exists for the quantity. Not used to found vat.
|
||||
}
|
||||
|
||||
//Replaces $fk_unit with the product's
|
||||
if ($idprod > 0)
|
||||
{
|
||||
$result=$productsupplier->fetch($idprod);
|
||||
@ -703,7 +705,7 @@ if (empty($reshook))
|
||||
$price_base_type = 'HT';
|
||||
|
||||
// TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first)
|
||||
$result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, '', '', 0, $npr, $price_base_type, $type, -1, 0, $array_options);
|
||||
$result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1_tx, $localtax2_tx, $qty, $idprod, $remise_percent, '', '', 0, $npr, $price_base_type, $type, -1, 0, $array_options, $productsupplier->fk_unit);
|
||||
}
|
||||
if ($idprod == -2 || $idprod == 0)
|
||||
{
|
||||
@ -730,6 +732,12 @@ if (empty($reshook))
|
||||
$desc = $product_desc;
|
||||
$type = GETPOST('type');
|
||||
|
||||
$fk_unit= GETPOST('units', 'int');
|
||||
|
||||
if ($fk_unit <= 0) {
|
||||
$fk_unit = null;
|
||||
}
|
||||
|
||||
$tva_tx = price2num($tva_tx); // When vat is text input field
|
||||
|
||||
// Local Taxes
|
||||
@ -740,18 +748,15 @@ if (empty($reshook))
|
||||
{
|
||||
$ht = price2num($_POST['price_ht']);
|
||||
$price_base_type = 'HT';
|
||||
|
||||
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
|
||||
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options);
|
||||
}
|
||||
else
|
||||
{
|
||||
$ttc = price2num($_POST['price_ttc']);
|
||||
$ht = $ttc / (1 + ($tva_tx / 100));
|
||||
$price_base_type = 'HT';
|
||||
//print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0
|
||||
$result=$object->addline($product_desc, $ht, $tva_tx,$localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options);
|
||||
}
|
||||
|
||||
$result=$object->addline($product_desc, $ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit);
|
||||
}
|
||||
|
||||
//print "xx".$tva_tx; exit;
|
||||
@ -793,6 +798,7 @@ if (empty($reshook))
|
||||
unset($_POST['np_markRate']);
|
||||
unset($_POST['dp_desc']);
|
||||
unset($_POST['idprodfournprice']);
|
||||
unset($_POST['units']);
|
||||
|
||||
unset($_POST['date_starthour']);
|
||||
unset($_POST['date_startmin']);
|
||||
|
||||
@ -576,4 +576,10 @@ alter table llx_commandedet add fk_unit integer default NULL;
|
||||
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
|
||||
alter table llx_contratdet add fk_unit integer default NULL;
|
||||
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
ALTER TABLE llx_contratdet ADD CONSTRAINT fk_contratdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
|
||||
alter table llx_commande_fournisseurdet add fk_unit integer default NULL;
|
||||
ALTER TABLE llx_commande_fournisseurdet ADD CONSTRAINT fk_commande_fournisseurdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
|
||||
alter table llx_facture_fourn_det add fk_unit integer default NULL;
|
||||
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
@ -66,5 +66,5 @@ create table llx_commande_fournisseur
|
||||
location_incoterms varchar(255), -- for incoterms
|
||||
import_key varchar(14),
|
||||
extraparams varchar(255) -- for stock other parameters with json format
|
||||
|
||||
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--
|
||||
-- ============================================================================
|
||||
|
||||
ALTER TABLE llx_commande_fournisseurdet ADD CONSTRAINT fk_commande_fournisseurdet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
@ -2,6 +2,7 @@
|
||||
-- Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
-- Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@ -47,5 +48,6 @@ create table llx_commande_fournisseurdet
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
special_code integer DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0,
|
||||
import_key varchar(14)
|
||||
import_key varchar(14),
|
||||
fk_unit integer DEFAULT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -22,3 +22,4 @@
|
||||
|
||||
ALTER TABLE llx_facture_fourn_det ADD INDEX idx_facture_fourn_det_fk_facture (fk_facture_fourn);
|
||||
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_facture FOREIGN KEY (fk_facture_fourn) REFERENCES llx_facture_fourn (rowid);
|
||||
ALTER TABLE llx_facture_fourn_det ADD CONSTRAINT fk_facture_fourn_det_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
@ -48,5 +48,6 @@ create table llx_facture_fourn_det
|
||||
fk_code_ventilation integer DEFAULT 0 NOT NULL,
|
||||
special_code integer DEFAULT 0, -- code pour les lignes speciales
|
||||
rang integer DEFAULT 0,
|
||||
import_key varchar(14)
|
||||
import_key varchar(14),
|
||||
fk_unit integer DEFAULT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -244,6 +244,7 @@ if (empty($reshook))
|
||||
$object->volume_units = GETPOST('volume_units');
|
||||
$object->finished = GETPOST('finished');
|
||||
$object->hidden = GETPOST('hidden')=='yes'?1:0;
|
||||
$object->fk_unit = GETPOST('units');
|
||||
if ($fk_unit > 0) {
|
||||
$object->fk_unit = $fk_unit;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user