';
diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php
index 1f22b67ac7c..caca78033d6 100644
--- a/htdocs/compta/bank/line.php
+++ b/htdocs/compta/bank/line.php
@@ -272,7 +272,8 @@ $sql .= " WHERE rowid=".$rowid;
$sql .= " ORDER BY dateo ASC";
$result = $db->query($sql);
if ($result) {
- $i = 0; $total = 0;
+ $i = 0;
+ $total = 0;
if ($db->num_rows($result)) {
$objp = $db->fetch_object($result);
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index 6c2e595e3d1..2882a4635fd 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -134,7 +134,8 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
*/
if (GETPOST('cancel', 'alpha')) {
- $action = 'list'; $massaction = '';
+ $action = 'list';
+ $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
@@ -490,7 +491,10 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $
print "\n";
-$totalarray = array(); $found = 0; $i = 0; $lastcurrencycode = '';
+$totalarray = array();
+$found = 0;
+$i = 0;
+$lastcurrencycode = '';
foreach ($accounts as $key => $type) {
if ($i >= $limit) {
diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php
index 27dfe941f88..d19ccbed908 100644
--- a/htdocs/compta/bank/various_payment/card.php
+++ b/htdocs/compta/bank/various_payment/card.php
@@ -341,8 +341,7 @@ foreach ($bankcateg->fetchAll() as $bankcategory) {
/* ************************************************************************** */
if ($action == 'create') {
// Update fields properties in realtime
- if (!empty($conf->use_javascript_ajax))
- {
+ if (!empty($conf->use_javascript_ajax)) {
print "\n".''."\n";
- }
-
- $out .= ' '."\n";
- }
- }
-
- $out .= $hookmanager->resPrint;
-
return $out;
}
-
/**
* Returns the rights used for this class
* @return stdClass
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index 19555adf3fb..6b50c73da8e 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -80,6 +80,9 @@ class Conf
'syslog' => array(),
);
+ // An array to store cache results ->cache['nameofcache']=...
+ public $cache = array();
+
public $logbuffer = array();
/**
@@ -196,13 +199,13 @@ class Conf
$this->modules_parts[$partname] = array();
}
$this->modules_parts[$partname][$params[0]][] = $value; // $value may be a string or an array
- }
- // If this is constant for all generic part activated by a module. It initializes
- // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
- // modules_parts['models'], modules_parts['theme']
- // modules_parts['sms'],
- // modules_parts['css'], ...
- elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
+ } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
+ // If this is constant for all generic part activated by a module. It initializes
+ // modules_parts['login'], modules_parts['menus'], modules_parts['substitutions'], modules_parts['triggers'], modules_parts['tpl'],
+ // modules_parts['models'], modules_parts['theme']
+ // modules_parts['sms'],
+ // modules_parts['css'], ...
+
$modulename = strtolower($reg[1]);
$partname = strtolower($reg[2]);
if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
@@ -221,9 +224,8 @@ class Conf
$value = '/'.$modulename.'/core/modules/'.$partname.'/'; // ex: partname = societe
}
$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value)); // $value may be a string or an array
- }
- // If this is a module constant (must be at end)
- elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
+ } elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
+ // If this is a module constant (must be at end)
$modulename = strtolower($reg[1]);
if ($modulename == 'propale') {
$modulename = 'propal';
diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php
index acddb09d547..66ee803d41a 100644
--- a/htdocs/core/class/cstate.class.php
+++ b/htdocs/core/class/cstate.class.php
@@ -123,7 +123,8 @@ class Cstate // extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
@@ -229,7 +230,8 @@ class Cstate // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
@@ -266,7 +268,8 @@ class Cstate // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php
index ff2bcc58f40..01a6eb5e697 100644
--- a/htdocs/core/class/ctypent.class.php
+++ b/htdocs/core/class/ctypent.class.php
@@ -130,7 +130,8 @@ class Ctypent // extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
@@ -244,7 +245,8 @@ class Ctypent // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
@@ -282,7 +284,8 @@ class Ctypent // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php
index 757e3fb0e66..e55d227de0e 100644
--- a/htdocs/core/class/cunits.class.php
+++ b/htdocs/core/class/cunits.class.php
@@ -133,7 +133,8 @@ class CUnits // extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
if (!$error) {
@@ -351,7 +352,8 @@ class CUnits // extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
@@ -389,7 +391,8 @@ class CUnits // extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
if (!$resql) {
- $error++; $this->errors[] = "Error ".$this->db->lasterror();
+ $error++;
+ $this->errors[] = "Error ".$this->db->lasterror();
}
// Commit or rollback
diff --git a/htdocs/core/class/defaultvalues.class.php b/htdocs/core/class/defaultvalues.class.php
new file mode 100644
index 00000000000..4244d0f63af
--- /dev/null
+++ b/htdocs/core/class/defaultvalues.class.php
@@ -0,0 +1,352 @@
+
+ * Copyright (C) 2021 Florian HENRY
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/code/class/defaultvalues.class.php
+ * \brief This file is a CRUD class file for DefaultValues (Create/Read/Update/Delete)
+ */
+
+// Put here all includes required by your class file
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
+//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
+
+/**
+ * Class for MyObject
+ */
+class DefaultValues extends CommonObject
+{
+ /**
+ * @var string ID to identify managed object.
+ */
+ public $element = 'defaultvalues';
+
+ /**
+ * @var string Name of table without prefix where object is stored. This is also the key used for extrafields management.
+ */
+ public $table_element = 'default_values';
+
+ /**
+ * @var int Does this object support multicompany module ?
+ * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
+ */
+ public $ismultientitymanaged = 1;
+
+ /**
+ * @var int Does object support extrafields ? 0=No, 1=Yes
+ */
+ public $isextrafieldmanaged = 0;
+
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = '';
+
+ /**
+ * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
+ * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
+ * 'label' the translation key.
+ * 'picto' is code of a picto to show before value in forms
+ * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
+ * 'position' is the sort order of field.
+ * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
+ * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
+ * 'noteditable' says if field is not editable (1 or 0)
+ * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
+ * 'index' if we want an index in database.
+ * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
+ * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
+ * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
+ * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
+ * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
+ * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
+ * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
+ * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
+ * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
+ * 'comment' is not used. You can store here any text of your choice. It is not used by application.
+ *
+ * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
+ */
+
+ // BEGIN MODULEBUILDER PROPERTIES
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields=array(
+ 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1),
+ 'type' =>array('type'=>'varchar(10)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
+ 'user_id' =>array('type'=>'integer', 'label'=>'Userid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25),
+ 'page' =>array('type'=>'varchar(255)', 'label'=>'RelativeURL', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
+ 'param' =>array('type'=>'varchar(255)', 'label'=>'Field', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
+ 'value' =>array('type'=>'varchar(128)', 'label'=>'Value', 'enabled'=>1, 'visible'=>-1, 'position'=>40),
+ );
+
+ /**
+ * @var int ID
+ */
+ public $rowid;
+
+ /**
+ * @var int Entity
+ */
+ public $entity;
+
+ /**
+ * @var string Type
+ */
+ public $type;
+
+ /**
+ * @var int User Id
+ */
+ public $user_id;
+
+ /**
+ * @var string Page
+ */
+ public $page;
+
+ /**
+ * @var string Param
+ */
+ public $param;
+
+ /**
+ * @var string Value
+ */
+ public $value;
+ // END MODULEBUILDER PROPERTIES
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ public function __construct(DoliDB $db)
+ {
+ global $conf, $langs;
+
+ $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;
+
+ // Unset fields that are disabled
+ foreach ($this->fields as $key => $val) {
+ if (isset($val['enabled']) && empty($val['enabled'])) {
+ unset($this->fields[$key]);
+ }
+ }
+
+ // Translate some data of arrayofkeyval
+ if (is_object($langs)) {
+ foreach ($this->fields as $key => $val) {
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
+ foreach ($val['arrayofkeyval'] as $key2 => $val2) {
+ $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ public function create(User $user, $notrigger = false)
+ {
+ return $this->createCommon($user, $notrigger);
+ }
+
+ /**
+ * Clone an object into another one
+ *
+ * @param User $user User that creates
+ * @param int $fromid Id of object to clone
+ * @return mixed New object created, <0 if KO
+ */
+ public function createFromClone(User $user, $fromid)
+ {
+ global $langs, $extrafields;
+ $error = 0;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $object = new self($this->db);
+
+ $this->db->begin();
+
+ // Load source object
+ $result = $object->fetchCommon($fromid);
+ if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
+
+
+ // Reset some properties
+ unset($object->id);
+
+ // Create clone
+ $object->context['createfromclone'] = 'createfromclone';
+ $result = $object->createCommon($user);
+ if ($result < 0) {
+ $error++;
+ $this->error = $object->error;
+ $this->errors = $object->errors;
+ }
+
+ unset($object->context['createfromclone']);
+
+ // End
+ if (!$error) {
+ $this->db->commit();
+ return $object;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @return int <0 if KO, 0 if not found, >0 if OK
+ */
+ public function fetch($id)
+ {
+ $result = $this->fetchCommon($id, null);
+ return $result;
+ }
+
+ /**
+ * Load list of objects in memory from the database.
+ *
+ * @param string $sortorder Sort Order
+ * @param string $sortfield Sort field
+ * @param int $limit limit
+ * @param int $offset Offset
+ * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...)
+ * @param string $filtermode Filter mode (AND or OR)
+ * @return array|int int <0 if KO, array of pages if OK
+ */
+ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
+ {
+ global $conf;
+
+ dol_syslog(__METHOD__, LOG_DEBUG);
+
+ $records = array();
+
+ $sql = 'SELECT ';
+ $sql .= $this->getFieldList();
+ $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+ $sql .= ' WHERE 1 = 1';
+ // Manage filter
+ $sqlwhere = array();
+ if (count($filter) > 0) {
+ foreach ($filter as $key => $value) {
+ if ($key == 't.rowid' || ($key == 't.entity' && !is_array($value)) || ($key == 't.user_id' && !is_array($value))) {
+ $sqlwhere[] = $key.'='.$value;
+ } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
+ $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\'';
+ } elseif ($key == 't.page' || $key == 't.param' || $key == 't.type') {
+ $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\'';
+ } elseif ($key == 'customsql') {
+ $sqlwhere[] = $value;
+ } elseif (is_array($value)) {
+ $sqlwhere[] = $key.' IN ('.implode(',', $value).')';
+ } else {
+ $sqlwhere[] = $key.' LIKE \'%'.$this->db->escape($value).'%\'';
+ }
+ }
+ }
+ if (count($sqlwhere) > 0) {
+ $sql .= ' AND ('.implode(' '.$filtermode.' ', $sqlwhere).')';
+ }
+
+ if (!empty($sortfield)) {
+ $sql .= $this->db->order($sortfield, $sortorder);
+ }
+ if (!empty($limit)) {
+ $sql .= ' '.$this->db->plimit($limit, $offset);
+ }
+
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < ($limit ? min($limit, $num) : $num)) {
+ $obj = $this->db->fetch_object($resql);
+
+ $record = new self($this->db);
+ $record->setVarsFromFetchObj($obj);
+
+ $records[$record->id] = $record;
+
+ $i++;
+ }
+ $this->db->free($resql);
+
+ return $records;
+ } else {
+ $this->errors[] = 'Error '.$this->db->lasterror();
+ dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
+
+ return -1;
+ }
+ }
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update(User $user, $notrigger = false)
+ {
+ return $this->updateCommon($user, $notrigger);
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param bool $notrigger false=launch triggers after, true=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete(User $user, $notrigger = false)
+ {
+ return $this->deleteCommon($user, $notrigger);
+ }
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ $this->initAsSpecimenCommon();
+ }
+}
diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php
index 0eecbbf6d36..b4218bbfd40 100644
--- a/htdocs/core/class/dolgeoip.class.php
+++ b/htdocs/core/class/dolgeoip.class.php
@@ -61,7 +61,8 @@ class DolGeoIP
require_once DOL_DOCUMENT_ROOT.'/includes/geoip2/geoip2.phar';
}
} else {
- print 'ErrorBadParameterInConstructor'; return 0;
+ print 'ErrorBadParameterInConstructor';
+ return 0;
}
// Here, function exists (embedded into PHP or exists because we made include)
@@ -129,7 +130,7 @@ class DolGeoIP
}
} else {
if (!function_exists('geoip_country_code_by_addr')) {
- return strtolower(geoip_country_code_by_name($this->gi, $ip));
+ return strtolower(geoip_country_code_by_name($ip));
}
return strtolower(geoip_country_code_by_addr($this->gi, $ip));
}
diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php
index 607993dc325..3672f7faa07 100644
--- a/htdocs/core/class/dolgraph.class.php
+++ b/htdocs/core/class/dolgraph.class.php
@@ -908,9 +908,8 @@ class DolGraph
$this->stringtoshow .= 'legend: {show: ' . ($showlegend ? 'true' : 'false') . ', position: \'ne\' }
});
}' . "\n";
- }
- // Other cases, graph of type 'bars', 'lines'
- else {
+ } else {
+ // Other cases, graph of type 'bars', 'lines'
// Add code to support tooltips
// TODO: remove js css and use graph-tooltip-inner class instead by adding css in each themes
$this->stringtoshow .= '
@@ -1262,9 +1261,8 @@ class DolGraph
$this->stringtoshow .= ']' . "\n";
$this->stringtoshow .= '}' . "\n";
$this->stringtoshow .= '});' . "\n";
- }
- // Other cases, graph of type 'bars', 'lines', 'linesnopoint'
- else {
+ } else {
+ // Other cases, graph of type 'bars', 'lines', 'linesnopoint'
$type = 'bar';
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') {
diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php
index 6f674c0b600..980c8c53dde 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -147,7 +147,8 @@ class Events // extends CommonObject
// Check parameters
if (empty($this->description)) {
- $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1;
+ $this->error = 'ErrorBadValueForParameterCreateEventDesc';
+ return -1;
}
// Insert request
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 35747920ec5..5a5b06054ff 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -251,7 +251,8 @@ class ExtraFields
}
if ($type == 'separate') {
- $unique = 0; $required = 0;
+ $unique = 0;
+ $required = 0;
} // Force unique and not required if this is a separator field to avoid troubles.
if ($elementtype == 'thirdparty') {
$elementtype = 'societe';
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index 21d948b2160..45bc622b9db 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -70,7 +70,8 @@ class FileUpload
$element = $pathname = 'projet';
$dir_output = $conf->$element->dir_output;
} elseif ($element == 'project_task') {
- $pathname = 'projet'; $filename = 'task';
+ $pathname = 'projet';
+ $filename = 'task';
$dir_output = $conf->projet->dir_output;
$parentForeignKey = 'fk_project';
$parentClass = 'Project';
@@ -80,20 +81,24 @@ class FileUpload
$element = 'ficheinter';
$dir_output = $conf->$element->dir_output;
} elseif ($element == 'order_supplier') {
- $pathname = 'fourn'; $filename = 'fournisseur.commande';
+ $pathname = 'fourn';
+ $filename = 'fournisseur.commande';
$dir_output = $conf->fournisseur->commande->dir_output;
} elseif ($element == 'invoice_supplier') {
- $pathname = 'fourn'; $filename = 'fournisseur.facture';
+ $pathname = 'fourn';
+ $filename = 'fournisseur.facture';
$dir_output = $conf->fournisseur->facture->dir_output;
} elseif ($element == 'product') {
$dir_output = $conf->product->multidir_output[$conf->entity];
} elseif ($element == 'productbatch') {
$dir_output = $conf->productbatch->multidir_output[$conf->entity];
} elseif ($element == 'action') {
- $pathname = 'comm/action'; $filename = 'actioncomm';
+ $pathname = 'comm/action';
+ $filename = 'actioncomm';
$dir_output = $conf->agenda->dir_output;
} elseif ($element == 'chargesociales') {
- $pathname = 'compta/sociales'; $filename = 'chargesociales';
+ $pathname = 'compta/sociales';
+ $filename = 'chargesociales';
$dir_output = $conf->tax->dir_output;
} else {
$dir_output = $conf->$element->dir_output;
diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php
index 8b211a34864..9d3ea8f39d6 100644
--- a/htdocs/core/class/hookmanager.class.php
+++ b/htdocs/core/class/hookmanager.class.php
@@ -228,11 +228,14 @@ class HookManager
}
// Init return properties
- $this->resPrint = ''; $this->resArray = array(); $this->resNbOfHooks = 0;
+ $this->resPrint = '';
+ $this->resArray = array();
+ $this->resNbOfHooks = 0;
// Loop on each hook to qualify modules that have declared context
$modulealreadyexecuted = array();
- $resaction = 0; $error = 0;
+ $resaction = 0;
+ $error = 0;
foreach ($this->hooks as $context => $modules) { // $this->hooks is an array with context as key and value is an array of modules that handle this context
if (!empty($modules)) {
foreach ($modules as $module => $actionclassinstance) {
@@ -265,7 +268,8 @@ class HookManager
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
if ($resaction < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) {
$error++;
- $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
+ $this->error = $actionclassinstance->error;
+ $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR);
}
@@ -275,9 +279,8 @@ class HookManager
if (!empty($actionclassinstance->resprints)) {
$this->resPrint .= $actionclassinstance->resprints;
}
- }
- // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
- else {
+ } else {
+ // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
// TODO. this test should be done into the method of hook by returning nothing
if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) {
continue;
@@ -294,14 +297,16 @@ class HookManager
}
if (is_numeric($resaction) && $resaction < 0) {
$error++;
- $this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
+ $this->error = $actionclassinstance->error;
+ $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR);
}
// TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string
if (!is_array($resaction) && !is_numeric($resaction)) {
dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR);
if (empty($actionclassinstance->resprints)) {
- $this->resPrint .= $resaction; $resaction = 0;
+ $this->resPrint .= $resaction;
+ $resaction = 0;
}
}
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 08a83d5ad0a..dd93dd268b7 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -488,7 +488,8 @@ class Form
$out .= ''."\n"; // Use for timestamp format
} elseif (preg_match('/^(select|autocomplete)/', $inputType)) {
$tmp = explode(':', $inputType);
- $inputType = $tmp[0]; $loadmethod = $tmp[1];
+ $inputType = $tmp[0];
+ $loadmethod = $tmp[1];
if (!empty($tmp[2])) {
$savemethod = $tmp[2];
}
@@ -502,7 +503,8 @@ class Form
$cols = (empty($tmp[2]) ? '80' : $tmp[2]);
} elseif (preg_match('/^ckeditor/', $inputType)) {
$tmp = explode(':', $inputType);
- $inputType = $tmp[0]; $toolbar = $tmp[1];
+ $inputType = $tmp[0];
+ $toolbar = $tmp[1];
if (!empty($tmp[2])) {
$width = $tmp[2];
}
@@ -594,15 +596,18 @@ class Form
$extrastyle = '';
if ($direction < 0) {
- $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-left: 3px !important;';
+ $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : '');
+ $extrastyle = 'padding: 0px; padding-left: 3px !important;';
}
if ($direction > 0) {
- $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : ''); $extrastyle = 'padding: 0px; padding-right: 3px !important;';
+ $extracss = ($extracss ? $extracss.' ' : '').($notabs != 3 ? 'inline-block' : '');
+ $extrastyle = 'padding: 0px; padding-right: 3px !important;';
}
$classfortooltip = 'classfortooltip';
- $s = ''; $textfordialog = '';
+ $s = '';
+ $textfordialog = '';
if ($tooltiptrigger == '') {
$htmltext = str_replace('"', '"', $htmltext);
@@ -2084,7 +2089,8 @@ class Form
if ($nbassignetouser) {
$out .= '
';
}
- $i = 0; $ownerid = 0;
+ $i = 0;
+ $ownerid = 0;
foreach ($assignedtouser as $key => $value) {
if ($value['id'] == $ownerid) {
continue;
@@ -2094,7 +2100,8 @@ class Form
$userstatic->fetch($value['id']);
$out .= $userstatic->getNomUrl(-1);
if ($i == 0) {
- $ownerid = $value['id']; $out .= ' ('.$langs->trans("Owner").')';
+ $ownerid = $value['id'];
+ $out .= ' ('.$langs->trans("Owner").')';
}
if ($nbassignetouser > 1 && $action != 'view') {
$out .= ' ';
@@ -3729,15 +3736,17 @@ class Form
* @param string $htmlname Nom de la zone select
* @param string $exclude To exclude a code value (Example: SRC_PROP)
* @param int $addempty Add an empty entry
+ * @param string $morecss Add more css to the HTML select component
+ * @param int $notooltip Do not show the tooltip for admin
* @return void
*/
- public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0)
+ public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0, $morecss = '', $notooltip = 0)
{
global $langs, $user;
$this->loadCacheInputReason();
- print '