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