mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-05 17:18:13 +01:00
clean code (#35183)
* clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code * clean code
This commit is contained in:
@@ -12474,54 +12474,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: ../../../htdocs/fichinter/card.php
|
path: ../../../htdocs/fichinter/card.php
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Call to function method_exists\(\) with \$this\(Fichinter\) and ''getLibStatut'' will always evaluate to true\.$#'
|
|
||||||
identifier: function.alreadyNarrowedType
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Call to function method_exists\(\) with \$this\(Fichinter\) and ''getNomUrl'' will always evaluate to true\.$#'
|
|
||||||
identifier: function.alreadyNarrowedType
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Call to function property_exists\(\) with \$this\(Fichinter\) and ''duration'' will always evaluate to true\.$#'
|
|
||||||
identifier: function.alreadyNarrowedType
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Negated boolean expression is always true\.$#'
|
|
||||||
identifier: booleanNot.alwaysTrue
|
|
||||||
count: 7
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Property Fichinter\:\:\$ref_client \(string\) in isset\(\) is not nullable\.$#'
|
|
||||||
identifier: isset.property
|
|
||||||
count: 2
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Property Fichinter\:\:\$statut \(int\) in isset\(\) is not nullable\.$#'
|
|
||||||
identifier: isset.property
|
|
||||||
count: 1
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Variable \$url in empty\(\) always exists and is not falsy\.$#'
|
|
||||||
identifier: empty.variable
|
|
||||||
count: 2
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinter.class.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: '#^Negated boolean expression is always true\.$#'
|
|
||||||
identifier: booleanNot.alwaysTrue
|
|
||||||
count: 2
|
|
||||||
path: ../../../htdocs/fichinter/class/fichinterligne.class.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: '#^Right side of && is always false\.$#'
|
message: '#^Right side of && is always false\.$#'
|
||||||
identifier: booleanAnd.rightAlwaysFalse
|
identifier: booleanAnd.rightAlwaysFalse
|
||||||
|
|||||||
@@ -929,7 +929,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
if ($id == DICT_PAIEMENT && strlen(GETPOST("code")) >= 6) { // 6 char max on code for payment mode codes
|
if ($id == DICT_PAIEMENT && strlen(GETPOST("code")) >= 6) { // 6 char max on code for payment mode codes
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), 6), null, 'errors');
|
setEventMessages($langs->transnoentities("ErrorFieldMustHaveLessThanXChar", $langs->transnoentities("Code"), '6'), null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean some parameters
|
// Clean some parameters
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
/* Copyright (C) 2024 William Mead <william.mead@manchenumerique.fr>
|
||||||
|
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -49,7 +50,7 @@ trait CommonSignedObject
|
|||||||
'STATUS_SIGNED_SENDER' => 1,
|
'STATUS_SIGNED_SENDER' => 1,
|
||||||
'STATUS_SIGNED_RECEIVER' => 2,
|
'STATUS_SIGNED_RECEIVER' => 2,
|
||||||
'STATUS_SIGNED_RECEIVER_ONLINE' => 3,
|
'STATUS_SIGNED_RECEIVER_ONLINE' => 3,
|
||||||
'STATUS_SIGNED_ALL' => 9 // To handle future kind of signature (ex: tripartite contract)
|
'STATUS_SIGNED_ALL' => 9, // To handle future kind of signature (ex: tripartite contract)
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,11 +141,9 @@ trait CommonSignedObject
|
|||||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||||
|
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
if (!$error) {
|
|
||||||
$this->oldcopy = clone $this;
|
$this->oldcopy = clone $this;
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger($triggercode, $user);
|
$result = $this->call_trigger($triggercode, $user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
|
|||||||
@@ -150,13 +150,13 @@ class Fichinter extends CommonObject
|
|||||||
public $duration;
|
public $duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int status
|
* @var int|null status
|
||||||
* @deprecated Use $status instead
|
* @deprecated Use $status instead
|
||||||
*/
|
*/
|
||||||
public $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
public $statut = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var int status
|
* @var int|null status
|
||||||
*/
|
*/
|
||||||
public $status = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
public $status = 0; // 0=draft, 1=validated, 2=invoiced, 3=Terminate
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ class Fichinter extends CommonObject
|
|||||||
if (!is_numeric($this->duration)) {
|
if (!is_numeric($this->duration)) {
|
||||||
$this->duration = 0;
|
$this->duration = 0;
|
||||||
}
|
}
|
||||||
if (isset($this->ref_client)) {
|
if (!empty($this->ref_client)) {
|
||||||
$this->ref_client = trim($this->ref_client);
|
$this->ref_client = trim($this->ref_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +432,7 @@ class Fichinter extends CommonObject
|
|||||||
if (!dol_strlen((string) $this->fk_project)) {
|
if (!dol_strlen((string) $this->fk_project)) {
|
||||||
$this->fk_project = 0;
|
$this->fk_project = 0;
|
||||||
}
|
}
|
||||||
if (isset($this->ref_client)) {
|
if (!empty($this->ref_client)) {
|
||||||
$this->ref_client = trim($this->ref_client);
|
$this->ref_client = trim($this->ref_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,12 +463,10 @@ class Fichinter extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||||
if ($this->db->query($sql)) {
|
if ($this->db->query($sql)) {
|
||||||
if (!$error) {
|
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$error && !$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
@@ -596,13 +594,11 @@ class Fichinter extends CommonObject
|
|||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if (!$error) {
|
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
|
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->status = self::STATUS_DRAFT;
|
$this->status = self::STATUS_DRAFT;
|
||||||
@@ -640,7 +636,7 @@ class Fichinter extends CommonObject
|
|||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
// Define new ref
|
// Define new ref
|
||||||
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
if ((preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
|
||||||
$num = $this->getNextNumRef($this->thirdparty);
|
$num = $this->getNextNumRef($this->thirdparty);
|
||||||
} else {
|
} else {
|
||||||
$num = $this->ref;
|
$num = $this->ref;
|
||||||
@@ -976,13 +972,13 @@ class Fichinter extends CommonObject
|
|||||||
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($option == 'nolink' || empty($url)) {
|
if ($option == 'nolink') {
|
||||||
$linkstart = '<span';
|
$linkstart = '<span';
|
||||||
} else {
|
} else {
|
||||||
$linkstart = '<a href="'.$url.'"';
|
$linkstart = '<a href="'.$url.'"';
|
||||||
}
|
}
|
||||||
$linkstart .= $linkclose.'>';
|
$linkstart .= $linkclose.'>';
|
||||||
if ($option == 'nolink' || empty($url)) {
|
if ($option == 'nolink') {
|
||||||
$linkend = '</span>';
|
$linkend = '</span>';
|
||||||
} else {
|
} else {
|
||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
@@ -1119,7 +1115,7 @@ class Fichinter extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (!$error && !$notrigger) {
|
if (!$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('FICHINTER_DELETE', $user);
|
$result = $this->call_trigger('FICHINTER_DELETE', $user);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
@@ -1131,12 +1127,10 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete linked object
|
// Delete linked object
|
||||||
if (!$error) {
|
|
||||||
$res = $this->deleteObjectLinked();
|
$res = $this->deleteObjectLinked();
|
||||||
if ($res < 0) {
|
if ($res < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Delete linked contacts
|
// Delete linked contacts
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
@@ -1510,6 +1504,7 @@ class Fichinter extends CommonObject
|
|||||||
$this->note_private = 'Private note';
|
$this->note_private = 'Private note';
|
||||||
$this->note_public = 'SPECIMEN';
|
$this->note_public = 'SPECIMEN';
|
||||||
$this->duration = 0;
|
$this->duration = 0;
|
||||||
|
$this->user_creation_id = 1;
|
||||||
$nbp = 25;
|
$nbp = 25;
|
||||||
$xnbp = 0;
|
$xnbp = 0;
|
||||||
while ($xnbp < $nbp) {
|
while ($xnbp < $nbp) {
|
||||||
@@ -1673,21 +1668,20 @@ class Fichinter extends CommonObject
|
|||||||
$return .= img_picto('', $this->picto);
|
$return .= img_picto('', $this->picto);
|
||||||
$return .= '</span>';
|
$return .= '</span>';
|
||||||
$return .= '<div class="info-box-content">';
|
$return .= '<div class="info-box-content">';
|
||||||
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
|
$return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">' . $this->getNomUrl() . '</span>';
|
||||||
if ($selected >= 0) {
|
if ($selected >= 0) {
|
||||||
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
$return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||||
}
|
}
|
||||||
if (!empty($arraydata['thirdparty'])) {
|
if (!empty($arraydata['thirdparty'])) {
|
||||||
$tmpthirdparty = $arraydata['thirdparty'];
|
$tmpthirdparty = $arraydata['thirdparty'];
|
||||||
'@phan-var-force Societe $tmpthirdparty';
|
'@phan-var-force Societe $tmpthirdparty';
|
||||||
|
/** @var Societe $tmpthirdparty */
|
||||||
$return .= '<br><span class="info-box-label">'.$tmpthirdparty->getNomUrl(1).'</span>';
|
$return .= '<br><span class="info-box-label">'.$tmpthirdparty->getNomUrl(1).'</span>';
|
||||||
}
|
}
|
||||||
if (property_exists($this, 'duration')) {
|
if (!empty($this->duration)) {
|
||||||
$return .= '<br><span class="info-box-label ">'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').'</span>';
|
$return .= '<br><span class="info-box-label ">'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').'</span>';
|
||||||
}
|
}
|
||||||
if (method_exists($this, 'getLibStatut')) {
|
|
||||||
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
|
$return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
|
||||||
}
|
|
||||||
$return .= '</div>';
|
$return .= '</div>';
|
||||||
$return .= '</div>';
|
$return .= '</div>';
|
||||||
$return .= '</div>';
|
$return .= '</div>';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||||
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
||||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||||
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
|
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
|
||||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||||
*
|
*
|
||||||
@@ -204,12 +204,10 @@ class FichinterLigne extends CommonObjectLine
|
|||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
|
||||||
$this->rowid = $this->id;
|
$this->rowid = $this->id;
|
||||||
|
|
||||||
if (!$error) {
|
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$result = $this->update_total();
|
$result = $this->update_total();
|
||||||
@@ -270,12 +268,10 @@ class FichinterLigne extends CommonObjectLine
|
|||||||
dol_syslog("FichinterLigne::update", LOG_DEBUG);
|
dol_syslog("FichinterLigne::update", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if (!$error) {
|
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$result = $this->update_total();
|
$result = $this->update_total();
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user