From c66bce7ec6a241b39a5369e7b0e17e879e5de3eb Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Wed, 13 Nov 2019 17:31:18 +0000 Subject: [PATCH] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../sociales/class/chargesociales.class.php | 170 +++++++++--------- htdocs/core/modules/modBom.class.php | 54 +++--- 2 files changed, 112 insertions(+), 112 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 2bc82fc8b78..fecc5a96aa1 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -35,14 +35,14 @@ class ChargeSociales extends CommonObject /** * @var string ID to identify managed object */ - public $element='chargesociales'; + public $element = 'chargesociales'; - public $table='chargesociales'; + public $table = 'chargesociales'; /** * @var string Name of table without prefix where object is stored */ - public $table_element='chargesociales'; + public $table_element = 'chargesociales'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -175,7 +175,7 @@ class ChargeSociales extends CommonObject } else { - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); return -1; } } @@ -187,10 +187,10 @@ class ChargeSociales extends CommonObject */ public function check() { - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); // Validation parametres - if (! $newamount > 0 || empty($this->date_ech) || empty($this->periode)) + if (!$newamount > 0 || empty($this->date_ech) || empty($this->periode)) { return false; } @@ -208,55 +208,55 @@ class ChargeSociales extends CommonObject public function create($user) { global $conf; - $error=0; + $error = 0; - $now=dol_now(); + $now = dol_now(); // Nettoyage parametres - $newamount=price2num($this->amount, 'MT'); + $newamount = price2num($this->amount, 'MT'); if (!$this->check()) { - $this->error="ErrorBadParameter"; + $this->error = "ErrorBadParameter"; return -2; } $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, date_creation)"; - $sql.= " VALUES (".$this->type; - $sql.= ", ".($this->fk_account>0 ? $this->fk_account:'NULL'); - $sql.= ", ".($this->mode_reglement_id>0 ? $this->mode_reglement_id:"NULL"); - $sql.= ", '".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", '".$this->db->idate($this->date_ech)."'"; - $sql.= ", '".$this->db->idate($this->periode)."'"; - $sql.= ", '".price2num($newamount)."'"; - $sql.= ", ".($this->fk_project>0?$this->fk_project:'NULL'); - $sql.= ", ".$conf->entity; - $sql.= ", ".$user->id; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ")"; + $sql .= " VALUES (".$this->type; + $sql .= ", ".($this->fk_account > 0 ? $this->fk_account : 'NULL'); + $sql .= ", ".($this->mode_reglement_id > 0 ? $this->mode_reglement_id : "NULL"); + $sql .= ", '".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", '".$this->db->idate($this->date_ech)."'"; + $sql .= ", '".$this->db->idate($this->periode)."'"; + $sql .= ", '".price2num($newamount)."'"; + $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 'NULL'); + $sql .= ", ".$conf->entity; + $sql .= ", ".$user->id; + $sql .= ", '".$this->db->idate($now)."'"; + $sql .= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); - $result=$this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); + $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); if ($result < 0) $error++; - if(empty($error)) { + if (empty($error)) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); - return -1*$error; + return -1 * $error; } } else { - $this->error=$this->db->error(); + $this->error = $this->db->error(); $this->db->rollback(); return -1; } @@ -271,23 +271,23 @@ class ChargeSociales extends CommonObject */ public function delete($user) { - $error=0; + $error = 0; $this->db->begin(); // Get bank transaction lines for this social contributions include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $account=new Account($this->db); - $lines_url=$account->get_url('', $this->id, 'sc'); + $account = new Account($this->db); + $lines_url = $account->get_url('', $this->id, 'sc'); // Delete bank urls foreach ($lines_url as $line_url) { - if (! $error) + if (!$error) { - $accountline=new AccountLine($this->db); + $accountline = new AccountLine($this->db); $accountline->fetch($line_url['fk_bank']); - $result=$accountline->delete_urls($user); + $result = $accountline->delete_urls($user); if ($result < 0) { $error++; @@ -296,31 +296,31 @@ class ChargeSociales extends CommonObject } // Delete payments - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementcharge WHERE fk_charge=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) + $resql = $this->db->query($sql); + if (!$resql) { $error++; - $this->error=$this->db->lasterror(); + $this->error = $this->db->lasterror(); } } - if (! $error) + if (!$error) { $this->db->commit(); return 1; @@ -342,31 +342,31 @@ class ChargeSociales extends CommonObject */ public function update($user, $notrigger = 0) { - $error=0; + $error = 0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; - $sql.= " SET libelle='".$this->db->escape($this->label?$this->label:$this->lib)."'"; - $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; - $sql.= ", periode='".$this->db->idate($this->periode)."'"; - $sql.= ", amount='".price2num($this->amount, 'MT')."'"; - $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL"); - $sql.= ", fk_user_modif=".$user->id; - $sql.= " WHERE rowid=".$this->id; + $sql .= " SET libelle='".$this->db->escape($this->label ? $this->label : $this->lib)."'"; + $sql .= ", date_ech='".$this->db->idate($this->date_ech)."'"; + $sql .= ", periode='".$this->db->idate($this->periode)."'"; + $sql .= ", amount='".price2num($this->amount, 'MT')."'"; + $sql .= ", fk_projet=".($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); + $sql .= ", fk_user_modif=".$user->id; + $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); + if (!$resql) { + $error++; $this->errors[] = "Error ".$this->db->lasterror(); } - if (! $error) + if (!$error) { - if (! $notrigger) + if (!$notrigger) { // Call trigger - $result=$this->call_trigger('SOCIALCHARGES_MODIFY', $user); + $result = $this->call_trigger('SOCIALCHARGES_MODIFY', $user); if ($result < 0) $error++; // End call triggers } @@ -375,13 +375,13 @@ class ChargeSociales extends CommonObject // Commit or rollback if ($error) { - foreach($this->errors as $errmsg) + foreach ($this->errors as $errmsg) { dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); } $this->db->rollback(); - return -1*$error; + return -1 * $error; } else { @@ -401,9 +401,9 @@ class ChargeSociales extends CommonObject global $conf; $sql = "SELECT SUM(f.amount) as amount"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; - $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND paye = 0"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as f"; + $sql .= " WHERE f.entity = ".$conf->entity; + $sql .= " AND paye = 0"; if ($year) { $sql .= " AND f.datev >= '$y-01-01' AND f.datev <= '$y-12-31' "; @@ -441,8 +441,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 1"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -459,8 +459,8 @@ class ChargeSociales extends CommonObject { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; - $sql.= " paye = 0"; - $sql.= " WHERE rowid = ".$this->id; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; $return = $this->db->query($sql); if ($return) return 1; else return -1; @@ -549,9 +549,9 @@ class ChargeSociales extends CommonObject { global $langs, $conf, $user, $form; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips - $result=''; + $result = ''; $url = DOL_URL_ROOT.'/compta/sociales/card.php?id='.$this->id; @@ -607,20 +607,20 @@ class ChargeSociales extends CommonObject */ public function getSommePaiement() { - $table='paiementcharge'; - $field='fk_charge'; + $table = 'paiementcharge'; + $field = 'fk_charge'; $sql = 'SELECT sum(amount) as amount'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$table; - $sql.= ' WHERE '.$field.' = '.$this->id; + $sql .= ' FROM '.MAIN_DB_PREFIX.$table; + $sql .= ' WHERE '.$field.' = '.$this->id; dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); - $resql=$this->db->query($sql); + $resql = $this->db->query($sql); if ($resql) { - $amount=0; + $amount = 0; $obj = $this->db->fetch_object($resql); - if ($obj) $amount=$obj->amount?$obj->amount:0; + if ($obj) $amount = $obj->amount ? $obj->amount : 0; $this->db->free($resql); return $amount; @@ -640,12 +640,12 @@ class ChargeSociales extends CommonObject public function info($id) { $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; - $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; - $sql.= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; - $sql.= " WHERE e.rowid = ".$id; + $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; + $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as e"; + $sql .= " WHERE e.rowid = ".$id; dol_syslog(get_class($this)."::info", LOG_DEBUG); - $result=$this->db->query($sql); + $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows($result)) @@ -696,14 +696,14 @@ class ChargeSociales extends CommonObject public function initAsSpecimen() { // Initialize parameters - $this->id=0; + $this->id = 0; $this->ref = 'SPECIMEN'; - $this->specimen=1; + $this->specimen = 1; $this->paye = 0; $this->date = dol_now(); - $this->date_ech=$this->date+3600*24*30; - $this->periode=$this->date+3600*24*30; - $this->amount=100; + $this->date_ech = $this->date + 3600 * 24 * 30; + $this->periode = $this->date + 3600 * 24 * 30; + $this->amount = 100; $this->label = 'Social contribution label'; $this->type = 1; $this->type_label = 'Type of social contribution'; diff --git a/htdocs/core/modules/modBom.class.php b/htdocs/core/modules/modBom.class.php index 714e15f0ee9..362e0c445ee 100644 --- a/htdocs/core/modules/modBom.class.php +++ b/htdocs/core/modules/modBom.class.php @@ -25,7 +25,7 @@ * \ingroup bom * \brief Description and activation file for module Bom */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; /** @@ -75,7 +75,7 @@ class modBom extends DolibarrModules // Name of image file used for this module. // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='bom'; + $this->picto = 'bom'; // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) $this->module_parts = array( @@ -103,15 +103,15 @@ class modBom extends DolibarrModules $this->config_page_url = array("bom.php"); // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->hidden = false; // A condition to hide module + $this->depends = array('modProduct'); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->requiredby = array('modMrp'); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) $this->langfiles = array("mrp"); //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(9,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->need_dolibarr_version = array(9, 0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) //$this->automatic_activation = array('FR'=>'BomWasAutomaticallyActivatedBecauseOfYourCountryChoice'); //$this->always_enabled = true; // If true, can't be disabled @@ -132,10 +132,10 @@ class modBom extends DolibarrModules 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' )*/ - if (! isset($conf->bom) || ! isset($conf->bom->enabled)) + if (!isset($conf->bom) || !isset($conf->bom->enabled)) { - $conf->bom=new stdClass(); - $conf->bom->enabled=0; + $conf->bom = new stdClass(); + $conf->bom->enabled = 0; } @@ -281,28 +281,28 @@ class modBom extends DolibarrModules // Exports - $r=1; + $r = 1; /* BEGIN MODULEBUILDER EXPORT BILLOFMATERIALS */ $langs->load("mrp"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='bom'; - $keyforclass = 'BOM'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bom'; + $this->export_code[$r] = $this->rights_class.'_'.$r; + $this->export_label[$r] = 'BomAndBomLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r] = 'bom'; + $keyforclass = 'BOM'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforclass = 'BOMLine'; $keyforclassfile='/bom/class/bom.class.php'; $keyforelement='bomline'; $keyforalias='tl'; + $keyforclass = 'BOMLine'; $keyforclassfile = '/bom/class/bom.class.php'; $keyforelement = 'bomline'; $keyforalias = 'tl'; include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; unset($this->export_fields_array[$r]['tl.fk_bom']); - $keyforselect ='bom_bom'; $keyforaliasextra='extra'; $keyforelement='bom'; + $keyforselect = 'bom_bom'; $keyforaliasextra = 'extra'; $keyforelement = 'bom'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $keyforselect ='bom_bomline'; $keyforaliasextra='extraline'; $keyforelement='bomline'; + $keyforselect = 'bom_bomline'; $keyforaliasextra = 'extraline'; $keyforelement = 'bomline'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_dependencies_array[$r]=array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('bom').')'; + $this->export_dependencies_array[$r] = array('bomline'=>'tl.rowid'); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r] = 'SELECT DISTINCT '; + $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'bom_bom as t'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bom_bomline as tl ON tl.fk_bom = t.rowid'; + $this->export_sql_end[$r] .= ' WHERE 1 = 1'; + $this->export_sql_end[$r] .= ' AND t.entity IN ('.getEntity('bom').')'; $r++; /* END MODULEBUILDER EXPORT BILLOFMATERIALS */ } @@ -319,7 +319,7 @@ class modBom extends DolibarrModules { global $conf, $langs; - $result=$this->_load_tables('/bom/sql/'); + $result = $this->_load_tables('/bom/sql/'); if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') // Create extrafields