Merge pull request #11328 from fappels/clean_10_beta

Fix scrutinizer bugs
This commit is contained in:
Laurent Destailleur 2019-06-13 10:18:59 +02:00 committed by GitHub
commit 60e1e89981
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 92 additions and 91 deletions

View File

@ -1647,7 +1647,7 @@ class Contrat extends CommonObject
// if buy price not defined, define buyprice as configured in margin admin // 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($pu_ht, $remise_percent)) < 0) if (($result = $this->defineBuyPrice($pu, $remise_percent)) < 0)
{ {
return $result; return $result;
} }

View File

@ -116,7 +116,6 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["code"]=$code; $_GET["code"]=$code;
$_GET["type"]=$encoding; $_GET["type"]=$encoding;
$_GET["height"]=$height;
$_GET["readable"]=$readable; $_GET["readable"]=$readable;
if ($code) { if ($code) {
@ -166,7 +165,6 @@ class modTcpdfbarcode extends ModeleBarCode
$_GET["code"]=$code; $_GET["code"]=$code;
$_GET["type"]=$encoding; $_GET["type"]=$encoding;
$_GET["height"]=$height;
$_GET["readable"]=$readable; $_GET["readable"]=$readable;
if ($code) { if ($code) {

View File

@ -117,13 +117,13 @@ class pdf_standard extends ModeleExpenseReport
public $emetteur; public $emetteur;
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf, $langs, $mysoc, $user; global $conf, $langs, $mysoc, $user;
// Translations // Translations
@ -172,12 +172,12 @@ class pdf_standard extends ModeleExpenseReport
$this->posxup=145; $this->posxup=145;
$this->posxqty=168; $this->posxqty=168;
$this->postotalttc=178; $this->postotalttc=178;
// if (empty($conf->projet->enabled)) { // if (empty($conf->projet->enabled)) {
// $this->posxtva-=20; // $this->posxtva-=20;
// $this->posxup-=20; // $this->posxup-=20;
// $this->posxqty-=20; // $this->posxqty-=20;
// $this->postotalttc-=20; // $this->postotalttc-=20;
// } // }
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxdate-=20; $this->posxdate-=20;
@ -196,19 +196,19 @@ class pdf_standard extends ModeleExpenseReport
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param Object $object Object to generate * @param Object $object Object to generate
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable // phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager; global $user, $langs, $conf, $mysoc, $db, $hookmanager;
@ -501,9 +501,9 @@ class pdf_standard extends ModeleExpenseReport
$posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs); $posy=$this->tablePayments($pdf, $object, $posy_start_of_totals, $outputlangs);
} }
// Pied de page // Page footer
$this->_pagefoot($pdf, $object, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPage(); if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -540,17 +540,17 @@ class pdf_standard extends ModeleExpenseReport
} }
} }
/** /**
* @param TCPDF $pdf Object PDF * @param TCPDF $pdf Object PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param int $linenumber line number * @param int $linenumber line number
* @param int $curY current y position * @param int $curY current y position
* @param int $default_font_size default siez of font * @param int $default_font_size default siez of font
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines) * @param int $hidedetails Hide details (0=no, 1=yes, 2=just special lines)
* @return void * @return void
*/ */
private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0) private function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
{ {
global $conf; global $conf;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -618,7 +618,7 @@ class pdf_standard extends ModeleExpenseReport
} }
$comment .= $object->lines[$linenumber]->comments; $comment .= $object->lines[$linenumber]->comments;
$pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1); $pdf->writeHTMLCell($this->posxtva-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $comment, 0, 1);
} }
/** /**
* Show top header of page. * Show top header of page.
@ -846,7 +846,7 @@ class pdf_standard extends ModeleExpenseReport
} }
} }
} }
} }
/** /**
* Show table for lines * Show table for lines
@ -1024,6 +1024,7 @@ class pdf_standard extends ModeleExpenseReport
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$totalpaid = 0;
$i=0; $i=0;
while ($i < $num) { while ($i < $num) {
$y+=$tab3_height; $y+=$tab3_height;

View File

@ -154,7 +154,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$widthtouse = $maxwidthtouse; $widthtouse = $maxwidthtouse;
$heighttouse = $maxheighttouse; $heighttouse = $maxheighttouse;
$logoHeight = $heighttouse; $logoHeight = $heighttouse;
$logoWidth = $heighttouse; $logoWidth = $widthtouse;
//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit; //var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
@ -175,9 +175,11 @@ class pdf_tcpdflabel extends CommonStickerGenerator
} }
elseif ($textleft!='' && $textright!='') // left and right part elseif ($textleft!='' && $textright!='') // left and right part
{ {
$logoHeight = $heighttouse/2;
$logoWidth = $widthtouse/2;
if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') ) // left part logo/barcode right part text if (($textleft == '%LOGO%' || $textleft == '%PHOTO%' || $textleft == '%BARCODE%') && !strstr($textright, '%') ) // left part logo/barcode right part text
{ {
if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, 0); if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+$xleft, $_PosY+$ytop, $logoWidth, 0);
elseif ($code && !empty($encoding)) elseif ($code && !empty($encoding))
{ {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse); $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft, $_PosY+$ytop, $widthtouse/2, $heighttouse);
@ -187,7 +189,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
} }
elseif (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text elseif (($textright == '%LOGO%' || $textright == '%PHOTO%' || $textright == '%BARCODE%') && !strstr($textleft, '%')) // right part logo/barcode left part text
{ {
if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, 0); if ($textright == '%LOGO%' && $logo) $pdf->Image($logo, $_PosX+($widthtouse/2), $_PosY+$ytop, $logoWidth, 0);
elseif ($code && !empty($encoding)) elseif ($code && !empty($encoding))
{ {
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse); $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+($widthtouse/2), $_PosY+$ytop, $widthtouse/2, $heighttouse);
@ -203,7 +205,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator
$this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse); $this->writeBarcode($pdf, $code, $encoding, $is2d, $_PosX+$xleft+$logoWidth+1, $_PosY+$ytop, $widthtouse-$logoWidth-1, $heighttouse);
} else { } else {
$pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop); $pdf->SetXY($_PosX+$xleft+$logoWidth+1, $_PosY+$ytop);
$pdf->MultiCell($widthtouse-$logoWidth1-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R'); $pdf->MultiCell($widthtouse-$logoWidth-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright), 0, 'R');
} }
} }
elseif ($textright == '%LOGO%') // right part logo left part text/barcode elseif ($textright == '%LOGO%') // right part logo left part text/barcode

View File

@ -1398,6 +1398,8 @@ class Expedition extends CommonObject
$this->total_localtax1 = 0; $this->total_localtax1 = 0;
$this->total_localtax2 = 0; $this->total_localtax2 = 0;
$line = new ExpeditionLigne($this->db);
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
@ -2562,8 +2564,6 @@ class ExpeditionLigne extends CommonObjectLine
$this->error = 'ErrorMandatoryParametersNotProvided'; $this->error = 'ErrorMandatoryParametersNotProvided';
return -1; return -1;
} }
// Clean parameters
if (empty($this->entrepot_id)) $this->entrepot_id='null';
$this->db->begin(); $this->db->begin();
@ -2574,7 +2574,7 @@ class ExpeditionLigne extends CommonObjectLine
$sql.= ", qty"; $sql.= ", qty";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= $this->fk_expedition; $sql.= $this->fk_expedition;
$sql.= ", ".$this->entrepot_id; $sql.= ", ".(empty($this->entrepot_id) ? 'NULL' : $this->entrepot_id);
$sql.= ", ".$this->fk_origin_line; $sql.= ", ".$this->fk_origin_line;
$sql.= ", ".$this->qty; $sql.= ", ".$this->qty;
$sql.= ")"; $sql.= ")";

View File

@ -247,10 +247,10 @@ class ProductFournisseur extends Product
if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation=''; if (empty($supplier_reputation) || $supplier_reputation == -1) $supplier_reputation='';
if ($delivery_time_days != '' && ! is_numeric($delivery_time_days)) $delivery_time_days = ''; if ($delivery_time_days != '' && ! is_numeric($delivery_time_days)) $delivery_time_days = '';
if ($price_base_type == 'TTC') if ($price_base_type == 'TTC')
{ {
$ttx = $tva_tx; $ttx = $tva_tx;
$buyprice = $buyprice/(1+($ttx/100)); $buyprice = $buyprice/(1+($ttx/100));
} }
// Multicurrency // Multicurrency
if ($conf->multicurrency->enabled) { if ($conf->multicurrency->enabled) {
@ -259,10 +259,10 @@ class ProductFournisseur extends Product
if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0; if (empty($multicurrency_buyprice)) $multicurrency_buyprice=0;
if ($multicurrency_price_base_type == 'TTC') if ($multicurrency_price_base_type == 'TTC')
{ {
$ttx = $tva_tx; $ttx = $tva_tx;
$multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100)); $multicurrency_buyprice = $multicurrency_buyprice/(1+($ttx/100));
} }
$multicurrency_buyprice=price2num($multicurrency_buyprice, 'MU'); $multicurrency_buyprice=price2num($multicurrency_buyprice, 'MU');
$multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty, 'MU'); $multicurrency_unitBuyPrice=price2num($multicurrency_buyprice/$qty, 'MU');
@ -369,7 +369,7 @@ class ProductFournisseur extends Product
// End call triggers // End call triggers
if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG)) if (! $error && empty($conf->global->PRODUCT_PRICE_SUPPLIER_NO_LOG))
{ {
$result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrenc, $multicurrency_code); $result = $this->logPrice($user, $now, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
} }
@ -911,21 +911,21 @@ class ProductFournisseur extends Product
return $out; return $out;
} }
/** /**
* Function used to replace a thirdparty id with another one. * Function used to replace a thirdparty id with another one.
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $origin_id Old thirdparty id * @param int $origin_id Old thirdparty id
* @param int $dest_id New thirdparty id * @param int $dest_id New thirdparty id
* @return bool * @return bool
*/ */
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{ {
$tables = array( $tables = array(
'product_fournisseur_price' 'product_fournisseur_price'
); );
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
} }
/** /**
@ -1089,7 +1089,7 @@ class ProductFournisseur extends Product
* *
* @return int < 0 NOK > 0 OK * @return int < 0 NOK > 0 OK
*/ */
private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice, $multicurrency_unitBuyPrice, $multicurrency_tx, $fk_multicurrency, $multicurrency_code) private function logPrice($user, $datec, $buyprice, $qty, $multicurrency_buyprice = null, $multicurrency_unitBuyPrice = null, $multicurrency_tx = null, $fk_multicurrency = null, $multicurrency_code = null)
{ {
// Add record into log table // Add record into log table
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log("; $sql = "INSERT INTO " . MAIN_DB_PREFIX . "product_fournisseur_price_log(";

View File

@ -59,12 +59,12 @@ class FormProduct
* Load in cache array list of warehouses * Load in cache array list of warehouses
* If fk_product is not 0, we do not use cache * If fk_product is not 0, we do not use cache
* *
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
* @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''.
* @param string $status warehouse status filter, following comma separated filter options can be used * @param string $status warehouse status filter, following comma separated filter options can be used
* 'warehouseopen' = select products from open warehouses, * 'warehouseopen' = select products from open warehouses,
* 'warehouseclosed' = select products from closed warehouses, * 'warehouseclosed' = select products from closed warehouses,
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only * 'warehouseinternal' = select products from warehouses for internal correct/transfer only
* @param boolean $sumStock sum total stock of a warehouse, default true * @param boolean $sumStock sum total stock of a warehouse, default true
* @param array $exclude warehouses ids to exclude * @param array $exclude warehouses ids to exclude
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @return int Nb of loaded lines, 0 if already loaded, <0 if KO
@ -114,9 +114,9 @@ class FormProduct
{ {
$sql.= " AND ps.fk_product = '".$fk_product."'"; $sql.= " AND ps.fk_product = '".$fk_product."'";
if (!empty($batch)) if (!empty($batch))
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'";
} }
} }
$sql.= " WHERE e.entity IN (".getEntity('stock').")"; $sql.= " WHERE e.entity IN (".getEntity('stock').")";
if (count($warehouseStatus)) if (count($warehouseStatus))
@ -173,9 +173,9 @@ class FormProduct
* @param String $final_label full label with all parents, separated by ' >> ' (completed on each call) * @param String $final_label full label with all parents, separated by ' >> ' (completed on each call)
* @return String full label with all parents, separated by ' >> ' * @return String full label with all parents, separated by ' >> '
*/ */
private function get_parent_path($tab, $final_label = '') private function get_parent_path($tab, $final_label = '')
{ {
//phpcs:enable //phpcs:enable
if(empty($final_label)) $final_label = $tab['label']; if(empty($final_label)) $final_label = $tab['label'];
if(empty($tab['parent_id'])) return $final_label; if(empty($tab['parent_id'])) return $final_label;
@ -195,9 +195,9 @@ class FormProduct
* @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value) * @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
* @param string $htmlname Name of html select html * @param string $htmlname Name of html select html
* @param string $filterstatus warehouse status filter, following comma separated filter options can be used * @param string $filterstatus warehouse status filter, following comma separated filter options can be used
* 'warehouseopen' = select products from open warehouses, * 'warehouseopen' = select products from open warehouses,
* 'warehouseclosed' = select products from closed warehouses, * 'warehouseclosed' = select products from closed warehouses,
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only * 'warehouseinternal' = select products from warehouses for internal correct/transfer only
* @param int $empty 1=Can be empty, 0 if not * @param int $empty 1=Can be empty, 0 if not
* @param int $disabled 1=Select is disabled * @param int $disabled 1=Select is disabled
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
@ -379,9 +379,9 @@ class FormProduct
*/ */
public function selectLotStock($selected = '', $htmlname = 'batch_id', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $empty_label = '', $forcecombo = 0, $events = array(), $morecss = 'minwidth200') public function selectLotStock($selected = '', $htmlname = 'batch_id', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array(), $empty_label = '', $forcecombo = 0, $events = array(), $morecss = 'minwidth200')
{ {
global $langs; global $conf, $langs;
dol_syslog(get_class($this)."::selectLot $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $fk_entrepot, $empty_label, $showstock, $forcecombo, $morecss", LOG_DEBUG); dol_syslog(get_class($this)."::selectLot $selected, $htmlname, $filterstatus, $empty, $disabled, $fk_product, $fk_entrepot, $empty_label, $forcecombo, $morecss", LOG_DEBUG);
$out=''; $out='';
$productIdArray = array(); $productIdArray = array();