From 39104009ef2c2ac0748fa64ab77da9bd87b0bd55 Mon Sep 17 00:00:00 2001
From: Matt Sidnell <54064522+pstructures@users.noreply.github.com>
Date: Wed, 8 Jul 2020 14:25:37 +0100
Subject: [PATCH] Updated to match inline with code received from fork
---
htdocs/core/class/commonobject.class.php | 1402 +++++++++-------------
1 file changed, 560 insertions(+), 842 deletions(-)
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index d6e8314155f..6045e4232c2 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -717,8 +717,7 @@ abstract class CommonObject
{
if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) {
$out .= ($outdone ? ' - ' : '').$this->region.' - '.$this->state;
- }
- else {
+ } else {
$out .= ($outdone ? ' - ' : '').$this->state;
}
$outdone++;
@@ -845,10 +844,8 @@ abstract class CommonObject
$this->errors = $ecmfile->errors;
}
*/
- }
- else return '';
- }
- elseif (empty($ecmfile->share))
+ } else return '';
+ } elseif (empty($ecmfile->share))
{
// Add entry into index
if ($initsharekey)
@@ -856,8 +853,7 @@ abstract class CommonObject
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$ecmfile->share = getRandomPassword(true);
$ecmfile->update($user);
- }
- else return '';
+ } else return '';
}
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -879,9 +875,7 @@ abstract class CommonObject
if ($relativelink)
{
$linktoreturn = 'document.php'.($paramlink ? '?'.$paramlink : '');
- }
- else
- {
+ } else {
$linktoreturn = $urlwithroot.'/document.php'.($paramlink ? '?'.$paramlink : '');
}
@@ -928,9 +922,7 @@ abstract class CommonObject
if (is_numeric($type_contact))
{
$id_type_contact = $type_contact;
- }
- else
- {
+ } else {
// We look for id type_contact
$sql = "SELECT tc.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as tc";
@@ -993,18 +985,14 @@ abstract class CommonObject
$this->db->commit();
return 1;
- }
- else
- {
+ } else {
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error = $this->db->errno();
$this->db->rollback();
echo 'err rollback';
return -2;
- }
- else
- {
+ } else {
$this->error = $this->db->error();
$this->db->rollback();
return -1;
@@ -1059,9 +1047,7 @@ abstract class CommonObject
if ($resql)
{
return 0;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
return -1;
}
@@ -1097,9 +1083,7 @@ abstract class CommonObject
$this->db->commit();
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
@@ -1135,9 +1119,7 @@ abstract class CommonObject
if ($this->db->query($sql))
{
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
return -1;
}
@@ -1197,9 +1179,7 @@ abstract class CommonObject
'nom'=>$obj->lastname, // For backward compatibility
'civility'=>$obj->civility, 'lastname'=>$obj->lastname, 'firstname'=>$obj->firstname, 'email'=>$obj->email, 'login'=>$obj->login, 'photo'=>$obj->photo, 'statuscontact'=>$obj->statuscontact,
'rowid'=>$obj->rowid, 'code'=>$obj->code, 'libelle'=>$libelle_type, 'status'=>$obj->statuslink, 'fk_c_type_contact'=>$obj->fk_c_type_contact);
- }
- else
- {
+ } else {
$tab[$i] = $obj->id;
}
@@ -1207,9 +1187,7 @@ abstract class CommonObject
}
return $tab;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
dol_print_error($this->db);
return -1;
@@ -1243,9 +1221,7 @@ abstract class CommonObject
$result = $this->update_contact($rowid, $newstatut);
$this->db->free($resql);
return $result;
- }
- else
- {
+ } else {
$this->error = $this->db->error();
dol_print_error($this->db);
return -1;
@@ -1297,9 +1273,7 @@ abstract class CommonObject
$i++;
}
return $tab;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
//dol_print_error($this->db);
return null;
@@ -1380,9 +1354,7 @@ abstract class CommonObject
}
}
return $tab;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
return null;
}
@@ -1442,9 +1414,7 @@ abstract class CommonObject
$result[$i] = $obj->fk_socpeople;
$i++;
}
- }
- else
- {
+ } else {
$this->error = $this->db->error();
return null;
}
@@ -1454,15 +1424,15 @@ abstract class CommonObject
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
- * Load object contact with id=$this->contactid into $this->contact
+ * Load object contact with id=$this->contact_id into $this->contact
*
- * @param int $contactid Id du contact. Use this->contactid if empty.
+ * @param int $contactid Id du contact. Use this->contact_id if empty.
* @return int <0 if KO, >0 if OK
*/
public function fetch_contact($contactid = null)
{
// phpcs:enable
- if (empty($contactid)) $contactid = $this->contactid;
+ if (empty($contactid)) $contactid = $this->contact_id;
if (empty($contactid)) return 0;
@@ -1505,8 +1475,7 @@ abstract class CommonObject
}
return $result;
- } else
- return -1;
+ } else return -1;
}
@@ -1576,9 +1545,7 @@ abstract class CommonObject
$this->barcode_type_label = $obj->label;
$this->barcode_type_coder = $obj->coder;
return 1;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -1785,9 +1752,7 @@ abstract class CommonObject
if (empty($this->fields) && method_exists($this, 'fetch'))
{
$result = $this->fetch($id);
- }
- else
- {
+ } else {
$result = $this->fetchCommon($id);
}
if ($result >= 0) $result = $this->call_trigger($trigkey, (!empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors
@@ -1799,15 +1764,11 @@ abstract class CommonObject
if (property_exists($this, $field)) $this->$field = $value;
$this->db->commit();
return 1;
- }
- else
- {
+ } else {
$this->db->rollback();
return -2;
}
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
@@ -1852,11 +1813,10 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
- }
- elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
+ } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
- $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
+ $sql .= " WHERE te.".$fieldid." < '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
if (!empty($filter))
@@ -1867,8 +1827,7 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
$tmparray = explode('@', $this->ismultientitymanaged);
$sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
- }
- elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
+ } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
@@ -1909,7 +1868,7 @@ abstract class CommonObject
elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
- $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
+ $sql .= " WHERE te.".$fieldid." > '".$this->db->escape($fieldid=='rowid' ? $this->id : $this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
if ($this->restrictiononfksoc == 1 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
if ($this->restrictiononfksoc == 2 && !$user->rights->societe->client->voir && !$socid) $sql .= " AND (sc.fk_user = ".$user->id.' OR te.fk_soc IS NULL)';
if (!empty($filter))
@@ -1966,7 +1925,7 @@ abstract class CommonObject
while ($i < $num)
{
if ($source == 'thirdparty') $contactAlreadySelected[$i] = $tab[$i]['socid'];
- else $contactAlreadySelected[$i] = $tab[$i]['id'];
+ else $contactAlreadySelected[$i] = $tab[$i]['id'];
$i++;
}
return $contactAlreadySelected;
@@ -1993,14 +1952,12 @@ abstract class CommonObject
if ($projectid) $sql .= ' SET fk_project = '.$projectid;
else $sql .= ' SET fk_project = NULL';
$sql .= ' WHERE rowid = '.$this->id;
- }
- elseif ($this->table_element == 'actioncomm') // Special case for actioncomm
+ } elseif ($this->table_element == 'actioncomm') // Special case for actioncomm
{
if ($projectid) $sql .= ' SET fk_project = '.$projectid;
else $sql .= ' SET fk_project = NULL';
$sql .= ' WHERE id = '.$this->id;
- }
- else // Special case for old architecture objects
+ } else // Special case for old architecture objects
{
if ($projectid) $sql .= ' SET fk_projet = '.$projectid;
else $sql .= ' SET fk_projet = NULL';
@@ -2012,9 +1969,7 @@ abstract class CommonObject
{
$this->fk_project = $projectid;
return 1;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -2046,16 +2001,12 @@ abstract class CommonObject
// for supplier
if (get_class($this) == 'Fournisseur') $this->mode_reglement_supplier_id = $id;
return 1;
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setPaymentMethods Erreur '.$sql.' - '.$this->db->error());
$this->error = $this->db->error();
return -1;
}
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setPaymentMethods, status of the object is incompatible');
$this->error = 'Status of the object is incompatible '.$this->statut;
return -2;
@@ -2087,16 +2038,12 @@ abstract class CommonObject
if ($rate) $this->setMulticurrencyRate($rate, 2);
return 1;
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setMulticurrencyCode Erreur '.$sql.' - '.$this->db->error());
$this->error = $this->db->error();
return -1;
}
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setMulticurrencyCode, status of the object is incompatible');
$this->error = 'Status of the object is incompatible '.$this->statut;
return -2;
@@ -2195,16 +2142,12 @@ abstract class CommonObject
}
return 1;
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setMulticurrencyRate Erreur '.$sql.' - '.$this->db->error());
$this->error = $this->db->error();
return -1;
}
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setMulticurrencyRate, status of the object is incompatible');
$this->error = 'Status of the object is incompatible '.$this->statut;
return -2;
@@ -2238,16 +2181,12 @@ abstract class CommonObject
if (get_class($this) == 'Fournisseur') $this->cond_reglement_supplier_id = $id;
$this->cond_reglement = $id; // for compatibility
return 1;
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setPaymentTerms Erreur '.$sql.' - '.$this->db->error());
$this->error = $this->db->error();
return -1;
}
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setPaymentTerms, status of the object is incompatible');
$this->error = 'Status of the object is incompatible '.$this->statut;
return -2;
@@ -2276,16 +2215,12 @@ abstract class CommonObject
{
$this->retained_warranty_fk_cond_reglement = $id;
return 1;
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms Erreur '.$sql.' - '.$this->db->error());
$this->error = $this->db->error();
return -1;
}
- }
- else
- {
+ } else {
dol_syslog(get_class($this).'::setRetainedWarrantyPaymentTerms, status of the object is incompatible');
$this->error = 'Status of the object is incompatible '.$this->statut;
return -2;
@@ -2311,9 +2246,7 @@ abstract class CommonObject
{
$this->fk_delivery_address = $id;
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->error();
dol_syslog(get_class($this).'::setDeliveryAddress Erreur '.$sql.' - '.$this->error);
return -1;
@@ -2437,9 +2370,7 @@ abstract class CommonObject
{
$this->modelpdf = $modelpdf;
return 1;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return 0;
}
@@ -2481,9 +2412,7 @@ abstract class CommonObject
dol_syslog(get_class($this).'::setBankAccount Error '.$sql.' - '.$this->db->error());
$this->error = $this->db->lasterror();
$error++;
- }
- else
- {
+ } else {
if (!$notrigger)
{
// Call trigger
@@ -2497,9 +2426,7 @@ abstract class CommonObject
{
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->fk_account = ($fk_account == 'NULL') ?null:$fk_account;
$this->db->commit();
return 1;
@@ -2546,8 +2473,7 @@ abstract class CommonObject
{
$row = $this->db->fetch_row($resql);
$nl = $row[0];
- }
- else dol_print_error($this->db);
+ } else dol_print_error($this->db);
if ($nl > 0)
{
// The goal of this part is to reorder all lines, with all children lines sharing the same
@@ -2589,9 +2515,7 @@ abstract class CommonObject
$this->updateRangOfLine($row, ($key + 1));
}
}
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -2601,10 +2525,11 @@ abstract class CommonObject
/**
* Get children of line
*
- * @param int $id Id of parent line
- * @return array Array with list of children lines id
+ * @param int $id Id of parent line
+ * @param int $includealltree 0 = 1st level child, 1 = All level child
+ * @return array Array with list of children lines id
*/
- public function getChildrenOfLine($id)
+ public function getChildrenOfLine($id, $includealltree = 0)
{
$rows = array();
@@ -2617,16 +2542,13 @@ abstract class CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
- $i = 0;
- $num = $this->db->num_rows($resql);
- while ($i < $num)
- {
- $row = $this->db->fetch_row($resql);
- $rows[$i] = $row[0];
- $i++;
+ if ($this->db->num_rows($resql) > 0) {
+ while ($row = $this->db->fetch_row($resql)) {
+ $rows[] = $row[0];
+ if (!empty($includealltree)) $rows = array_merge($rows, $this->getChildrenOfLine($row[0]), $includealltree);
+ }
}
}
-
return $rows;
}
@@ -2737,9 +2659,7 @@ abstract class CommonObject
{
dol_print_error($this->db);
}
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -2771,9 +2691,7 @@ abstract class CommonObject
{
dol_print_error($this->db);
}
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -2846,16 +2764,13 @@ abstract class CommonObject
if (!empty($row[0]))
{
return $row[0];
- }
- else
- {
+ } else {
return $this->getRangOfLine($fk_parent_line);
}
}
}
// If not, search the last rang of element
- else
- {
+ else {
$sql = 'SELECT max('.$positionfield.') FROM '.MAIN_DB_PREFIX.$this->table_element_line;
$sql .= ' WHERE '.$this->fk_element.' = '.$this->id;
@@ -2894,9 +2809,7 @@ abstract class CommonObject
{
$this->ref_ext = $ref_ext;
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->error();
return -1;
}
@@ -2941,15 +2854,12 @@ abstract class CommonObject
{
if ($suffix == '_public') $this->note_public = $note;
elseif ($suffix == '_private') $this->note_private = $note;
- else
- {
+ else {
$this->note = $note; // deprecated
$this->note_private = $note;
}
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
return -1;
}
@@ -3214,14 +3124,10 @@ abstract class CommonObject
if (!$error)
{
return 1;
- }
- else
- {
+ } else {
return -1;
}
- }
- else
- {
+ } else {
dol_print_error($this->db, 'Bad request in update_price');
return -1;
}
@@ -3266,9 +3172,7 @@ abstract class CommonObject
{
$this->db->commit();
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return 0;
@@ -3341,15 +3245,12 @@ abstract class CommonObject
{
$sql .= "fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."'";
if ($withtargettype) $sql .= " AND targettype = '".$targettype."'";
- }
- elseif ($justtarget)
+ } elseif ($justtarget)
{
$sql .= "fk_target = ".$targetid." AND targettype = '".$targettype."'";
if ($withsourcetype) $sql .= " AND sourcetype = '".$sourcetype."'";
}
- }
- else
- {
+ } else {
$sql .= "(fk_source = ".$sourceid." AND sourcetype = '".$sourcetype."')";
$sql .= " ".$clause." (fk_target = ".$targetid." AND targettype = '".$targettype."')";
}
@@ -3369,14 +3270,11 @@ abstract class CommonObject
if ($justsource)
{
$this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target;
- }
- elseif ($justtarget)
+ } elseif ($justtarget)
{
$this->linkedObjectsIds[$obj->sourcetype][$obj->rowid] = $obj->fk_source;
}
- }
- else
- {
+ } else {
if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype)
{
$this->linkedObjectsIds[$obj->targettype][$obj->rowid] = $obj->fk_target;
@@ -3407,32 +3305,23 @@ abstract class CommonObject
// To work with non standard classpath or module name
if ($objecttype == 'facture') {
$classpath = 'compta/facture/class';
- }
- elseif ($objecttype == 'facturerec') {
+ } elseif ($objecttype == 'facturerec') {
$classpath = 'compta/facture/class'; $module = 'facture';
- }
- elseif ($objecttype == 'propal') {
+ } elseif ($objecttype == 'propal') {
$classpath = 'comm/propal/class';
- }
- elseif ($objecttype == 'supplier_proposal') {
+ } elseif ($objecttype == 'supplier_proposal') {
$classpath = 'supplier_proposal/class';
- }
- elseif ($objecttype == 'shipping') {
+ } elseif ($objecttype == 'shipping') {
$classpath = 'expedition/class'; $subelement = 'expedition'; $module = 'expedition_bon';
- }
- elseif ($objecttype == 'delivery') {
+ } elseif ($objecttype == 'delivery') {
$classpath = 'livraison/class'; $subelement = 'livraison'; $module = 'livraison_bon';
- }
- elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') {
+ } elseif ($objecttype == 'invoice_supplier' || $objecttype == 'order_supplier') {
$classpath = 'fourn/class'; $module = 'fournisseur';
- }
- elseif ($objecttype == 'fichinter') {
+ } elseif ($objecttype == 'fichinter') {
$classpath = 'fichinter/class'; $subelement = 'fichinter'; $module = 'ficheinter';
- }
- elseif ($objecttype == 'subscription') {
+ } elseif ($objecttype == 'subscription') {
$classpath = 'adherents/class'; $module = 'adherent';
- }
- elseif ($objecttype == 'contact') {
+ } elseif ($objecttype == 'contact') {
$module = 'societe';
}
@@ -3441,23 +3330,17 @@ abstract class CommonObject
if ($objecttype == 'order') {
$classfile = 'commande'; $classname = 'Commande';
- }
- elseif ($objecttype == 'invoice_supplier') {
+ } elseif ($objecttype == 'invoice_supplier') {
$classfile = 'fournisseur.facture'; $classname = 'FactureFournisseur';
- }
- elseif ($objecttype == 'order_supplier') {
+ } elseif ($objecttype == 'order_supplier') {
$classfile = 'fournisseur.commande'; $classname = 'CommandeFournisseur';
- }
- elseif ($objecttype == 'supplier_proposal') {
+ } elseif ($objecttype == 'supplier_proposal') {
$classfile = 'supplier_proposal'; $classname = 'SupplierProposal';
- }
- elseif ($objecttype == 'facturerec') {
+ } elseif ($objecttype == 'facturerec') {
$classfile = 'facture-rec'; $classname = 'FactureRec';
- }
- elseif ($objecttype == 'subscription') {
+ } elseif ($objecttype == 'subscription') {
$classfile = 'subscription'; $classname = 'Subscription';
- }
- elseif ($objecttype == 'project' || $objecttype == 'projet') {
+ } elseif ($objecttype == 'project' || $objecttype == 'projet') {
$classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project';
}
@@ -3481,17 +3364,13 @@ abstract class CommonObject
}
}
}
- }
- else
- {
+ } else {
unset($this->linkedObjectsIds[$objecttype]);
}
}
}
return 1;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3522,8 +3401,7 @@ abstract class CommonObject
$sql .= ", sourcetype = '".$this->db->escape($sourcetype)."'";
$sql .= " WHERE fk_target = ".$this->id;
$sql .= " AND targettype = '".$this->db->escape($this->element)."'";
- }
- elseif ($updatetarget)
+ } elseif ($updatetarget)
{
$sql .= "fk_target = ".$targetid;
$sql .= ", targettype = '".$this->db->escape($targettype)."'";
@@ -3535,9 +3413,7 @@ abstract class CommonObject
if ($this->db->query($sql))
{
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
return -1;
}
@@ -3572,21 +3448,16 @@ abstract class CommonObject
if ($rowid > 0)
{
$sql .= " rowid = ".$rowid;
- }
- else
- {
+ } else {
if ($deletesource)
{
$sql .= " fk_source = ".$sourceid." AND sourcetype = '".$this->db->escape($sourcetype)."'";
$sql .= " AND fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."'";
- }
- elseif ($deletetarget)
+ } elseif ($deletetarget)
{
$sql .= " fk_target = ".$targetid." AND targettype = '".$this->db->escape($targettype)."'";
$sql .= " AND fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."'";
- }
- else
- {
+ } else {
$sql .= " (fk_source = ".$this->id." AND sourcetype = '".$this->db->escape($this->element)."')";
$sql .= " OR";
$sql .= " (fk_target = ".$this->id." AND targettype = '".$this->db->escape($this->element)."')";
@@ -3597,9 +3468,7 @@ abstract class CommonObject
if ($this->db->query($sql))
{
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->errors[] = $this->error;
return -1;
@@ -3676,16 +3545,12 @@ abstract class CommonObject
}
return 1;
- }
- else
- {
+ } else {
$this->db->rollback();
dol_syslog(get_class($this)."::setStatut ".$this->error, LOG_ERR);
return -1;
}
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
@@ -3724,11 +3589,8 @@ abstract class CommonObject
{
$this->canvas = $obj->canvas;
return 1;
- }
- else return 0;
- }
- else
- {
+ } else return 0;
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3801,16 +3663,13 @@ abstract class CommonObject
if (is_numeric($elementname)) // old usage
{
$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $table);
- }
- else // new usage: $elementname=Translation key
+ } else // new usage: $elementname=Translation key
{
$this->errors[] = $langs->trans("ErrorRecordHasAtLeastOneChildOfType", $langs->transnoentitiesnoconv($elementname));
}
break; // We found at least one, we stop here
}
- }
- else
- {
+ } else {
$this->errors[] = $this->db->lasterror();
return -1;
}
@@ -3819,8 +3678,7 @@ abstract class CommonObject
{
$this->errors[] = "ErrorRecordHasChildren";
return $haschild;
- }
- else return 0;
+ } else return 0;
}
/**
@@ -3912,8 +3770,7 @@ abstract class CommonObject
{
if (empty($totalToShip)) $totalToShip = 0; // Avoid warning because $totalToShip is ''
$totalToShip += $line->qty_shipped; // defined for shipment only
- }
- elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty))
+ } elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty))
{
if (empty($totalToShip)) $totalToShip = 0;
$totalToShip += $line->qty; // defined for reception only
@@ -3923,8 +3780,7 @@ abstract class CommonObject
if ($this->element == 'shipping') {
// for shipments
$qty = $line->qty_shipped ? $line->qty_shipped : 0;
- }
- else {
+ } else {
$qty = $line->qty ? $line->qty : 0;
}
@@ -3951,8 +3807,7 @@ abstract class CommonObject
{
$trueWeightUnit = pow(10, $weightUnit);
$totalWeight += $weight * $qty * $trueWeightUnit;
- }
- else {
+ } else {
if ($weight_units == 99) {
// conversion 1 Pound = 0.45359237 KG
$trueWeightUnit = 0.45359237;
@@ -3961,8 +3816,7 @@ abstract class CommonObject
// conversion 1 Ounce = 0.0283495 KG
$trueWeightUnit = 0.0283495;
$totalWeight += $weight * $qty * $trueWeightUnit;
- }
- else {
+ } else {
$totalWeight += $weight * $qty; // This may be wrong if we mix different units
}
}
@@ -3972,9 +3826,7 @@ abstract class CommonObject
$trueVolumeUnit = pow(10, $volumeUnit);
//print $line->volume;
$totalVolume += $volume * $qty * $trueVolumeUnit;
- }
- else
- {
+ } else {
$totalVolume += $volume * $qty; // This may be wrong if we mix different units
}
}
@@ -4005,9 +3857,7 @@ abstract class CommonObject
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->db->commit();
return 1;
}
@@ -4058,14 +3908,10 @@ abstract class CommonObject
{
$res = $this->db->fetch_object($resql);
return 'Incoterm : '.$res->code.' - '.$this->location_incoterms;
- }
- else
- {
+ } else {
return '';
}
- }
- else
- {
+ } else {
$this->errors[] = $this->db->lasterror();
return false;
}
@@ -4101,14 +3947,11 @@ abstract class CommonObject
$this->label_incoterms = $obj->libelle;
}
return 1;
- }
- else
- {
+ } else {
$this->errors[] = $this->db->lasterror();
return -1;
}
- }
- else return -1;
+ } else return -1;
}
@@ -4149,9 +3992,7 @@ abstract class CommonObject
if (!empty($module))
{
$tpl = dol_buildpath($reldir.'/objectline_create.tpl.php');
- }
- else
- {
+ } else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_create.tpl.php';
}
@@ -4216,9 +4057,7 @@ abstract class CommonObject
if (!empty($module))
{
$tpl = dol_buildpath($reldir.'/objectline_title.tpl.php');
- }
- else
- {
+ } else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_title.tpl.php';
}
if (empty($conf->file->strict_mode)) {
@@ -4245,9 +4084,7 @@ abstract class CommonObject
{
$parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element);
$reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- }
- else
- {
+ } else {
$parameters = array('line'=>$line, 'num'=>$num, 'i'=>$i, 'dateSelector'=>$dateSelector, 'seller'=>$seller, 'buyer'=>$buyer, 'selected'=>$selected, 'table_element_line'=>$line->table_element, 'fk_parent_line'=>$line->fk_parent_line);
$reshook = $hookmanager->executeHooks('printObjectSubLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
@@ -4328,9 +4165,7 @@ abstract class CommonObject
}
$label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $line->product_label;
- }
- else
- {
+ } else {
$label = $line->product_label;
}
@@ -4349,9 +4184,7 @@ abstract class CommonObject
if (!empty($module))
{
$tpl = dol_buildpath($reldir.'/objectline_view.tpl.php');
- }
- else
- {
+ } else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_view.tpl.php';
}
@@ -4380,9 +4213,7 @@ abstract class CommonObject
if (!empty($module))
{
$tpl = dol_buildpath($reldir.'/objectline_edit.tpl.php');
- }
- else
- {
+ } else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/objectline_edit.tpl.php';
}
@@ -4442,9 +4273,7 @@ abstract class CommonObject
$action = '';
$hookmanager->executeHooks('printOriginObjectLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
}
- }
- else
- {
+ } else {
$this->printOriginLine($line, '', $restrictlist, '/core/tpl', $selectedLines);
}
@@ -4474,18 +4303,14 @@ abstract class CommonObject
if (!empty($line->date_start))
{
$date_start = $line->date_start;
- }
- else
- {
+ } else {
$date_start = $line->date_debut_prevue;
if ($line->date_debut_reel) $date_start = $line->date_debut_reel;
}
if (!empty($line->date_end))
{
$date_end = $line->date_end;
- }
- else
- {
+ } else {
$date_end = $line->date_fin_prevue;
if ($line->date_fin_reel) $date_end = $line->date_fin_reel;
}
@@ -4500,8 +4325,7 @@ abstract class CommonObject
$discount = new DiscountAbsolute($this->db);
$discount->fk_soc = $this->socid;
$this->tpl['label'] .= $discount->getNomUrl(0, 'discount');
- }
- elseif (!empty($line->fk_product))
+ } elseif (!empty($line->fk_product))
{
$productstatic = new Product($this->db);
$productstatic->id = $line->fk_product;
@@ -4519,9 +4343,7 @@ abstract class CommonObject
{
$this->tpl['label'] .= get_date_range($date_start, $date_end);
}
- }
- else
- {
+ } else {
$this->tpl['label'] .= ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''), 'service') : img_object($langs->trans(''), 'product')));
if (!empty($line->desc)) {
$this->tpl['label'] .= $line->desc;
@@ -4543,32 +4365,25 @@ abstract class CommonObject
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
- }
- elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object
+ } elseif ($line->desc == '(DEPOSIT)') // TODO Not sure this is used for source object
{
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
- }
- elseif ($line->desc == '(EXCESS RECEIVED)')
+ } elseif ($line->desc == '(EXCESS RECEIVED)')
{
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
- }
- elseif ($line->desc == '(EXCESS PAID)')
+ } elseif ($line->desc == '(EXCESS PAID)')
{
$discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except);
$this->tpl['description'] = $langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));
- }
- else
- {
+ } else {
$this->tpl['description'] = dol_trunc($line->desc, 60);
}
- }
- else
- {
+ } else {
$this->tpl['description'] = ' ';
}
@@ -4595,9 +4410,7 @@ abstract class CommonObject
if (!empty($module))
{
$tpl = dol_buildpath($reldir.'/originproductline.tpl.php');
- }
- else
- {
+ } else {
$tpl = DOL_DOCUMENT_ROOT.$reldir.'/originproductline.tpl.php';
}
@@ -4648,9 +4461,7 @@ abstract class CommonObject
{
$this->db->commit();
return 1;
- }
- else
- {
+ } else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return 0;
@@ -4684,9 +4495,7 @@ abstract class CommonObject
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
if (!$notrigger)
{
$result = $this->call_trigger(strtoupper($element).'_DELETE_RESOURCE', $user);
@@ -4849,9 +4658,7 @@ abstract class CommonObject
{
$arrayofrecords = array(); // The write_file of templates of adherent class need this var
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
- }
- else
- {
+ } else {
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
}
// After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
@@ -4919,9 +4726,7 @@ abstract class CommonObject
if ($result < 0) {
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
- }
- else
- {
+ } else {
$ecmfile->entity = $conf->entity;
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
@@ -4960,9 +4765,7 @@ abstract class CommonObject
}
}
}
- }
- else
- {
+ } else {
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
}
@@ -4970,9 +4773,7 @@ abstract class CommonObject
dol_meta_create($this);
return 1;
- }
- else
- {
+ } else {
$outputlangs->charset_output = $sav_charset_output;
dol_print_error($this->db, "Error generating document for ".__CLASS__.". Error: ".$obj->error, $obj->errors);
return -1;
@@ -4987,8 +4788,7 @@ abstract class CommonObject
}
return -1;
}
- }
- else return $reshook;
+ } else return $reshook;
}
/**
@@ -5093,9 +4893,7 @@ abstract class CommonObject
if (!empty($this->errors))
{
$this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice.
- }
- else
- {
+ } else {
$this->errors = $interface->errors;
}
}
@@ -5156,9 +4954,7 @@ abstract class CommonObject
if (preg_match('/date/', $type))
{
$this->array_languages[$key][$codelang] = $this->db->jdate($value);
- }
- else
- {
+ } else {
$this->array_languages[$key][$codelang] = $value;
}
@@ -5170,9 +4966,7 @@ abstract class CommonObject
if ($numrows) return $numrows;
else return 0;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -5221,14 +5015,12 @@ abstract class CommonObject
// Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters
$value_key = dol_mktime(0, 0, 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]);
- }
- elseif (in_array($key_type, array('datetime')))
+ } elseif (in_array($key_type, array('datetime')))
{
// Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters
$value_key = dol_mktime($_POST[$postfieldkey."hour"], $_POST[$postfieldkey."min"], 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]);
- }
- elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
+ } elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
{
$value_arr = GETPOST($postfieldkey, 'array'); // check if an array
if (!empty($value_arr)) {
@@ -5236,14 +5028,11 @@ abstract class CommonObject
} else {
$value_key = '';
}
- }
- elseif (in_array($key_type, array('price', 'double')))
+ } elseif (in_array($key_type, array('price', 'double')))
{
$value_arr = GETPOST($postfieldkey, 'alpha');
$value_key = price2num($value_arr);
- }
- else
- {
+ } else {
$value_key = GETPOST($postfieldkey);
if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = '';
}
@@ -5323,9 +5112,7 @@ abstract class CommonObject
$extrafields->fetch_name_optionals_label($this->table_element);
}
$optionsArray = (!empty($extrafields->attributes[$this->table_element]['label']) ? $extrafields->attributes[$this->table_element]['label'] : null);
- }
- else
- {
+ } else {
global $extrafields;
dol_syslog("Warning: fetch_optionals was called with param optionsArray defined when you should pass null now", LOG_WARNING);
}
@@ -5366,9 +5153,7 @@ abstract class CommonObject
{
//var_dump($extrafields->attributes[$this->table_element]['type'][$key]);
$this->array_options["options_".$key] = $this->db->jdate($value);
- }
- else
- {
+ } else {
$this->array_options["options_".$key] = $value;
}
@@ -5392,9 +5177,7 @@ abstract class CommonObject
if ($numrows) return $numrows;
else return 0;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -5427,9 +5210,7 @@ abstract class CommonObject
$this->error = $this->db->lasterror();
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->db->commit();
return 1;
}
@@ -5504,9 +5285,7 @@ abstract class CommonObject
$value = dol_eval($attrfieldcomputed, 1, 0);
dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG);
$new_array_options[$key] = $value;
- }
- else
- {
+ } else {
$new_array_options[$key] = null;
}
}
@@ -5518,8 +5297,7 @@ abstract class CommonObject
{
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value == '')
+ } elseif ($value == '')
{
$new_array_options[$key] = null;
}
@@ -5531,8 +5309,7 @@ abstract class CommonObject
dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value == '')
+ } elseif ($value == '')
{
$new_array_options[$key] = null;
}
@@ -5563,21 +5340,16 @@ abstract class CommonObject
if ($this->array_options[$key] == $this->oldcopy->array_options[$key]) // If old value crypted in database is same than submited new value, it means we don't change it, so we don't update.
{
$new_array_options[$key] = $this->array_options[$key]; // Value is kept
- }
- else
- {
+ } else {
// var_dump($algo);
$newvalue = dol_hash($this->array_options[$key], $algo);
$new_array_options[$key] = $newvalue;
}
- }
- else
- {
+ } else {
$new_array_options[$key] = $this->array_options[$key]; // Value is kept
}
}
- }
- else // Common usage
+ } else // Common usage
{
$new_array_options[$key] = $this->array_options[$key];
}
@@ -5604,24 +5376,20 @@ abstract class CommonObject
if ($value == '-1') // -1 is key for no defined in combo list of objects
{
$new_array_options[$key] = '';
- }
- elseif ($value)
+ } elseif ($value)
{
$object = new $InfoFieldList[0]($this->db);
if (is_numeric($value)) $res = $object->fetch($value);
else $res = $object->fetch('', $value);
if ($res > 0) $new_array_options[$key] = $object->id;
- else
- {
+ else {
$this->error = "Id/Ref '".$value."' for object '".$object->element."' not found";
$this->db->rollback();
return -1;
}
}
- }
- else
- {
+ } else {
dol_syslog('Error bad setup of extrafield', LOG_WARNING);
}
break;
@@ -5668,9 +5436,7 @@ abstract class CommonObject
if ($new_array_options[$key] != '' || $new_array_options[$key] == '0')
{
$sql .= ",'".$this->db->escape($new_array_options[$key])."'";
- }
- else
- {
+ } else {
$sql .= ",null";
}
}
@@ -5711,14 +5477,11 @@ abstract class CommonObject
{
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->db->commit();
return 1;
}
- }
- else return 0;
+ } else return 0;
}
/**
@@ -5761,8 +5524,7 @@ abstract class CommonObject
{
$this->errors[] = $langs->trans("ExtraLanguageHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value == '')
+ } elseif ($value == '')
{
$new_array_languages[$key] = null;
}
@@ -5774,8 +5536,7 @@ abstract class CommonObject
dol_syslog($langs->trans("ExtraLanguageHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
$this->errors[] = $langs->trans("ExtraLanguageHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value == '')
+ } elseif ($value == '')
{
$new_array_languages[$key] = null;
}
@@ -5834,21 +5595,18 @@ abstract class CommonObject
{
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->db->commit();
return 1;
}
- }
- else return 0;
+ } else return 0;
}
/**
* Update an extra field value for the current object.
* Data to describe values to update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
*
- * @param string $key Key of the extrafield (without starting 'options_')
+ * @param string $key Key of the extrafield to update (without starting 'options_')
* @param string $trigger If defined, call also the trigger (for example COMPANY_MODIFY)
* @param User $userused Object user
* @return int -1=error, O=did nothing, 1=OK
@@ -5889,8 +5647,7 @@ abstract class CommonObject
{
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value === '')
+ } elseif ($value === '')
{
$this->array_options["options_".$key] = null;
}
@@ -5902,8 +5659,7 @@ abstract class CommonObject
dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
- }
- elseif ($value === '')
+ } elseif ($value === '')
{
$this->array_options["options_".$key] = null;
}
@@ -5964,14 +5720,11 @@ abstract class CommonObject
dol_syslog(__METHOD__.$this->error, LOG_ERR);
$this->db->rollback();
return -1;
- }
- else
- {
+ } else {
$this->db->commit();
return 1;
}
- }
- else return 0;
+ } else return 0;
}
/**
@@ -6084,39 +5837,30 @@ abstract class CommonObject
if (empty($morecss) && !empty($val['css']))
{
$morecss = $val['css'];
- }
- elseif (empty($morecss))
+ } elseif (empty($morecss))
{
if ($type == 'date')
{
$morecss = 'minwidth100imp';
- }
- elseif ($type == 'datetime' || $type == 'link') // link means an foreign key to another primary id
+ } elseif ($type == 'datetime' || $type == 'link') // link means an foreign key to another primary id
{
$morecss = 'minwidth200imp';
- }
- elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
+ } elseif (in_array($type, array('int', 'integer', 'price')) || preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
{
$morecss = 'maxwidth75';
} elseif ($type == 'url') {
$morecss = 'minwidth400';
- }
- elseif ($type == 'boolean')
+ } elseif ($type == 'boolean')
{
$morecss = '';
- }
- else
- {
+ } else {
if (round($size) < 12)
{
$morecss = 'minwidth100';
- }
- elseif (round($size) <= 48)
+ } elseif (round($size) <= 48)
{
$morecss = 'minwidth200';
- }
- else
- {
+ } else {
$morecss = 'minwidth400';
}
}
@@ -6134,56 +5878,44 @@ abstract class CommonObject
// TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
- }
- elseif (in_array($type, array('duration')))
+ } elseif (in_array($type, array('duration')))
{
$out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1);
- }
- elseif (in_array($type, array('int', 'integer')))
+ } elseif (in_array($type, array('int', 'integer')))
{
$tmp = explode(',', $size);
$newsize = $tmp[0];
$out = '';
- }
- elseif (in_array($type, array('real')))
+ } elseif (in_array($type, array('real')))
{
$out = '';
- }
- elseif (preg_match('/varchar/', $type))
+ } elseif (preg_match('/varchar/', $type))
{
$out = '';
- }
- elseif (in_array($type, array('mail', 'phone', 'url')))
+ } elseif (in_array($type, array('mail', 'phone', 'url')))
{
$out = '';
- }
- elseif ($type == 'text')
+ } elseif ($type == 'text')
{
if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%');
$out = $doleditor->Create(1);
- }
- else
- {
+ } else {
$out = '';
}
- }
- elseif ($type == 'html')
+ } elseif ($type == 'html')
{
if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
{
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, !empty($conf->fckeditor->enabled) && $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_5, '90%');
$out = $doleditor->Create(1);
- }
- else
- {
+ } else {
$out = '';
}
- }
- elseif ($type == 'boolean')
+ } elseif ($type == 'boolean')
{
$checked = '';
if (!empty($value)) {
@@ -6192,22 +5924,19 @@ abstract class CommonObject
$checked = ' value="1" ';
}
$out = '';
- }
- elseif ($type == 'price')
+ } elseif ($type == 'price')
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value = price($value);
}
$out = ' '.$langs->getCurrencySymbol($conf->currency);
- }
- elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
+ } elseif (preg_match('/^double(\([0-9],[0-9]\)){0,1}/', $type))
{
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value = price($value);
}
$out = ' ';
- }
- elseif ($type == 'select')
+ } elseif ($type == 'select')
{
$out = '';
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
@@ -6228,8 +5957,7 @@ abstract class CommonObject
$out .= '>'.$val.'';
}
$out .= '';
- }
- elseif ($type == 'sellist')
+ } elseif ($type == 'sellist')
{
$out = '';
if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2))
@@ -6296,14 +6024,10 @@ abstract class CommonObject
{
$sql .= ' as main, '.MAIN_DB_PREFIX.$InfoFieldList[0].'_extrafields as extra';
$sqlwhere .= ' WHERE extra.fk_object=main.'.$InfoFieldList[2].' AND '.$InfoFieldList[4];
- }
- else
- {
+ } else {
$sqlwhere .= ' WHERE '.$InfoFieldList[4];
}
- }
- else
- {
+ } else {
$sqlwhere .= ' WHERE 1=1';
}
// Some tables may have field, some other not. For the moment we disable it.
@@ -6338,9 +6062,7 @@ abstract class CommonObject
{
$labeltoshow .= $obj->$field_toshow.' ';
}
- }
- else
- {
+ } else {
$labeltoshow = $obj->{$InfoFieldList[1]};
}
$labeltoshow = dol_trunc($labeltoshow, 45);
@@ -6357,16 +6079,13 @@ abstract class CommonObject
}
}
$out .= '';
- }
- else
- {
+ } else {
if (!$notrans)
{
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
if ($translabel != $obj->{$InfoFieldList[1]}) {
$labeltoshow = dol_trunc($translabel, 18);
- }
- else {
+ } else {
$labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}, 18);
}
}
@@ -6390,19 +6109,16 @@ abstract class CommonObject
$i++;
}
$this->db->free($resql);
- }
- else {
+ } else {
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
';
}
}
$out .= '';
- }
- elseif ($type == 'checkbox')
+ } elseif ($type == 'checkbox')
{
$value_arr = explode(',', $value);
$out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%');
- }
- elseif ($type == 'radio')
+ } elseif ($type == 'radio')
{
$out = '';
foreach ($param['options'] as $keyopt => $val)
@@ -6413,13 +6129,11 @@ abstract class CommonObject
$out .= ($value == $keyopt ? 'checked' : '');
$out .= '/>
';
}
- }
- elseif ($type == 'chkbxlst')
+ } elseif ($type == 'chkbxlst')
{
if (is_array($value)) {
$value_arr = $value;
- }
- else {
+ } else {
$value_arr = explode(',', $value);
}
@@ -6557,8 +6271,7 @@ abstract class CommonObject
print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
';
}
}
- }
- elseif ($type == 'link')
+ } elseif ($type == 'link')
{
$param_list = array_keys($param['options']); // $param_list='ObjectName:classPath[:AddCreateButtonOrNot[:Filter]]'
$param_list_array = explode(':', $param_list[0]);
@@ -6583,13 +6296,11 @@ abstract class CommonObject
$out .= '';
}
}
- }
- elseif ($type == 'password')
+ } elseif ($type == 'password')
{
// If prefix is 'search_', field is used as a filter, we use a common text field.
$out = '';
- }
- elseif ($type == 'array')
+ } elseif ($type == 'array')
{
$newval = $val;
$newval['type'] = 'varchar(256)';
@@ -6668,8 +6379,7 @@ abstract class CommonObject
{
$type = 'varchar'; // convert varchar(xx) int varchar
$size = $reg[1];
- }
- elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
+ } elseif (preg_match('/varchar/', $type)) $type = 'varchar'; // convert varchar(xx) int varchar
if (is_array($val['arrayofkeyval'])) $type = 'select';
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) $type = 'link';
@@ -6685,8 +6395,7 @@ abstract class CommonObject
{
$type = 'link';
$param['options'] = array($reg[1].':'.$reg[2]=>$reg[1].':'.$reg[2]);
- }
- elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
+ } elseif (preg_match('/^sellist:(.*):(.*):(.*):(.*)/i', $val['type'], $reg)) {
$param['options'] = array($reg[1].':'.$reg[2].':'.$reg[3].':'.$reg[4] => 'N');
$type = 'sellist';
}
@@ -6711,35 +6420,26 @@ abstract class CommonObject
if ($type == 'date')
{
$morecss = 'minwidth100imp';
- }
- elseif ($type == 'datetime' || $type == 'timestamp')
+ } elseif ($type == 'datetime' || $type == 'timestamp')
{
$morecss = 'minwidth200imp';
- }
- elseif (in_array($type, array('int', 'double', 'price')))
+ } elseif (in_array($type, array('int', 'double', 'price')))
{
$morecss = 'maxwidth75';
- }
- elseif ($type == 'url')
+ } elseif ($type == 'url')
{
$morecss = 'minwidth400';
- }
- elseif ($type == 'boolean')
+ } elseif ($type == 'boolean')
{
$morecss = '';
- }
- else
- {
+ } else {
if (round($size) < 12)
{
$morecss = 'minwidth100';
- }
- elseif (round($size) <= 48)
+ } elseif (round($size) <= 48)
{
$morecss = 'minwidth200';
- }
- else
- {
+ } else {
$morecss = 'minwidth400';
}
}
@@ -6755,59 +6455,49 @@ abstract class CommonObject
} else {
$value = '';
}
- }
- elseif ($type == 'datetime' || $type == 'timestamp')
+ } elseif ($type == 'datetime' || $type == 'timestamp')
{
if (!empty($value)) {
$value = dol_print_date($value, 'dayhour');
} else {
$value = '';
}
- }
- elseif ($type == 'duration')
+ } elseif ($type == 'duration')
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
if (!is_null($value) && $value !== '') {
$value = convertSecondToTime($value, 'allhourmin');
}
- }
- elseif ($type == 'double' || $type == 'real')
+ } elseif ($type == 'double' || $type == 'real')
{
if (!is_null($value) && $value !== '') {
$value = price($value);
}
- }
- elseif ($type == 'boolean')
+ } elseif ($type == 'boolean')
{
$checked = '';
if (!empty($value)) {
$checked = ' checked ';
}
$value = '';
- }
- elseif ($type == 'mail')
+ } elseif ($type == 'mail')
{
$value = dol_print_email($value, 0, 0, 0, 64, 1, 1);
- }
- elseif ($type == 'url')
+ } elseif ($type == 'url')
{
$value = dol_print_url($value, '_blank', 32, 1);
- }
- elseif ($type == 'phone')
+ } elseif ($type == 'phone')
{
$value = dol_print_phone($value, '', 0, 0, '', ' ', 1);
- }
- elseif ($type == 'price')
+ } elseif ($type == 'price')
{
if (!is_null($value) && $value !== '') {
$value = price($value, 0, $langs, 0, 0, -1, $conf->currency);
}
- }
- elseif ($type == 'select')
+ } elseif ($type == 'select')
{
$value = $param['options'][$value];
- }
- elseif ($type == 'sellist')
+ } elseif ($type == 'sellist')
{
$param_list = array_keys($param['options']);
$InfoFieldList = explode(":", $param_list[0]);
@@ -6868,9 +6558,7 @@ abstract class CommonObject
$value .= $obj->$field_toshow.' ';
}
}
- }
- else
- {
+ } else {
$translabel = '';
if (!empty($obj->{$InfoFieldList[1]})) {
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
@@ -6881,14 +6569,11 @@ abstract class CommonObject
$value = $obj->{$InfoFieldList[1]};
}
}
- }
- else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
- }
- elseif ($type == 'radio')
+ } else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
+ } elseif ($type == 'radio')
{
$value = $param['options'][$value];
- }
- elseif ($type == 'checkbox')
+ } elseif ($type == 'checkbox')
{
$value_arr = explode(',', $value);
$value = '';
@@ -6900,8 +6585,7 @@ abstract class CommonObject
}
$value = '
';
}
- }
- else
- {
+ } else {
if (empty($maxHeight) || $photo_vignette && $imgarray['height'] > $maxHeight)
{
$return .= '';
$return .= '