From 6131d5a2b4a0c1fc9d9a616e4041fa7744022831 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:19:00 +0200 Subject: [PATCH 1/3] Fix scrutinizer --- htdocs/expedition/class/expedition.class.php | 63 ---------------- .../fournisseur.commande.dispatch.class.php | 7 ++ htdocs/reception/card.php | 12 ++-- htdocs/reception/class/reception.class.php | 71 +------------------ 4 files changed, 16 insertions(+), 137 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index acb54dde6f3..9035413b533 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2069,69 +2069,6 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update/create delivery method. - * - * @param string $id id method to activate - * - * @return void - */ - public function update_delivery_method($id = '') - { - // phpcs:enable - if ($id == '') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; - $resql = $this->db->query($sql); - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql .= " code='".$this->db->escape($this->update['code'])."'"; - $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql .= ",description='".$this->db->escape($this->update['description'])."'"; - $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".((int) $id); - $resql = $this->db->query($sql); - } - if ($resql < 0) { - dol_print_error($this->db, ''); - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Activate delivery method. - * - * @param int $id id method to activate - * @return void - */ - public function activ_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * DesActivate delivery method. - * - * @param int $id id method to desactivate - * - * @return void - */ - public function disable_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql .= " WHERE rowid= ".((int) $id); - - $resql = $this->db->query($sql); - } - - /** * Forge an set tracking url * diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 2ed936ee1f6..5bfafff57b5 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -80,6 +80,13 @@ class CommandeFournisseurDispatch extends CommonObjectLine public $fk_commandefourndet; public $qty; + public $qty_asked; + + public $libelle; + public $desc; + public $tva_tx; + public $vat_src_code; + public $ref_supplier; /** * @var int ID diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index cdd82525b6e..f5ce925efc3 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -270,9 +270,9 @@ if (empty($reshook)) { $object->origin_id = $origin_id; $object->fk_project = GETPOST('projectid', 'int'); $object->weight = GETPOST('weight', 'int') == '' ? null : GETPOST('weight', 'int'); - $object->sizeH = GETPOST('sizeH', 'int') == '' ? null : GETPOST('sizeH', 'int'); - $object->sizeW = GETPOST('sizeW', 'int') == '' ? null : GETPOST('sizeW', 'int'); - $object->sizeS = GETPOST('sizeS', 'int') == '' ? null : GETPOST('sizeS', 'int'); + $object->trueHeight = GETPOST('trueHeight', 'int') == '' ? null : GETPOST('trueHeight', 'int'); + $object->trueWidth = GETPOST('trueWidth', 'int') == '' ? null : GETPOST('trueWidth', 'int'); + $object->trueDepth = GETPOST('trueDepth', 'int') == '' ? null : GETPOST('trueDepth', 'int'); $object->size_units = GETPOST('size_units', 'int'); $object->weight_units = GETPOST('weight_units', 'int'); @@ -849,9 +849,9 @@ if ($action == 'create') { // Dim print ''; print $langs->trans("Width").' x '.$langs->trans("Height").' x '.$langs->trans("Depth"); - print ' '; - print ' x '; - print ' x '; + print ' '; + print ' x '; + print ' x '; print ' '; $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 2ff316ecb58..eea65c440e1 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -273,9 +273,9 @@ class Reception extends CommonObject $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : "null"); $sql .= ", '".$this->db->escape($this->tracking_number)."'"; $sql .= ", ".(is_null($this->weight) ? "NULL" : ((double) $this->weight)); - $sql .= ", ".(is_null($this->sizeS) ? "NULL" : ((double) $this->sizeS)); // TODO Should use this->trueDepth - $sql .= ", ".(is_null($this->sizeW) ? "NULL" : ((double) $this->sizeW)); // TODO Should use this->trueWidth - $sql .= ", ".(is_null($this->sizeH) ? "NULL" : ((double) $this->sizeH)); // TODO Should use this->trueHeight + $sql .= ", ".(is_null($this->trueDepth) ? "NULL" : ((double) $this->trueDepth)); + $sql .= ", ".(is_null($this->trueWidth) ? "NULL" : ((double) $this->trueWidth)); + $sql .= ", ".(is_null($this->trueHeight) ? "NULL" : ((double) $this->trueHeight)); $sql .= ", ".(is_null($this->weight_units) ? "NULL" : ((double) $this->weight_units)); $sql .= ", ".(is_null($this->size_units) ? "NULL" : ((double) $this->size_units)); $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); @@ -744,7 +744,6 @@ class Reception extends CommonObject if (!empty($this->origin) && $this->origin_id > 0 && ($this->origin == 'order_supplier' || $this->origin == 'commandeFournisseur')) { if (empty($this->commandeFournisseur)) { - $this->commandeFournisseur = null; $this->fetch_origin(); if (empty($this->commandeFournisseur->lines)) { $res = $this->commandeFournisseur->fetch_lines(); @@ -1485,70 +1484,6 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update/create delivery method. - * - * @param string $id id method to activate - * - * @return void - */ - public function update_delivery_method($id = '') - { - // phpcs:enable - if ($id == '') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; - $resql = $this->db->query($sql); - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql .= " code='".$this->db->escape($this->update['code'])."'"; - $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql .= ",description='".$this->db->escape($this->update['description'])."'"; - $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".((int) $id); - $resql = $this->db->query($sql); - } - if ($resql < 0) { - dol_print_error($this->db, ''); - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Activate delivery method. - * - * @param int $id id method to activate - * - * @return void - */ - public function activ_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * DesActivate delivery method. - * - * @param int $id id method to desactivate - * - * @return void - */ - public function disable_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - /** * Forge an set tracking url * From 0559cc08ac1c33cb110213578f048cff65bda16e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:28:27 +0200 Subject: [PATCH 2/3] Fix scrutinizer remove unused functions --- htdocs/compta/index.php | 2 - htdocs/core/lib/invoice.lib.php | 240 -------------------------------- 2 files changed, 242 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 207f806dc74..8cef74e4fc7 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -102,11 +102,9 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); print '
'; -//print getCustomerInvoicePieChart($socid); print getNumberInvoicesPieChart('customers'); print '
'; print getNumberInvoicesPieChart('fourn'); -//print getPurchaseInvoicePieChart($socid); print '
'; print getCustomerInvoiceDraftTable($max, $socid); print '
'; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 7c24d17d61e..786483e257b 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -245,246 +245,6 @@ function supplier_invoice_rec_prepare_head($object) return $head; } -/** - * Return a HTML table that contains a pie chart of customer invoices - * - * @param int $socid (Optional) Show only results from the customer with this id - * @return string A HTML table that contains a pie chart of customer invoices - */ -function getCustomerInvoicePieChart($socid = 0) -{ - global $conf, $db, $langs, $user; - - if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) { - return ''; - } - - $sql = "SELECT count(f.rowid), f.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture').")"; - if ($user->socid) { - $sql .= ' AND f.fk_soc = '.((int) $user->socid); - } - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - $sql .= " GROUP BY f.fk_statut"; - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $vals = array(); - - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - $vals[$row[1]] = $row[0]; - $total += $row[0]; - } - - $i++; - } - - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $result = '
'; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $objectstatic = new Facture($db); - $array = array(Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED); - $dataseries = array(); - - foreach ($array as $status) { - $objectstatic->statut = $status; - $objectstatic->paye = $status == Facture::STATUS_CLOSED ? -1 : 0; - - $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Facture::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == Facture::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == Facture::STATUS_CLOSED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == Facture::STATUS_ABANDONED) { - $colorseries[$status] = $badgeStatus6; - } - - if (!$conf->use_javascript_ajax) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - } - - if ($conf->use_javascript_ajax) { - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('150'); - $dolgraph->setWidth('300'); - $dolgraph->draw('idgraphcustomerinvoices'); - - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= '
'.$langs->trans("Statistics").' - '.$langs->trans("CustomerInvoice").'
'.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$dolgraph->show($total ? 0 : 1).'
'.$langs->trans("Total").''.$total.'
'; - $result .= '
'; - - return $result; -} - - -/** - * Return a HTML table that contains a pie chart of supplier invoices - * - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that contains a pie chart of supplier invoices - */ -function getPurchaseInvoicePieChart($socid = 0) -{ - global $conf, $db, $langs, $user; - - if (!((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire))) { - return ''; - } - - $sql = "SELECT count(f.rowid), f.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($user->socid) { - $sql .= ' AND f.fk_soc = '.((int) $user->socid); - } - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - $sql .= " GROUP BY f.fk_statut"; - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $vals = array(); - - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - $vals[$row[1]] = $row[0]; - $total += $row[0]; - } - - $i++; - } - - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $result = '
'; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $objectstatic = new FactureFournisseur($db); - $array = array(FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED); - $dataseries = array(); - - foreach ($array as $status) { - $objectstatic->statut = $status; - $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0; - - $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == FactureFournisseur::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == FactureFournisseur::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == FactureFournisseur::STATUS_CLOSED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == FactureFournisseur::STATUS_ABANDONED) { - $colorseries[$status] = $badgeStatus6; - } - - if (!$conf->use_javascript_ajax) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - } - - if ($conf->use_javascript_ajax) { - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('150'); - $dolgraph->setWidth('300'); - $dolgraph->draw('idgraphpurchaseinvoices'); - - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= '
'.$langs->trans("Statistics").' - '.$langs->trans("SupplierInvoice").'
'.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$dolgraph->show($total ? 0 : 1).'
'.$langs->trans("Total").''.$total.'
'; - $result .= '
'; - - return $result; -} - /** * Return an HTML table that contains a pie chart of the number of customers or supplier invoices * From 5a489e4594d189be410ddb34c42f0a13634c4ec6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:43:45 +0200 Subject: [PATCH 3/3] Fix scrutinizer --- htdocs/expensereport/class/expensereport.class.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 1ed0e7a30f5..9a69784adce 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -112,6 +112,9 @@ class ExpenseReport extends CommonObject public $fk_user_validator; // User that is defined to approve // Validation + /* @deprecated */ + public $datevalid; + public $date_valid; // User making validation public $fk_user_valid; public $user_valid_infos; @@ -1806,8 +1809,6 @@ class ExpenseReport extends CommonObject // We don't know seller and buyer for expense reports $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company $buyer = new Societe($this->db); $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller); @@ -1891,10 +1892,7 @@ class ExpenseReport extends CommonObject if (!is_object($seller)) { $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company } - //$buyer = new Societe($this->db); $expensereportrule = new ExpenseReportRule($db); $rulestocheck = $expensereportrule->getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); @@ -1979,10 +1977,7 @@ class ExpenseReport extends CommonObject if (!is_object($seller)) { $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company } - //$buyer = new Societe($this->db); $expenseik = new ExpenseReportIk($this->db); $range = $expenseik->getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); @@ -2618,9 +2613,11 @@ class ExpenseReportLine extends CommonObjectLine public $projet_ref; public $projet_title; + public $rang; public $vatrate; public $vat_src_code; + public $tva_tx; public $localtax1_tx; public $localtax2_tx; public $localtax1_type;