Work on saving supplier_ref into database lines

This commit is contained in:
Laurent Destailleur 2017-11-12 16:06:08 +01:00
parent 955ed7dbbf
commit bf121f9b3c
7 changed files with 73 additions and 53 deletions

View File

@ -273,8 +273,11 @@ else {
?> ?>
</td> </td>
<?php if ($object->element == 'supplier_proposal') { ?> <?php
<td class="nobottom linecolresupplier" align="right"><input id="fourn_ref" name="fourn_ref" class="flat" size="10" value=""></td> if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier') // We must have same test in printObjectLines
{
?>
<td class="nobottom linecolresupplier" align="right"><input id="fourn_ref" name="fourn_ref" class="flat" size="10" value="<?php echo (isset($_POST["fourn_ref"])?GETPOST("fourn_ref",'alpha',2):''); ?>"></td>
<?php } ?> <?php } ?>
<td class="nobottom linecolvat" align="right"><?php <td class="nobottom linecolvat" align="right"><?php
@ -735,6 +738,7 @@ function setforfree() {
jQuery("#tva_tx").show(); jQuery("#tva_tx").show();
jQuery("#buying_price").val('').show(); jQuery("#buying_price").val('').show();
jQuery("#fournprice_predef").hide(); jQuery("#fournprice_predef").hide();
jQuery("#title_fourn_ref").show();
jQuery("#title_vat").show(); jQuery("#title_vat").show();
jQuery("#title_up_ht").show(); jQuery("#title_up_ht").show();
jQuery("#title_up_ht_currency").show(); jQuery("#title_up_ht_currency").show();
@ -758,6 +762,7 @@ function setforpredef() {
jQuery("#fourn_ref").hide(); jQuery("#fourn_ref").hide();
jQuery("#tva_tx").hide(); jQuery("#tva_tx").hide();
jQuery("#buying_price").show(); jQuery("#buying_price").show();
jQuery("#title_fourn_ref").hide();
jQuery("#title_vat").hide(); jQuery("#title_vat").hide();
jQuery("#title_up_ht").hide(); jQuery("#title_up_ht").hide();
jQuery("#title_up_ht_currency").hide(); jQuery("#title_up_ht_currency").hide();

View File

@ -1392,7 +1392,7 @@ class CommandeFournisseur extends CommonOrder
* @param float $txlocaltax2 Localtax2 tax * @param float $txlocaltax2 Localtax2 tax
* @param int $fk_product Id product * @param int $fk_product Id product
* @param int $fk_prod_fourn_price Id supplier price * @param int $fk_prod_fourn_price Id supplier price
* @param string $fourn_ref Supplier reference price * @param string $ref_supplier Supplier reference price
* @param float $remise_percent Remise * @param float $remise_percent Remise
* @param string $price_base_type HT or TTC * @param string $price_base_type HT or TTC
* @param float $pu_ttc Unit price TTC * @param float $pu_ttc Unit price TTC
@ -1408,13 +1408,13 @@ class CommandeFournisseur extends CommonOrder
* @param int $origin_id Id of origin object * @param int $origin_id Id of origin object
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
*/ */
public 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, $pu_ht_devise=0, $origin='', $origin_id=0) public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0.0, $txlocaltax2=0.0, $fk_product=0, $fk_prod_fourn_price=0, $ref_supplier='', $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, $pu_ht_devise=0, $origin='', $origin_id=0)
{ {
global $langs,$mysoc,$conf; global $langs,$mysoc,$conf;
$error = 0; $error = 0;
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"); dol_syslog(get_class($this)."::addline $desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $fk_prod_fourn_price, $ref_supplier, $remise_percent, $price_base_type, $pu_ttc, $type, $fk_unit");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters // Clean parameters
@ -1441,7 +1441,6 @@ class CommandeFournisseur extends CommonOrder
$pu=$pu_ttc; $pu=$pu_ttc;
} }
$desc=trim($desc); $desc=trim($desc);
$ref_supplier=''; // Ref of supplier price when we add line
// Check parameters // Check parameters
if ($qty < 1 && ! $fk_product) if ($qty < 1 && ! $fk_product)
@ -1460,16 +1459,16 @@ class CommandeFournisseur extends CommonOrder
if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED)) if (empty($conf->global->SUPPLIER_ORDER_WITH_NOPRICEDEFINED))
{ {
// Check quantity is enough // Check quantity is enough
dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." fourn_ref=".$fourn_ref); dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_prod_fourn_price=".$fk_prod_fourn_price." qty=".$qty." ref_supplier=".$ref_supplier);
$prod = new Product($this->db, $fk_product); $prod = new Product($this->db, $fk_product);
if ($prod->fetch($fk_product) > 0) if ($prod->fetch($fk_product) > 0)
{ {
$product_type = $prod->type; $product_type = $prod->type;
$label = $prod->label; $label = $prod->label;
// We use 'none' instead of $fourn_ref, because fourn_ref may not exists anymore. So we will take the first supplier price ok. // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok.
// If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price.
$result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc
if ($result > 0) if ($result > 0)
{ {
$pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice
@ -2335,8 +2334,8 @@ class CommandeFournisseur extends CommonOrder
* @param string $desc Description de la ligne * @param string $desc Description de la ligne
* @param double $pu Prix unitaire * @param double $pu Prix unitaire
* @param double $qty Quantity * @param double $qty Quantity
* @param double $remise_percent Pourcentage de remise de la ligne * @param double $remise_percent Percent discount on line
* @param double $txtva Taux TVA * @param double $txtva VAT rate
* @param double $txlocaltax1 Localtax1 tax * @param double $txlocaltax1 Localtax1 tax
* @param double $txlocaltax2 Localtax2 tax * @param double $txlocaltax2 Localtax2 tax
* @param double $price_base_type Type of price base * @param double $price_base_type Type of price base
@ -2348,9 +2347,10 @@ class CommandeFournisseur extends CommonOrder
* @param array $array_options Extrafields array * @param array $array_options Extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param double $pu_ht_devise Unit price in currency * @param double $pu_ht_devise Unit price in currency
* @param string $ref_supplier Supplier ref
* @return int < 0 if error, > 0 if ok * @return int < 0 if error, > 0 if ok
*/ */
public 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, $pu_ht_devise = 0) public 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, $pu_ht_devise=0, $ref_supplier='')
{ {
global $mysoc, $conf; global $mysoc, $conf;
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit");
@ -2430,6 +2430,7 @@ class CommandeFournisseur extends CommonOrder
//$this->line->label=$label; //$this->line->label=$label;
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty=$qty; $this->line->qty=$qty;
$this->line->ref_supplier=$ref_supplier;
$this->line->vat_src_code = $vat_src_code; $this->line->vat_src_code = $vat_src_code;
$this->line->tva_tx = $txtva; $this->line->tva_tx = $txtva;
@ -3277,6 +3278,7 @@ class CommandeFournisseurLigne extends CommonOrderLine
// Mise a jour ligne en base // Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql.= " description='".$this->db->escape($this->desc)."'"; $sql.= " description='".$this->db->escape($this->desc)."'";
$sql.= ", ref='".$this->db->escape($this->ref_supplier)."'";
$sql.= ", subprice='".price2num($this->subprice)."'"; $sql.= ", subprice='".price2num($this->subprice)."'";
//$sql.= ",remise='".price2num($remise)."'"; //$sql.= ",remise='".price2num($remise)."'";
$sql.= ", remise_percent='".price2num($this->remise_percent)."'"; $sql.= ", remise_percent='".price2num($this->remise_percent)."'";

View File

@ -1372,11 +1372,12 @@ class FactureFournisseur extends CommonInvoice
* @param string $fk_unit Code of the unit to use. Null to use the default one * @param string $fk_unit Code of the unit to use. Null to use the default one
* @param int $origin_id id origin document * @param int $origin_id id origin document
* @param double $pu_ht_devise Amount in currency * @param double $pu_ht_devise Amount in currency
* @param string $ref_supplier Supplier ref
* @return int >0 if OK, <0 if KO * @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. * 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.
*/ */
public 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, $origin_id=0, $pu_ht_devise=0) public 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, $origin_id=0, $pu_ht_devise=0, $ref_supplier='')
{ {
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); 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'; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@ -1435,6 +1436,7 @@ class FactureFournisseur extends CommonInvoice
//$this->line->label=$label; // deprecated //$this->line->label=$label; // deprecated
$this->line->desc=$desc; $this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
$this->line->ref_supplier=$ref_supplier;
$this->line->vat_src_code=$vat_src_code; $this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva; $this->line->tva_tx=$txtva;
@ -2616,6 +2618,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET";
$sql.= " description ='".$this->db->escape($this->description)."'"; $sql.= " description ='".$this->db->escape($this->description)."'";
$sql.= ", ref ='".$this->db->escape($this->ref)."'";
$sql.= ", pu_ht = ".price2num($this->pu_ht); $sql.= ", pu_ht = ".price2num($this->pu_ht);
$sql.= ", pu_ttc = ".price2num($this->pu_ttc); $sql.= ", pu_ttc = ".price2num($this->pu_ttc);
$sql.= ", qty = ".price2num($this->qty); $sql.= ", qty = ".price2num($this->qty);
@ -2743,7 +2746,7 @@ class SupplierInvoiceLine extends CommonObjectLine
// Insertion dans base de la ligne // Insertion dans base de la ligne
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,'; $sql.= ' (fk_facture_fourn, fk_parent_line, label, description, ref, qty,';
$sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,'; $sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,';
$sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,'; $sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,';
@ -2754,6 +2757,7 @@ class SupplierInvoiceLine extends CommonObjectLine
$sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " '".$this->db->escape($this->desc)."',";
$sql.= " '".$this->db->escape($this->ref_supplier)."',";
$sql.= " ".price2num($this->qty).","; $sql.= " ".price2num($this->qty).",";
$sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").","; $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->db->escape($this->vat_src_code)."'").",";

View File

@ -446,6 +446,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$ref_supplier = GETPOST('fourn_ref','alpha');
$fk_unit= GETPOST('units', 'alpha'); $fk_unit= GETPOST('units', 'alpha');
@ -470,7 +471,7 @@ if (empty($reshook))
$pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht_devise = price2num($price_ht_devise, 'MU');
$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, $pu_ht_devise); $result=$object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, 0, 0, $ref_supplier, $remise_percent, $price_base_type, $ttc, $type,'','', $date_start, $date_end, $array_options, $fk_unit, $pu_ht_devise);
} }
//print "xx".$tva_tx; exit; //print "xx".$tva_tx; exit;
@ -507,6 +508,7 @@ if (empty($reshook))
unset($_POST['price_ht']); unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']); unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']); unset($_POST['price_ttc']);
unset($_POST['fourn_ref']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['label']); unset($_POST['label']);
unset($localtax1_tx); unset($localtax1_tx);
@ -553,7 +555,7 @@ if (empty($reshook))
} }
$productsupplier = new ProductFournisseur($db); $productsupplier = new ProductFournisseur($db);
if ($productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 ) if ($line->fk_product > 0 && $productsupplier->get_buyprice(0, price2num($_POST['qty']), $line->fk_product, 'none', GETPOST('socid','int')) < 0 )
{ {
setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings'); setEventMessages($langs->trans("ErrorQtyTooLowForThisSupplier"), null, 'warnings');
} }
@ -620,7 +622,8 @@ if (empty($reshook))
$date_end, $date_end,
$array_options, $array_options,
$_POST['units'], $_POST['units'],
$pu_ht_devise $pu_ht_devise,
GETPOST('fourn_ref','alpha')
); );
unset($_POST['qty']); unset($_POST['qty']);
unset($_POST['type']); unset($_POST['type']);
@ -629,6 +632,7 @@ if (empty($reshook))
unset($_POST['dp_desc']); unset($_POST['dp_desc']);
unset($_POST['np_desc']); unset($_POST['np_desc']);
unset($_POST['pu']); unset($_POST['pu']);
unset($_POST['fourn_ref']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['date_start']); unset($_POST['date_start']);
unset($_POST['date_end']); unset($_POST['date_end']);

View File

@ -845,6 +845,7 @@ if (empty($reshook))
if ($result >= 0) if ($result >= 0)
{ {
unset($_POST['label']); unset($_POST['label']);
unset($_POST['fourn_ref']);
unset($_POST['date_starthour']); unset($_POST['date_starthour']);
unset($_POST['date_startmin']); unset($_POST['date_startmin']);
unset($_POST['date_startsec']); unset($_POST['date_startsec']);
@ -998,7 +999,6 @@ if (empty($reshook))
$type = $productsupplier->type; $type = $productsupplier->type;
$price_base_type = 'HT'; $price_base_type = 'HT';
// TODO Save the product supplier ref into database (like done for supplier propal and order) into field ref_supplier (must rename field ref into ref_supplier first)
$result=$object->addline( $result=$object->addline(
$desc, $desc,
$productsupplier->fourn_pu, $productsupplier->fourn_pu,
@ -1017,7 +1017,8 @@ if (empty($reshook))
-1, -1,
0, 0,
$array_options, $array_options,
$productsupplier->fk_unit $productsupplier->fk_unit,
$productsupplier->fourn_ref
); );
} }
if ($idprod == -99 || $idprod == 0) if ($idprod == -99 || $idprod == 0)
@ -1042,6 +1043,7 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$ref_supplier = GETPOST('fourn_ref','alpha');
$fk_unit= GETPOST('units', 'alpha'); $fk_unit= GETPOST('units', 'alpha');
@ -1063,7 +1065,7 @@ if (empty($reshook))
$price_base_type = 'HT'; $price_base_type = 'HT';
$pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht_devise = price2num($price_ht_devise, 'MU');
$result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise); $result=$object->addline($product_desc, $pu_ht, $tva_tx, $localtax1_tx, $localtax2_tx, $qty, 0, $remise_percent, $date_start, $date_end, 0, $tva_npr, $price_base_type, $type, -1, 0, $array_options, $fk_unit, 0, $pu_ht_devise, $ref_supplier);
} }
//print "xx".$tva_tx; exit; //print "xx".$tva_tx; exit;
@ -1098,6 +1100,7 @@ if (empty($reshook))
unset($_POST['price_ht']); unset($_POST['price_ht']);
unset($_POST['multicurrency_price_ht']); unset($_POST['multicurrency_price_ht']);
unset($_POST['price_ttc']); unset($_POST['price_ttc']);
unset($_POST['fourn_ref']);
unset($_POST['tva_tx']); unset($_POST['tva_tx']);
unset($_POST['label']); unset($_POST['label']);
unset($localtax1_tx); unset($localtax1_tx);

View File

@ -362,7 +362,7 @@ if (empty($reshook))
$array_options = $lines[$i]->array_options; $array_options = $lines[$i]->array_options;
} }
$result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->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, $array_options, $lines[$i]->ref_fourn, $lines[$i]->fk_unit); $result = $object->addline($desc, $lines[$i]->subprice, $lines[$i]->qty, $lines[$i]->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, $array_options, $lines[$i]->ref_supplier, $lines[$i]->fk_unit);
if ($result > 0) { if ($result > 0) {
$lineid = $result; $lineid = $result;
@ -523,10 +523,10 @@ if (empty($reshook))
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef=''; $predef='';
$ref_fourn = GETPOST('fourn_ref');
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):''); $product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
$date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_start=dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); $date_end=dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$ref_supplier = GETPOST('fourn_ref','alpha');
if (GETPOST('prod_entry_mode') == 'free') if (GETPOST('prod_entry_mode') == 'free')
{ {
@ -614,6 +614,7 @@ if (empty($reshook))
$label = $productsupplier->label; $label = $productsupplier->label;
$desc = $productsupplier->description; $desc = $productsupplier->description;
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc);
$ref_supplier = $productsupplier->ref_supplier;
$tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
$tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice'));
@ -641,7 +642,7 @@ if (empty($reshook))
$buyingprice, $buyingprice,
$label, $label,
$array_options, $array_options,
$ref_fourn, $ref_supplier,
$fk_unit $fk_unit
); );
//var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit; //var_dump($tva_tx);var_dump($productsupplier->fourn_pu);var_dump($price_base_type);exit;
@ -692,7 +693,7 @@ if (empty($reshook))
$price_base_type = 'HT'; $price_base_type = 'HT';
} }
$result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_fourn, $fk_unit); $result = $object->addline($desc, $ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $ref_supplier, $fk_unit);
//$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); //$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);
} }
@ -829,9 +830,9 @@ if (empty($reshook))
if (! $error) { if (! $error) {
$db->begin(); $db->begin();
$ref_fourn = GETPOST('fourn_ref'); $ref_supplier = GETPOST('fourn_ref','alpha');
$fk_unit = GETPOST('units'); $fk_unit = GETPOST('units');
$result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_options, $ref_fourn, $fk_unit); $result = $object->updateline(GETPOST('lineid'), $pu_ht, GETPOST('qty'), GETPOST('remise_percent'), $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $array_options, $ref_supplier, $fk_unit);
if ($result >= 0) { if ($result >= 0) {
$db->commit(); $db->commit();

View File

@ -2436,7 +2436,7 @@ class SupplierProposal extends CommonObject
$sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.fk_product_fournisseur_price as fk_fournprice, pt.buy_price_ht as pa_ht, pt.special_code, pt.localtax1_tx, pt.localtax2_tx,';
$sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc, pt.ref_fourn as ref_produit_fourn,'; $sql.= ' p.description as product_desc, pt.ref_fourn as ref_supplier,';
$sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit';
$sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
@ -2483,7 +2483,8 @@ class SupplierProposal extends CommonObject
$this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->special_code = $obj->special_code;
$this->lines[$i]->rang = $obj->rang; $this->lines[$i]->rang = $obj->rang;
$this->lines[$i]->ref_fourn = $obj->ref_produit_fourn; $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated
$this->lines[$i]->ref_supplier = $obj->ref_supplier;
// Multicurrency // Multicurrency
$this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency;