From 8d06189621556b824bf504d71a3a49d81abc90f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 Apr 2023 02:05:43 +0200 Subject: [PATCH] Fix qodana warning --- htdocs/admin/receiptprinter.php | 1 + htdocs/bookmarks/class/bookmark.class.php | 6 ++++ htdocs/compta/facture/class/facture.class.php | 2 +- .../class/bonprelevement.class.php | 5 ++++ htdocs/core/class/dolreceiptprinter.class.php | 28 +++++++++++++++++-- htdocs/core/class/fiscalyear.class.php | 2 +- .../class/emailcollector.class.php | 4 +-- htdocs/expensereport/card.php | 6 ++-- htdocs/imports/class/import.class.php | 2 +- htdocs/product/price.php | 2 +- 10 files changed, 47 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index a8ae4501ca5..f515ea56600 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -317,6 +317,7 @@ if ($mode == 'config' && $user->admin) { print ''.$langs->trans("Parameters").''; print ''; print "\n"; + $ret = $printer->listprinters(); $nbofprinters = count($printer->listprinters); diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index f1f81f9e45c..389603fb161 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -54,6 +54,12 @@ class Bookmark extends CommonObject */ public $db; + /** + * Last error code on a local method + * @var int Error number + */ + public $errno; + /** * @var int ID */ diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0368882885b..18de3c14b64 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1507,7 +1507,7 @@ class Facture extends CommonInvoice * * @param Object $object Object source * @param User $user Object user - * @param Array(int) $lines Ids of lines to use for invoice. If empty, all lines will be used. + * @param array $lines Ids of lines to use for invoice. If empty, all lines will be used. * @return int <0 if KO, 0 if nothing done, 1 if OK */ public function createFromContract($object, User $user, $lines = array()) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index f4f88885a00..3c2fb078746 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -82,6 +82,11 @@ class BonPrelevement extends CommonObject public $invoice_in_error = array(); public $thirdparty_in_error = array(); + /** + * @var resource Handler of the file for direct debit or credit transfer order + */ + public $file; + const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 2bc26fa324c..5b3050216e6 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -144,6 +144,18 @@ class dolReceiptPrinter extends Printer */ public $orderprinter; + /** + * Array with list of printers + * @var array List of printers + */ + public $listprinters; + + /** + * Array with list of printer templates + * @var array List of printer templates + */ + public $listprinterstemplates; + /** * @var string Error code (or message) */ @@ -246,20 +258,24 @@ class dolReceiptPrinter extends Printer } /** - * list printers + * List printers into the array ->listprinters * * @return int 0 if OK; >0 if KO */ public function listPrinters() { global $conf; + $error = 0; $line = 0; $obj = array(); + $sql = "SELECT rowid, name, fk_type, fk_profile, parameter"; $sql .= " FROM ".$this->db->prefix()."printer_receipt"; - $sql .= " WHERE entity = ".$conf->entity; + $sql .= " WHERE entity = ".((int) $conf->entity); + $resql = $this->db->query($sql); + if ($resql) { $num = $this->db->num_rows($resql); while ($line < $num) { @@ -308,7 +324,9 @@ class dolReceiptPrinter extends Printer $error++; $this->errors[] = $this->db->lasterror; } + $this->listprinters = $obj; + return $error; } @@ -321,13 +339,17 @@ class dolReceiptPrinter extends Printer public function listPrintersTemplates() { global $conf; + $error = 0; $line = 0; $obj = array(); + $sql = "SELECT rowid, name, template"; $sql .= " FROM ".$this->db->prefix()."printer_receipt_template"; $sql .= " WHERE entity = ".$conf->entity; + $resql = $this->db->query($sql); + if ($resql) { $num = $this->db->num_rows($resql); while ($line < $num) { @@ -338,7 +360,9 @@ class dolReceiptPrinter extends Printer $error++; $this->errors[] = $this->db->lasterror; } + $this->listprinterstemplates = $obj; + return $error; } diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index cfc0c02f19e..ede7f101fc9 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -304,7 +304,7 @@ class Fiscalyear extends CommonObject $datas['date_start'] .= '
'.$langs->trans('DateStart').': '.dol_print_date($this->date_start, 'day'); } if (isset($this->date_start)) { - $datas['date_end'] .= '
'.$langs->trans('DateEnd').': '.dol_print_date($this->date_end, 'day');; + $datas['date_end'] .= '
'.$langs->trans('DateEnd').': '.dol_print_date($this->date_end, 'day'); } return $datas; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 783583122d7..cb06609562d 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2115,7 +2115,7 @@ class EmailCollector extends CommonObject $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from); if ($result > 0) { dol_syslog("We found a thirdparty with the email ".$from); - $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyid = $thirdpartystatic->id; $thirdpartyfoundby = 'email ('.$from.')'; } } @@ -2143,7 +2143,7 @@ class EmailCollector extends CommonObject $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); if ($result > 0) { dol_syslog("We found a thirdparty with the email ".$replyto); - $thirdpartyid = $thirdpartystatic->id;; + $thirdpartyid = $thirdpartystatic->id; $thirdpartyfoundby = 'email ('.$replyto.')'; } } diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 42bb44bfdbe..55ce88d66dc 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2076,7 +2076,7 @@ if ($action == 'create') { foreach ($object->lines as &$line) { $numline = $i + 1; - if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int')) { + if ($action != 'editline' || $line->id != GETPOST('rowid', 'int')) { print ''; // Num @@ -2246,7 +2246,7 @@ if ($action == 'create') { print ''; } - if ($action == 'editline' && $line->rowid == GETPOST('rowid', 'int')) { + if ($action == 'editline' && $line->id == GETPOST('rowid', 'int')) { // Add line with link to add new file or attach line to an existing file $colspan = 11; if (isModEnabled('project')) { @@ -2337,7 +2337,7 @@ if ($action == 'create') { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { print ''; - $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->rowid, 'date' => $line->dates); + $params = array('fk_expense' => $object->id, 'fk_expense_det' => $line->id, 'date' => $line->dates); print $form->selectExpenseCategories($line->fk_c_exp_tax_cat, 'fk_c_exp_tax_cat', 1, array(), 'fk_c_type_fees', $userauthor->default_c_exp_tax_cat, $params); print ''; } diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 61ac4929d40..e9211362408 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -56,6 +56,7 @@ class Import public $errors = array(); // To store import templates + public $id; public $hexa; // List of fields in the export profile public $datatoimport; public $model_name; // Name of export profile @@ -338,7 +339,6 @@ class Import */ public function delete($user, $notrigger = 0) { - global $conf, $langs; $error = 0; $sql = "DELETE FROM ".MAIN_DB_PREFIX."import_model"; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 08757602907..d62760611c2 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -69,8 +69,8 @@ if ($user->socid) { $socid = $user->socid; } +$object = new Product($db); if ($id > 0 || !empty($ref)) { - $object = new Product($db); $object->fetch($id, $ref); }