';
$columntitle = "WithdrawalsReceipts";
+ $columntitlethirdparty = "CustomerCode";
+ $columncodethirdparty = "s.code_client";
if ($type == 'bank-transfer') {
$columntitle = "BankTransferReceipts";
+ $columntitlethirdparty = "SupplierCode";
+ $columncodethirdparty = "s.code_fournisseur";
}
print '
| '.$form->editfieldkey('Categories', 'contcats', '', $object, 0).' | ';
print '';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1);
diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php
index 41a6a74dd4b..0ba88228666 100644
--- a/htdocs/contact/consumption.php
+++ b/htdocs/contact/consumption.php
@@ -167,7 +167,7 @@ if ($object->thirdparty->client) {
}
}
-if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) {
+if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) {
$elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
}
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 801c859924e..1e497b0ab2e 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -342,6 +342,9 @@ $formother = new FormOther($db);
$formcompany = new FormCompany($db);
$contactstatic = new Contact($db);
+$morejs=array();
+$morecss = array();
+
if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
$contactstatic->loadCacheOfProspStatus();
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 317aebecfd1..eb3a29bb3e9 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -1263,9 +1263,9 @@ if ($action == 'create') {
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1);
} elseif ($action == 'activate') {
$formquestion = array(
- array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), /*'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0),*/ /*'socid', '(s.client=1 OR s.client=2 OR s.client=3)'*/),
+ array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), 'value' => dol_now()),
array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ '', ''),
- array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300')
+ array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300', 'moreattr'=>'autofocus')
);
$formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280);
} elseif ($action == 'clone') {
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index 506a1465fdc..39dba81976f 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -61,7 +61,7 @@ if ($action == 'add' && !empty($permissiontoadd)) {
continue; // The field was not submited to be saved
}
} else {
- if (!GETPOSTISSET($key)) {
+ if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
continue; // The field was not submited to be saved
}
}
@@ -91,6 +91,12 @@ if ($action == 'add' && !empty($permissiontoadd)) {
} elseif ($object->fields[$key]['type'] == 'reference') {
$tmparraykey = array_keys($object->param_list);
$value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2');
+ } elseif (preg_match('/^chkbxlst:(.*)/', $object->fields[$key]['type'])) {
+ $value = '';
+ $values_arr = GETPOST($key, 'array');
+ if (!empty($values_arr)) {
+ $value = implode(',', $values_arr);
+ }
} else {
if ($key == 'lang') {
$value = GETPOST($key, 'aZ09') ?GETPOST($key, 'aZ09') : "";
@@ -134,6 +140,8 @@ if ($action == 'add' && !empty($permissiontoadd)) {
}
if (!$error) {
+ $db->begin();
+
$result = $object->create($user);
if ($result > 0) {
// Creation OK
@@ -141,14 +149,19 @@ if ($action == 'add' && !empty($permissiontoadd)) {
$categories = GETPOST('categories', 'array:int');
$object->setCategories($categories);
}
+
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
+ $db->commit();
+
if (empty($noback)) {
header("Location: " . $urltogo);
exit;
}
} else {
+ $db->rollback();
+
$error++;
// Creation KO
if (!empty($object->errors)) {
@@ -177,7 +190,7 @@ if ($action == 'update' && !empty($permissiontoadd)) {
continue;
}
} else {
- if (!GETPOSTISSET($key)) {
+ if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
continue; // The field was not submited to be saved
}
}
@@ -215,6 +228,12 @@ if ($action == 'update' && !empty($permissiontoadd)) {
$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
} elseif ($object->fields[$key]['type'] == 'reference') {
$value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2');
+ } elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) {
+ $value = '';
+ $values_arr = GETPOST($key, 'array');
+ if (!empty($values_arr)) {
+ $value = implode(',', $values_arr);
+ }
} else {
if ($key == 'lang') {
$value = GETPOST($key, 'aZ09');
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index bee63613bca..d0b64fdca77 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -895,7 +895,12 @@ abstract class CommonDocGenerator
//Add value to store price with currency
$array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency']));
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') {
- $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]];
+ $valueofselectkey = $object->array_options['options_'.$key];
+ if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) {
+ $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey];
+ } else {
+ $object->array_options['options_'.$key] = '';
+ }
} elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') {
$valArray = explode(',', $object->array_options['options_'.$key]);
$output = array();
@@ -945,7 +950,11 @@ abstract class CommonDocGenerator
}
}
- $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
+ if (array_key_exists('option_'.$key, $object->array_options)) {
+ $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key]));
+ } else {
+ $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => ''));
+ }
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index b0ea04adb3e..01665e99ca5 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -588,6 +588,10 @@ abstract class CommonObject
public $alreadypaid;
+ private $labelStatus;
+ private $labelStatusShort;
+
+
/**
* @var array List of child tables. To test if we can delete object.
*/
@@ -6763,6 +6767,9 @@ abstract class CommonObject
} elseif (preg_match('/^(sellist):(.*):(.*)/i', $val['type'], $reg)) {
$param['options'] = array($reg[2].':'.$reg[3] => 'N');
$type = 'sellist';
+ } elseif (preg_match('/^chkbxlst:(.*)/i', $val['type'], $reg)) {
+ $param['options'] = array($reg[1] => 'N');
+ $type = 'chkbxlst';
} elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) {
$param['options'] = array();
$type = 'varchar';
@@ -6865,7 +6872,7 @@ abstract class CommonObject
$out = '';
} elseif (preg_match('/varchar/', $type)) {
$out = ' 0 ? ' maxlength="'.$size.'"' : '').' value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
- } elseif (in_array($type, array('mail', 'phone', 'url'))) {
+ } elseif (in_array($type, array('email', 'mail', 'phone', 'url', 'ip'))) {
$out = '';
} 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
@@ -6916,7 +6923,9 @@ abstract class CommonObject
if ((string) $keyb == '') {
continue;
}
- if (strpos($valb, "|") !== false) list($valb, $parent) = explode('|', $valb);
+ if (strpos($valb, "|") !== false) {
+ list($valb, $parent) = explode('|', $valb);
+ }
$out .= '';
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num) {
- $labeltoshow = '';
- $obj = $this->db->fetch_object($resql);
-
- // Several field into label (eq table:code|libelle:rowid)
- $notrans = false;
- $fields_label = explode('|', $InfoFieldList[1]);
- if (count($fields_label) > 1) {
- $notrans = true;
- foreach ($fields_label as $field_toshow) {
- $labeltoshow .= $obj->$field_toshow.' ';
- }
- } else {
- $labeltoshow = $obj->{$InfoFieldList[1]};
+ $sqlwhere = '';
+ $sql = "SELECT " . $keyList;
+ $sql .= " FROM " . $this->db->prefix() . $InfoFieldList[0];
+ if (!empty($InfoFieldList[4])) {
+ // can use SELECT request
+ if (strpos($InfoFieldList[4], '$SEL$') !== false) {
+ $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]);
}
- $labeltoshow = dol_trunc($labeltoshow, 45);
- if ($value == $obj->rowid) {
- foreach ($fields_label as $field_toshow) {
- $translabel = $langs->trans($obj->$field_toshow);
- if ($translabel != $obj->$field_toshow) {
- $labeltoshow = dol_trunc($translabel).' ';
- } else {
- $labeltoshow = dol_trunc($obj->$field_toshow).' ';
- }
- }
- $out .= '';
+ // current object id can be use into filter
+ if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) {
+ $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]);
} else {
- if (!$notrans) {
- $translabel = $langs->trans($obj->{$InfoFieldList[1]});
- if ($translabel != $obj->{$InfoFieldList[1]}) {
- $labeltoshow = dol_trunc($translabel, 18);
- } else {
- $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]});
+ $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]);
+ }
+
+ //We have to join on extrafield table
+ if (strpos($InfoFieldList[4], 'extra') !== false) {
+ $sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra";
+ $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4];
+ } else {
+ $sqlwhere .= " WHERE " . $InfoFieldList[4];
+ }
+ } else {
+ $sqlwhere .= ' WHERE 1=1';
+ }
+ // Some tables may have field, some other not. For the moment we disable it.
+ if (in_array($InfoFieldList[0], array('tablewithentity'))) {
+ $sqlwhere .= " AND entity = " . ((int) $conf->entity);
+ }
+ $sql .= $sqlwhere;
+ //print $sql;
+
+ $sql .= ' ORDER BY ' . implode(', ', $fields_label);
+
+ dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $out .= '';
+ $num = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num) {
+ $labeltoshow = '';
+ $obj = $this->db->fetch_object($resql);
+
+ // Several field into label (eq table:code|libelle:rowid)
+ $notrans = false;
+ $fields_label = explode('|', $InfoFieldList[1]);
+ if (count($fields_label) > 1) {
+ $notrans = true;
+ foreach ($fields_label as $field_toshow) {
+ $labeltoshow .= $obj->$field_toshow . ' ';
}
+ } else {
+ $labeltoshow = $obj->{$InfoFieldList[1]};
}
- if (empty($labeltoshow)) {
- $labeltoshow = '(not defined)';
- }
+ $labeltoshow = dol_trunc($labeltoshow, 45);
+
if ($value == $obj->rowid) {
- $out .= '';
+ foreach ($fields_label as $field_toshow) {
+ $translabel = $langs->trans($obj->$field_toshow);
+ if ($translabel != $obj->$field_toshow) {
+ $labeltoshow = dol_trunc($translabel) . ' ';
+ } else {
+ $labeltoshow = dol_trunc($obj->$field_toshow) . ' ';
+ }
+ }
+ $out .= '';
+ } else {
+ if (!$notrans) {
+ $translabel = $langs->trans($obj->{$InfoFieldList[1]});
+ if ($translabel != $obj->{$InfoFieldList[1]}) {
+ $labeltoshow = dol_trunc($translabel, 18);
+ } else {
+ $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]});
+ }
+ }
+ if (empty($labeltoshow)) {
+ $labeltoshow = '(not defined)';
+ }
+ if ($value == $obj->rowid) {
+ $out .= '';
+ }
+
+ if (!empty($InfoFieldList[3]) && $parentField) {
+ $parent = $parentName . ':' . $obj->{$parentField};
+ $isDependList = 1;
+ }
+
+ $out .= '';
}
- if (!empty($InfoFieldList[3]) && $parentField) {
- $parent = $parentName.':'.$obj->{$parentField};
- $isDependList = 1;
- }
-
- $out .= '';
+ $i++;
}
-
- $i++;
+ $this->db->free($resql);
+ } else {
+ print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters. ';
}
- $this->db->free($resql);
} else {
- print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters. ';
+ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
+ $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1);
+ $out .= '';
+ foreach ($data as $data_key => $data_value) {
+ $out .= ' |