';
/*
diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php
index 7046a61e2d5..a5ba127a54d 100644
--- a/htdocs/fichinter/class/api_interventions.class.php
+++ b/htdocs/fichinter/class/api_interventions.class.php
@@ -32,7 +32,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'socid',
'fk_project',
'description',
@@ -41,7 +41,7 @@ class Interventions extends DolibarrApi
/**
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDSLINE = array(
+ public static $FIELDSLINE = array(
'description',
'date',
'duree',
@@ -117,27 +117,37 @@ class Interventions extends DolibarrApi
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
- if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
+ $search_sale = DolibarrApiAccess::$user->id;
+ }
$sql = "SELECT t.rowid";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ }
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as t";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ }
$sql .= ' WHERE t.entity IN ('.getEntity('intervention').')';
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc";
- if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
- if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= " AND t.fk_soc = sc.fk_soc";
+ }
+ if ($socids) {
+ $sql .= " AND t.fk_soc IN (".$socids.")";
+ }
+ if ($search_sale > 0) {
+ $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ }
// Insert sale filter
if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
// Add sql filters
- if ($sqlfilters)
- {
- if (!DolibarrApi::_checkFilters($sqlfilters))
- {
+ if ($sqlfilters) {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
}
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -146,8 +156,7 @@ class Interventions extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
if ($limit) {
- if ($page < 0)
- {
+ if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@@ -158,13 +167,11 @@ class Interventions extends DolibarrApi
dol_syslog("API Rest request");
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit));
$i = 0;
- while ($i < $min)
- {
+ while ($i < $min) {
$obj = $this->db->fetch_object($result);
$fichinter_static = new Fichinter($this->db);
if ($fichinter_static->fetch($obj->rowid)) {
@@ -216,28 +223,28 @@ class Interventions extends DolibarrApi
* @return int
*/
/* TODO
- public function getLines($id)
- {
- if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
- throw new RestException(401);
- }
+ public function getLines($id)
+ {
+ if(! DolibarrApiAccess::$user->rights->ficheinter->lire) {
+ throw new RestException(401);
+ }
- $result = $this->fichinter->fetch($id);
- if( ! $result ) {
- throw new RestException(404, 'Intervention not found');
- }
+ $result = $this->fichinter->fetch($id);
+ if( ! $result ) {
+ throw new RestException(404, 'Intervention not found');
+ }
- if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- $this->fichinter->getLinesArray();
- $result = array();
- foreach ($this->fichinter->lines as $line) {
- array_push($result,$this->_cleanObjectDatas($line));
- }
- return $result;
- }
- */
+ if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ $this->fichinter->getLinesArray();
+ $result = array();
+ foreach ($this->fichinter->lines as $line) {
+ array_push($result,$this->_cleanObjectDatas($line));
+ }
+ return $result;
+ }
+ */
/**
* Add a line to given intervention
@@ -270,11 +277,11 @@ class Interventions extends DolibarrApi
}
$updateRes = $this->fichinter->addLine(
- DolibarrApiAccess::$user,
- $id,
- $this->fichinter->description,
- $this->fichinter->date,
- $this->fichinter->duree
+ DolibarrApiAccess::$user,
+ $id,
+ $this->fichinter->description,
+ $this->fichinter->date,
+ $this->fichinter->duree
);
if ($updateRes > 0) {
@@ -369,8 +376,7 @@ class Interventions extends DolibarrApi
*/
public function closeFichinter($id)
{
- if (!DolibarrApiAccess::$user->rights->ficheinter->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->ficheinter->creer) {
throw new RestException(401, "Insuffisant rights");
}
$result = $this->fichinter->fetch($id);
@@ -408,8 +414,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$fichinter[$field] = $data[$field];
}
return $fichinter;
@@ -447,8 +454,9 @@ class Interventions extends DolibarrApi
{
$fichinter = array();
foreach (Interventions::$FIELDSLINE as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$fichinter[$field] = $data[$field];
}
return $fichinter;
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 39ac094132a..cea1b1ca48c 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -204,8 +204,7 @@ class Fichinter extends CommonObject
$sql = "SELECT count(fi.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as fi";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON fi.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$user->socid)
- {
+ if (!$user->rights->societe->client->voir && !$user->socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND";
@@ -213,10 +212,8 @@ class Fichinter extends CommonObject
$sql .= " ".$clause." fi.entity IN (".getEntity('intervention').")";
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
$this->nb["interventions"] = $obj->nb;
}
$this->db->free($resql);
@@ -244,21 +241,20 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create ref=".$this->ref);
// Check parameters
- if (!empty($this->ref)) // We check that ref is not already used
- {
+ if (!empty($this->ref)) { // We check that ref is not already used
$result = self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used
- if ($result > 0)
- {
+ if ($result > 0) {
$this->error = 'ErrorRefAlreadyExists';
dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING);
$this->db->rollback();
return -1;
}
}
- if (!is_numeric($this->duration)) $this->duration = 0;
+ if (!is_numeric($this->duration)) {
+ $this->duration = 0;
+ }
- if ($this->socid <= 0)
- {
+ if ($this->socid <= 0) {
$this->error = 'ErrorBadParameterForFunc';
dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1;
@@ -304,42 +300,42 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
- if ($this->id)
- {
+ if ($this->id) {
$this->ref = '(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."fichinter SET ref='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
// Add linked object
- if (!$error && $this->origin && $this->origin_id)
- {
+ if (!$error && $this->origin && $this->origin_id) {
$ret = $this->add_object_linked();
- if (!$ret) dol_print_error($this->db);
+ if (!$ret) {
+ dol_print_error($this->db);
+ }
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
@@ -370,14 +366,14 @@ class Fichinter extends CommonObject
{
global $conf;
- if (!is_numeric($this->duration)) {
- $this->duration = 0;
- }
- if (!dol_strlen($this->fk_project)) {
- $this->fk_project = 0;
- }
+ if (!is_numeric($this->duration)) {
+ $this->duration = 0;
+ }
+ if (!dol_strlen($this->fk_project)) {
+ $this->fk_project = 0;
+ }
- $error = 0;
+ $error = 0;
$this->db->begin();
@@ -391,22 +387,20 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- if (!$error)
- {
+ if ($this->db->query($sql)) {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_MODIFY', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
@@ -437,14 +431,14 @@ class Fichinter extends CommonObject
if ($ref) {
$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
$sql .= " AND f.ref='".$this->db->escape($ref)."'";
- } else $sql .= " WHERE f.rowid=".$rowid;
+ } else {
+ $sql .= " WHERE f.rowid=".$rowid;
+ }
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -470,7 +464,9 @@ class Fichinter extends CommonObject
$this->extraparams = (array) json_decode($obj->extraparams, true);
- if ($this->statut == 0) $this->brouillon = 1;
+ if ($this->statut == 0) {
+ $this->brouillon = 1;
+ }
// Retrieve extrafields
$this->fetch_optionals();
@@ -479,8 +475,7 @@ class Fichinter extends CommonObject
* Lines
*/
$result = $this->fetch_lines();
- if ($result < 0)
- {
+ if ($result < 0) {
return -3;
}
$this->db->free($resql);
@@ -505,8 +500,7 @@ class Fichinter extends CommonObject
$error = 0;
// Protection
- if ($this->statut <= self::STATUS_DRAFT)
- {
+ if ($this->statut <= self::STATUS_DRAFT) {
return 0;
}
@@ -519,8 +513,7 @@ class Fichinter extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
if (!$error) {
$this->oldcopy = clone $this;
}
@@ -528,7 +521,9 @@ class Fichinter extends CommonObject
if (!$error) {
// Call trigger
$result = $this->call_trigger('FICHINTER_UNVALIDATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
}
if (!$error) {
@@ -560,15 +555,13 @@ class Fichinter extends CommonObject
$error = 0;
- if ($this->statut != 1)
- {
+ if ($this->statut != 1) {
$this->db->begin();
$now = dol_now();
// 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 (!$error && (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);
} else {
$num = $this->ref;
@@ -586,51 +579,48 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::setValid", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($this->db);
$error++;
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_VALIDATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref))
- {
+ if (preg_match('/^[\(]?PROV/i', $this->ref)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// Now we rename also files into index
$sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'ficheinter/".$this->db->escape($this->newref)."'";
$sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'ficheinter/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
$resql = $this->db->query($sql);
- if (!$resql) { $error++; $this->error = $this->db->lasterror(); }
+ if (!$resql) {
+ $error++; $this->error = $this->db->lasterror();
+ }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->ficheinter->dir_output.'/'.$oldref;
$dirdest = $conf->ficheinter->dir_output.'/'.$newref;
- if (!$error && file_exists($dirsource))
- {
+ if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::setValid rename dir ".$dirsource." into ".$dirdest);
- if (@rename($dirsource, $dirdest))
- {
+ if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->ficheinter->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
- foreach ($listoffiles as $fileentry)
- {
+ foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
@@ -643,8 +633,7 @@ class Fichinter extends CommonObject
}
// Set new ref and define current statut
- if (!$error)
- {
+ if (!$error) {
$this->ref = $num;
$this->statut = 1;
$this->brouillon = 0;
@@ -740,8 +729,7 @@ class Fichinter extends CommonObject
{
// phpcs:enable
// Init/load array of translation of status
- if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo))
- {
+ if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) {
global $langs;
$langs->load("fichinter");
@@ -785,19 +773,20 @@ class Fichinter extends CommonObject
$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
- if ($option !== 'nolink')
- {
+ if ($option !== 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
- }
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
+ }
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowIntervention");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@@ -817,16 +806,23 @@ class Fichinter extends CommonObject
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
global $action;
$hookmanager->initHooks(array('interventiondao'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $result = $hookmanager->resPrint;
- else $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
return $result;
}
@@ -844,8 +840,7 @@ class Fichinter extends CommonObject
global $conf, $db, $langs;
$langs->load("interventions");
- if (!empty($conf->global->FICHEINTER_ADDON))
- {
+ if (!empty($conf->global->FICHEINTER_ADDON)) {
$mybool = false;
$file = "mod_".$conf->global->FICHEINTER_ADDON.".php";
@@ -870,8 +865,7 @@ class Fichinter extends CommonObject
$numref = "";
$numref = $obj->getNextValue($soc, $this);
- if ($numref != "")
- {
+ if ($numref != "") {
return $numref;
} else {
dol_print_error($db, "Fichinter::getNextNumRef ".$obj->error);
@@ -905,10 +899,8 @@ class Fichinter extends CommonObject
$sql .= " WHERE f.rowid = ".$id;
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -921,14 +913,12 @@ class Fichinter extends CommonObject
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
- if ($obj->fk_user_valid)
- {
+ if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
- if ($obj->fk_user_modification)
- {
+ if ($obj->fk_user_modification) {
$muser = new User($this->db);
$muser->fetch($obj->fk_user_modification);
$this->user_modification = $muser;
@@ -956,27 +946,27 @@ class Fichinter extends CommonObject
$this->db->begin();
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('FICHINTER_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
// Delete linked object
- if (!$error)
- {
+ if (!$error) {
$res = $this->deleteObjectLinked();
- if ($res < 0) $error++;
+ if ($res < 0) {
+ $error++;
+ }
}
// Delete linked contacts
- if (!$error)
- {
+ if (!$error) {
$res = $this->delete_linked_contact();
- if ($res < 0)
- {
+ if ($res < 0) {
$this->error = 'ErrorFailToDeleteLinkedContact';
$error++;
}
@@ -988,62 +978,61 @@ class Fichinter extends CommonObject
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_fichinter = ".$this->id.")";
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet";
$sql .= " WHERE fk_fichinter = ".$this->id;
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Remove extrafields
$res = $this->deleteExtraFields();
- if ($res < 0) $error++;
+ if ($res < 0) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Delete object
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinter";
$sql .= " WHERE rowid = ".$this->id;
dol_syslog("Fichinter::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql) $error++;
+ if (!$resql) {
+ $error++;
+ }
}
- if (!$error)
- {
+ if (!$error) {
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
$this->deleteEcmFiles();
// Remove directory with files
$fichinterref = dol_sanitizeFileName($this->ref);
- if ($conf->ficheinter->dir_output)
- {
+ if ($conf->ficheinter->dir_output) {
$dir = $conf->ficheinter->dir_output."/".$fichinterref;
$file = $conf->ficheinter->dir_output."/".$fichinterref."/".$fichinterref.".pdf";
- if (file_exists($file))
- {
+ if (file_exists($file)) {
dol_delete_preview($this);
- if (!dol_delete_file($file, 0, 0, 0, $this)) // For triggers
- {
+ if (!dol_delete_file($file, 0, 0, 0, $this)) { // For triggers
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteFile", $file);
return 0;
}
}
- if (file_exists($dir))
- {
- if (!dol_delete_dir_recursive($dir))
- {
+ if (file_exists($dir)) {
+ if (!dol_delete_dir_recursive($dir)) {
$langs->load("errors");
$this->error = $langs->trans("ErrorFailToDeleteDir", $dir);
return 0;
@@ -1052,8 +1041,7 @@ class Fichinter extends CommonObject
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -1075,15 +1063,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET datei = '".$this->db->idate($date_delivery)."'";
$sql .= " WHERE rowid = ".$this->id;
$sql .= " AND fk_statut = 0";
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->date_delivery = $date_delivery;
return 1;
} else {
@@ -1107,15 +1093,13 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET description = '".$this->db->escape($description)."',";
$sql .= " fk_user_modif = ".$user->id;
$sql .= " WHERE rowid = ".$this->id;
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->description = $description;
return 1;
} else {
@@ -1140,14 +1124,12 @@ class Fichinter extends CommonObject
// phpcs:enable
global $conf;
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter ";
$sql .= " SET fk_contrat = ".((int) $contractid);
$sql .= " WHERE rowid = ".$this->id;
- if ($this->db->query($sql))
- {
+ if ($this->db->query($sql)) {
$this->fk_contrat = $contractid;
return 1;
} else {
@@ -1176,19 +1158,18 @@ class Fichinter extends CommonObject
$this->db->begin();
// get extrafields so they will be clone
- foreach ($this->lines as $line)
+ foreach ($this->lines as $line) {
$line->fetch_optionals();
+ }
// Load source object
$objFrom = clone $this;
// Change socid if needed
- if (!empty($socid) && $socid != $this->socid)
- {
+ if (!empty($socid) && $socid != $this->socid) {
$objsoc = new Societe($this->db);
- if ($objsoc->fetch($socid) > 0)
- {
+ if ($objsoc->fetch($socid) > 0) {
$this->socid = $objsoc->id;
//$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
//$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
@@ -1213,31 +1194,31 @@ class Fichinter extends CommonObject
// Create clone
$this->context['createfromclone'] = 'createfromclone';
$result = $this->create($user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
// Add lines because it is not included into create function
- foreach ($this->lines as $line)
- {
+ foreach ($this->lines as $line) {
$this->addline($user, $this->id, $line->desc, $line->datei, $line->duration);
}
// Hook of thirdparty module
- if (is_object($hookmanager))
- {
+ if (is_object($hookmanager)) {
$parameters = array('objFrom'=>$objFrom);
$action = '';
$reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) $error++;
+ if ($reshook < 0) {
+ $error++;
+ }
}
}
unset($this->context['createfromclone']);
// End
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -1262,8 +1243,7 @@ class Fichinter extends CommonObject
{
dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration");
- if ($this->statut == 0)
- {
+ if ($this->statut == 0) {
$this->db->begin();
// Insertion ligne
@@ -1280,8 +1260,7 @@ class Fichinter extends CommonObject
$result = $line->insert($user);
- if ($result >= 0)
- {
+ if ($result >= 0) {
$this->db->commit();
return 1;
} else {
@@ -1317,8 +1296,7 @@ class Fichinter extends CommonObject
$this->duration = 0;
$nbp = 25;
$xnbp = 0;
- while ($xnbp < $nbp)
- {
+ while ($xnbp < $nbp) {
$line = new FichinterLigne($this->db);
$line->desc = $langs->trans("Description")." ".$xnbp;
$line->datei = ($now - 3600 * (1 + $xnbp));
@@ -1348,12 +1326,10 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$objp = $this->db->fetch_object($resql);
$line = new FichinterLigne($this->db);
@@ -1466,8 +1442,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->id = $objp->rowid;
@@ -1503,14 +1478,12 @@ class FichinterLigne extends CommonObjectLine
$this->db->begin();
$rangToUse = $this->rang;
- if ($rangToUse == -1)
- {
+ if ($rangToUse == -1) {
// Recupere rang max de la ligne d'intervention dans $rangmax
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'fichinterdet';
$sql .= ' WHERE fk_fichinter ='.$this->fk_fichinter;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$rangToUse = $obj->max + 1;
} else {
@@ -1532,16 +1505,13 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::insert", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'fichinterdet');
$this->rowid = $this->id;
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
@@ -1549,15 +1519,15 @@ class FichinterLigne extends CommonObjectLine
$result = $this->update_total();
- if ($result > 0)
- {
+ if ($result > 0) {
$this->rang = $rangToUse;
- if (!$notrigger)
- {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
}
@@ -1602,31 +1572,27 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if (!$error)
- {
+ if ($resql) {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
$result = $this->update_total();
- if ($result > 0)
- {
- if (!$notrigger)
- {
+ if ($result > 0) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_UPDATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $result;
} else {
@@ -1660,11 +1626,12 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$obj = $this->db->fetch_object($resql);
$total_duration = 0;
- if (!empty($obj->total_duration)) $total_duration = $obj->total_duration;
+ if (!empty($obj->total_duration)) {
+ $total_duration = $obj->total_duration;
+ }
$sql = "UPDATE ".MAIN_DB_PREFIX."fichinter";
$sql .= " SET duree = ".$total_duration;
@@ -1674,8 +1641,7 @@ class FichinterLigne extends CommonObjectLine
dol_syslog("FichinterLigne::update_total", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$this->db->commit();
return 1;
} else {
@@ -1703,8 +1669,7 @@ class FichinterLigne extends CommonObjectLine
$error = 0;
- if ($this->statut == 0)
- {
+ if ($this->statut == 0) {
dol_syslog(get_class($this)."::deleteline lineid=".$this->id);
$this->db->begin();
@@ -1718,16 +1683,15 @@ class FichinterLigne extends CommonObjectLine
$sql = "DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$result = $this->update_total();
- if ($result > 0)
- {
- if (!$notrigger)
- {
+ if ($result > 0) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINEFICHINTER_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -1;
+ }
// End call triggers
}
diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php
index 418e1232bb8..8ed842a70c9 100644
--- a/htdocs/fichinter/class/fichinterrec.class.php
+++ b/htdocs/fichinter/class/fichinterrec.class.php
@@ -214,8 +214,8 @@ class FichinterRec extends Fichinter
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
/*
- * Lines
- */
+ * Lines
+ */
$num = count($fichintsrc->lines);
for ($i = 0; $i < $num; $i++) {
//var_dump($fichintsrc->lines[$i]);
@@ -239,13 +239,14 @@ class FichinterRec extends Fichinter
$fichintsrc->lines[$i]->fk_unit
);
- if ($result_insert < 0)
+ if ($result_insert < 0) {
$error++;
+ }
}
- if ($error)
+ if ($error) {
$this->db->rollback();
- else {
+ } else {
$this->db->commit();
return $this->id;
}
@@ -277,8 +278,11 @@ class FichinterRec extends Fichinter
$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.auto_validate';
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
$sql .= ' FROM '.MAIN_DB_PREFIX.'fichinter_rec as f';
- if ($rowid > 0) $sql .= ' WHERE f.rowid='.$rowid;
- elseif ($ref) $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
+ if ($rowid > 0) {
+ $sql .= ' WHERE f.rowid='.$rowid;
+ } elseif ($ref) {
+ $sql .= " WHERE f.titre='".$this->db->escape($ref)."'";
+ }
dol_syslog(get_class($this)."::fetch rowid=".$rowid, LOG_DEBUG);
@@ -421,7 +425,9 @@ class FichinterRec extends Fichinter
*/
public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1)
{
- if (empty($rowid)) $rowid = $this->id;
+ if (empty($rowid)) {
+ $rowid = $this->id;
+ }
dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
@@ -481,14 +487,20 @@ class FichinterRec extends Fichinter
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Check parameters
- if ($type < 0) return -1;
+ if ($type < 0) {
+ return -1;
+ }
if ($this->brouillon) {
// Clean parameters
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
- if (!$qty) $qty = 1;
- if (!$info_bits) $info_bits = 0;
+ if (!$qty) {
+ $qty = 1;
+ }
+ if (!$info_bits) {
+ $info_bits = 0;
+ }
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
if (!preg_match('/\((.*)\)/', $txtva)) {
@@ -623,7 +635,9 @@ class FichinterRec extends Fichinter
$url = DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$this->id;
- if ($short) return $url;
+ if ($short) {
+ return $url;
+ }
$picto = 'intervention';
@@ -709,7 +723,9 @@ class FichinterRec extends Fichinter
dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->frequency = $frequency;
- if (!empty($unit)) $this->unit_frequency = $unit;
+ if (!empty($unit)) {
+ $this->unit_frequency = $unit;
+ }
return 1;
} else {
dol_print_error($this->db);
@@ -732,13 +748,17 @@ class FichinterRec extends Fichinter
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
- if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
+ if ($increment_nb_gen_done > 0) {
+ $sql .= ', nb_gen_done = nb_gen_done + 1';
+ }
$sql .= ' WHERE rowid = '.$this->id;
dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
if ($this->db->query($sql)) {
$this->date_when = $date;
- if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
+ if ($increment_nb_gen_done > 0) {
+ $this->nb_gen_done++;
+ }
return 1;
} else {
dol_print_error($this->db);
@@ -759,7 +779,9 @@ class FichinterRec extends Fichinter
return -1;
}
- if (empty($nb)) $nb = 0;
+ if (empty($nb)) {
+ $nb = 0;
+ }
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
$sql .= ' SET nb_gen_max = '.$nb;
@@ -818,8 +840,9 @@ class FichinterRec extends Fichinter
$sql .= ' SET nb_gen_done = nb_gen_done + 1';
$sql .= ' , date_last_gen = now()';
// si on et arrivé à la fin des génération
- if ($this->nb_gen_max == $this->nb_gen_done + 1)
+ if ($this->nb_gen_max == $this->nb_gen_done + 1) {
$sql .= ' , statut = 1';
+ }
$sql .= ' WHERE rowid = '.$this->id;
diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php
index 5df841bf6f2..a0d22cf1e2a 100644
--- a/htdocs/fichinter/class/fichinterstats.class.php
+++ b/htdocs/fichinter/class/fichinterstats.class.php
@@ -64,8 +64,7 @@ class FichinterStats extends Stats
$this->userid = $userid;
$this->cachefilesuffix = $mode;
- if ($mode == 'customer')
- {
+ if ($mode == 'customer') {
$object = new Fichinter($this->db);
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
$this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl";
@@ -73,14 +72,17 @@ class FichinterStats extends Stats
$this->field_line = '0';
//$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled
}
- if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id;
+ }
$this->where .= ($this->where ? ' AND ' : '')."c.entity IN (".getEntity('fichinter').')';
- if ($this->socid)
- {
+ if ($this->socid) {
$this->where .= " AND c.fk_soc = ".$this->socid;
}
- if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid;
+ if ($this->userid > 0) {
+ $this->where .= ' AND c.fk_user_author = '.$this->userid;
+ }
}
/**
@@ -96,7 +98,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -118,7 +122,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
@@ -139,7 +145,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -161,7 +169,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%m') as dm, 0";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
@@ -181,7 +191,9 @@ class FichinterStats extends Stats
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg";
$sql .= " FROM ".$this->from;
- if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ if (!$user->rights->societe->client->voir && !$this->socid) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+ }
$sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC');
diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php
index bace3d10231..7957479e611 100644
--- a/htdocs/fichinter/contact.php
+++ b/htdocs/fichinter/contact.php
@@ -39,13 +39,14 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
$result = $object->fetch($id, $ref);
-if (!$result)
-{
+if (!$result) {
print 'Record not found';
exit;
}
@@ -54,17 +55,14 @@ if (!$result)
* Adding a new contact
*/
-if ($action == 'addcontact' && $user->rights->ficheinter->creer)
-{
- if ($result > 0 && $id > 0)
- {
+if ($action == 'addcontact' && $user->rights->ficheinter->creer) {
+ if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
$typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type'));
$result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09'));
}
- if ($result >= 0)
- {
+ if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@@ -77,21 +75,14 @@ if ($action == 'addcontact' && $user->rights->ficheinter->creer)
setEventMessages($mesg, null, 'errors');
}
-}
-
-// Toggle the status of a contact
-elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer)
-{
+} elseif ($action == 'swapstatut' && $user->rights->ficheinter->creer) {
+ // Toggle the status of a contact
$result = $object->swapContactStatus(GETPOST('ligne', 'int'));
-}
-
-// Deletes a contact
-elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer)
-{
+} elseif ($action == 'deletecontact' && $user->rights->ficheinter->creer) {
+ // Deletes a contact
$result = $object->delete_contact(GETPOST('lineid', 'int'));
- if ($result >= 0)
- {
+ if ($result >= 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
} else {
@@ -114,8 +105,7 @@ llxHeader('', $langs->trans("Intervention"));
// Mode vue et edition
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@@ -133,12 +123,10 @@ if ($id > 0 || !empty($ref))
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
- if (!empty($conf->projet->enabled))
- {
+ if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->ficheinter->creer)
- {
+ if ($user->rights->ficheinter->creer) {
if ($action != 'classify') {
//$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
@@ -174,15 +162,20 @@ if ($id > 0 || !empty($ref))
print '
';
- if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) $hideaddcontactforuser = 1;
- if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) $hideaddcontactforthirdparty = 1;
+ if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_USER)) {
+ $hideaddcontactforuser = 1;
+ }
+ if (!empty($conf->global->FICHINTER_HIDE_ADD_CONTACT_THIPARTY)) {
+ $hideaddcontactforthirdparty = 1;
+ }
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
- foreach ($dirtpls as $reldir)
- {
+ foreach ($dirtpls as $reldir) {
$res = @include dol_buildpath($reldir.'/contacts.tpl.php');
- if ($res) break;
+ if ($res) {
+ break;
+ }
}
}
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index aaab2072013..ba1f22c122b 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -47,7 +47,9 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
@@ -56,12 +58,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "name";
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "name";
+}
$object = new Fichinter($db);
@@ -86,8 +94,7 @@ $form = new Form($db);
llxHeader('', $langs->trans("Intervention"));
-if ($object->id)
-{
+if ($object->id) {
$object->fetch_thirdparty();
$head = fichinter_prepare_head($object);
@@ -98,8 +105,7 @@ if ($object->id)
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
- foreach ($filearray as $key => $file)
- {
+ foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
@@ -115,12 +121,10 @@ if ($object->id)
// Thirdparty
$morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
// Project
- if (!empty($conf->projet->enabled))
- {
+ if (!empty($conf->projet->enabled)) {
$langs->load("projects");
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->commande->creer)
- {
+ if ($user->rights->commande->creer) {
if ($action != 'classify') {
//$morehtmlref.='
' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php
index 3ea69f8d185..863463e8d0e 100644
--- a/htdocs/fichinter/index.php
+++ b/htdocs/fichinter/index.php
@@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php';
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
-if (!$user->rights->ficheinter->lire) accessforbidden();
+if (!$user->rights->ficheinter->lire) {
+ accessforbidden();
+}
$hookmanager = new HookManager($db);
@@ -42,8 +44,7 @@ $langs->load("interventions");
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid > 0)
-{
+if ($user->socid > 0) {
$action = '';
$socid = $user->socid;
}
@@ -66,8 +67,7 @@ print load_fiche_titre($langs->trans("InterventionsArea"), '', 'intervention');
print '
';
-if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
-{
+if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
// Search ficheinter
$var = false;
print '
';
diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php
index a53c69b77bd..39ac695f84e 100644
--- a/htdocs/fichinter/info.php
+++ b/htdocs/fichinter/info.php
@@ -40,13 +40,14 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
$object = new Fichinter($db);
-if (!$object->fetch($id, $ref) > 0)
-{
+if (!$object->fetch($id, $ref) > 0) {
dol_print_error($db);
exit;
}
@@ -77,15 +78,14 @@ $morehtmlref = '