Merge pull request #11303 from atm-florian/10.0

fix various little stuff from scrutinizer (undeclared vriable, misspelling variable, mistype declaration)
This commit is contained in:
Laurent Destailleur 2019-06-07 15:21:30 +02:00 committed by GitHub
commit 0edd94c4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 33 additions and 40 deletions

View File

@ -202,9 +202,6 @@ class BookKeeping extends CommonObject
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
} }
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) { if (isset($this->import_key)) {
$this->import_key = trim($this->import_key); $this->import_key = trim($this->import_key);
} }
@ -522,9 +519,6 @@ class BookKeeping extends CommonObject
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
} }
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) { if (isset($this->import_key)) {
$this->import_key = trim($this->import_key); $this->import_key = trim($this->import_key);
} }
@ -1139,9 +1133,6 @@ class BookKeeping extends CommonObject
if (isset($this->sens)) { if (isset($this->sens)) {
$this->sens = trim($this->sens); $this->sens = trim($this->sens);
} }
if (isset($this->fk_user_author)) {
$this->fk_user_author = trim($this->fk_user_author);
}
if (isset($this->import_key)) { if (isset($this->import_key)) {
$this->import_key = trim($this->import_key); $this->import_key = trim($this->import_key);
} }

View File

@ -91,7 +91,10 @@ elseif ($action == 'update_currency')
{ {
if ($currency->fetch($fk_multicurrency) > 0) if ($currency->fetch($fk_multicurrency) > 0)
{ {
$currency->updateRate($rate); $result=$currency->updateRate($rate);
if ($result<0) {
setEventMessages(null, $currency->errors, 'errors');
}
} }
} }
} }

View File

@ -6227,6 +6227,7 @@ abstract class CommonObject
$value=''; $value='';
if (is_array($value_arr) && count($value_arr)>0) if (is_array($value_arr) && count($value_arr)>0)
{ {
$toprint=array();
foreach ($value_arr as $keyval=>$valueval) { foreach ($value_arr as $keyval=>$valueval) {
$toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>'; $toprint[]='<li class="select2-search-choice-dolibarr noborderoncategories" style="background: #aaa">'.$param['options'][$valueval].'</li>';
} }

View File

@ -247,25 +247,20 @@ class Cstate // extends CommonObject
// } // }
//} //}
// Commit or rollback // Commit or rollback
if ($error) 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);
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); }
$this->error.=($this->error?', '.$errmsg:$errmsg); $this->db->rollback();
} return -1 * $error;
$this->db->rollback(); } else {
return -1*$error; $this->db->commit();
} return 1;
else }
{
$this->db->commit();
return 1;
}
} }
/** /**
* Delete object in database * Delete object in database
* *

View File

@ -684,6 +684,7 @@ class DoliDBMysqli extends DoliDB
// ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment'); // ex. : $fields['rowid'] = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql = "CREATE TABLE ".$table."("; $sql = "CREATE TABLE ".$table."(";
$i=0; $i=0;
$sqlfields=array();
foreach($fields as $field_name => $field_desc) foreach($fields as $field_name => $field_desc)
{ {
$sqlfields[$i] = $field_name." "; $sqlfields[$i] = $field_name." ";

View File

@ -582,7 +582,7 @@ class doc_generic_project_odt extends ModelePDFProjects
); );
complete_substitutions_array($substitutionarray, $langs, $object); complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook // Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
// Open and load template // Open and load template

View File

@ -1145,9 +1145,10 @@ class Expedition extends CommonObject
* Delete shipment. * Delete shipment.
* Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element) * Warning, do not delete a shipment if a delivery is linked to (with table llx_element_element)
* *
* @param int $notrigger Disable triggers
* @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO
*/ */
public function delete() public function delete($notrigger = 0)
{ {
global $conf, $langs, $user; global $conf, $langs, $user;

View File

@ -48,13 +48,13 @@ class LoanSchedule extends CommonObject
/** /**
* @var string Create date * @var string Create date
*/ */
public $datec=''; public $datec;
public $tms=''; public $tms;
/** /**
* @var string Payment date * @var string Payment date
*/ */
public $datep=''; public $datep;
public $amounts=array(); // Array of amounts public $amounts=array(); // Array of amounts
public $amount_capital; // Total amount of payment public $amount_capital; // Total amount of payment
@ -275,17 +275,13 @@ class LoanSchedule extends CommonObject
$error=0; $error=0;
// Clean parameters // Clean parameters
if (isset($this->fk_loan)) $this->fk_loan=trim($this->fk_loan);
if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital); if (isset($this->amount_capital)) $this->amount_capital=trim($this->amount_capital);
if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance); if (isset($this->amount_insurance)) $this->amount_insurance=trim($this->amount_insurance);
if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest); if (isset($this->amount_interest)) $this->amount_interest=trim($this->amount_interest);
if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment);
if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment);
if (isset($this->note_private)) $this->note_private=trim($this->note_private); if (isset($this->note_private)) $this->note_private=trim($this->note_private);
if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->note_public)) $this->note_public=trim($this->note_public);
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank); if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
@ -564,6 +560,9 @@ class LoanSchedule extends CommonObject
*/ */
public function paimenttorecord($loanid, $datemax) public function paimenttorecord($loanid, $datemax)
{ {
$result=array();
$sql = "SELECT p.rowid"; $sql = "SELECT p.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p "; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as p ";
$sql.= " WHERE p.fk_loan = " . $loanid; $sql.= " WHERE p.fk_loan = " . $loanid;

View File

@ -417,6 +417,7 @@ class MultiCurrency extends CommonObject
else else
{ {
$this->rate = null; $this->rate = null;
$this->errors=$currencyRate->errors;
return -1; return -1;
} }
} }

View File

@ -1660,7 +1660,7 @@ class Project extends CommonObject
// phpcs:enable // phpcs:enable
$sql="UPDATE ".MAIN_DB_PREFIX.$tableName; $sql="UPDATE ".MAIN_DB_PREFIX.$tableName;
if ($TableName=="actioncomm") if ($tableName=="actioncomm")
{ {
$sql.= " SET fk_project=NULL"; $sql.= " SET fk_project=NULL";
$sql.= " WHERE id=".$elementSelectId; $sql.= " WHERE id=".$elementSelectId;
@ -1738,7 +1738,7 @@ class Project extends CommonObject
$sql.= " AND pt.fk_projet = ".$this->id; $sql.= " AND pt.fk_projet = ".$this->id;
$sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; $sql.= " AND (ptt.task_date >= '".$this->db->idate($datestart)."' ";
$sql.= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')"; $sql.= " AND ptt.task_date <= '".$this->db->idate(dol_time_plus_duree($datestart, 1, 'w') - 1)."')";
if ($task_id) $sql.= " AND ptt.fk_task=".$taskid; if ($taskid) $sql.= " AND ptt.fk_task=".$taskid;
if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid; if (is_numeric($userid)) $sql.= " AND ptt.fk_user=".$userid;
//print $sql; //print $sql;
@ -1794,7 +1794,8 @@ class Project extends CommonObject
// For external user, no check is done on company because readability is managed by public status of project and assignement. // For external user, no check is done on company because readability is managed by public status of project and assignement.
//$socid=$user->societe_id; //$socid=$user->societe_id;
if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1, $socid); $projectsListId = null;
if (! $user->rights->projet->all->lire) $projectsListId = $this->getProjectsAuthorizedForUser($user, 0, 1);
$sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee"; $sql = "SELECT p.rowid, p.fk_statut as status, p.fk_opp_status, p.datee as datee";
$sql.= " FROM (".MAIN_DB_PREFIX."projet as p"; $sql.= " FROM (".MAIN_DB_PREFIX."projet as p";
@ -1804,7 +1805,7 @@ class Project extends CommonObject
//if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid";
$sql.= " WHERE p.fk_statut = 1"; $sql.= " WHERE p.fk_statut = 1";
$sql.= " AND p.entity IN (".getEntity('project').')'; $sql.= " AND p.entity IN (".getEntity('project').')';
if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; if (! empty($projectsListId)) $sql.= " AND p.rowid IN (".$projectsListId.")";
// No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser
//if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
// For external user, no check is done on company permission because readability is managed by public status of project and assignement. // For external user, no check is done on company permission because readability is managed by public status of project and assignement.