Fix qodana warning

This commit is contained in:
Laurent Destailleur 2023-04-26 02:05:43 +02:00
parent f228aa1a80
commit 8d06189621
10 changed files with 47 additions and 11 deletions

View File

@ -317,6 +317,7 @@ if ($mode == 'config' && $user->admin) {
print '<th>'.$langs->trans("Parameters").'</th>'; print '<th>'.$langs->trans("Parameters").'</th>';
print '<th></th>'; print '<th></th>';
print "</tr>\n"; print "</tr>\n";
$ret = $printer->listprinters(); $ret = $printer->listprinters();
$nbofprinters = count($printer->listprinters); $nbofprinters = count($printer->listprinters);

View File

@ -54,6 +54,12 @@ class Bookmark extends CommonObject
*/ */
public $db; public $db;
/**
* Last error code on a local method
* @var int Error number
*/
public $errno;
/** /**
* @var int ID * @var int ID
*/ */

View File

@ -1507,7 +1507,7 @@ class Facture extends CommonInvoice
* *
* @param Object $object Object source * @param Object $object Object source
* @param User $user Object user * @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 * @return int <0 if KO, 0 if nothing done, 1 if OK
*/ */
public function createFromContract($object, User $user, $lines = array()) public function createFromContract($object, User $user, $lines = array())

View File

@ -82,6 +82,11 @@ class BonPrelevement extends CommonObject
public $invoice_in_error = array(); public $invoice_in_error = array();
public $thirdparty_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_DRAFT = 0;
const STATUS_TRANSFERED = 1; const STATUS_TRANSFERED = 1;

View File

@ -144,6 +144,18 @@ class dolReceiptPrinter extends Printer
*/ */
public $orderprinter; 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) * @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 * @return int 0 if OK; >0 if KO
*/ */
public function listPrinters() public function listPrinters()
{ {
global $conf; global $conf;
$error = 0; $error = 0;
$line = 0; $line = 0;
$obj = array(); $obj = array();
$sql = "SELECT rowid, name, fk_type, fk_profile, parameter"; $sql = "SELECT rowid, name, fk_type, fk_profile, parameter";
$sql .= " FROM ".$this->db->prefix()."printer_receipt"; $sql .= " FROM ".$this->db->prefix()."printer_receipt";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".((int) $conf->entity);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ($line < $num) { while ($line < $num) {
@ -308,7 +324,9 @@ class dolReceiptPrinter extends Printer
$error++; $error++;
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
} }
$this->listprinters = $obj; $this->listprinters = $obj;
return $error; return $error;
} }
@ -321,13 +339,17 @@ class dolReceiptPrinter extends Printer
public function listPrintersTemplates() public function listPrintersTemplates()
{ {
global $conf; global $conf;
$error = 0; $error = 0;
$line = 0; $line = 0;
$obj = array(); $obj = array();
$sql = "SELECT rowid, name, template"; $sql = "SELECT rowid, name, template";
$sql .= " FROM ".$this->db->prefix()."printer_receipt_template"; $sql .= " FROM ".$this->db->prefix()."printer_receipt_template";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".$conf->entity;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
while ($line < $num) { while ($line < $num) {
@ -338,7 +360,9 @@ class dolReceiptPrinter extends Printer
$error++; $error++;
$this->errors[] = $this->db->lasterror; $this->errors[] = $this->db->lasterror;
} }
$this->listprinterstemplates = $obj; $this->listprinterstemplates = $obj;
return $error; return $error;
} }

View File

@ -304,7 +304,7 @@ class Fiscalyear extends CommonObject
$datas['date_start'] .= '<br><b>'.$langs->trans('DateStart').':</b> '.dol_print_date($this->date_start, 'day'); $datas['date_start'] .= '<br><b>'.$langs->trans('DateStart').':</b> '.dol_print_date($this->date_start, 'day');
} }
if (isset($this->date_start)) { if (isset($this->date_start)) {
$datas['date_end'] .= '<br><b>'.$langs->trans('DateEnd').':</b> '.dol_print_date($this->date_end, 'day');; $datas['date_end'] .= '<br><b>'.$langs->trans('DateEnd').':</b> '.dol_print_date($this->date_end, 'day');
} }
return $datas; return $datas;

View File

@ -2115,7 +2115,7 @@ class EmailCollector extends CommonObject
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from); $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $from);
if ($result > 0) { if ($result > 0) {
dol_syslog("We found a thirdparty with the email ".$from); dol_syslog("We found a thirdparty with the email ".$from);
$thirdpartyid = $thirdpartystatic->id;; $thirdpartyid = $thirdpartystatic->id;
$thirdpartyfoundby = 'email ('.$from.')'; $thirdpartyfoundby = 'email ('.$from.')';
} }
} }
@ -2143,7 +2143,7 @@ class EmailCollector extends CommonObject
$result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto); $result = $thirdpartystatic->fetch(0, '', '', '', '', '', '', '', '', '', $replyto);
if ($result > 0) { if ($result > 0) {
dol_syslog("We found a thirdparty with the email ".$replyto); dol_syslog("We found a thirdparty with the email ".$replyto);
$thirdpartyid = $thirdpartystatic->id;; $thirdpartyid = $thirdpartystatic->id;
$thirdpartyfoundby = 'email ('.$replyto.')'; $thirdpartyfoundby = 'email ('.$replyto.')';
} }
} }

View File

@ -2076,7 +2076,7 @@ if ($action == 'create') {
foreach ($object->lines as &$line) { foreach ($object->lines as &$line) {
$numline = $i + 1; $numline = $i + 1;
if ($action != 'editline' || $line->rowid != GETPOST('rowid', 'int')) { if ($action != 'editline' || $line->id != GETPOST('rowid', 'int')) {
print '<tr class="oddeven linetr" data-id="'.$line->id.'">'; print '<tr class="oddeven linetr" data-id="'.$line->id.'">';
// Num // Num
@ -2246,7 +2246,7 @@ if ($action == 'create') {
print '</tr>'; print '</tr>';
} }
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 // Add line with link to add new file or attach line to an existing file
$colspan = 11; $colspan = 11;
if (isModEnabled('project')) { if (isModEnabled('project')) {
@ -2337,7 +2337,7 @@ if ($action == 'create') {
if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) { if (!empty($conf->global->MAIN_USE_EXPENSE_IK)) {
print '<td class="fk_c_exp_tax_cat">'; print '<td class="fk_c_exp_tax_cat">';
$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 $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 '</td>'; print '</td>';
} }

View File

@ -56,6 +56,7 @@ class Import
public $errors = array(); public $errors = array();
// To store import templates // To store import templates
public $id;
public $hexa; // List of fields in the export profile public $hexa; // List of fields in the export profile
public $datatoimport; public $datatoimport;
public $model_name; // Name of export profile public $model_name; // Name of export profile
@ -338,7 +339,6 @@ class Import
*/ */
public function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
global $conf, $langs;
$error = 0; $error = 0;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."import_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."import_model";

View File

@ -69,8 +69,8 @@ if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$object = new Product($db);
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$object = new Product($db);
$object->fetch($id, $ref); $object->fetch($id, $ref);
} }