';
print "\n".'Error returned: ';
print nl2br($messagetoshow);
diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php
index 82984409325..37ad82602fb 100644
--- a/htdocs/societe/class/api_contacts.class.php
+++ b/htdocs/societe/class/api_contacts.class.php
@@ -34,7 +34,7 @@ class Contacts extends DolibarrApi
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'lastname',
);
@@ -71,8 +71,7 @@ class Contacts extends DolibarrApi
*/
public function get($id, $includecount = 0, $includeroles = 0)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
if ($id == 0) {
@@ -81,23 +80,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch($id);
}
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if ($includecount)
- {
+ if ($includecount) {
$this->contact->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$this->contact->fetchRoles();
}
@@ -119,8 +114,7 @@ class Contacts extends DolibarrApi
*/
public function getByEmail($email, $includecount = 0, $includeroles = 0)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
if (empty($email)) {
@@ -129,23 +123,19 @@ class Contacts extends DolibarrApi
$result = $this->contact->fetch('', '', '', $email);
}
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- if ($includecount)
- {
+ if ($includecount) {
$this->contact->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$this->contact->fetchRoles();
}
@@ -176,8 +166,7 @@ class Contacts extends DolibarrApi
$obj_ret = array();
- if (!DolibarrApiAccess::$user->rights->societe->contact->lire)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
}
@@ -186,8 +175,9 @@ class Contacts 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)
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) {
$search_sale = DolibarrApiAccess::$user->id;
+ }
$sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as t";
@@ -201,15 +191,18 @@ class Contacts extends DolibarrApi
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON t.fk_soc = s.rowid";
$sql .= ' WHERE t.entity IN ('.getEntity('socpeople').')';
- if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")";
+ if ($socids) {
+ $sql .= " AND t.fk_soc IN (".$socids.")";
+ }
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0)
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
$sql .= " AND t.fk_soc = sc.fk_soc";
- if ($search_sale > 0)
+ }
+ if ($search_sale > 0) {
$sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ }
// Insert sale filter
- if ($search_sale > 0)
- {
+ if ($search_sale > 0) {
$sql .= " AND sc.fk_user = ".$search_sale;
}
@@ -220,10 +213,8 @@ class Contacts extends DolibarrApi
}
// 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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -232,10 +223,8 @@ class Contacts extends DolibarrApi
$sql .= $this->db->order($sortfield, $sortorder);
- if ($limit)
- {
- if ($page < 0)
- {
+ if ($limit) {
+ if ($page < 0) {
$page = 0;
}
$offset = $limit * $page;
@@ -243,24 +232,19 @@ class Contacts extends DolibarrApi
$sql .= $this->db->plimit($limit + 1, $offset);
}
$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);
$contact_static = new Contact($this->db);
- if ($contact_static->fetch($obj->rowid))
- {
+ if ($contact_static->fetch($obj->rowid)) {
$contact_static->fetchRoles();
- if ($includecount)
- {
+ if ($includecount) {
$contact_static->load_ref_elements();
}
- if ($includeroles)
- {
+ if ($includeroles) {
$contact_static->fetchRoles();
}
@@ -272,8 +256,7 @@ class Contacts extends DolibarrApi
} else {
throw new RestException(503, 'Error when retrieve contacts : '.$sql);
}
- if (!count($obj_ret))
- {
+ if (!count($obj_ret)) {
throw new RestException(404, 'Contacts not found');
}
return $obj_ret;
@@ -287,15 +270,13 @@ class Contacts extends DolibarrApi
*/
public function post($request_data = null)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401, 'No permission to create/update contacts');
}
// Check mandatory fields
$result = $this->_validate($request_data);
- foreach ($request_data as $field => $value)
- {
+ foreach ($request_data as $field => $value) {
$this->contact->$field = $value;
}
if ($this->contact->create(DolibarrApiAccess::$user) < 0) {
@@ -313,30 +294,29 @@ class Contacts extends DolibarrApi
*/
public function put($id, $request_data = null)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->creer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->creer) {
throw new RestException(401, 'No permission to create/update contacts');
}
$result = $this->contact->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- foreach ($request_data as $field => $value)
- {
- if ($field == 'id') continue;
+ foreach ($request_data as $field => $value) {
+ if ($field == 'id') {
+ continue;
+ }
$this->contact->$field = $value;
}
- if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update'))
+ if ($this->contact->update($id, DolibarrApiAccess::$user, 1, '', '', 'update')) {
return $this->get($id);
+ }
return false;
}
@@ -349,18 +329,15 @@ class Contacts extends DolibarrApi
*/
public function delete($id)
{
- if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer)
- {
+ if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) {
throw new RestException(401, 'No permission to delete contacts');
}
$result = $this->contact->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Contact not found');
}
- if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe'))
- {
+ if (!DolibarrApi::_checkAccessToResource('contact', $this->contact->id, 'socpeople&societe')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$this->contact->oldcopy = clone $this->contact;
@@ -382,10 +359,12 @@ class Contacts extends DolibarrApi
//throw new RestException(401);
//}
- if (!isset($request_data["login"]))
+ if (!isset($request_data["login"])) {
throw new RestException(400, "login field missing");
- if (!isset($request_data["password"]))
+ }
+ if (!isset($request_data["password"])) {
throw new RestException(400, "password field missing");
+ }
if (!DolibarrApiAccess::$user->rights->societe->contact->lire) {
throw new RestException(401, 'No permission to read contacts');
diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php
index 3e8a6c91f92..be61d3a3436 100644
--- a/htdocs/societe/class/api_thirdparties.class.php
+++ b/htdocs/societe/class/api_thirdparties.class.php
@@ -33,7 +33,7 @@ class Thirdparties extends DolibarrApi
*
* @var array $FIELDS Mandatory fields, checked when create and update object
*/
- static $FIELDS = array(
+ public static $FIELDS = array(
'name'
);
@@ -137,46 +137,68 @@ class Thirdparties 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."societe as t";
if ($category > 0) {
- if ($mode != 4) $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
- if (!in_array($mode, array(1, 2, 3))) $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
+ if ($mode != 4) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c";
+ }
+ if (!in_array($mode, array(1, 2, 3))) {
+ $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as cc";
+ }
+ }
+ 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 .= ", ".MAIN_DB_PREFIX."c_stcomm as st";
$sql .= " WHERE t.entity IN (".getEntity('societe').")";
$sql .= " AND t.fk_stcomm = st.id";
- if ($mode == 1) $sql .= " AND t.client IN (1, 3)";
- elseif ($mode == 2) $sql .= " AND t.client IN (2, 3)";
- elseif ($mode == 3) $sql .= " AND t.client IN (0)";
- elseif ($mode == 4) $sql .= " AND t.fournisseur IN (1)";
+ if ($mode == 1) {
+ $sql .= " AND t.client IN (1, 3)";
+ } elseif ($mode == 2) {
+ $sql .= " AND t.client IN (2, 3)";
+ } elseif ($mode == 3) {
+ $sql .= " AND t.client IN (0)";
+ } elseif ($mode == 4) {
+ $sql .= " AND t.fournisseur IN (1)";
+ }
// Select thirdparties of given category
if ($category > 0) {
- if (!empty($mode) && $mode != 4) { $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid"; }
- elseif (!empty($mode) && $mode == 4) { $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid"; }
- else { $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))"; }
+ if (!empty($mode) && $mode != 4) {
+ $sql .= " AND c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid";
+ } elseif (!empty($mode) && $mode == 4) {
+ $sql .= " AND cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid";
+ } else {
+ $sql .= " AND ((c.fk_categorie = ".$this->db->escape($category)." AND c.fk_soc = t.rowid) OR (cc.fk_categorie = ".$this->db->escape($category)." AND cc.fk_soc = t.rowid))";
+ }
}
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc";
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) {
+ $sql .= " AND t.rowid = sc.fk_soc";
+ }
//if ($email != NULL) $sql.= " AND s.email = \"".$email."\"";
- if ($socids) $sql .= " AND t.rowid IN (".$socids.")";
- if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ if ($socids) {
+ $sql .= " AND t.rowid 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)
- {
+ 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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
@@ -195,13 +217,11 @@ class Thirdparties extends DolibarrApi
}
$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);
$soc_static = new Societe($this->db);
if ($soc_static->fetch($obj->rowid)) {
@@ -235,8 +255,9 @@ class Thirdparties extends DolibarrApi
foreach ($request_data as $field => $value) {
$this->company->$field = $value;
}
- if ($this->company->create(DolibarrApiAccess::$user) < 0)
+ if ($this->company->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors));
+ }
return $this->company->id;
}
@@ -264,7 +285,9 @@ class Thirdparties extends DolibarrApi
}
foreach ($request_data as $field => $value) {
- if ($field == 'id') continue;
+ if ($field == 'id') {
+ continue;
+ }
$this->company->$field = $value;
}
@@ -295,8 +318,7 @@ class Thirdparties extends DolibarrApi
$error = 0;
- if ($id == $idtodelete)
- {
+ if ($id == $idtodelete) {
throw new RestException(400, 'Try to merge a thirdparty into itself');
}
@@ -345,26 +367,26 @@ class Thirdparties extends DolibarrApi
'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur',
'model_pdf', 'fk_projet'
);
- foreach ($listofproperties as $property)
- {
- if (empty($object->$property)) $object->$property = $soc_origin->$property;
+ foreach ($listofproperties as $property) {
+ if (empty($object->$property)) {
+ $object->$property = $soc_origin->$property;
+ }
}
// Concat some data
$listofproperties = array(
'note_public', 'note_private'
);
- foreach ($listofproperties as $property)
- {
+ foreach ($listofproperties as $property) {
$object->$property = dol_concatdesc($object->$property, $soc_origin->$property);
}
// Merge extrafields
- if (is_array($soc_origin->array_options))
- {
- foreach ($soc_origin->array_options as $key => $val)
- {
- if (empty($object->array_options[$key])) $object->array_options[$key] = $val;
+ if (is_array($soc_origin->array_options)) {
+ foreach ($soc_origin->array_options as $key => $val) {
+ if (empty($object->array_options[$key])) {
+ $object->array_options[$key] = $val;
+ }
}
}
@@ -378,8 +400,7 @@ class Thirdparties extends DolibarrApi
// If thirdparty has a new code that is same than origin, we clean origin code to avoid duplicate key from database unique keys.
if ($soc_origin->code_client == $object->code_client
|| $soc_origin->code_fournisseur == $object->code_fournisseur
- || $soc_origin->barcode == $object->barcode)
- {
+ || $soc_origin->barcode == $object->barcode) {
dol_syslog("We clean customer and supplier code so we will be able to make the update of target");
$soc_origin->code_client = '';
$soc_origin->code_fournisseur = '';
@@ -389,8 +410,7 @@ class Thirdparties extends DolibarrApi
// Update
$result = $object->update($object->id, $user, 0, 1, 1, 'merge');
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
@@ -425,8 +445,7 @@ class Thirdparties extends DolibarrApi
);
//First, all core objects must update their tables
- foreach ($objects as $object_name => $object_file)
- {
+ foreach ($objects as $object_name => $object_file) {
require_once DOL_DOCUMENT_ROOT.$object_file;
if (!$error && !$object_name::replaceThirdparty($this->db, $soc_origin->id, $object->id)) {
@@ -584,8 +603,7 @@ class Thirdparties extends DolibarrApi
}
$result = $this->company->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@@ -593,13 +611,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
- if (is_numeric($result) && $result < 0)
- {
+ if (is_numeric($result) && $result < 0) {
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
}
- if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
- {
+ if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
return array();
}
@@ -702,8 +718,7 @@ class Thirdparties extends DolibarrApi
}
$result = $this->company->fetch($id);
- if (!$result)
- {
+ if (!$result) {
throw new RestException(404, 'Thirdparty not found');
}
@@ -711,13 +726,11 @@ class Thirdparties extends DolibarrApi
$result = $categories->getListForItem($id, 'supplier', $sortfield, $sortorder, $limit, $page);
- if (is_numeric($result) && $result < 0)
- {
+ if (is_numeric($result) && $result < 0) {
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
}
- if (is_numeric($result) && $result == 0) // To fix a return of 0 instead of empty array of method getListForItem
- {
+ if (is_numeric($result) && $result == 0) { // To fix a return of 0 instead of empty array of method getListForItem
return array();
}
@@ -1005,8 +1018,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT f.ref, f.type as factype, re.fk_facture_source, re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc, re.description, re.fk_facture, re.fk_facture_line";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as re, ".MAIN_DB_PREFIX."facture as f";
$sql .= " WHERE f.rowid = re.fk_facture_source AND re.fk_soc = ".$id;
- if ($filter == "available") $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
- if ($filter == "used") $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
+ if ($filter == "available") {
+ $sql .= " AND re.fk_facture IS NULL AND re.fk_facture_line IS NULL";
+ }
+ if ($filter == "used") {
+ $sql .= " AND (re.fk_facture IS NOT NULL OR re.fk_facture_line IS NOT NULL)";
+ }
$sql .= $this->db->order($sortfield, $sortorder);
@@ -1137,7 +1154,9 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE fk_soc = ".$id." ";
+ if ($id) {
+ $sql .= " WHERE fk_soc = ".$id." ";
+ }
$result = $this->db->query($sql);
@@ -1150,11 +1169,9 @@ class Thirdparties extends DolibarrApi
$accounts = array();
- if ($result)
- {
+ if ($result) {
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new CompanyBankAccount($this->db);
if ($account->fetch($obj->rowid)) {
@@ -1209,8 +1226,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->create(DolibarrApiAccess::$user) < 0)
+ if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating Company Bank account');
+ }
if (empty($account->rum)) {
require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
@@ -1219,8 +1237,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
+ }
return $this->_cleanObjectDatas($account);
}
@@ -1264,8 +1283,9 @@ class Thirdparties extends DolibarrApi
$account->date_rum = dol_now();
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating values');
+ }
return $this->_cleanObjectDatas($account);
}
@@ -1290,8 +1310,9 @@ class Thirdparties extends DolibarrApi
$account->fetch($bankaccount_id);
- if (!$account->socid == $id)
+ if (!$account->socid == $id) {
throw new RestException(401);
+ }
return $account->delete(DolibarrApiAccess::$user);
}
@@ -1342,8 +1363,12 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE fk_soc = ".$id." ";
- if ($companybankid) $sql .= " AND rowid = ".$companybankid."";
+ if ($id) {
+ $sql .= " WHERE fk_soc = ".$id." ";
+ }
+ if ($companybankid) {
+ $sql .= " AND rowid = ".$companybankid."";
+ }
$i = 0;
$accounts = array();
@@ -1409,7 +1434,9 @@ class Thirdparties extends DolibarrApi
*/
$sql = "SELECT rowid, fk_soc, key_account, site, date_creation, tms FROM ".MAIN_DB_PREFIX."societe_account";
$sql .= " WHERE fk_soc = $id";
- if ($site) $sql .= " AND site ='$site'";
+ if ($site) {
+ $sql .= " AND site ='$site'";
+ }
$result = $this->db->query($sql);
@@ -1422,8 +1449,7 @@ class Thirdparties extends DolibarrApi
$accounts = array();
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
@@ -1493,8 +1519,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->create(DolibarrApiAccess::$user) < 0)
+ if ($account->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating SocieteAccount entity. Ensure that the ID of thirdparty provided does exist!');
+ }
$this->_cleanObjectDatas($account);
@@ -1582,8 +1609,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount entity.');
+ }
}
$this->_cleanObjectDatas($account);
@@ -1624,8 +1652,9 @@ class Thirdparties extends DolibarrApi
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_account WHERE fk_soc = ".$id." AND site = '".$this->db->escape($request_data['site'])."' ";
$result = $this->db->query($sql);
- if ($result && $this->db->num_rows($result) !== 0)
+ if ($result && $this->db->num_rows($result) !== 0) {
throw new RestException(409, "You are trying to update this thirdparty SocieteAccount (gateway record) site member from $site to ".$request_data['site']." but another SocieteAccount entity already exists for this thirdparty with this site key.");
+ }
}
$obj = $this->db->fetch_object($result);
@@ -1636,8 +1665,9 @@ class Thirdparties extends DolibarrApi
$account->$field = $value;
}
- if ($account->update(DolibarrApiAccess::$user) < 0)
+ if ($account->update(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error updating SocieteAccount account');
+ }
$this->_cleanObjectDatas($account);
@@ -1713,8 +1743,7 @@ class Thirdparties extends DolibarrApi
$i = 0;
$num = $this->db->num_rows($result);
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $this->db->fetch_object($result);
$account = new SocieteAccount($this->db);
$account->fetch($obj->rowid);
@@ -1781,8 +1810,9 @@ class Thirdparties extends DolibarrApi
{
$thirdparty = array();
foreach (Thirdparties::$FIELDS as $field) {
- if (!isset($data[$field]))
+ if (!isset($data[$field])) {
throw new RestException(400, "$field field missing");
+ }
$thirdparty[$field] = $data[$field];
}
return $thirdparty;
diff --git a/htdocs/societe/class/client.class.php b/htdocs/societe/class/client.class.php
index f88027b1491..6b09d88ac71 100644
--- a/htdocs/societe/class/client.class.php
+++ b/htdocs/societe/class/client.class.php
@@ -64,8 +64,7 @@ class Client extends Societe
$sql = "SELECT count(s.rowid) as nb, s.client";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- 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";
@@ -75,12 +74,14 @@ class Client extends Societe
$sql .= " GROUP BY s.client";
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- if ($obj->client == 1 || $obj->client == 3) $this->nb["customers"] += $obj->nb;
- if ($obj->client == 2 || $obj->client == 3) $this->nb["prospects"] += $obj->nb;
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if ($obj->client == 1 || $obj->client == 3) {
+ $this->nb["customers"] += $obj->nb;
+ }
+ if ($obj->client == 2 || $obj->client == 3) {
+ $this->nb["prospects"] += $obj->nb;
+ }
}
$this->db->free($resql);
return 1;
@@ -101,8 +102,10 @@ class Client extends Societe
{
global $langs;
- $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
- if ($active >= 0) $sql .= " WHERE active = ".$active;
+ $sql = "SELECT id, code, libelle as label, picto FROM ".MAIN_DB_PREFIX."c_stcomm";
+ if ($active >= 0) {
+ $sql .= " WHERE active = ".$active;
+ }
$resql = $this->db->query($sql);
$num = $this->db->num_rows($resql);
$i = 0;
diff --git a/htdocs/societe/class/companybankaccount.class.php b/htdocs/societe/class/companybankaccount.class.php
index a123fa749c9..ab8271d7b70 100644
--- a/htdocs/societe/class/companybankaccount.class.php
+++ b/htdocs/societe/class/companybankaccount.class.php
@@ -84,32 +84,33 @@ class CompanyBankAccount extends Account
$error = 0;
// Correct default_rib to be sure to have always one default
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe_rib where fk_soc = ".$this->socid." AND default_rib = 1 AND type = 'ban'";
- $result = $this->db->query($sql);
- if ($result)
- {
+ $result = $this->db->query($sql);
+ if ($result) {
$numrows = $this->db->num_rows($result);
- if ($this->default_rib && $numrows > 0) $this->default_rib = 0;
- if (empty($this->default_rib) && $numrows == 0) $this->default_rib = 1;
+ if ($this->default_rib && $numrows > 0) {
+ $this->default_rib = 0;
+ }
+ if (empty($this->default_rib) && $numrows == 0) {
+ $this->default_rib = 1;
+ }
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_rib (fk_soc, type, datec)";
$sql .= " VALUES (".$this->socid.", 'ban', '".$this->db->idate($now)."')";
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->affected_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->affected_rows($resql)) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."societe_rib");
- if (!$notrigger)
- {
- // Call trigger
+ if (!$notrigger) {
+ // Call trigger
$result = $this->call_trigger('COMPANY_RIB_CREATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- if (!$error)
- {
+ if (!$error) {
return 1;
} else {
return 0;
@@ -136,10 +137,16 @@ class CompanyBankAccount extends Account
global $conf;
$error = 0;
- if (!$this->id) return -1;
+ if (!$this->id) {
+ return -1;
+ }
- if (dol_strlen($this->domiciliation) > 255) $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
- if (dol_strlen($this->owner_address) > 255) $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
+ if (dol_strlen($this->domiciliation) > 255) {
+ $this->domiciliation = dol_trunc($this->domiciliation, 254, 'right', 'UTF-8', 1);
+ }
+ if (dol_strlen($this->owner_address) > 255) {
+ $this->owner_address = dol_trunc($this->owner_address, 254, 'right', 'UTF-8', 1);
+ }
$sql = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET";
$sql .= " bank = '".$this->db->escape($this->bank)."'";
@@ -153,28 +160,28 @@ class CompanyBankAccount extends Account
$sql .= ",proprio = '".$this->db->escape($this->proprio)."'";
$sql .= ",owner_address = '".$this->db->escape($this->owner_address)."'";
$sql .= ",default_rib = ".$this->default_rib;
- if ($conf->prelevement->enabled)
- {
+ if ($conf->prelevement->enabled) {
$sql .= ",frstrecur = '".$this->db->escape($this->frstrecur)."'";
$sql .= ",rum = '".$this->db->escape($this->rum)."'";
$sql .= ",date_rum = ".($this->date_rum ? "'".$this->db->idate($this->date_rum)."'" : "null");
}
- if (trim($this->label) != '')
+ if (trim($this->label) != '') {
$sql .= ",label = '".$this->db->escape($this->label)."'";
- else $sql .= ",label = NULL";
+ } else {
+ $sql .= ",label = NULL";
+ }
$sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
- if ($result)
- {
- if (!$notrigger)
- {
+ if ($result) {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('COMPANY_RIB_MODIFY', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- if (!$error)
- {
+ if (!$error) {
return 1;
} else {
return -1;
@@ -199,24 +206,29 @@ class CompanyBankAccount extends Account
*/
public function fetch($id, $socid = 0, $default = 1, $type = 'ban')
{
- if (empty($id) && empty($socid)) return -1;
+ if (empty($id) && empty($socid)) {
+ return -1;
+ }
$sql = "SELECT rowid, type, fk_soc, bank, number, code_banque, code_guichet, cle_rib, bic, iban_prefix as iban, domiciliation, proprio,";
$sql .= " owner_address, default_rib, label, datec, tms as datem, rum, frstrecur, date_rum";
$sql .= " FROM ".MAIN_DB_PREFIX."societe_rib";
- if ($id) $sql .= " WHERE rowid = ".$id;
- if ($socid)
- {
+ if ($id) {
+ $sql .= " WHERE rowid = ".$id;
+ }
+ if ($socid) {
$sql .= " WHERE fk_soc = ".$socid;
- if ($default > -1) $sql .= " AND default_rib = ".$this->db->escape($default);
- if ($type) $sql .= " AND type ='".$this->db->escape($type)."'";
+ if ($default > -1) {
+ $sql .= " AND default_rib = ".$this->db->escape($default);
+ }
+ if ($type) {
+ $sql .= " AND type ='".$this->db->escape($type)."'";
+ }
}
$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->ref = $obj->fk_soc.'-'.$obj->label; // Generate an artificial ref
@@ -268,28 +280,26 @@ class CompanyBankAccount extends Account
$this->db->begin();
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('COMPANY_RIB_DELETE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_rib";
$sql .= " WHERE rowid = ".$this->id;
- if (!$this->db->query($sql))
- {
+ if (!$this->db->query($sql)) {
$error++;
$this->errors[] = $this->db->lasterror();
}
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -332,10 +342,8 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1);
- if ($result1)
- {
- if ($this->db->num_rows($result1) == 0)
- {
+ if ($result1) {
+ if ($this->db->num_rows($result1) == 0) {
return 0;
} else {
$obj = $this->db->fetch_object($result1);
@@ -352,8 +360,7 @@ class CompanyBankAccount extends Account
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);
- if (!$result2 || !$result3)
- {
+ if (!$result2 || !$result3) {
dol_print_error($this->db);
$this->db->rollback();
return -1;
diff --git a/htdocs/societe/class/companypaymentmode.class.php b/htdocs/societe/class/companypaymentmode.class.php
index e88ea0e4f7c..39b14862f12 100644
--- a/htdocs/societe/class/companypaymentmode.class.php
+++ b/htdocs/societe/class/companypaymentmode.class.php
@@ -232,8 +232,12 @@ class CompanyPaymentMode extends CommonObject
$this->db = $db;
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible'] = 0;
- if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled'] = 0;
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
+ $this->fields['rowid']['visible'] = 0;
+ }
+ if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
+ $this->fields['entity']['enabled'] = 0;
+ }
}
/**
@@ -313,8 +317,12 @@ class CompanyPaymentMode extends CommonObject
*/
public function fetch($id, $ref = null, $socid = 0, $type = '', $morewhere = '')
{
- if ($socid) $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
- if ($type) $morewhere .= " AND type = '".$this->db->escape($type)."'";
+ if ($socid) {
+ $morewhere .= " AND fk_soc = ".$this->db->escape($socid)." AND default_rib = 1";
+ }
+ if ($type) {
+ $morewhere .= " AND type = '".$this->db->escape($type)."'";
+ }
$result = $this->fetchCommon($id, $ref, $morewhere);
//if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
@@ -375,7 +383,9 @@ class CompanyPaymentMode extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- 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 = '';
$companylink = '';
@@ -386,33 +396,40 @@ class CompanyPaymentMode extends CommonObject
$url = dol_buildpath('/monmodule/companypaymentmode_card.php', 1).'?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("ShowCompanyPaymentMode");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$linkstart = '';
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($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 ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -433,33 +450,36 @@ class CompanyPaymentMode extends CommonObject
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result1 = $this->db->query($sql1);
- if ($result1)
- {
- if ($this->db->num_rows($result1) == 0)
- {
+ if ($result1) {
+ if ($this->db->num_rows($result1) == 0) {
return 0;
} else {
$obj = $this->db->fetch_object($result1);
$type = '';
- if (empty($alltypes)) $type = $obj->type;
+ if (empty($alltypes)) {
+ $type = $obj->type;
+ }
$this->db->begin();
$sql2 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 0, tms = tms";
$sql2 .= " WHERE default_rib <> 0 AND fk_soc = ".$obj->fk_soc;
- if ($type) $sql2 .= " AND type = '".$this->db->escape($type)."'";
+ if ($type) {
+ $sql2 .= " AND type = '".$this->db->escape($type)."'";
+ }
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result2 = $this->db->query($sql2);
$sql3 = "UPDATE ".MAIN_DB_PREFIX."societe_rib SET default_rib = 1";
$sql3 .= " WHERE rowid = ".$obj->id;
- if ($type) $sql3 .= " AND type = '".$this->db->escape($type)."'";
+ if ($type) {
+ $sql3 .= " AND type = '".$this->db->escape($type)."'";
+ }
dol_syslog(get_class($this).'::setAsDefault', LOG_DEBUG);
$result3 = $this->db->query($sql3);
- if (!$result2 || !$result3)
- {
+ if (!$result2 || !$result3) {
dol_print_error($this->db);
$this->db->rollback();
return -1;
@@ -496,8 +516,7 @@ class CompanyPaymentMode extends CommonObject
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
- if (empty($this->labelStatus) || empty($this->labelStatusShort))
- {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
@@ -507,7 +526,9 @@ class CompanyPaymentMode extends CommonObject
}
$statusType = 'status5';
- if ($status == self::STATUS_ENABLED) $statusType = 'status4';
+ if ($status == self::STATUS_ENABLED) {
+ $statusType = 'status4';
+ }
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
@@ -525,28 +546,23 @@ class CompanyPaymentMode extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$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_cloture)
- {
+ if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 115750dd0ab..6121625ba41 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -905,9 +905,8 @@ class Societe extends CommonObject
// Ajout du commercial affecte
if ($this->commercial_id != '' && $this->commercial_id != -1) {
$this->add_commercial($user, $this->commercial_id);
- }
- // si un commercial cree un client il lui est affecte automatiquement
- elseif (empty($user->rights->societe->client->voir)) {
+ } elseif (empty($user->rights->societe->client->voir)) {
+ // si un commercial cree un client il lui est affecte automatiquement
$this->add_commercial($user, $user->id);
}
@@ -2626,20 +2625,17 @@ class Societe extends CommonObject
$s = '';
if (empty($option) || preg_match('/prospect/', $option)) {
- if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
- {
+ if (($this->client == 2 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
$s .= ''.dol_substr($langs->trans("Prospect"), 0, 1).'';
}
}
if (empty($option) || preg_match('/customer/', $option)) {
- if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
- {
+ if (($this->client == 1 || $this->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
$s .= ''.dol_substr($langs->trans("Customer"), 0, 1).'';
}
}
if (empty($option) || preg_match('/supplier/', $option)) {
- if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur)
- {
+ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $this->fournisseur) {
$s .= ''.dol_substr($langs->trans("Supplier"), 0, 1).'';
}
}
@@ -3811,8 +3807,7 @@ class Societe extends CommonObject
dol_syslog("We ask to create a contact/address too", LOG_DEBUG);
$result = $this->create_individual($user);
- if ($result < 0)
- {
+ if ($result < 0) {
setEventMessages($this->error, $this->errors, 'errors');
$this->db->rollback();
return -1;
@@ -4682,8 +4677,7 @@ class Societe extends CommonObject
$this->db->commit();
return 1;
- }
- else {
+ } else {
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php
index a315044683b..64a914ff549 100644
--- a/htdocs/societe/class/societeaccount.class.php
+++ b/htdocs/societe/class/societeaccount.class.php
@@ -172,7 +172,9 @@ class SocieteAccount extends CommonObject
$this->db = $db;
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
+ $this->fields['rowid']['visible'] = 0;
+ }
}
/**
@@ -248,7 +250,9 @@ class SocieteAccount extends CommonObject
public function fetch($id, $ref = null)
{
$result = $this->fetchCommon($id, $ref);
- if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
+ if ($result > 0 && !empty($this->table_element_line)) {
+ $this->fetchLines();
+ }
return $result;
}
@@ -375,7 +379,9 @@ class SocieteAccount extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- 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 = '';
@@ -388,33 +394,40 @@ class SocieteAccount extends CommonObject
$url = dol_buildpath('/website/websiteaccount_card.php', 1).'?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("WebsiteAccount");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$linkstart = '';
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($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 ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
return $result;
@@ -444,35 +457,49 @@ class SocieteAccount extends CommonObject
// phpcs:enable
global $langs;
- if ($mode == 0)
- {
+ if ($mode == 0) {
$prefix = '';
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- } elseif ($mode == 1)
- {
- if ($status == 1) return $langs->trans('Enabled');
- elseif ($status == 0) return $langs->trans('Disabled');
- } elseif ($mode == 2)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- } elseif ($mode == 3)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
- } elseif ($mode == 4)
- {
- if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
- elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
- } elseif ($mode == 5)
- {
- if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
- } elseif ($mode == 6)
- {
- if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
- elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ if ($status == 1) {
+ return $langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled');
+ }
+ } elseif ($mode == 1) {
+ if ($status == 1) {
+ return $langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled');
+ }
+ } elseif ($mode == 2) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+ }
+ } elseif ($mode == 3) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5');
+ }
+ } elseif ($mode == 4) {
+ if ($status == 1) {
+ return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+ } elseif ($status == 0) {
+ return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+ }
+ } elseif ($mode == 5) {
+ if ($status == 1) {
+ return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ }
+ } elseif ($mode == 6) {
+ if ($status == 1) {
+ return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
+ } elseif ($status == 0) {
+ return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+ }
}
}
@@ -489,28 +516,23 @@ class SocieteAccount extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$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_cloture)
- {
+ if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
diff --git a/htdocs/societe/consumption.php b/htdocs/societe/consumption.php
index fe8c2adb7bc..3a0e97228ef 100644
--- a/htdocs/societe/consumption.php
+++ b/htdocs/societe/consumption.php
@@ -35,22 +35,32 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thi
// Security check
$socid = GETPOST('socid', 'int');
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'societe', $socid, '&societe');
$object = new Societe($db);
-if ($socid > 0) $object->fetch($socid);
+if ($socid > 0) {
+ $object->fetch($socid);
+}
// Sort & Order fields
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$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 = 'DESC';
-if (!$sortfield) $sortfield = 'dateprint';
+if (!$sortorder) {
+ $sortorder = 'DESC';
+}
+if (!$sortfield) {
+ $sortfield = 'dateprint';
+}
// Search fields
$sref = GETPOST("sref");
@@ -59,8 +69,7 @@ $month = GETPOST('month', 'int');
$year = GETPOST('year', 'int');
// Clean up on purge search criteria ?
-if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
-{
+if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
$sref = '';
$sprod_fulldescr = '';
$year = '';
@@ -83,7 +92,9 @@ $hookmanager->initHooks(array('consumptionthirdparty'));
$parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
@@ -96,12 +107,13 @@ $formother = new FormOther($db);
$productstatic = new Product($db);
$title = $langs->trans("Referers", $object->name);
-if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name." - ".$title;
+if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
+ $title = $object->name." - ".$title;
+}
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url);
-if (empty($socid))
-{
+if (empty($socid)) {
dol_print_error($db);
exit;
}
@@ -118,15 +130,13 @@ print '
';
print '';
print '
';
-if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
-{
+if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '
';
// Prefix
- if (!empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
- {
+ if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
print '
'.$langs->trans('Prefix').'
'.$object->prefix_comm.'
';
}
- if ($object->client)
- {
+ if ($object->client) {
print '