From 56afefd6ad4528ebefc8e1f0f7c610c8c7d7ae05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Jun 2021 07:12:45 +0200 Subject: [PATCH 1/6] fix warnings --- htdocs/product/class/product.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 1afd1e74e23..18b0529a5da 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2666,14 +2666,14 @@ class Product extends CommonObject $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid"; $sql .= " WHERE "; $sql .= " b.entity IN (".getEntity('bom').")"; - $sql .= " AND b.fk_product =".$this->id; + $sql .= " AND b.fk_product =".((int) $this->id); $sql .= " GROUP BY b.rowid"; $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - $this->stats_bom['nb_toproduce'] = $obj->nb_toproduce ? $obj->nb_toproduce : 0; - $this->stats_bom['qty_toproduce'] = $obj->qty_toproduce ? price2num($obj->qty_toproduce) : 0; + $this->stats_bom['nb_toproduce'] = !empty($obj->nb_toproduce) ? $obj->nb_toproduce : 0; + $this->stats_bom['qty_toproduce'] = !empty($obj->qty_toproduce) ? price2num($obj->qty_toproduce) : 0; } else { $this->error = $this->db->error(); $error++; @@ -2685,13 +2685,13 @@ class Product extends CommonObject $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid"; $sql .= " WHERE "; $sql .= " b.entity IN (".getEntity('bom').")"; - $sql .= " AND bl.fk_product =".$this->id; + $sql .= " AND bl.fk_product =".((int) $this->id); $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); - $this->stats_bom['nb_toconsume'] = $obj->nb_toconsume ? $obj->nb_toconsume : 0; - $this->stats_bom['qty_toconsume'] = $obj->qty_toconsume ? price2num($obj->qty_toconsume) : 0; + $this->stats_bom['nb_toconsume'] = !empty($obj->nb_toconsume) ? $obj->nb_toconsume : 0; + $this->stats_bom['qty_toconsume'] = !empty($obj->qty_toconsume) ? price2num($obj->qty_toconsume) : 0; } else { $this->error = $this->db->error(); $error++; From 3ca8de8fabe98081a162d0d915605ea0c919ae55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Jun 2021 07:20:41 +0200 Subject: [PATCH 2/6] fix warning --- htdocs/product/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 0c922fab0dd..b4804751086 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1236,8 +1236,8 @@ if ($resql) { $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; // deprecated - $product_static->ref_supplier = $obj->ref_supplier; + $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated + $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; $product_static->label = $obj->label; $product_static->finished = $obj->finished; $product_static->type = $obj->fk_product_type; From a723a8f93e81547d4c22cf1bc39196325882b067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 12 Jun 2021 18:40:00 +0200 Subject: [PATCH 3/6] remove phpcs warning --- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/modules/modFacture.class.php | 32 ++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index f3ebef1e49f..64cc72a8879 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -363,7 +363,7 @@ function show_stats_for_company($product, $socid) global $conf, $langs, $user, $db, $hookmanager; $form = new Form($db); - + $nblines = 0; print ''; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index b296fa3b32c..a9765f45ada 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -120,8 +120,36 @@ class modFacture extends DolibarrModules $arraydate = dol_getdate(dol_now()); $datestart = dol_mktime(23, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0=>array('label'=>'RecurringInvoices', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture-rec.class.php', 'objectname'=>'FactureRec', 'method'=>'createRecurringInvoices', 'parameters'=>'', 'comment'=>'Generate recurring invoices', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>1, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart), - 1=>array('label'=>'SendEmailsRemindersOnInvoiceDueDate', 'jobtype'=>'method', 'class'=>'compta/facture/class/facture.class.php', 'objectname'=>'Facture', 'method'=>'sendEmailsRemindersOnInvoiceDueDate', 'parameters'=>"10,all,EmailTemplateCode", 'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last paramater is the code of email template to use (an email template with EmailTemplateCode must exists. the version in the language of the thirdparty will be used in priority).', 'frequency'=>1, 'unitfrequency'=>3600 * 24, 'priority'=>50, 'status'=>0, 'test'=>'$conf->facture->enabled', 'datestart'=>$datestart), + 0 => array( + 'label'=>'RecurringInvoices', + 'jobtype'=>'method', + 'class'=>'compta/facture/class/facture-rec.class.php', + 'objectname'=>'FactureRec', + 'method'=>'createRecurringInvoices', + 'parameters'=>'', + 'comment'=>'Generate recurring invoices', + 'frequency'=>1, + 'unitfrequency'=>3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->facture->enabled', + 'datestart'=>$datestart + ), + 1 => array( + 'label'=>'SendEmailsRemindersOnInvoiceDueDate', + 'jobtype'=>'method', + 'class'=>'compta/facture/class/facture.class.php', + 'objectname'=>'Facture', + 'method'=>'sendEmailsRemindersOnInvoiceDueDate', + 'parameters'=>"10,all,EmailTemplateCode", + 'comment'=>'Send an emails when the unpaid invoices reach a due date + n days = today. First param is the offset n of days, second parameter is "all" or a payment mode code, last paramater is the code of email template to use (an email template with EmailTemplateCode must exists. the version in the language of the thirdparty will be used in priority).', + 'frequency'=>1, + 'unitfrequency'=>3600 * 24, + 'priority'=>50, + 'status'=>0, + 'test'=>'$conf->facture->enabled', + 'datestart'=>$datestart + ), ); // Permissions From ebc0cc75dd7916af6eefadf65c28320bcca7451f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 13 Jun 2021 15:37:54 +0200 Subject: [PATCH 4/6] fix warning --- htdocs/core/modules/member/modules_cards.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index 0e041a17559..937e8a06870 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -48,7 +48,7 @@ class ModelePDFCards * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - public function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; From 519d7f1d0f3271c78789c121c286c06ab74aa351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 13 Jun 2021 15:47:42 +0200 Subject: [PATCH 5/6] fix warnings --- htdocs/ticket/list.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 45a11a9daef..3ba138bb99e 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -765,19 +765,19 @@ foreach ($object->fields as $key => $val) { if (!empty($arrayfields['t.'.$key]['checked'])) { if ($key == 'type_code') { print ''; - $formTicket->selectTypesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); + $formTicket->selectTypesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'category_code') { print ''; - $formTicket->selectGroupTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); + $formTicket->selectGroupTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'severity_code') { print ''; - $formTicket->selectSeveritiesTickets(dol_escape_htmltag($search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); + $formTicket->selectSeveritiesTickets(dol_escape_htmltag(empty($search[$key]) ? '' : $search[$key]), 'search_'.$key.'', '', 2, 1, 1, 0, ($val['css'] ? $val['css'] : 'maxwidth150')); print ''; } elseif ($key == 'fk_user_assign' || $key == 'fk_user_create') { print ''; - print $form->select_dolusers($search[$key], 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth125')); + print $form->select_dolusers((empty($search[$key]) ? '' : $search[$key]), 'search_'.$key, 1, null, 0, '', '', '0', 0, 0, '', 0, '', ($val['css'] ? $val['css'] : 'maxwidth125')); print ''; } elseif ($key == 'fk_statut') { $arrayofstatus = array(); @@ -791,7 +791,7 @@ foreach ($object->fields as $key => $val) { print ''; //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); $selectedarray = null; - if ($search[$key]) { + if (!empty($search[$key])) { $selectedarray = array_values($search[$key]); } print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth100 maxwidth150', 1, 0, '', '', ''); @@ -832,7 +832,7 @@ foreach ($object->fields as $key => $val) { } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print ''; } From 791e4ab05617e4da77aab9c041765462b2db6b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 13 Jun 2021 15:59:22 +0200 Subject: [PATCH 6/6] fix warning --- htdocs/compta/facture/class/facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1f633015cd4..1ee946e8a00 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -4250,7 +4250,7 @@ class Facture extends CommonInvoice $generic_facture->statut = $obj->fk_statut; $response->nbtodo++; - $response->total += $obj->total; + $response->total += $obj->total_ht; if ($generic_facture->hasDelay()) { $response->nbtodolate++;