dolibarr 19.0.4
commonfieldsinimport.inc.php
1<?php
2
3if (empty($keyforclass) || empty($keyforclassfile) || empty($keyforelement)) {
4 //print $keyforclass.' - '.$keyforclassfile.' - '.$keyforelement;
5 dol_print_error('', 'include of file commonfieldsinimport.inc.php was done but var $keyforclass or $keyforclassfile or $keyforelement was not set');
6 exit;
7}
8if (empty($keyforalias)) {
9 $keyforalias = 't';
10}
11
12dol_include_once($keyforclassfile);
13if (class_exists($keyforclass)) {
14 $tmpobject = new $keyforclass($this->db);
15
16 // Add common fields
17 foreach ($tmpobject->fields as $keyfield => $valuefield) {
18 $fieldname = $keyforalias.'.'.$keyfield;
19 $fieldlabel = ucfirst($valuefield['label']);
20 $typeFilter = "Text";
21 $typefield = preg_replace('/\‍(.*$/', '', $valuefield['type']); // double(24,8) -> double
22 switch ($typefield) {
23 case 'int':
24 case 'integer':
25 case 'double':
26 case 'price':
27 $typeFilter = "Numeric";
28 break;
29 case 'date':
30 case 'datetime':
31 case 'timestamp':
32 $typeFilter = "Date";
33 break;
34 case 'boolean':
35 $typeFilter = "Boolean";
36 break;
37 /*
38 * case 'sellist':
39 * $tmp='';
40 * $tmpparam=jsonOrUnserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
41 * if ($tmpparam['options'] && is_array($tmpparam['options'])) {
42 * $tmpkeys=array_keys($tmpparam['options']);
43 * $tmp=array_shift($tmpkeys);
44 * }
45 * if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter="List:".$tmp;
46 * break;
47 */
48 }
49 $helpfield = '';
50 if (!empty($valuefield['help'])) {
51 $helpfield = preg_replace('/\‍(.*$/', '', $valuefield['help']);
52 }
53 if ($valuefield['enabled']) {
54 $this->import_fields_array[$r][$fieldname] = $fieldlabel;
55 $this->import_TypeFields_array[$r][$fieldname] = $typeFilter;
56 $this->import_entities_array[$r][$fieldname] = $keyforelement;
57 $this->import_help_array[$r][$fieldname] = $helpfield;
58 }
59 }
60} else {
61 dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
62}
63// End add common fields
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.