27@phan-var-force DolibarrModules $this
35if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra)) {
37 dol_print_error(
null,
'include of file extrafieldsinexport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
45$cachekey = $keyforselect.
'_'.
$conf->entity;
46if (!isset(
$conf->cache[
'extrafieldsinexport'][$cachekey])) {
47 $sql =
"SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX.
"extrafields";
48 $sql .=
" WHERE elementtype = '".$this->db->escape($keyforselect).
"' AND type <> 'separate' AND entity IN (0, ".((int)
$conf->entity).
') ORDER BY pos ASC';
50 $tmparrayextrafieldsinexport = array();
51 $resql = $this->db->query($sql);
53 while ($obj = $this->db->fetch_object($resql)) {
54 $tmparrayextrafieldsinexport[] = $obj;
57 $conf->cache[
'extrafieldsinexport'][$cachekey] = $tmparrayextrafieldsinexport;
59if (!empty(
$conf->cache[
'extrafieldsinexport'][$cachekey])) {
60 foreach (
$conf->cache[
'extrafieldsinexport'][$cachekey] as $obj) {
61 '@phan-var-force stdClass $obj';
62 $fieldname = $keyforaliasextra.
'.'.$obj->name;
63 $fieldlabel = ucfirst($obj->label);
65 $typefield = preg_replace(
'/\(.*$/',
'', $obj->type);
71 $typeFilter =
"Numeric";
79 $typeFilter =
"Boolean";
85 if ($tmpparam[
'options'] && is_array($tmpparam[
'options'])) {
86 $typeFilter =
"Select:".$obj->param;
93 if (is_array($tmpparam) && array_key_exists(
'options', $tmpparam) && $tmpparam[
'options'] && is_array($tmpparam[
'options'])) {
94 $tmpkeys = array_keys($tmpparam[
'options']);
95 $tmp = array_shift($tmpkeys);
97 if (preg_match(
'/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', (
string) $tmp)) {
98 $typeFilter =
"List:".$tmp;
102 if ($obj->type !=
'separate') {
104 if (empty($obj->fieldcomputed)) {
105 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
106 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
107 $this->export_entities_array[$r][$fieldname] = $keyforelement;
110 $this->export_fields_array[$r][$fieldname] = $fieldlabel;
111 $this->export_TypeFields_array[$r][$fieldname] = $typeFilter.
'Compute';
112 $this->export_special_array[$r][$fieldname] = $obj->fieldcomputed;
113 $this->export_entities_array[$r][$fieldname] = $keyforelement;
jsonOrUnserialize($stringtodecode, $assoc=true)
Decode an encoded string.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...