From 3e723af0189ce964550999462e4962068ae90182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 1 Sep 2018 23:46:13 +0200 Subject: [PATCH] start changing phpcs:ignore --- htdocs/comm/propal/class/propal.class.php | 66 +++++--- htdocs/contrat/class/contrat.class.php | 36 +++-- htdocs/cron/class/cronjob.class.php | 16 +- htdocs/expedition/class/expedition.class.php | 52 +++--- .../class/paymentexpensereport.class.php | 8 +- htdocs/product/card.php | 2 +- .../product/class/html.formproduct.class.php | 10 +- htdocs/product/class/product.class.php | 149 ++++++++++++------ htdocs/product/class/productbatch.class.php | 7 +- .../inventory/class/inventory.class.php | 15 +- .../class/productstockentrepot.class.php | 5 +- test/phpunit/CoreTest.php | 3 +- 12 files changed, 235 insertions(+), 134 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index d59ccc63d1c..e8437e66498 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -232,9 +232,10 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Add line into array products - * $this->thirdparty should be loaded + * Add line into array products + * $this->thirdparty should be loaded * * @param int $idproduct Product Id to add * @param int $qty Quantity @@ -244,9 +245,9 @@ class Propal extends CommonObject * TODO Replace calls to this function by generation objet Ligne * inserted into table $this->products */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function add_product($idproduct, $qty, $remise_percent=0) { + // phpcs:enable global $conf, $mysoc; if (! $qty) $qty = 1; @@ -293,15 +294,16 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function insert_discount($idremise) { + // phpcs:enable global $langs; include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1172,6 +1174,7 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Insert into DB a proposal object completely defined by its data members (ex, results from copy). * @@ -1179,9 +1182,9 @@ class Propal extends CommonObject * @return int Id of the new object if ok, <0 if ko * @see create */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function create_from($user) { + // phpcs:enable // i love this function because $this->products is not used in create function... $this->products=$this->lines; @@ -1564,15 +1567,16 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_lines($only_product=0) { + // phpcs:enable $this->lines=array(); $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,'; @@ -1803,6 +1807,7 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Define proposal date * @@ -1811,9 +1816,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_date($user, $date, $notrigger=0) { + // phpcs:enable if (empty($date)) { $this->error='ErrorBadParameter'; @@ -1871,6 +1876,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Define end validity date * @@ -1879,9 +1885,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_echeance($user, $date_fin_validite, $notrigger=0) { + // phpcs:enable if (! empty($user->rights->propal->creer)) { $error=0; @@ -1932,6 +1938,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set delivery date * @@ -1940,9 +1947,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_date_livraison($user, $date_livraison, $notrigger=0) { + // phpcs:enable if (! empty($user->rights->propal->creer)) { $error=0; @@ -1993,6 +2000,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set delivery * @@ -2001,9 +2009,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_availability($user, $id, $notrigger=0) { + // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error=0; @@ -2063,6 +2071,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set source of demand * @@ -2071,9 +2080,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_demand_reason($user, $id, $notrigger=0) { + // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) { $error=0; @@ -2135,6 +2144,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set customer reference number * @@ -2143,9 +2153,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_ref_client($user, $ref_client, $notrigger=0) { + // phpcs:enable if (! empty($user->rights->propal->creer)) { $error=0; @@ -2199,6 +2209,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set an overall discount on the proposal * @@ -2207,9 +2218,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_remise_percent($user, $remise, $notrigger=0) { + // phpcs:enable $remise=trim($remise)?trim($remise):0; if (! empty($user->rights->propal->creer)) @@ -2265,6 +2276,7 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -2273,9 +2285,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_remise_absolue($user, $remise, $notrigger=0) { + // phpcs:enable $remise=trim($remise)?trim($remise):0; if (! empty($user->rights->propal->creer)) @@ -2550,6 +2562,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set draft status * @@ -2557,9 +2570,9 @@ class Propal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_draft($user, $notrigger=0) { + // phpcs:enable $error=0; $this->db->begin(); @@ -2608,6 +2621,7 @@ class Propal extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of proposal (eventually filtered on user) into an array * @@ -2621,9 +2635,9 @@ class Propal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function liste_array($shortlist=0, $draft=0, $notcurrentuser=0, $socid=0, $limit=0, $offset=0, $sortfield='p.datep', $sortorder='DESC') { + // phpcs:enable global $user; $ga = array(); @@ -2695,15 +2709,16 @@ class Propal extends CommonObject return $this->InvoiceArrayList($this->id); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Returns an array with id and ref of related invoices * * @param int $id Id propal * @return array Array of invoices id */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function InvoiceArrayList($id) { + // phpcs:enable $ga = array(); $linkedInvoices = array(); @@ -2974,6 +2989,7 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Change source demand * @@ -2982,9 +2998,9 @@ class Propal extends CommonObject * @return int >0 si ok, <0 si ko * @deprecated use set_demand_reason */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function demand_reason($demand_reason_id, $notrigger=0) { + // phpcs:enable global $user; if ($this->statut >= self::STATUS_DRAFT) @@ -3115,6 +3131,7 @@ class Propal extends CommonObject return $this->LibStatut($this->statut, $mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -3122,9 +3139,9 @@ class Propal extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($statut,$mode=1) { + // phpcs:enable global $conf; // Init/load array of translation of status @@ -3158,9 +3175,10 @@ class Propal extends CommonObject if ($mode == 4) return img_picto($this->labelstatut[$statut],$statuttrans).' '.$this->labelstatut[$statut]; if ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); if ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],$statuttrans); - } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -3168,9 +3186,9 @@ class Propal extends CommonObject * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_board($user,$mode) { + // phpcs:enable global $conf, $langs; $clause = " WHERE"; @@ -3336,14 +3354,15 @@ class Propal extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_state_board() { + // phpcs:enable global $user; $this->nb=array(); @@ -4223,15 +4242,16 @@ class PropaleLigne extends CommonObjectLine } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_total() { + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index c7601cf9c1d..ee62ee5680c 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -236,6 +236,7 @@ class Contrat extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Activate a contract line * @@ -246,9 +247,9 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function active_line($user, $line_id, $date, $date_end='', $comment='') { + // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); if ($result < 0) { @@ -259,6 +260,7 @@ class Contrat extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Close a contract line * @@ -268,9 +270,9 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function close_line($user, $line_id, $date_end, $comment='') { + // phpcs:enable $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); if ($result < 0) { @@ -702,15 +704,16 @@ class Contrat extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_lines() { + // phpcs:enable $this->nbofserviceswait=0; $this->nbofservicesopened=0; $this->nbofservicesexpired=0; @@ -1780,6 +1783,7 @@ class Contrat extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Update statut of contract according to services * @@ -1787,9 +1791,9 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @deprecated This function will never be used. Status of a contract is status of its lines. */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_statut($user) { + // phpcs:enable dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); // If draft, we keep it (should not happen) @@ -1819,6 +1823,7 @@ class Contrat extends CommonObject return $this->LibStatut($this->statut,$mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoi label of a given contrat status * @@ -1826,9 +1831,9 @@ class Contrat extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($statut,$mode) { + // phpcs:enable global $langs; $langs->load("contracts"); if ($mode == 0) @@ -2002,15 +2007,16 @@ class Contrat extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of line rowid * * @param int $statut Status of lines to get * @return array Array of line's rowid */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function array_detail($statut=-1) { + // phpcs:enable $tab=array(); $sql = "SELECT cd.rowid"; @@ -2078,6 +2084,7 @@ class Contrat extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2085,9 +2092,9 @@ class Contrat extends CommonObject * @param string $mode "inactive" pour services a activer, "expired" pour services expires * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_board($user,$mode) { + // phpcs:enable global $conf, $langs; $this->from = " FROM ".MAIN_DB_PREFIX."contrat as c"; @@ -2157,14 +2164,15 @@ class Contrat extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_state_board() { + // phpcs:enable global $conf, $user; $this->nb=array(); @@ -2580,6 +2588,7 @@ class ContratLigne extends CommonObjectLine return $this->LibStatut($this->statut,$mode,((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return label of a contract line status * @@ -2589,9 +2598,9 @@ class ContratLigne extends CommonObjectLine * @param string $moreatt More attribute * @return string Libelle */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps static function LibStatut($statut,$mode,$expired=-1,$moreatt='') { + // phpcs:enable global $langs; $langs->load("contracts"); if ($mode == 0) @@ -3003,15 +3012,16 @@ class ContratLigne extends CommonObjectLine } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process * * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_total() { + // phpcs:enable $this->db->begin(); // Mise a jour ligne en base @@ -3120,6 +3130,7 @@ class ContratLigne extends CommonObjectLine } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Activate a contract line * @@ -3129,9 +3140,9 @@ class ContratLigne extends CommonObjectLine * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function active_line($user, $date, $date_end = '', $comment = '') { + // phpcs:enable global $langs, $conf; $error = 0; @@ -3178,6 +3189,7 @@ class ContratLigne extends CommonObjectLine } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Close a contract line * @@ -3187,9 +3199,9 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function close_line($user, $date_end, $comment = '', $notrigger=0) { + // phpcs:enable global $langs, $conf; // Update object diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 02fd4a95643..7c9396c70e8 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -368,6 +368,7 @@ class Cronjob extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load object in memory from the database * @@ -380,10 +381,10 @@ class Cronjob extends CommonObject * @param int $processing Processing or not * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='', $processing=-1) { - global $langs; + // phpcs:enable + global $langs; $this->lines=array(); @@ -920,6 +921,7 @@ class Cronjob extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Run a job. * Once job is finished, status and nb of run is updated. @@ -928,9 +930,9 @@ class Cronjob extends CommonObject * @param string $userlogin User login * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function run_jobs($userlogin) { + // phpcs:enable global $langs, $conf; $now=dol_now(); @@ -1191,6 +1193,7 @@ class Cronjob extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Reprogram a job * @@ -1198,9 +1201,9 @@ class Cronjob extends CommonObject * @param timestamp $now Date returned by dol_now() * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function reprogram_jobs($userlogin, $now) { + // phpcs:enable dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; @@ -1279,6 +1282,7 @@ class Cronjob extends CommonObject return $this->LibStatut($this->status,$mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1286,10 +1290,10 @@ class Cronjob extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($status,$mode=0) { - global $langs; + // phpcs:enable + global $langs; $langs->load('users'); if ($mode == 0) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8a46f14c829..e40faafeefd 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -48,14 +48,14 @@ class Expedition extends CommonObject * @var string ID to identify managed object */ public $element="shipping"; - + public $fk_element="fk_expedition"; - + /** * @var string Name of table without prefix where object is stored */ public $table_element="expedition"; - + public $table_element_line="expeditiondet"; public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe public $picto = 'sending'; @@ -380,6 +380,7 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Create a expedition line * @@ -389,9 +390,9 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, line_id if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function create_line($entrepot_id, $origin_line_id, $qty,$array_options=0) { + //phpcs:enable $expeditionline = new ExpeditionLigne($this->db); $expeditionline->fk_expedition = $this->id; $expeditionline->entrepot_id = $entrepot_id; @@ -407,6 +408,7 @@ class Expedition extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Create the detail (eat-by date) of the expedition line * @@ -414,9 +416,9 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function create_line_batch($line_ext,$array_options=0) { + // phpcs:enable $error = 0; $stockLocationQty = array(); // associated array with batch qty in stock location @@ -478,7 +480,7 @@ class Expedition extends CommonObject $sql.= ", e.note_private, e.note_public"; $sql.= ', e.fk_incoterms, e.location_incoterms'; $sql.= ', i.libelle as libelle_incoterms'; - $sql.= ', s.libelle as shipping_method'; + $sql.= ', s.libelle as shipping_method'; $sql.= ", el.fk_source as origin_id, el.sourcetype as origin"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = e.rowid AND el.targettype = '".$this->db->escape($this->element)."'"; @@ -807,15 +809,16 @@ class Expedition extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Create a delivery receipt from a shipment * * @param User $user User * @return int <0 if KO, >=0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function create_delivery($user) { + // phpcs:enable global $conf; if ($conf->livraison_bon->enabled) @@ -915,6 +918,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Add a shipment line with batch record * @@ -922,9 +926,9 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function addline_batch($dbatch,$array_options=0) { + // phpcs:enable global $conf,$langs; $num = count($this->lines); @@ -1303,14 +1307,15 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load lines * * @return int >0 if OK, Otherwise if KO */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_lines() { + // phpcs:enable global $conf, $mysoc; // TODO: recuperer les champs du document associe a part @@ -1590,6 +1595,7 @@ class Expedition extends CommonObject return $this->LibStatut($this->statut,$mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return label of a status * @@ -1597,9 +1603,9 @@ class Expedition extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($statut,$mode) { + // phpcs:enable global $langs; if ($mode==0) @@ -1713,6 +1719,7 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Set the planned delivery date * @@ -1720,9 +1727,9 @@ class Expedition extends CommonObject * @param timestamp $date_livraison Date de livraison * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_date_livraison($user, $date_livraison) { + // phpcs:enable if ($user->rights->expedition->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."expedition"; @@ -1748,14 +1755,15 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_delivery_methods() { + // phpcs:enable global $langs; $this->meths = array(); @@ -1775,15 +1783,16 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Fetch all deliveries method and return an array. Load array this->listmeths. * * @param id $id only this carrier, all if none * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function list_delivery_methods($id='') { + // phpcs:enable global $langs; $this->listmeths = array(); @@ -1810,6 +1819,7 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Update/create delivery method. * @@ -1817,9 +1827,9 @@ class Expedition extends CommonObject * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_delivery_method($id='') { + // phpcs:enable if ($id=='') { $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; @@ -1839,6 +1849,7 @@ class Expedition extends CommonObject if ($resql < 0) dol_print_error($this->db,''); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Activate delivery method. * @@ -1846,15 +1857,16 @@ class Expedition extends CommonObject * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function activ_delivery_method($id) { + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; $sql.= ' WHERE rowid='.$id; $resql = $this->db->query($sql); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * DesActivate delivery method. * @@ -1862,9 +1874,9 @@ class Expedition extends CommonObject * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function disable_delivery_method($id) { + // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; $sql.= ' WHERE rowid='.$id; @@ -1872,15 +1884,16 @@ class Expedition extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Forge an set tracking url * * @param string $value Value * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function GetUrlTrackingStatus($value='') { + // phpcs:enable if (! empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; @@ -2058,14 +2071,15 @@ class Expedition extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * * @return int <0 if ko, >0 if ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function set_billed() { + // phpcs:enable global $user; $error=0; @@ -2293,7 +2307,7 @@ class ExpeditionLigne extends CommonObjectLine * @var string ID to identify managed object */ public $element='expeditiondet'; - + /** * @var string Name of table without prefix where object is stored */ diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 0dceeae4808..fa581161494 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -450,16 +450,17 @@ class PaymentExpenseReport extends CommonObject return ''; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoi le libelle d'un statut donne * - * @param int $statut Id statut + * @param int $statut Id statut * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($statut,$mode=0) { + // phpcs:enable global $langs; return ''; @@ -604,15 +605,16 @@ class PaymentExpenseReport extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Update link between the expense report payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_fk_bank($id_bank) { + // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 672ad334422..52815c1303d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1068,7 +1068,7 @@ else print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) - { + { // Volume print ''.$langs->trans("Volume").''; print ''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 4eee6ffe502..22b5e4656a7 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -167,6 +167,7 @@ class FormProduct } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return full path to current warehouse in $tab (recursive function) * @@ -174,10 +175,9 @@ class FormProduct * @param String $final_label full label with all parents, separated by ' >> ' (completed on each call) * @return String full label with all parents, separated by ' >> ' */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps private function get_parent_path($tab, $final_label='') { - + //phpcs:enable if(empty($final_label)) $final_label = $tab['label']; if(empty($tab['parent_id'])) return $final_label; @@ -282,6 +282,7 @@ class FormProduct } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Output a combo box with list of units * pour l'instant on ne definit pas les unites dans la base @@ -292,12 +293,13 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function select_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0) { + //phpcs:enable print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return a combo box with list of units * For the moment, units labels are defined in measuring_units_string @@ -308,9 +310,9 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return string */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_measuring_units($name='measuring_units', $measuring_style='', $default='0', $adddefault=0) { + //phpcs:enable global $langs,$conf,$mysoc; $langs->load("other"); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index cdacd56e432..4f81927dca0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -692,19 +692,20 @@ class Product extends CommonObject return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Check barcode * - * @param string $valuetotest Value to test - * @param string $typefortest Type of barcode (ISBN, EAN, ...) + * @param string $valuetotest Value to test + * @param string $typefortest Type of barcode (ISBN, EAN, ...) * @return int 0 if OK * -1 ErrorBadBarCodeSyntax * -2 ErrorBarCodeRequired * -3 ErrorBarCodeAlreadyUsed */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function check_barcode($valuetotest,$typefortest) { + // phpcs:enable global $conf; if (! empty($conf->barcode->enabled) && ! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { @@ -1446,6 +1447,7 @@ class Product extends CommonObject + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Insert a track that we changed a customer price * @@ -1453,9 +1455,9 @@ class Product extends CommonObject * @param int $level price level to change * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function _log_price($user,$level=0) { + // phpcs:enable global $conf; $now=dol_now(); @@ -1485,6 +1487,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Delete a price line * @@ -1492,9 +1495,9 @@ class Product extends CommonObject * @param int $rowid Line id to delete * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function log_price_delete($user, $rowid) { + // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty"; $sql.= " WHERE fk_product_price=".$rowid; $resql=$this->db->query($sql); @@ -1514,6 +1517,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Read price used by a provider. * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref. @@ -1526,9 +1530,9 @@ class Product extends CommonObject * @param int $fk_soc If of supplier * @return int <-1 if KO, -1 if qty not enough, 0 if OK but nothing found, id_product if OK and found. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_buyprice($prodfournprice, $qty, $product_id=0, $fourn_ref='', $fk_soc=0) { + // phpcs:enable global $conf; $result = 0; @@ -2216,15 +2220,16 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats propale pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_propale($socid=0) { + // phpcs:enable global $conf; global $user; @@ -2260,15 +2265,16 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats propale pour le produit/service * * @param int $socid Id thirdparty * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_proposal_supplier($socid=0) { + // phpcs:enable global $conf; global $user; @@ -2304,6 +2310,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats commande client pour le produit/service * @@ -2312,9 +2319,9 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Array of stats (nb=nb of order, qty=qty ordered) */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_commande($socid=0,$filtrestatut='', $forVirtualStock = 0) { + // phpcs:enable global $conf,$user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,"; @@ -2401,6 +2408,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats commande fournisseur pour le produit/service * @@ -2409,9 +2417,9 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_commande_fournisseur($socid=0,$filtrestatut='', $forVirtualStock = 0) { + // phpcs:enable global $conf,$user; $sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_suppliers, COUNT(DISTINCT c.rowid) as nb,"; @@ -2445,6 +2453,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats expedition client pour le produit/service * @@ -2453,9 +2462,9 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_sending($socid=0,$filtrestatut='', $forVirtualStock = 0) { + // phpcs:enable global $conf,$user; $sql = "SELECT COUNT(DISTINCT e.fk_soc) as nb_customers, COUNT(DISTINCT e.rowid) as nb,"; @@ -2493,6 +2502,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats réception fournisseur pour le produit/service * @@ -2501,9 +2511,9 @@ class Product extends CommonObject * @param int $forVirtualStock Ignore rights filter for virtual stock calculation. * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_reception($socid=0,$filtrestatut='', $forVirtualStock = 0) { + // phpcs:enable global $conf,$user; $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; @@ -2537,15 +2547,16 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats contrat pour le produit/service * - * @param int $socid Id societe + * @param int $socid Id societe * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_contrat($socid=0) { + // phpcs:enable global $conf; global $user; @@ -2580,15 +2591,16 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats facture pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_facture($socid=0) { + // phpcs:enable global $conf; global $user; @@ -2623,15 +2635,16 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Charge tableau des stats facture pour le produit/service * * @param int $socid Id societe * @return array Tableau des stats */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stats_facture_fournisseur($socid=0) { + // phpcs:enable global $conf; global $user; @@ -2666,6 +2679,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return an array formated for showing graphs * @@ -2674,9 +2688,9 @@ class Product extends CommonObject * @param int $year Year (0=current year) * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function _get_stats($sql, $mode, $year=0) { + // phpcs:enable $resql = $this->db->query($sql); if ($resql) { @@ -2731,6 +2745,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or customers invoices in which product is included * @@ -2741,9 +2756,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_vente($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf; global $user; @@ -2768,6 +2783,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or supplier invoices in which product is included * @@ -2778,9 +2794,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_achat($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf; global $user; @@ -2804,6 +2820,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode, $year); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or proposals in which product is included * @@ -2814,9 +2831,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_propal($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf; global $user; @@ -2840,6 +2857,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode, $year); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or proposals in which product is included * @@ -2850,9 +2868,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_propalsupplier($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf; global $user; @@ -2876,6 +2894,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode, $year); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or orders in which product is included * @@ -2886,9 +2905,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_order($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; @@ -2911,6 +2930,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode, $year); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return nb of units or orders in which product is included * @@ -2921,9 +2941,9 @@ class Product extends CommonObject * @param string $morefilter More sql filters * @return array <0 if KO, result[month]=array(valuex,valuey) where month is 0 to 11 */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_nb_ordersupplier($socid, $mode, $filteronproducttype=-1, $year=0, $morefilter='') { + // phpcs:enable global $conf, $user; $sql = "SELECT sum(d.qty), date_format(c.date_commande, '%Y%m')"; @@ -2946,6 +2966,7 @@ class Product extends CommonObject return $this->_get_stats($sql,$mode, $year); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Link a product/service to a parent product/service * @@ -2955,9 +2976,9 @@ class Product extends CommonObject * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int < 0 if KO, > 0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function add_sousproduit($id_pere, $id_fils, $qty, $incdec=1) { + // phpcs:enable // Clean parameters if (! is_numeric($id_pere)) $id_pere=0; if (! is_numeric($id_fils)) $id_fils=0; @@ -3003,6 +3024,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Modify composed product * @@ -3012,9 +3034,9 @@ class Product extends CommonObject * @param int $incdec 1=Increase/decrease stock of child when parent stock increase/decrease * @return int < 0 if KO, > 0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function update_sousproduit($id_pere, $id_fils, $qty, $incdec=1) { + // phpcs:enable // Clean parameters if (! is_numeric($id_pere)) $id_pere=0; if (! is_numeric($id_fils)) $id_fils=0; @@ -3037,6 +3059,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retire le lien entre un sousproduit et un produit/service * @@ -3044,9 +3067,9 @@ class Product extends CommonObject * @param int $fk_child Id du produit a ne plus lie * @return int < 0 if KO, > 0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function del_sousproduit($fk_parent, $fk_child) { + // phpcs:enable if (! is_numeric($fk_parent)) $fk_parent=0; if (! is_numeric($fk_child)) $fk_child=0; @@ -3064,16 +3087,17 @@ class Product extends CommonObject return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Verifie si c'est un sous-produit * - * @param int $fk_parent Id du produit auquel le produit est lie - * @param int $fk_child Id du produit lie + * @param int $fk_parent Id du produit auquel le produit est lie + * @param int $fk_child Id du produit lie * @return int < 0 si erreur, > 0 si ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function is_sousproduit($fk_parent, $fk_child) { + // phpcs:enable $sql = "SELECT fk_product_pere, qty, incdec"; $sql.= " FROM ".MAIN_DB_PREFIX."product_association"; $sql.= " WHERE fk_product_pere = '".$fk_parent."'"; @@ -3105,6 +3129,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Add a supplier price for the product. * Note: Duplicate ref is accepted for different quantity only, or for different companies. @@ -3115,9 +3140,9 @@ class Product extends CommonObject * @param float $quantity Quantity minimum for price * @return int < 0 if KO, 0 if link already exists for this product, > 0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function add_fournisseur($user, $id_fourn, $ref_fourn, $quantity) { + // phpcs:enable global $conf; $now=dol_now(); @@ -3210,14 +3235,15 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoie la liste des fournisseurs du produit/service * * @return array Tableau des id de fournisseur */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function list_suppliers() { + // phpcs:enable global $conf; $list = array(); @@ -3243,6 +3269,7 @@ class Product extends CommonObject return $list; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Recopie les prix d'un produit/service sur un autre * @@ -3250,9 +3277,9 @@ class Product extends CommonObject * @param int $toId Id product target * @return nt < 0 if KO, > 0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function clone_price($fromId, $toId) { + // phpcs:enable $this->db->begin(); // les prix @@ -3272,6 +3299,7 @@ class Product extends CommonObject return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Clone links between products * @@ -3279,9 +3307,9 @@ class Product extends CommonObject * @param int $toId Product id * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function clone_associations($fromId, $toId) { + // phpcs:enable $this->db->begin(); $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_association (fk_product_pere, fk_product_fils, qty)'; @@ -3299,6 +3327,7 @@ class Product extends CommonObject return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Recopie les fournisseurs et prix fournisseurs d'un produit/service sur un autre * @@ -3306,9 +3335,9 @@ class Product extends CommonObject * @param int $toId Id produit cible * @return int < 0 si erreur, > 0 si ok */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function clone_fournisseurs($fromId, $toId) { + // phpcs:enable $this->db->begin(); $now=dol_now(); @@ -3347,6 +3376,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Fonction recursive uniquement utilisee par get_arbo_each_prod, recompose l'arborescence des sousproduits * Define value of this->res @@ -3358,9 +3388,9 @@ class Product extends CommonObject * @param int $id_parent Id parent * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function fetch_prod_arbo($prod, $compl_path="", $multiply=1, $level=1, $id_parent=0) { + // phpcs:enable global $conf,$langs; $product = new Product($this->db); @@ -3407,6 +3437,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Build the tree of subproducts into an array * this->sousprods is loaded by this->get_sousproduits_arbo() @@ -3414,9 +3445,9 @@ class Product extends CommonObject * @param int $multiply Because each sublevel must be multiplicated by parent nb * @return array $this->res */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_arbo_each_prod($multiply=1) { + // phpcs:enable $this->res = array(); if (isset($this->sousprods) && is_array($this->sousprods)) { @@ -3558,15 +3589,16 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return tree of all subproducts for product. Tree contains id, name and quantity. * Set this->sousprods * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_sousproduits_arbo() { + // phpcs:enable $parent=array(); foreach($this->getChildsArbo($this->id) as $keyChild => $valueChild) // Warning. getChildsArbo can call getChildsArbo recursively. Starting point is $value[0]=id of product @@ -3760,6 +3792,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return label of a given status * @@ -3768,9 +3801,9 @@ class Product extends CommonObject * @param int $type 0=Status "to sell", 1=Status "to buy", 2=Status "to Batch" * @return string Label of status */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($status,$mode=0,$type=0) { + // phpcs:enable global $conf, $langs; $langs->load('products'); @@ -3855,6 +3888,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Adjust stock in a warehouse for product * @@ -3869,9 +3903,9 @@ class Product extends CommonObject * @param int $origin_id Origin id of element * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function correct_stock($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $inventorycode='', $origin_element='', $origin_id=null) { + // phpcs:enable if ($id_entrepot) { $this->db->begin(); @@ -3901,6 +3935,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Adjust stock in a warehouse for product with batch number * @@ -3918,9 +3953,9 @@ class Product extends CommonObject * @param int $origin_id Origin id of element * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function correct_stock_batch($user, $id_entrepot, $nbpiece, $movement, $label='', $price=0, $dlc='', $dluo='',$lot='', $inventorycode='', $origin_element='', $origin_id=null) { + // phpcs:enable if ($id_entrepot) { $this->db->begin(); @@ -3950,6 +3985,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) * This function need a lot of load. If you use it on list, use a cache to execute it once for each product id. @@ -3964,9 +4000,9 @@ class Product extends CommonObject * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock, getBatchInfo */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_stock($option='') { + // phpcs:enable global $conf; $this->stock_reel = 0; @@ -4031,6 +4067,7 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load value ->stock_theorique of a product. Property this->id must be defined. * This function need a lot of load. If you use it on list, use a cache to execute it one for each product id. @@ -4038,9 +4075,9 @@ class Product extends CommonObject * @return int < 0 if KO, > 0 if OK * @see load_stock, getBatchInfo */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_virtual_stock() { + // phpcs:enable global $conf; $stock_commande_client=0; @@ -4131,6 +4168,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Move an uploaded file described into $file array into target directory $sdir. * @@ -4138,9 +4176,9 @@ class Product extends CommonObject * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function add_photo($sdir, $file) { + // phpcs:enable global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -4173,15 +4211,16 @@ class Product extends CommonObject else return -1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return if at least one photo is available * * @param string $sdir Directory to scan * @return boolean True if at least one photo is available, False if not */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function is_photo_available($sdir) { + // phpcs:enable include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; @@ -4210,6 +4249,7 @@ class Product extends CommonObject } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retourne tableau de toutes les photos du produit * @@ -4217,9 +4257,9 @@ class Product extends CommonObject * @param int $nbmax Nombre maximum de photos (0=pas de max) * @return array Tableau de photos */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function liste_photos($dir,$nbmax=0) { + // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; @@ -4266,15 +4306,16 @@ class Product extends CommonObject return $tabobj; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Efface la photo du produit et sa vignette * * @param string $file Chemin de l'image * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function delete_photo($file) { + // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; @@ -4302,29 +4343,31 @@ class Product extends CommonObject } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load size of image file * * @param string $file Path to file * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_image_size($file) { + // phpcs:enable $file_osencoded=dol_osencode($file); $infoImg = getimagesize($file_osencoded); // Get information on image $this->imgWidth = $infoImg[0]; // Largeur de l'image $this->imgHeight = $infoImg[1]; // Hauteur de l'image } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Load indicators this->nb for the dashboard * * @return int <0 if KO, >0 if OK */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function load_state_board() { + // phpcs:enable global $conf, $user, $hookmanager; $this->nb=array(); @@ -4380,6 +4423,7 @@ class Product extends CommonObject return ($this->type == Product::TYPE_SERVICE ? true : false); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Get a barcode from the module to generate barcode values. * Return value is stored into this->barcode @@ -4388,9 +4432,9 @@ class Product extends CommonObject * @param string $type Barcode type (ean, isbn, ...) * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function get_barcode($object,$type='') { + // phpcs:enable global $conf; $result=''; @@ -4509,14 +4553,15 @@ class Product extends CommonObject } - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + /** * Return minimum product recommended price * - * @return int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE + * @return int Minimum recommanded price that is higher price among all suppliers * PRODUCT_MINIMUM_RECOMMENDED_PRICE */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function min_recommended_price() { + // phpcs:enable global $conf; $maxpricesupplier=0; diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 16ff44e563c..fc36c64a3eb 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -73,7 +73,7 @@ class Productbatch extends CommonObject $error=0; // Clean parameters - $this->clean_param(); + $this->cleanParam(); // Check parameters // Put here code to add control on parameters values @@ -204,7 +204,7 @@ class Productbatch extends CommonObject $error=0; // Clean parameters - $this->clean_param(); + $this->cleanParam(); // TODO Check qty is ok for stock move. Negative may not be allowed. if ($this->qty < 0) @@ -402,8 +402,7 @@ class Productbatch extends CommonObject * * @return void */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - private function clean_param() + private function cleanParam() { if (isset($this->fk_product_stock)) $this->fk_product_stock=(int) trim($this->fk_product_stock); if (isset($this->batch)) $this->batch=trim($this->batch); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 19fa3e3e627..ae5cbd0e580 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -38,7 +38,7 @@ class Inventory extends CommonObject * @var string ID to identify managed object */ public $element = 'inventory'; - + /** * @var string Name of table without prefix where object is stored */ @@ -48,7 +48,7 @@ class Inventory extends CommonObject * @var array Does inventory support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 1; - + /** * @var string String with name of icon for inventory */ @@ -123,22 +123,22 @@ class Inventory extends CommonObject * @var int Name of subtable line */ //public $table_element_line = 'inventorydet'; - + /** * @var int Field with ID of parent key if this field has a parent */ //public $fk_element = 'fk_inventory'; - + /** * @var int Name of subtable class that manage subtable lines */ //public $class_element_line = 'Inventoryline'; - + /** * @var array Array of child tables (child tables to delete before deleting a record) */ //protected $childtables=array('inventorydet'); - + /** * @var InventoryLine[] Array of subtable lines */ @@ -339,6 +339,7 @@ class Inventory extends CommonObject return $this->LibStatut($this->status,$mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return the status * @@ -346,9 +347,9 @@ class Inventory extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto, 6=Long label + Picto * @return string Label of status */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps static function LibStatut($status,$mode=0) { + // phpcs:enable global $langs; if ($mode == 0) diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 651ee59c22e..e0c15d03520 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -44,7 +44,7 @@ class ProductStockEntrepot extends CommonObject * @var string Id to identify managed objects */ public $element = 'ProductStockEntrepot'; - + /** * @var string Name of table without prefix where object is stored */ @@ -511,6 +511,7 @@ class ProductStockEntrepot extends CommonObject return $this->LibStatut($this->status,$mode); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -518,9 +519,9 @@ class ProductStockEntrepot extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function LibStatut($status,$mode=0) { + // phpcs:enable global $langs; if ($mode == 0) diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index c29adf0861f..c725d668763 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -250,6 +250,7 @@ class CoreTest extends PHPUnit_Framework_TestCase // This is code copied from main.inc.php !!!!!!!!!!!!!!! + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST, PHP_SELF). * @@ -257,9 +258,9 @@ class CoreTest extends PHPUnit_Framework_TestCase * @param string $type 1=GET, 0=POST, 2=PHP_SELF * @return int >0 if there is an injection */ - // phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps function test_sql_and_script_inject($val, $type) { + // phpcs:enable $inj = 0; // For SQL Injection (only GET and POST are used to be included into bad escaped SQL requests) if ($type != 2)