dolibarr  13.0.2
extrafieldsinexport.inc.php
1 <?php
2 
3 if (empty($keyforselect) || empty($keyforelement) || empty($keyforaliasextra))
4 {
5  //print $keyforselet.' - '.$keyforelement.' - '.$keyforaliasextra;
6  dol_print_error('', 'include of file extrafieldsinexport.inc.php was done but var $keyforselect or $keyforelement or $keyforaliasextra was not set');
7  exit;
8 }
9 
10 // Add extra fields
11 $sql = "SELECT name, label, type, param, fieldcomputed, fielddefault FROM ".MAIN_DB_PREFIX."extrafields";
12 $sql .= " WHERE elementtype = '".$this->db->escape($keyforselect)."' AND type != 'separate' AND entity IN (0, ".$conf->entity.') ORDER BY pos ASC';
13 //print $sql;
14 $resql = $this->db->query($sql);
15 if ($resql) // This can fail when class is used on old database (during migration for example)
16 {
17  while ($obj = $this->db->fetch_object($resql))
18  {
19  $fieldname = $keyforaliasextra.'.'.$obj->name;
20  $fieldlabel = ucfirst($obj->label);
21  $typeFilter = "Text";
22  $typefield = preg_replace('/\(.*$/', '', $obj->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  case 'select':
39  if (!empty($conf->global->EXPORT_LABEL_FOR_SELECT))
40  {
41  $tmpparam = unserialize($obj->param); // $tmpparam may be array with 'options' = array(key1=>val1, key2=>val2 ...)
42  if ($tmpparam['options'] && is_array($tmpparam['options'])) {
43  $typeFilter = "Select:".$obj->param;
44  }
45  }
46  break;
47  case 'sellist':
48  $tmp = '';
49  $tmpparam = unserialize($obj->param); // $tmp ay be array 'options' => array 'c_currencies:code_iso:code_iso' => null
50  if ($tmpparam['options'] && is_array($tmpparam['options'])) {
51  $tmpkeys = array_keys($tmpparam['options']);
52  $tmp = array_shift($tmpkeys);
53  }
54  if (preg_match('/[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/', $tmp)) $typeFilter = "List:".$tmp;
55  break;
56  }
57  if ($obj->type != 'separate')
58  {
59  // If not a computed field
60  if (empty($obj->fieldcomputed))
61  {
62  $this->export_fields_array[$r][$fieldname] = $fieldlabel;
63  $this->export_TypeFields_array[$r][$fieldname] = $typeFilter;
64  $this->export_entities_array[$r][$fieldname] = $keyforelement;
65  }
66  // If this is a computed field
67  else {
68  $this->export_fields_array[$r][$fieldname] = $fieldlabel;
69  $this->export_TypeFields_array[$r][$fieldname] = $typeFilter.'Compute';
70  $this->export_special_array[$r][$fieldname] = $obj->fieldcomputed;
71  $this->export_entities_array[$r][$fieldname] = $keyforelement;
72  }
73  }
74  }
75 }
76 // End add axtra fields
$conf db
API class for accounts.
Definition: inc.php:54
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...