34if (!defined(
'USE_CUSTOM_REPORT_AS_INCLUDE')) {
35 require
'../main.inc.php';
38 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
39 $massaction =
GETPOST(
'massaction',
'alpha');
41 $mode =
GETPOST(
'mode',
'alpha');
42 $objecttype =
GETPOST(
'objecttype',
'aZ09arobase');
43 $tabfamily =
GETPOST(
'tabfamily',
'aZ09');
45 $search_measures =
GETPOST(
'search_measures',
'array');
48 if (
GETPOST(
'search_xaxis',
'alpha') &&
GETPOST(
'search_xaxis',
'alpha') !=
'-1') {
49 $search_xaxis = array(
GETPOST(
'search_xaxis',
'alpha'));
51 $search_xaxis = array();
54 if (
GETPOST(
'search_groupby',
'alpha') &&
GETPOST(
'search_groupby',
'alpha') !=
'-1') {
55 $search_groupby = array(
GETPOST(
'search_groupby',
'alpha'));
57 $search_groupby = array();
60 $search_yaxis =
GETPOST(
'search_yaxis',
'array');
61 $search_graph =
GETPOST(
'search_graph',
'restricthtml');
65 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
71 $offset = $limit * $page;
72 $pageprev = $page - 1;
73 $pagenext = $page + 1;
75 $diroutputmassaction = $conf->user->dir_temp.
'/'.$user->id.
'/customreport';
82 if (empty($user) || empty($user->id)) {
83 print
'Page is called as an include but $user and its permission loaded with getrights() are not defined. We stop here.';
87 print
'Page is called as an include but $object is not defined. We stop here.';
95if (!isset($search_measures)) {
96 $search_measures = array(0 =>
't.count');
99 $objecttype =
$object->element.($object->module ?
'@'.$object->module :
'');
101if (empty($objecttype)) {
102 $objecttype =
'thirdparty';
105require_once DOL_DOCUMENT_ROOT.
"/core/class/extrafields.class.php";
106require_once DOL_DOCUMENT_ROOT.
"/core/class/html.form.class.php";
107require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
108require_once DOL_DOCUMENT_ROOT.
"/core/lib/company.lib.php";
109require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
110require_once DOL_DOCUMENT_ROOT.
"/core/lib/customreports.lib.php";
111require_once DOL_DOCUMENT_ROOT.
"/core/class/dolgraph.class.php";
112require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
113require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formother.class.php";
116$langs->loadLangs(array(
"companies",
"other",
"exports",
"sendings"));
120$hookmanager->initHooks(array(
'customreport'));
126$ObjectClassName =
'';
129 'thirdparty' => array(
'langs' =>
'companies',
'label' =>
'ThirdParties',
'picto' =>
'company',
'ObjectClassName' =>
'Societe',
'enabled' => isModEnabled(
'societe'),
'ClassPath' =>
"/societe/class/societe.class.php"),
130 'contact' => array(
'label' =>
'Contacts',
'picto' =>
'contact',
'ObjectClassName' =>
'Contact',
'enabled' => isModEnabled(
'societe'),
'ClassPath' =>
"/contact/class/contact.class.php"),
131 'proposal' => array(
'label' =>
'Proposals',
'picto' =>
'proposal',
'ObjectClassName' =>
'Propal',
'enabled' => isModEnabled(
'propal'),
'ClassPath' =>
"/comm/propal/class/propal.class.php"),
132 'order' => array(
'label' =>
'Orders',
'picto' =>
'order',
'ObjectClassName' =>
'Commande',
'enabled' => isModEnabled(
'order'),
'ClassPath' =>
"/commande/class/commande.class.php"),
133 'invoice' => array(
'langs' =>
'facture',
'label' =>
'Invoices',
'picto' =>
'bill',
'ObjectClassName' =>
'Facture',
'enabled' => isModEnabled(
'invoice'),
'ClassPath' =>
"/compta/facture/class/facture.class.php"),
134 'invoice_template' => array(
'label' =>
'PredefinedInvoices',
'picto' =>
'bill',
'ObjectClassName' =>
'FactureRec',
'enabled' => isModEnabled(
'invoice'),
'ClassPath' =>
"/compta/class/facturerec.class.php",
'langs' =>
'bills'),
135 'contract' => array(
'label' =>
'Contracts',
'picto' =>
'contract',
'ObjectClassName' =>
'Contrat',
'enabled' => isModEnabled(
'contract'),
'ClassPath' =>
"/contrat/class/contrat.class.php",
'langs' =>
'contracts'),
136 'contractdet' => array(
'label' =>
'ContractLines',
'picto' =>
'contract',
'ObjectClassName' =>
'ContratLigne',
'enabled' => isModEnabled(
'contract'),
'ClassPath' =>
"/contrat/class/contrat.class.php",
'langs' =>
'contracts'),
137 'bom' => array(
'label' =>
'BOM',
'picto' =>
'bom',
'ObjectClassName' =>
'Bom',
'enabled' => isModEnabled(
'bom')),
138 'mrp' => array(
'label' =>
'MO',
'picto' =>
'mrp',
'ObjectClassName' =>
'Mo',
'enabled' => isModEnabled(
'mrp'),
'ClassPath' =>
"/mrp/class/mo.class.php"),
139 'ticket' => array(
'label' =>
'Ticket',
'picto' =>
'ticket',
'ObjectClassName' =>
'Ticket',
'enabled' => isModEnabled(
'ticket')),
140 'member' => array(
'label' =>
'Adherent',
'picto' =>
'member',
'ObjectClassName' =>
'Adherent',
'enabled' => isModEnabled(
'member'),
'ClassPath' =>
"/adherents/class/adherent.class.php",
'langs' =>
'members'),
141 'cotisation' => array(
'label' =>
'Subscriptions',
'picto' =>
'member',
'ObjectClassName' =>
'Subscription',
'enabled' => isModEnabled(
'member'),
'ClassPath' =>
"/adherents/class/subscription.class.php",
'langs' =>
'members'),
146$parameters = array(
'objecttype' => $objecttype,
'tabfamily' => $tabfamily);
147$reshook = $hookmanager->executeHooks(
'loadDataForCustomReports', $parameters,
$object, $action);
150} elseif (is_array($hookmanager->resArray)) {
151 if (!empty($hookmanager->resArray[
'title'])) {
152 $title = $hookmanager->resArray[
'title'];
154 if (!empty($hookmanager->resArray[
'picto'])) {
155 $picto = $hookmanager->resArray[
'picto'];
157 if (!empty($hookmanager->resArray[
'head'])) {
158 $head = array_merge($head, $hookmanager->resArray[
'head']);
160 if (!empty($hookmanager->resArray[
'arrayoftype'])) {
161 foreach ($hookmanager->resArray[
'arrayoftype'] as $key => $val) {
162 $arrayoftype[$key] = $val;
170 if (!empty($arrayoftype[$objecttype][
'ClassPath'])) {
171 $fileforclass = $arrayoftype[$objecttype][
'ClassPath'];
173 $fileforclass =
"/".$objecttype.
"/class/".$objecttype.
".class.php";
177 $ObjectClassName = $arrayoftype[$objecttype][
'ObjectClassName'];
178 if (!empty($ObjectClassName)) {
179 if (class_exists($ObjectClassName)) {
180 $object =
new $ObjectClassName($db);
182 print
'Failed to load class for type '.$objecttype.
'. Class file found but Class object named '.$ObjectClassName.
' not found.';
185 print
'Failed to load class for type '.$objecttype.
'. Class file name is unknown.';
188 print
'Failed to load class for type '.$objecttype.
'. Class path not found.';
192'@phan-var-force CommonObject $object';
196if ($user->socid > 0) {
202$extrafields->fetch_name_optionals_label(
'all');
205if (!empty(
$object->table_element)) {
206 $search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
208 $search_array_options = array();
211$search_component_params = array(
'');
212$search_component_params_hidden = trim(
GETPOST(
'search_component_params_hidden',
'alphanohtml'));
213$search_component_params_input = trim(
GETPOST(
'search_component_params_input',
'alphanohtml'));
222 $value = $search_component_params_input;
224 $value = preg_replace(
'/([a-z\.]+)\s*([!<>=]+|in|notin|like|notlike)\s*/',
'\1:\2:', $value);
225 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
228 $crits = explode(
' ', trim($value));
232 foreach ($crits as $crit) {
237 $tmpcrits = explode(
'|', $crit);
239 foreach ($tmpcrits as $tmpcrit) {
240 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
243 $tmpcrit = trim($tmpcrit);
247 $parenthesislevel = 0;
248 $rescheckfilter =
dolCheckFilters($tmpcrit, $errorstr, $parenthesislevel);
249 if ($rescheckfilter) {
250 while ($parenthesislevel > 0) {
251 $tmpcrit = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $tmpcrit));
256 $field = preg_replace(
'/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/',
'', $tmpcrit);
257 $tmpcrit = preg_replace(
'/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/',
'\1', $tmpcrit);
260 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
263 $newcrit = preg_replace(
'/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/',
'', $tmpcrit);
267 preg_match(
'/:([!<>=\s]+|in|notin|like|notlike):/', $tmpcrit, $reg);
268 if (!empty($reg[1])) {
271 if ($newcrit !=
'') {
272 if (!preg_match(
'/^\'[^\']*\'$/', $newcrit)) {
274 $newres .=
'('.$field.
':'.$operator.
':'.((float) $numnewcrit).
')';
276 $newres .=
'('.$field.
':'.$operator.
":".((string) $newcrit).
')';
284 $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
291 $search_component_params_input = $res;
297$search_component_params_hidden = implode(
' AND ', array_merge($arrayofandtagshidden, $arrayofandtagsinput));
300$MAXUNIQUEVALFORGROUP = 20;
301$MAXMEASURESINBARGRAPH = 20;
302$SHOWLEGEND = (isset($SHOWLEGEND) ? $SHOWLEGEND : 1);
304$YYYY = substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1).substr($langs->trans(
"Year"), 0, 1);
305$MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
306$DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
307$HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
308$MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
309$SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
311$arrayofmesures = array();
312$arrayofxaxis = array();
313$arrayofgroupby = array();
314$arrayofyaxis = array();
315$arrayofvaluesforgroupby = array();
322if (!empty(
$object->element_for_permission)) {
323 $features =
$object->element_for_permission;
325 $features = $features.(empty(
$object->module) ?
'' :
'@'.$object->module);
345$form =
new Form($db);
348if (!defined(
'USE_CUSTOM_REPORT_AS_INCLUDE')) {
349 llxHeader(
'', $langs->transnoentitiesnoconv(
'CustomReports'),
'');
358$newarrayoftype = array();
359foreach ($arrayoftype as $key => $val) {
360 if (
dol_eval($val[
'enabled'], 1, 1,
'1')) {
361 $newarrayoftype[$key] = $arrayoftype[$key];
363 if (!empty($val[
'langs'])) {
364 $langs->load($val[
'langs']);
369$arrayofmesures =
fillArrayOfMeasures(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofmesures, 0, $count);
370$arrayofmesures =
dol_sort_array($arrayofmesures,
'position',
'asc', 0, 0, 1);
373$arrayofxaxis =
fillArrayOfXAxis(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofxaxis, 0, $count);
374$arrayofxaxis =
dol_sort_array($arrayofxaxis,
'position',
'asc', 0, 0, 1);
377$arrayofgroupby =
fillArrayOfGroupBy(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofgroupby, 0, $count);
378$arrayofgroupby =
dol_sort_array($arrayofgroupby,
'position',
'asc', 0, 0, 1);
382if ($action ==
'viewgraph') {
383 if (!count($search_measures)) {
384 setEventMessages($langs->trans(
"AtLeastOneMeasureIsRequired"),
null,
'warnings');
385 } elseif ($mode ==
'graph' && count($search_xaxis) > 1) {
386 setEventMessages($langs->trans(
"OnlyOneFieldForXAxisIsPossible"),
null,
'warnings');
387 $search_xaxis = array(0 => $search_xaxis[0]);
389 if (count($search_groupby) >= 2) {
390 setEventMessages($langs->trans(
"ErrorOnlyOneFieldForGroupByIsPossible"),
null,
'warnings');
391 $search_groupby = array(0 => $search_groupby[0]);
393 if (!count($search_xaxis)) {
394 setEventMessages($langs->trans(
"AtLeastOneXAxisIsRequired"),
null,
'warnings');
395 } elseif ($mode ==
'graph' && $search_graph ==
'bars' && count($search_measures) > $MAXMEASURESINBARGRAPH) {
396 $langs->load(
"errors");
397 setEventMessages($langs->trans(
"GraphInBarsAreLimitedToNMeasures", $MAXMEASURESINBARGRAPH),
null,
'warnings');
398 $search_graph =
'lines';
404if (is_array($search_groupby) && count($search_groupby)) {
406 foreach ($search_groupby as $gkey => $gval) {
407 $gvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $gval);
409 if (preg_match(
'/\-year$/', $search_groupby[$gkey])) {
410 $tmpval = preg_replace(
'/\-year$/',
'', $search_groupby[$gkey]);
411 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y')";
412 } elseif (preg_match(
'/\-month$/', $search_groupby[$gkey])) {
413 $tmpval = preg_replace(
'/\-month$/',
'', $search_groupby[$gkey]);
414 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y-%m')";
415 } elseif (preg_match(
'/\-day$/', $search_groupby[$gkey])) {
416 $tmpval = preg_replace(
'/\-day$/',
'', $search_groupby[$gkey]);
417 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y-%m-%d')";
419 $fieldtocount = $search_groupby[$gkey];
422 $sql =
"SELECT DISTINCT ".$fieldtocount.
" as val";
424 if (strpos($fieldtocount,
'te') === 0) {
425 $tabletouse =
$object->table_element;
426 $tablealiastouse =
'te';
427 if (!empty($arrayofgroupby[$gval])) {
428 $tmpval = explode(
'.', $gval);
429 $tabletouse = $arrayofgroupby[$gval][
'table'];
430 $tablealiastouse = $tmpval[0];
435 $sql .=
" FROM ".MAIN_DB_PREFIX.$tabletouse.
"_extrafields as ".$tablealiastouse;
437 $tabletouse =
$object->table_element;
438 $tablealiastouse =
't';
439 if (!empty($arrayofgroupby[$gval])) {
440 $tmpval = explode(
'.', $gval);
441 $tabletouse = $arrayofgroupby[$gval][
'table'];
442 $tablealiastouse = $tmpval[0];
444 $sql .=
" FROM ".MAIN_DB_PREFIX.$tabletouse.
" as ".$tablealiastouse;
455 $sql .=
" LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
458 $resql = $db->query($sql);
463 while ($obj = $db->fetch_object($resql)) {
464 if (is_null($obj->val)) {
465 $keytouse =
'__NULL__';
466 $valuetranslated = $langs->transnoentitiesnoconv(
"NotDefined");
467 } elseif ($obj->val ===
'') {
469 $valuetranslated = $langs->transnoentitiesnoconv(
"Empty");
471 $keytouse = (string) $obj->val;
472 $valuetranslated = $obj->val;
476 if (!empty(
$object->fields[$gvalwithoutprefix][
'arrayofkeyval'])) {
477 $valuetranslated =
$object->fields[$gvalwithoutprefix][
'arrayofkeyval'][$obj->val];
478 if (is_null($valuetranslated)) {
479 $valuetranslated = $langs->transnoentitiesnoconv(
"UndefinedKey");
481 $valuetranslated = $langs->trans($valuetranslated);
482 } elseif (preg_match(
'/integer:([^:]+):([^:]+)$/',
$object->fields[$gvalwithoutprefix][
'type'], $regs)) {
483 $classname = $regs[1];
484 $classpath = $regs[2];
486 if (class_exists($classname)) {
487 $tmpobject =
new $classname($db);
488 $tmpobject->fetch($obj->val);
489 foreach ($tmpobject->fields as $fieldkey => $field) {
490 if ($field[
'showoncombobox']) {
491 $valuetranslated = $tmpobject->$fieldkey;
500 $arrayofvaluesforgroupby[
'g_'.$gkey][$keytouse] = $valuetranslated;
503 $tmpfield = explode(
'.', $gval);
504 if ($tmpfield[0] !=
't' || (is_array(
$object->fields[$tmpfield[1]]) && empty(
$object->fields[$tmpfield[1]][
'notnull']))) {
505 dol_syslog(
"The group by field ".$gval.
" may be null (because field is null or it is a left join), so we add __NULL__ entry in list of possible values");
507 $arrayofvaluesforgroupby[
'g_'.$gkey][
'__NULL__'] = $langs->transnoentitiesnoconv(
"NotDefined");
510 if (is_array($arrayofvaluesforgroupby[
'g_'.$gkey])) {
511 asort($arrayofvaluesforgroupby[
'g_'.$gkey]);
515 if (is_array($arrayofvaluesforgroupby[
'g_'.$gkey]) && count($arrayofvaluesforgroupby[
'g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
516 $langs->load(
"errors");
518 if (strpos($fieldtocount,
'te') === 0) {
522 $keyforlabeloffield = $extrafields->attributes[
$object->table_element][
'label'][$gvalwithoutprefix];
523 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
524 } elseif (strpos($fieldtocount,
't__') === 0) {
526 if (preg_match(
'/^(.*)\.(.*)/', $gvalwithoutprefix, $reg)) {
533 $labeloffield = $arrayofgroupby[$fieldtocount][
'labelnohtml'];
535 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
539 if (preg_match(
'/^(.*)\-(year|month|day)/', $gvalwithoutprefix, $reg)) {
540 $gvalwithoutprefix = preg_replace(
'/\-(year|month|day)/',
'', $gvalwithoutprefix);
541 $keyforlabeloffield =
$object->fields[$gvalwithoutprefix][
'label'];
542 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).
'-'.$reg[2];
544 $keyforlabeloffield =
$object->fields[$gvalwithoutprefix][
'label'];
545 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
549 setEventMessages($langs->trans(
"ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield),
null,
'warnings');
550 $search_groupby = array();
560$endyear = $tmparray[
'year'];
561$endmonth = $tmparray[
'mon'];
563$startyear = $endyear - 2;
568if (!defined(
'MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
569 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'" autocomplete="off">';
570 print
'<input type="hidden" name="token" value="'.newToken().
'">';
571 print
'<input type="hidden" name="action" value="viewgraph">';
572 print
'<input type="hidden" name="tabfamily" value="'.$tabfamily.
'">';
576 $viewmode .=
'<div class="divadvancedsearchfield">';
577 $arrayofgraphs = array(
'bars' =>
'Bars',
'lines' =>
'Lines');
578 $viewmode .=
'<div class="inline-block opacitymedium"><span class="fas fa-chart-area paddingright" title="'.$langs->trans(
"Graph").
'"></span>'.$langs->trans(
"Graph").
'</div> ';
579 $viewmode .= $form->selectarray(
'search_graph', $arrayofgraphs, $search_graph, 0, 0, 0,
'', 1, 0, 0,
'',
'graphtype width100');
580 $viewmode .=
'</div>';
583 $massactionbutton =
'';
588 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1,
'object_action', 0, $nav.
'<span class="marginleftonly"></span>'.$newcardbutton,
'', $limit, 1, 0, 1, $viewmode);
591 foreach ($newarrayoftype as $tmpkey => $tmpval) {
592 $newarrayoftype[$tmpkey][
'label'] =
img_picto(
'', $tmpval[
'picto'],
'class="pictofixedwidth"').$langs->trans($tmpval[
'label']);
595 print
'<div class="liste_titre liste_titre_bydiv liste_titre_bydiv_inlineblock centpercent">';
598 print
'<div class="divadvancedsearchfield center floatnone">';
599 print
'<div class="inline-block"><span class="opacitymedium">'.$langs->trans(
"StatisticsOn").
'</span></div> ';
600 print $form->selectarray(
'objecttype', $newarrayoftype, $objecttype, 0, 0, 0,
'', 1, 0, 0,
'',
'minwidth200', 1,
'', 0, 1);
601 if (empty($conf->use_javascript_ajax)) {
602 print
'<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans(
"Refresh").
'">';
604 print
'<!-- js code to reload page with good object type -->
605 <script nonce="'.getNonce().
'" type="text/javascript">
606 jQuery(document).ready(function() {
607 jQuery("#objecttype").change(function() {
608 console.log("Reload for "+jQuery("#objecttype").val());
609 location.href = "'.$_SERVER[
"PHP_SELF"].
'?objecttype="+jQuery("#objecttype").val()+"'.($tabfamily ?
'&tabfamily='.urlencode($tabfamily) :
'').(
GETPOSTINT(
'show_search_component_params_hidden') ?
'&show_search_component_params_hidden='.((int)
GETPOSTINT(
'show_search_component_params_hidden')) :
'').
'";
614 print
'</div><div class="clearboth"></div>';
618 print
'<div class="divadvancedsearchfield">';
619 print $form->searchComponent(array(
$object->element =>
$object->fields), $search_component_params, array(), $search_component_params_hidden);
626 print
'<div class="divadvancedsearchfield clearboth">';
627 print
'<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"Measures")).
'"></span><span class="fas fa-caret-left caretleftaxis" title="'.
dol_escape_htmltag($langs->trans(
"Measures")).
'"></span></div>';
628 $simplearrayofmesures = array();
629 foreach ($arrayofmesures as $key => $val) {
630 $simplearrayofmesures[$key] = $arrayofmesures[$key][
'label'];
632 print $form->multiselectarray(
'search_measures', $simplearrayofmesures, $search_measures, 0, 0,
'minwidth300', 1, 0,
'',
'', $langs->trans(
"Measures"));
637 print
'<div class="divadvancedsearchfield">';
638 print
'<div class="inline-block"><span class="fas fa-ruler-combined paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"XAxis")).
'"></span><span class="fas fa-caret-down caretdownaxis" title="'.
dol_escape_htmltag($langs->trans(
"XAxis")).
'"></span></div>';
640 print $formother->selectXAxisField(
$object, $search_xaxis, $arrayofxaxis, $langs->trans(
"XAxis"),
'minwidth300 maxwidth400');
645 print
'<div class="divadvancedsearchfield">';
646 print
'<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"GroupBy")).
'"></span></div>';
647 print $formother->selectGroupByField(
$object, $search_groupby, $arrayofgroupby,
'minwidth250 maxwidth300', $langs->trans(
"GroupBy"));
651 if ($mode ==
'grid') {
653 print
'<div class="divadvancedsearchfield">';
654 foreach (
$object->fields as $key => $val) {
655 if (empty($val[
'measure']) && (!isset($val[
'enabled']) ||
dol_eval($val[
'enabled'], 1, 1,
'1'))) {
656 if (in_array($key, array(
'id',
'rowid',
'entity',
'last_main_doc',
'extraparams'))) {
659 if (preg_match(
'/^fk_/', $key)) {
662 if (in_array($val[
'type'], array(
'html',
'text'))) {
665 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
666 $arrayofyaxis[
't.'.$key.
'-year'] = array(
667 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
')',
668 'position' => $val[
'position'],
669 'table' =>
$object->table_element
671 $arrayofyaxis[
't.'.$key.
'-month'] = array(
672 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
')',
673 'position' => $val[
'position'],
674 'table' =>
$object->table_element
676 $arrayofyaxis[
't.'.$key.
'-day'] = array(
677 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
'-'.$DD.
')',
678 'position' => $val[
'position'],
679 'table' =>
$object->table_element
682 $arrayofyaxis[
't.'.$key] = array(
683 'label' => $val[
'label'],
684 'position' => (
int) $val[
'position'],
685 'table' =>
$object->table_element
691 if (
$object->isextrafieldmanaged) {
692 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
693 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key]) && (!isset($extrafields->attributes[
$object->table_element][
'enabled'][$key]) ||
dol_eval($extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'1'))) {
694 $arrayofyaxis[
'te.'.$key] = array(
695 'label' => $extrafields->attributes[
$object->table_element][
'label'][$key],
696 'position' => (
int) $extrafields->attributes[
$object->table_element][
'pos'][$key],
697 'table' =>
$object->table_element
703 $arrayofyaxislabel = array();
704 foreach ($arrayofyaxis as $key => $val) {
705 $arrayofyaxislabel[$key] = $val[
'label'];
707 print
'<div class="inline-block opacitymedium"><span class="fas fa-ruler-vertical paddingright" title="'.$langs->trans(
"YAxis").
'"></span>'.$langs->trans(
"YAxis").
'</div> ';
708 print $form->multiselectarray(
'search_yaxis', $arrayofyaxislabel, $search_yaxis, 0, 0,
'minwidth100', 1);
712 if ($mode ==
'graph') {
716 print
'<div class="divadvancedsearchfield">';
717 print
'<input type="submit" class="button buttongen button-save nomargintop" value="'.$langs->trans(
"Refresh").
'">';
725if (!empty($search_measures) && !empty($search_xaxis)) {
731 foreach ($search_xaxis as $key => $val) {
732 if (preg_match(
'/\-year$/', $val)) {
733 $tmpval = preg_replace(
'/\-year$/',
'', $val);
734 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y') as x_".$key.
', ';
735 } elseif (preg_match(
'/\-month$/', $val)) {
736 $tmpval = preg_replace(
'/\-month$/',
'', $val);
737 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m') as x_".$key.
', ';
738 } elseif (preg_match(
'/\-day$/', $val)) {
739 $tmpval = preg_replace(
'/\-day$/',
'', $val);
740 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d') as x_".$key.
', ';
742 $sql .= $val.
" as x_".$key.
", ";
745 if (!empty($search_groupby)) {
746 foreach ($search_groupby as $key => $val) {
747 if (preg_match(
'/\-year$/', $val)) {
748 $tmpval = preg_replace(
'/\-year$/',
'', $val);
749 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y') as g_".$key.
', ';
750 } elseif (preg_match(
'/\-month$/', $val)) {
751 $tmpval = preg_replace(
'/\-month$/',
'', $val);
752 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m') as g_".$key.
', ';
753 } elseif (preg_match(
'/\-day$/', $val)) {
754 $tmpval = preg_replace(
'/\-day$/',
'', $val);
755 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d') as g_".$key.
', ';
757 $sql .= $val.
" as g_".$key.
", ";
761 foreach ($search_measures as $key => $val) {
762 if ($val ==
't.count') {
763 $sql .=
"COUNT(t.".$fieldid.
") as y_".$key.
', ';
764 } elseif (preg_match(
'/\-sum$/', $val)) {
765 $tmpval = preg_replace(
'/\-sum$/',
'', $val);
766 $sql .=
"SUM(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
767 } elseif (preg_match(
'/\-average$/', $val)) {
768 $tmpval = preg_replace(
'/\-average$/',
'', $val);
769 $sql .=
"AVG(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
770 } elseif (preg_match(
'/\-min$/', $val)) {
771 $tmpval = preg_replace(
'/\-min$/',
'', $val);
772 $sql .=
"MIN(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
773 } elseif (preg_match(
'/\-max$/', $val)) {
774 $tmpval = preg_replace(
'/\-max$/',
'', $val);
775 $sql .=
"MAX(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
778 $sql = preg_replace(
'/,\s*$/',
'', $sql);
779 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
781 if (
$object->isextrafieldmanaged) {
782 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as te ON te.fk_object = t.".$fieldid;
785 if (
$object->ismultientitymanaged) {
786 if (
$object->ismultientitymanaged == 1) {
789 $tmparray = explode(
'@',
$object->ismultientitymanaged);
790 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1].
" as parenttableforentity ON t.".$tmparray[0].
" = parenttableforentity.rowid";
791 $sql .=
" AND parenttableforentity.entity IN (".getEntity($tmparray[1]).
")";
796 $listoftablesalreadyadded = array(
$object->table_element =>
$object->table_element);
800 foreach ($search_xaxis as $key => $val) {
801 if (!empty($arrayofxaxis[$val])) {
802 $tmpval = explode(
'.', $val);
805 foreach ($tmpforloop as $tmptable => $tmptablealias) {
806 if (! in_array($tmptable, $listoftablesalreadyadded)) {
807 $tmpforexplode = explode(
'__', $tmptablealias);
808 $endpart = end($tmpforexplode);
809 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
811 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
812 $listoftablesalreadyadded[$tmptable] = $tmptable;
814 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
815 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
816 $listoftablesalreadyadded[$tmptable] = $tmptable;
821 $errormessage =
'Found a key into search_xaxis not found into arrayofxaxis';
827 foreach ($search_groupby as $key => $val) {
828 if (!empty($arrayofgroupby[$val])) {
829 $tmpval = explode(
'.', $val);
832 foreach ($tmpforloop as $tmptable => $tmptablealias) {
833 if (! in_array($tmptable, $listoftablesalreadyadded)) {
834 $tmpforexplode = explode(
'__', $tmptablealias);
835 $endpart = end($tmpforexplode);
836 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
838 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
839 $listoftablesalreadyadded[$tmptable] = $tmptable;
841 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
842 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
843 $listoftablesalreadyadded[$tmptable] = $tmptable;
848 $errormessage =
'Found a key into search_groupby not found into arrayofgroupby';
854 foreach ($search_measures as $key => $val) {
855 if (!empty($arrayofmesures[$val])) {
856 $tmpval = explode(
'.', $val);
859 foreach ($tmpforloop as $tmptable => $tmptablealias) {
860 if (! in_array($tmptable, $listoftablesalreadyadded)) {
861 $tmpforexplode = explode(
'__', $tmptablealias);
862 $endpart = end($tmpforexplode);
863 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
865 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
866 $listoftablesalreadyadded[$tmptable] = $tmptable;
868 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
869 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
870 $listoftablesalreadyadded[$tmptable] = $tmptable;
875 $errormessage =
'Found a key into search_measures not found into arrayofmesures';
879 $sql .=
" WHERE 1 = 1";
880 if (
$object->ismultientitymanaged == 1) {
881 $sql .=
" AND t.entity IN (".getEntity(
$object->element).
")";
884 $sqlfilters = $search_component_params_hidden;
888 $sql .=
" GROUP BY ";
889 foreach ($search_xaxis as $key => $val) {
890 if (preg_match(
'/\-year$/', $val)) {
891 $tmpval = preg_replace(
'/\-year$/',
'', $val);
892 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
893 } elseif (preg_match(
'/\-month$/', $val)) {
894 $tmpval = preg_replace(
'/\-month$/',
'', $val);
895 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
896 } elseif (preg_match(
'/\-day$/', $val)) {
897 $tmpval = preg_replace(
'/\-day$/',
'', $val);
898 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
903 if (!empty($search_groupby)) {
904 foreach ($search_groupby as $key => $val) {
905 if (preg_match(
'/\-year$/', $val)) {
906 $tmpval = preg_replace(
'/\-year$/',
'', $val);
907 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
908 } elseif (preg_match(
'/\-month$/', $val)) {
909 $tmpval = preg_replace(
'/\-month$/',
'', $val);
910 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
911 } elseif (preg_match(
'/\-day$/', $val)) {
912 $tmpval = preg_replace(
'/\-day$/',
'', $val);
913 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
919 $sql = preg_replace(
'/,\s*$/',
'', $sql);
920 $sql .=
' ORDER BY ';
921 foreach ($search_xaxis as $key => $val) {
922 if (preg_match(
'/\-year$/', $val)) {
923 $tmpval = preg_replace(
'/\-year$/',
'', $val);
924 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
925 } elseif (preg_match(
'/\-month$/', $val)) {
926 $tmpval = preg_replace(
'/\-month$/',
'', $val);
927 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
928 } elseif (preg_match(
'/\-day$/', $val)) {
929 $tmpval = preg_replace(
'/\-day$/',
'', $val);
930 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
935 if (!empty($search_groupby)) {
936 foreach ($search_groupby as $key => $val) {
937 if (preg_match(
'/\-year$/', $val)) {
938 $tmpval = preg_replace(
'/\-year$/',
'', $val);
939 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
940 } elseif (preg_match(
'/\-month$/', $val)) {
941 $tmpval = preg_replace(
'/\-month$/',
'', $val);
942 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
943 } elseif (preg_match(
'/\-day$/', $val)) {
944 $tmpval = preg_replace(
'/\-day$/',
'', $val);
945 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
951 $sql = preg_replace(
'/,\s*$/',
'', $sql);
954 if (!empty($customsql)) {
961 print
'<div class="warning">';
969foreach ($search_measures as $key => $val) {
970 $legend[] = $langs->trans($arrayofmesures[$val][
'label']);
973$useagroupby = (is_array($search_groupby) && count($search_groupby));
981 $resql = $db->query($sql);
983 print
'<div class="warning">';
991 while ($obj = $db->fetch_object($resql)) {
994 $xval = $search_xaxis[0];
995 $fieldforxkey =
'x_0';
996 $xlabel = $obj->$fieldforxkey;
997 $xvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $xval);
1000 if (!empty(
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'])) {
1001 $xlabel =
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'][$obj->$fieldforxkey];
1003 $labeltouse = (($xlabel || $xlabel ==
'0') ?
dol_trunc($xlabel, 20,
'middle') : ($xlabel ===
'' ? $langs->transnoentitiesnoconv(
"Empty") : $langs->transnoentitiesnoconv(
"NotDefined")));
1005 if ($oldlabeltouse !==
'' && ($labeltouse != $oldlabeltouse)) {
1009 $oldlabeltouse = $labeltouse;
1022 foreach ($search_measures as $key => $val) {
1024 foreach ($search_groupby as $gkey) {
1027 foreach ($arrayofvaluesforgroupby[
'g_'.$gi] as $gvaluepossiblekey => $gvaluepossiblelabel) {
1028 $ykeysuffix = $gvaluepossiblelabel;
1029 $gvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $gval);
1031 $fieldfory =
'y_'.$key;
1032 $fieldforg =
'g_'.$gi;
1033 $fieldforybis =
'y_'.$key.
'_'.$ykeysuffix;
1037 if (!is_array($data[$xi])) {
1038 $data[$xi] = array();
1041 if (!array_key_exists(
'label', $data[$xi])) {
1042 $data[$xi] = array();
1043 $data[$xi][
'label'] = $labeltouse;
1046 $objfieldforg = $obj->$fieldforg;
1047 if (is_null($objfieldforg)) {
1048 $objfieldforg =
'__NULL__';
1051 if ($gvaluepossiblekey ==
'0') {
1053 if ($objfieldforg ==
'0') {
1055 $data[$xi][$fieldforybis] = $obj->$fieldfory;
1056 } elseif (!isset($data[$xi][$fieldforybis])) {
1058 $data[$xi][$fieldforybis] =
'0';
1062 if ((
string) $objfieldforg === (
string) $gvaluepossiblekey) {
1064 $data[$xi][$fieldforybis] = $obj->$fieldfory;
1065 } elseif (!isset($data[$xi][$fieldforybis])) {
1067 $data[$xi][$fieldforybis] =
'0';
1076 $xval = $search_xaxis[0];
1077 $fieldforxkey =
'x_0';
1078 $xlabel = $obj->$fieldforxkey;
1079 $xvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $xval);
1082 if (!empty(
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'])) {
1083 $xlabel =
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'][$obj->$fieldforxkey];
1086 $labeltouse = (($xlabel || $xlabel ==
'0') ?
dol_trunc($xlabel, 20,
'middle') : ($xlabel ===
'' ? $langs->transnoentitiesnoconv(
"Empty") : $langs->transnoentitiesnoconv(
"NotDefined")));
1087 $xarrayforallseries = array(
'label' => $labeltouse);
1088 foreach ($search_measures as $key => $val) {
1089 $fieldfory =
'y_'.$key;
1090 $xarrayforallseries[$fieldfory] = $obj->$fieldfory;
1092 $data[$xi] = $xarrayforallseries;
1097 $totalnbofrecord = count($data);
1102print
'<!-- Section to show the result -->'.
"\n";
1103print
'<div class="customreportsoutput'.($totalnbofrecord ?
'' :
' customreportsoutputnotdata').
'">';
1106if ($mode ==
'grid') {
1110if ($mode ==
'graph') {
1112 $HEIGHT = (empty($_SESSION[
'dol_screenheight']) ? 400 : $_SESSION[
'dol_screenheight'] - 500);
1116 $mesg = $px1->isGraphKo();
1120 $px1->SetData($data);
1123 $arrayoftypes = array();
1124 foreach ($search_measures as $key => $val) {
1125 $arrayoftypes[] = $search_graph;
1128 $px1->SetLegend($legend);
1129 $px1->setShowLegend($SHOWLEGEND);
1130 $px1->SetMinValue($px1->GetFloorMinValue());
1131 $px1->SetMaxValue($px1->GetCeilMaxValue());
1132 $px1->SetWidth($WIDTH);
1133 $px1->SetHeight($HEIGHT);
1134 $px1->SetYLabel($langs->trans(
"Y"));
1135 $px1->SetShading(3);
1136 $px1->SetHorizTickIncrement(1);
1137 $px1->SetCssPrefix(
"cssboxes");
1138 $px1->SetType($arrayoftypes);
1139 $px1->mode =
'depth';
1142 $dir = $conf->user->dir_temp;
1145 if (!empty(
$object->element)) {
1146 $filenamekey = $dir.
'/customreport_'.
$object->element.(empty($customreportkey) ?
'' : $customreportkey).
'.png';
1147 $fileurlkey = DOL_URL_ROOT.
'/viewimage.php?modulepart=user&file=customreport_'.
$object->element.(empty($customreportkey) ?
'' : $customreportkey).
'.png';
1150 if (isset($filenamekey) && isset($fileurlkey)) {
1151 $px1->draw($filenamekey, $fileurlkey);
1154 $texttoshow = $langs->trans(
"NoRecordFound");
1155 if (!GETPOSTISSET(
'search_measures') || !GETPOSTISSET(
'search_xaxis')) {
1156 $texttoshow = $langs->trans(
"SelectYourGraphOptionsFirst");
1159 print $px1->show($totalnbofrecord ? 0 : $texttoshow);
1163if ($sql && !defined(
'MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
1165 print
'<br>'.info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sql, 0, 0, 1,
'',
'TechnicalInformation');
1170if (!defined(
'USE_CUSTOM_REPORT_AS_INCLUDE')) {
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroupby, $level=0, &$count=0, &$tablepath='')
Fill arrayofgrupby for an object.
fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesures, $level=0, &$count=0, &$tablepath='')
Fill arrayofmesures for an object.
fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, $level=0, &$count=0, &$tablepath='')
Fill arrayofmesures for an object.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dolCheckFilters($sqlfilters, &$error='', &$parenthesislevel=0)
Return if a $sqlfilters parameter has a valid balance of parenthesis.
dolForgeExplodeAnd($sqlfilters)
Explode an universal search string with AND parts.
dolExplodeIntoArray($string, $delimiter=';', $kv='=')
Split a string with 2 keys into key array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.