diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 741f5f086a9..3020c53f83d 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1248,9 +1248,7 @@ abstract class CommonObject
{
$sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,";
$sql .= " tc.code, tc.libelle";
- //$sql.= ", s.fk_soc";
$sql .= " FROM (".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc)";
- //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as s ON ec.fk_socpeople=s.rowid"; // Si contact de type external, alors il est lie a une societe
$sql .= " WHERE ec.rowid =".$rowid;
$sql .= " AND ec.fk_c_type_contact=tc.rowid";
$sql .= " AND tc.element = '".$this->db->escape($this->element)."'";
@@ -2449,8 +2447,6 @@ abstract class CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
$sql .= " SET model_pdf = '".$this->db->escape($newmodelpdf)."'";
$sql .= " WHERE rowid = ".$this->id;
- // if ($this->element == 'facture') $sql.= " AND fk_statut < 2";
- // if ($this->element == 'propal') $sql.= " AND fk_statut = 0";
dol_syslog(get_class($this)."::setDocModel", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -2565,8 +2561,7 @@ abstract class CommonObject
} 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
- // counter that parents.
+ // The goal of this part is to reorder all lines, with all children lines sharing the same counter that parents.
$rows = array();
// We first search all lines that are parent lines (for multilevel details lines)
@@ -5459,7 +5454,6 @@ abstract class CommonObject
$sql .= ")";
$resql = $this->db->query($sql);
-
if (!$resql)
{
$this->error = $this->db->lasterror();
@@ -5927,8 +5921,7 @@ abstract class CommonObject
}
}
- if (in_array($type, array('date', 'datetime')))
- {
+ if (in_array($type, array('date', 'datetime'))) {
$tmp = explode(',', $size);
$newsize = $tmp[0];
@@ -5939,25 +5932,19 @@ 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 (preg_match('/^text/', $type))
- {
+ } elseif (preg_match('/^text/', $type)) {
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';
@@ -5966,18 +5953,15 @@ abstract class CommonObject
} else {
$out = '';
}
- } elseif (preg_match('/^html/', $type))
- {
- if (!preg_match('/search_/', $keyprefix)) // If keyprefix is search_ or search_options_, we must just use a simple text field
- {
+ } elseif (preg_match('/^html/', $type)) {
+ 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 {
$out = '';
}
- } elseif ($type == 'boolean')
- {
+ } elseif ($type == 'boolean') {
$checked = '';
if (!empty($value)) {
$checked = ' checked value="1" ';
@@ -5985,20 +5969,17 @@ 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))
{
@@ -6018,18 +5999,15 @@ 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))
- {
+ if (!empty($conf->use_javascript_ajax) && !empty($conf->global->MAIN_EXTRAFIELDS_USE_SELECT2)) {
include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
$out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0);
}
$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)
{
@@ -6190,8 +6166,7 @@ abstract class CommonObject
$out .= ($value == $keyopt ? 'checked' : '');
$out .= '/>
';
}
- } elseif ($type == 'chkbxlst')
- {
+ } elseif ($type == 'chkbxlst') {
if (is_array($value)) {
$value_arr = $value;
} else {
@@ -6332,8 +6307,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]);
$showempty = (($required && $default != '') ? 0 : 1);
@@ -6358,25 +6332,20 @@ 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)';
$out = '';
-
- $inputs = array();
if (!empty($value)) {
foreach ($value as $option) {
$out .= ' ';
$out .= $this->showInputField($newval, $keyprefix.$key.$keysuffix.'[]', $option, $moreparam, '', '', $morecss).'
';
}
}
-
$out .= '';
$newInput = ' ';
@@ -6479,27 +6448,20 @@ abstract class CommonObject
if (empty($morecss))
{
- if ($type == 'date')
- {
+ 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 {
- if (round($size) < 12)
- {
+ if (round($size) < 12) {
$morecss = 'minwidth100';
- } elseif (round($size) <= 48)
- {
+ } elseif (round($size) <= 48) {
$morecss = 'minwidth200';
} else {
$morecss = 'minwidth400';
@@ -6510,57 +6472,47 @@ abstract class CommonObject
// Format output value differently according to properties of field
if ($key == 'ref' && method_exists($this, 'getNomUrl')) $value = $this->getNomUrl(1, '', 0, '', 1);
elseif ($key == 'status' && method_exists($this, 'getLibStatut')) $value = $this->getLibStatut(3);
- elseif ($type == 'date')
- {
+ elseif ($type == 'date') {
if (!empty($value)) {
$value = dol_print_date($value, 'day');
} 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')
{
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]);
@@ -6632,11 +6584,9 @@ abstract class CommonObject
}
}
} else dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
- } elseif ($type == 'radio')
- {
+ } elseif ($type == 'radio') {
$value = $param['options'][$value];
- } elseif ($type == 'checkbox')
- {
+ } elseif ($type == 'checkbox') {
$value_arr = explode(',', $value);
$value = '';
if (is_array($value_arr) && count($value_arr) > 0)
@@ -6647,8 +6597,7 @@ abstract class CommonObject
}
$value = ''.implode(' ', $toprint).'
';
}
- } elseif ($type == 'chkbxlst')
- {
+ } elseif ($type == 'chkbxlst') {
$value_arr = explode(',', $value);
$param_list = array_keys($param['options']);
@@ -6714,8 +6663,7 @@ abstract class CommonObject
} else {
dol_syslog(get_class($this).'::showOutputField error '.$this->db->lasterror(), LOG_WARNING);
}
- } elseif ($type == 'link')
- {
+ } elseif ($type == 'link') {
$out = '';
// only if something to display (perf)
@@ -6741,14 +6689,11 @@ abstract class CommonObject
return 'Error bad setup of extrafield';
}
} else $value = '';
- } elseif (preg_match('/^(text|html)/', $type))
- {
+ } elseif (preg_match('/^(text|html)/', $type)) {
$value = dol_htmlentitiesbr($value);
- } elseif ($type == 'password')
- {
+ } elseif ($type == 'password') {
$value = preg_replace('/./i', '*', $value);
- } elseif ($type == 'array')
- {
+ } elseif ($type == 'array') {
$value = implode('
', $value);
}
@@ -7381,8 +7326,7 @@ abstract class CommonObject
*/
protected function isArray($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['type']) && $info['type'] == 'array') return true;
else return false;
}
@@ -7409,8 +7353,7 @@ abstract class CommonObject
*/
public function isDuration($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['type']) && ($info['type'] == 'duration')) return true;
else return false;
} else return false;
@@ -7424,8 +7367,7 @@ abstract class CommonObject
*/
public function isInt($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['type']) && ($info['type'] == 'int' || preg_match('/^integer/i', $info['type']))) return true;
else return false;
} else return false;
@@ -7439,8 +7381,7 @@ abstract class CommonObject
*/
public function isFloat($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['type']) && (preg_match('/^(double|real|price)/i', $info['type']))) return true;
else return false;
}
@@ -7455,8 +7396,7 @@ abstract class CommonObject
*/
public function isText($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['type']) && $info['type'] == 'text') return true;
else return false;
}
@@ -7471,8 +7411,7 @@ abstract class CommonObject
*/
protected function canBeNull($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['notnull']) && $info['notnull'] != '1') return true;
else return false;
}
@@ -7487,8 +7426,7 @@ abstract class CommonObject
*/
protected function isForcedToNullIfZero($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['notnull']) && $info['notnull'] == '-1') return true;
else return false;
}
@@ -7503,8 +7441,7 @@ abstract class CommonObject
*/
protected function isIndex($info)
{
- if (is_array($info))
- {
+ if (is_array($info)) {
if (isset($info['index']) && $info['index'] == true) return true;
else return false;
}
@@ -7591,8 +7528,7 @@ abstract class CommonObject
{
foreach ($this->fields as $field => $info)
{
- if ($this->isDate($info))
- {
+ if ($this->isDate($info)) {
if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') $this->{$field} = 0;
else $this->{$field} = strtotime($obj->{$field});
} elseif ($this->isArray($info))
@@ -7604,12 +7540,10 @@ abstract class CommonObject
} else {
$this->{$field} = array();
}
- } elseif ($this->isInt($info))
- {
+ } elseif ($this->isInt($info)) {
if ($field == 'rowid') $this->id = (int) $obj->{$field};
else {
- if ($this->isForcedToNullIfZero($info))
- {
+ if ($this->isForcedToNullIfZero($info)) {
if (empty($obj->{$field})) $this->{$field} = null;
else $this->{$field} = (double) $obj->{$field};
} else {
@@ -7620,10 +7554,8 @@ abstract class CommonObject
}
}
}
- } elseif ($this->isFloat($info))
- {
- if ($this->isForcedToNullIfZero($info))
- {
+ } elseif ($this->isFloat($info)) {
+ if ($this->isForcedToNullIfZero($info)) {
if (empty($obj->{$field})) $this->{$field} = null;
else $this->{$field} = (double) $obj->{$field};
} else {