diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 65769ea795f..40e258a8e82 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1412,7 +1412,7 @@ class Commande extends CommonOrder if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la commande meme - $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$mysoc); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -1469,7 +1469,7 @@ class Commande extends CommonOrder $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; $vat_src_code = ''; // May be defined into tva_tx - + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); @@ -1799,7 +1799,7 @@ class Commande extends CommonOrder $line->product_type = $objp->product_type; $line->qty = $objp->qty; - $line->vat_src_code = $objp->vat_src_code; + $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; $line->localtax1_tx = $objp->localtax1_tx; $line->localtax2_tx = $objp->localtax2_tx; @@ -3389,7 +3389,7 @@ class Commande extends CommonOrder global $conf, $langs, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $result=''; if (! empty($conf->expedition->enabled) && ($option == 1 || $option == 2)) $url = DOL_URL_ROOT.'/expedition/shipment.php?id='.$this->id; @@ -3426,7 +3426,7 @@ class Commande extends CommonOrder $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 245947932a3..e9da56d2093 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -45,7 +45,7 @@ class CommandeFournisseur extends CommonOrder public $fk_element = 'fk_commande'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='order'; - + /** * {@inheritdoc} */ @@ -132,9 +132,9 @@ class CommandeFournisseur extends CommonOrder * Draft status */ const STATUS_DRAFT = 0; - - - + + + /** * Constructor * @@ -318,7 +318,7 @@ class CommandeFournisseur extends CommonOrder $line->subprice = $objp->subprice; $line->pu_ht = $objp->subprice; $line->remise_percent = $objp->remise_percent; - + $line->vat_src_code = $objp->vat_src_code; $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; @@ -615,7 +615,7 @@ class CommandeFournisseur extends CommonOrder $picto='order'; $url = DOL_URL_ROOT.'/fourn/commande/card.php?id='.$this->id; - + $linkclose=''; if (empty($notooltip)) { @@ -627,7 +627,7 @@ class CommandeFournisseur extends CommonOrder $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -1378,7 +1378,7 @@ class CommandeFournisseur extends CommonOrder } $desc=trim($desc); $ref_supplier=''; // Ref of supplier price when we add line - + // Check parameters if ($qty < 1 && ! $fk_product) { @@ -1402,7 +1402,7 @@ class CommandeFournisseur extends CommonOrder { $product_type = $prod->type; $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. // 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); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$fourn_ref/$this->fk_soc @@ -1417,7 +1417,7 @@ class CommandeFournisseur extends CommonOrder $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); $this->db->rollback(); dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); - //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$pu = $prod->fourn_pu; // We do not overwrite unit price //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price return -1; } @@ -1463,7 +1463,7 @@ class CommandeFournisseur extends CommonOrder $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, $product_type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx,$pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1482,7 +1482,7 @@ class CommandeFournisseur extends CommonOrder $localtax2_type=$localtaxes_type[2]; $subprice = price2num($pu,'MU'); - + $rangmax = $this->line_max(); $rang = $rangmax + 1; @@ -1508,7 +1508,7 @@ class CommandeFournisseur extends CommonOrder $this->line->subprice=$pu_ht; $this->line->rang=$this->rang; $this->line->info_bits=$info_bits; - + $this->line->vat_src_code=$vat_src_code; $this->line->total_ht=$total_ht; $this->line->total_tva=$total_tva; @@ -1548,7 +1548,7 @@ class CommandeFournisseur extends CommonOrder if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la commande meme - $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -1993,7 +1993,7 @@ class CommandeFournisseur extends CommonOrder $old_statut = $this->statut; $this->statut = $statut; $this->actionmsg2 = $comment; - + // Call trigger $result=$this->call_trigger('ORDER_SUPPLIER_RECEIVE',$user); if ($result < 0) $error++; @@ -2326,7 +2326,7 @@ class CommandeFournisseur extends CommonOrder $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, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -2809,7 +2809,7 @@ class CommandeFournisseur extends CommonOrder return $text; } - + /** * Calc status regarding dispatch stock * @@ -2818,7 +2818,7 @@ class CommandeFournisseur extends CommonOrder * @param string $comment Comment * @return int <0 if KO, 0 if not applicable, >0 if OK */ - public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='') + public function calcAndSetStatusDispatch(User $user, $closeopenorder=1, $comment='') { global $conf, $langs; @@ -2835,14 +2835,14 @@ class CommandeFournisseur extends CommonOrder $filter['t.status']=1; } $ret=$supplierorderdispatch->fetchAll('','',0,0,$filter); - if ($ret<0) + if ($ret<0) { $this->error=$supplierorderdispatch->error; $this->errors=$supplierorderdispatch->errors; return $ret; - } - else + } + else { - if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) + if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) { //Build array with quantity deliverd by product foreach($supplierorderdispatch->lines as $line) { @@ -2851,12 +2851,12 @@ class CommandeFournisseur extends CommonOrder foreach($this->lines as $line) { $qtywished[$line->fk_product]+=$line->qty; } - + $date_liv = dol_now(); - + //Compare array $diff_array=array_diff_assoc($qtydelivered,$qtywished); - + if (count($diff_array)==0) //No diff => mean everythings is received { if ($closeopenorder) @@ -2878,8 +2878,8 @@ class CommandeFournisseur extends CommonOrder } return 4; } - } - else + } + else { //Diff => received partially $ret = $this->Livraison($user, $date_liv, 'par', $comment); // GETPOST("type") is 'tot', 'par', 'nev', 'can' @@ -3004,12 +3004,12 @@ 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->multicurrency_subprice = $objp->multicurrency_subprice; $this->multicurrency_total_ht = $objp->multicurrency_total_ht; $this->multicurrency_total_tva = $objp->multicurrency_total_tva; $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - + $this->db->free($result); return 1; } @@ -3198,7 +3198,7 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql.= ", subprice='".price2num($this->subprice)."'"; //$sql.= ",remise='".price2num($remise)."'"; $sql.= ", remise_percent='".price2num($this->remise_percent)."'"; - + $sql.= ", vat_src_code = '".(empty($this->vat_src_code)?'':$this->vat_src_code)."'"; $sql.= ", tva_tx='".price2num($this->tva_tx)."'"; $sql.= ", localtax1_tx='".price2num($this->total_localtax1)."'"; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 38d0fcd5bfb..f4cf4762a91 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1422,7 +1422,7 @@ class FactureFournisseur extends CommonInvoice if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la facture meme - $result=$this->update_price(1,'auto',0,$mysoc); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$this->thirdparty); // The addline method is designed to add line from user input so total calculation with update_price must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 23c8257a4f5..1ff988e19fd 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -50,7 +50,7 @@ class SupplierProposal extends CommonObject public $fk_element='fk_supplier_proposal'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto='propal'; - + /** * {@inheritdoc} */ @@ -140,7 +140,7 @@ class SupplierProposal extends CommonObject var $multicurrency_total_ht; var $multicurrency_total_tva; var $multicurrency_total_ttc; - + /** * Draft status */ @@ -160,10 +160,10 @@ class SupplierProposal extends CommonObject /** * Billed or processed quote */ - const STATUS_BILLED = 4; - - - + const STATUS_BILLED = 4; + + + /** * Constructor * @@ -407,7 +407,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $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, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -419,7 +419,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Rang to use $rangtouse = $rang; if ($rangtouse == -1) @@ -487,7 +487,7 @@ class SupplierProposal extends CommonObject $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; - + // Mise en option de la ligne if (empty($qty) && empty($special_code)) $this->line->special_code=3; @@ -506,7 +506,7 @@ class SupplierProposal extends CommonObject if (! empty($fk_parent_line)) $this->line_order(true,'DESC'); // Mise a jour informations denormalisees au niveau de la propale meme - $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. + $result=$this->update_price(1,'auto',0,$this->thirdparty); // This method is designed to add line from user input so total calculation must be done using 'auto' mode. if ($result > 0) { $this->db->commit(); @@ -583,7 +583,7 @@ class SupplierProposal extends CommonObject $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc); $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, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -595,7 +595,7 @@ class SupplierProposal extends CommonObject $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; - + // Anciens indicateurs: $price, $remise (a ne plus utiliser) $price = $pu; if ($remise_percent > 0) @@ -662,7 +662,7 @@ class SupplierProposal extends CommonObject if (is_array($array_option) && count($array_option)>0) { $this->line->array_options=$array_option; } - + // Multicurrency $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); $this->line->multicurrency_total_ht = $multicurrency_total_ht; @@ -1181,7 +1181,7 @@ class SupplierProposal extends CommonObject $this->multicurrency_total_ht = $obj->multicurrency_total_ht; $this->multicurrency_total_tva = $obj->multicurrency_total_tva; $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - + if ($obj->fk_statut == 0) { $this->brouillon = 1; @@ -1272,7 +1272,7 @@ class SupplierProposal extends CommonObject $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; $line->fk_unit = $objp->fk_unit; - + $this->lines[$i] = $line; $i++; @@ -1654,7 +1654,7 @@ class SupplierProposal extends CommonObject { $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } - + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -1705,7 +1705,7 @@ class SupplierProposal extends CommonObject $productsupplier = new ProductFournisseur($this->db); dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) + foreach ($this->lines as $product) { if ($product->subprice <= 0) continue; @@ -1722,7 +1722,7 @@ class SupplierProposal extends CommonObject $this->createPriceFournisseur($product, $user); } } - + return 1; } @@ -2150,7 +2150,7 @@ class SupplierProposal extends CommonObject $response->label = $label; $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; $response->img = img_object($langs->trans("SupplierProposals"),"propal"); - + // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) { @@ -2188,7 +2188,7 @@ class SupplierProposal extends CommonObject global $user,$langs,$conf; // Load array of products prodids - $num_prods = 0; + $num_prods = 0; $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; @@ -2251,7 +2251,7 @@ class SupplierProposal extends CommonObject $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; } - + $this->lines[$xnbp]=$line; $this->total_ht += $line->total_ht; @@ -2376,10 +2376,10 @@ class SupplierProposal extends CommonObject global $langs, $conf, $user; if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - + $url=''; $result=''; - + $label=''.$langs->trans("ShowSupplierProposal").''; if (! empty($this->ref)) $label.= '
'.$langs->trans('Ref').': '.$this->ref; @@ -2397,7 +2397,7 @@ class SupplierProposal extends CommonObject if ($option == 'document') { $url = DOL_URL_ROOT.'/supplier_proposal/document.php?id='.$this->id. $get_params; } - + $linkclose=''; if (empty($notooltip) && $user->rights->propal->lire) { @@ -2409,7 +2409,7 @@ class SupplierProposal extends CommonObject $linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose.=' class="classfortooltip"'; } - + $linkstart = ''; $linkend=''; @@ -2433,7 +2433,7 @@ class SupplierProposal extends CommonObject function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal - + $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $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,'; @@ -2487,7 +2487,7 @@ class SupplierProposal extends CommonObject $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_produit_fourn; - + // Multicurrency $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; @@ -2544,7 +2544,7 @@ class SupplierProposal extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } - + /** * Function used to replace a thirdparty id with another one. * @@ -2558,10 +2558,10 @@ class SupplierProposal extends CommonObject $tables = array( 'supplier_proposal' ); - + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); } - + } @@ -2672,7 +2672,7 @@ class SupplierProposalLine extends CommonObjectLine var $skip_update_total; // Skip update price total for special lines var $ref_fourn; - + // Multicurrency var $fk_multicurrency; var $multicurrency_code; @@ -2753,7 +2753,7 @@ class SupplierProposalLine extends CommonObjectLine $this->product_desc = $objp->product_desc; $this->ref_fourn = $objp->ref_produit_forun; - + // Multicurrency $this->fk_multicurrency = $objp->fk_multicurrency; $this->multicurrency_code = $objp->multicurrency_code; @@ -2801,11 +2801,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -2872,7 +2872,7 @@ class SupplierProposalLine extends CommonObjectLine { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); $this->id=$this->rowid; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -2985,11 +2985,11 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_parent_line)) $this->fk_parent_line=0; if (empty($this->fk_fournprice)) $this->fk_fournprice=0; if (empty($this->fk_unit)) $this->fk_unit=0; - + if (empty($this->pa_ht)) $this->pa_ht=0; // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) + if ($this->pa_ht == 0) { if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) { @@ -3033,14 +3033,14 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); - + // Multicurrency $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; $sql.= " , fk_unit=".$this->fk_unit; - + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG);