dolibarr  7.0.0-beta
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 
10 dol_include_once($keyforclassfile);
11 if (class_exists($keyforclass))
12 {
13  $tmpobject=new $keyforclass($this->db);
14 
15  // Add common fields
16  foreach($tmpobject->fields as $keyfield => $valuefield)
17  {
18  $fieldname = 't' . '.' . $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=unserialize($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  if ($valuefield['enabled']) {
50  $this->export_fields_array[$r][$fieldname] = $fieldlabel;
51  $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
52  $this->export_entities_array[$r][$fieldname] = $keyforelement;
53  }
54  }
55 }
56 else
57 {
58  dol_print_error($this->db, 'Failed to find class '.$keyforclass.', even after the include of '.$keyforclassfile);
59 }
60 // End add common fields
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Return a prefix to use for this Dolibarr instance, for session/cookie names or email id...