Fix type lines import

This commit is contained in:
John 2018-02-23 12:12:36 +01:00
parent 768c09bc74
commit 3b54afc9b2

View File

@ -2095,7 +2095,7 @@ if (empty($reshook))
&& ($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA || $object->type == Facture::TYPE_SITUATION))
{
$fromElement = GETPOST('fromelement');
$fromElementid = intval(GETPOST('fromelementid'));
$fromElementid = GETPOST('fromelementid');
$importLines = GETPOST('line_checkbox');
if(!empty($importLines) && is_array($importLines) && !empty($fromElement) && ctype_alpha($fromElement) && !empty($fromElementid))
@ -2110,11 +2110,11 @@ if (empty($reshook))
$error = 0;
foreach($importLines as $lineId)
{
$lineId = intval($lineId);
$originLine = new $lineClassName($db);
if($originLine->fetch( $fromElementid ) > 0)
if(intval($fromElementid) > 0 && $originLine->fetch( $lineId ) > 0)
{
$originLine->fetch_optionals(intval($fromElementid));
$originLine->fetch_optionals($lineId);
$desc = $originLine->desc;
$pu_ht = $originLine->subprice;
$qty = $originLine->qty;
@ -2130,7 +2130,7 @@ if (empty($reshook))
$fk_remise_except = $originLine->fk_remise_except;
$price_base_type='HT';
$pu_ttc=0;
$type = $object->type;
$type = $originLine->product_type;
$rang=$nextRang++;
$special_code = $originLine->special_code;
$origin = $originLine->element;
@ -2146,7 +2146,6 @@ if (empty($reshook))
$pu_ht_devise = $originLine->multicurrency_subprice;
$res = $object->addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $ventil, $info_bits, $fk_remise_except, $price_base_type, $pu_ttc, $type, $rang, $special_code, $origin, $origin_id, $fk_parent_line, $fk_fournprice, $pa_ht, $label, $array_options, $situation_percent, $fk_prev_id, $fk_unit,$pu_ht_devise);
if($res > 0){
$importCount++;
}else{