35if (!defined(
'USE_CUSTOM_REPORT_AS_INCLUDE')) {
36 require
'../main.inc.php';
39 $action =
GETPOST(
'action',
'aZ09') ?
GETPOST(
'action',
'aZ09') :
'view';
40 $massaction =
GETPOST(
'massaction',
'alpha');
42 $mode =
GETPOST(
'mode',
'alpha');
43 $objecttype = (string)
GETPOST(
'objecttype',
'aZ09arobase');
44 $tabfamily =
GETPOST(
'tabfamily',
'aZ09');
46 $search_measures =
GETPOST(
'search_measures',
'array');
49 if (
GETPOST(
'search_xaxis',
'alpha') &&
GETPOST(
'search_xaxis',
'alpha') !=
'-1') {
50 $search_xaxis = array(
GETPOST(
'search_xaxis',
'alpha'));
52 $search_xaxis = array();
55 if (
GETPOST(
'search_groupby',
'alpha') &&
GETPOST(
'search_groupby',
'alpha') !=
'-1') {
56 $search_groupby = array(
GETPOST(
'search_groupby',
'alpha'));
58 $search_groupby = array();
61 '@phan-var-force string[] $search_groupby';
63 $search_yaxis =
GETPOST(
'search_yaxis',
'array');
64 $search_graph =
GETPOST(
'search_graph',
'restricthtml');
68 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71 if (empty($page) || $page == -1 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha') || (empty($toselect) && $massaction ===
'0')) {
74 $offset = $limit * $page;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
78 $diroutputmassaction = $conf->user->dir_temp.
'/'.$user->id.
'/customreport';
84 @phan-var-force int<0,1> $SHOWLEGEND
85 @phan-var-force string customreportkey
91 if (empty($user) || empty($user->id)) {
92 print
'Page is called as an include but $user and its permission loaded with loadRights() are not defined. We stop here.';
96 print
'Page is called as an include but $object is not defined. We stop here.';
104if (!isset($search_measures)) {
105 $search_measures = array(0 =>
't.count');
108 $objecttype =
$object->element.($object->module ?
'@'.$object->module :
'');
110if (empty($objecttype)) {
111 $objecttype =
'thirdparty';
114require_once DOL_DOCUMENT_ROOT.
"/core/class/extrafields.class.php";
115require_once DOL_DOCUMENT_ROOT.
"/core/class/html.form.class.php";
116require_once DOL_DOCUMENT_ROOT.
"/core/lib/admin.lib.php";
117require_once DOL_DOCUMENT_ROOT.
"/core/lib/company.lib.php";
118require_once DOL_DOCUMENT_ROOT.
"/core/lib/date.lib.php";
119require_once DOL_DOCUMENT_ROOT.
"/core/lib/customreports.lib.php";
120require_once DOL_DOCUMENT_ROOT.
"/core/class/dolgraph.class.php";
121require_once DOL_DOCUMENT_ROOT.
"/core/class/doleditor.class.php";
122require_once DOL_DOCUMENT_ROOT.
"/core/class/html.formother.class.php";
125$langs->loadLangs(array(
"companies",
"other",
"exports",
"sendings"));
129$hookmanager->initHooks(array(
'customreport'));
134$keyforlabeloffield =
null;
136$ObjectClassName =
'';
139 'thirdparty' => array(
'langs' =>
'companies',
'label' =>
'ThirdParties',
'picto' =>
'company',
'ObjectClassName' =>
'Societe',
'enabled' => isModEnabled(
'societe'),
'ClassPath' =>
"/societe/class/societe.class.php"),
140 'contact' => array(
'label' =>
'Contacts',
'picto' =>
'contact',
'ObjectClassName' =>
'Contact',
'enabled' => isModEnabled(
'societe'),
'ClassPath' =>
"/contact/class/contact.class.php"),
141 'proposal' => array(
'label' =>
'Proposals',
'picto' =>
'proposal',
'ObjectClassName' =>
'Propal',
'enabled' => isModEnabled(
'propal'),
'ClassPath' =>
"/comm/propal/class/propal.class.php"),
142 'order' => array(
'label' =>
'Orders',
'picto' =>
'order',
'ObjectClassName' =>
'Commande',
'enabled' => isModEnabled(
'order'),
'ClassPath' =>
"/commande/class/commande.class.php"),
143 'invoice' => array(
'langs' =>
'facture',
'label' =>
'Invoices',
'picto' =>
'bill',
'ObjectClassName' =>
'Facture',
'enabled' => isModEnabled(
'invoice'),
'ClassPath' =>
"/compta/facture/class/facture.class.php"),
144 'invoice_template' => array(
'label' =>
'PredefinedInvoices',
'picto' =>
'bill',
'ObjectClassName' =>
'FactureRec',
'enabled' => isModEnabled(
'invoice'),
'ClassPath' =>
"/compta/class/facturerec.class.php",
'langs' =>
'bills'),
145 'contract' => array(
'label' =>
'Contracts',
'picto' =>
'contract',
'ObjectClassName' =>
'Contrat',
'enabled' => isModEnabled(
'contract'),
'ClassPath' =>
"/contrat/class/contrat.class.php",
'langs' =>
'contracts'),
146 'contractdet' => array(
'label' =>
'ContractLines',
'picto' =>
'contract',
'ObjectClassName' =>
'ContratLigne',
'enabled' => isModEnabled(
'contract'),
'ClassPath' =>
"/contrat/class/contrat.class.php",
'langs' =>
'contracts'),
147 'bom' => array(
'label' =>
'BOM',
'picto' =>
'bom',
'ObjectClassName' =>
'Bom',
'enabled' => isModEnabled(
'bom')),
148 'mrp' => array(
'label' =>
'MO',
'picto' =>
'mrp',
'ObjectClassName' =>
'Mo',
'enabled' => isModEnabled(
'mrp'),
'ClassPath' =>
"/mrp/class/mo.class.php"),
149 'ticket' => array(
'label' =>
'Ticket',
'picto' =>
'ticket',
'ObjectClassName' =>
'Ticket',
'enabled' => isModEnabled(
'ticket')),
150 'member' => array(
'label' =>
'Adherent',
'picto' =>
'member',
'ObjectClassName' =>
'Adherent',
'enabled' => isModEnabled(
'member'),
'ClassPath' =>
"/adherents/class/adherent.class.php",
'langs' =>
'members'),
151 'cotisation' => array(
'label' =>
'Subscriptions',
'picto' =>
'member',
'ObjectClassName' =>
'Subscription',
'enabled' => isModEnabled(
'member'),
'ClassPath' =>
"/adherents/class/subscription.class.php",
'langs' =>
'members'),
156$parameters = array(
'objecttype' => $objecttype,
'tabfamily' => $tabfamily);
157$reshook = $hookmanager->executeHooks(
'loadDataForCustomReports', $parameters,
$object, $action);
160} elseif (is_array($hookmanager->resArray)) {
161 if (!empty($hookmanager->resArray[
'title'])) {
162 $title = $hookmanager->resArray[
'title'];
164 if (!empty($hookmanager->resArray[
'picto'])) {
165 $picto = $hookmanager->resArray[
'picto'];
167 if (!empty($hookmanager->resArray[
'head'])) {
168 $head = array_merge($head, $hookmanager->resArray[
'head']);
170 if (!empty($hookmanager->resArray[
'arrayoftype'])) {
171 foreach ($hookmanager->resArray[
'arrayoftype'] as $key => $val) {
172 $arrayoftype[$key] = $val;
180 if (!empty($arrayoftype[$objecttype][
'ClassPath'])) {
181 $fileforclass = $arrayoftype[$objecttype][
'ClassPath'];
183 $fileforclass =
"/".$objecttype.
"/class/".$objecttype.
".class.php";
187 $ObjectClassName = $arrayoftype[$objecttype][
'ObjectClassName'];
188 if (!empty($ObjectClassName)) {
189 if (class_exists($ObjectClassName)) {
190 $object =
new $ObjectClassName($db);
192 print
'Failed to load class for type '.$objecttype.
'. Class file found but Class object named '.$ObjectClassName.
' not found.';
195 print
'Failed to load class for type '.$objecttype.
'. Class file name is unknown.';
198 print
'Failed to load class for type '.$objecttype.
'. Class path not found.';
202'@phan-var-force CommonObject $object';
206if ($user->socid > 0) {
212$extrafields->fetch_name_optionals_label(
'all');
215$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
217$search_component_params = array(
'');
218$search_component_params_hidden = trim(
GETPOST(
'search_component_params_hidden',
'alphanohtml'));
219$search_component_params_input = trim(
GETPOST(
'search_component_params_input',
'alphanohtml'));
228 $value = $search_component_params_input;
230 $value = preg_replace(
'/([a-z\.]+)\s*([!<>=]+|in|notin|like|notlike)\s*/',
'\1:\2:', $value);
231 $value = preg_replace(
'/\s*\|\s*/',
'|', $value);
234 $crits = explode(
' ', trim($value));
238 foreach ($crits as $crit) {
243 $tmpcrits = explode(
'|', $crit);
245 foreach ($tmpcrits as $tmpcrit) {
246 if ($tmpcrit !==
'0' && empty($tmpcrit)) {
249 $tmpcrit = trim($tmpcrit);
253 $parenthesislevel = 0;
254 $rescheckfilter =
dolCheckFilters($tmpcrit, $errorstr, $parenthesislevel);
255 if ($rescheckfilter) {
256 while ($parenthesislevel > 0) {
257 $tmpcrit = preg_replace(
'/^\(/',
'', preg_replace(
'/\)$/',
'', $tmpcrit));
262 $field = preg_replace(
'/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:).*$/',
'', $tmpcrit);
263 $tmpcrit = preg_replace(
'/^.*(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/',
'\1', $tmpcrit);
266 $newres .= (($i2 > 0 || $i3 > 0) ?
' OR ' :
'');
269 $newcrit = preg_replace(
'/(:[!<>=\s]+:|:in:|:notin:|:like:|:notlike:)/',
'', $tmpcrit);
273 preg_match(
'/:([!<>=\s]+|in|notin|like|notlike):/', $tmpcrit, $reg);
274 if (!empty($reg[1])) {
277 if ($newcrit !=
'') {
278 if (!preg_match(
'/^\'[^\']*\'$/', $newcrit)) {
280 $newres .=
'('.$field.
':'.$operator.
':'.((float) $numnewcrit).
')';
282 $newres .=
'('.$field.
':'.$operator.
":".((string) $newcrit).
')';
290 $res = $res.($res ?
' AND ' :
'').($i2 > 1 ?
'(' :
'').$newres.($i2 > 1 ?
')' :
'');
297 $search_component_params_input = $res;
303$search_component_params_hidden = implode(
' AND ', array_merge($arrayofandtagshidden, $arrayofandtagsinput));
306$MAXUNIQUEVALFORGROUP = 20;
307$MAXMEASURESINBARGRAPH = 20;
308$SHOWLEGEND = (isset($SHOWLEGEND) ? $SHOWLEGEND : 1);
310$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);
311$MM = substr($langs->trans(
"Month"), 0, 1).substr($langs->trans(
"Month"), 0, 1);
312$DD = substr($langs->trans(
"Day"), 0, 1).substr($langs->trans(
"Day"), 0, 1);
313$HH = substr($langs->trans(
"Hour"), 0, 1).substr($langs->trans(
"Hour"), 0, 1);
314$MI = substr($langs->trans(
"Minute"), 0, 1).substr($langs->trans(
"Minute"), 0, 1);
315$SS = substr($langs->trans(
"Second"), 0, 1).substr($langs->trans(
"Second"), 0, 1);
317$arrayofmesures = array();
318$arrayofxaxis = array();
319$arrayofgroupby = array();
320$arrayofyaxis = array();
321$arrayofvaluesforgroupby = array();
324if (!empty(
$object->element_for_permission)) {
325 $features =
$object->element_for_permission;
327 $features .= (empty(
$object->module) ?
'' :
'@'.$object->module);
347$form =
new Form($db);
350if (!defined(
'USE_CUSTOM_REPORT_AS_INCLUDE')) {
351 llxHeader(
'', $langs->transnoentitiesnoconv(
'CustomReports'),
'');
360$newarrayoftype = array();
361foreach ($arrayoftype as $key => $val) {
362 if (
dol_eval($val[
'enabled'], 1, 1,
'1')) {
363 $newarrayoftype[$key] = $arrayoftype[$key];
365 if (!empty($val[
'langs'])) {
366 $langs->load($val[
'langs']);
371$arrayofmesures =
fillArrayOfMeasures(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofmesures, 0, $count);
372$arrayofmesures =
dol_sort_array($arrayofmesures,
'position',
'asc', 0, 0, 1);
375$arrayofxaxis =
fillArrayOfXAxis(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofxaxis, 0, $count);
376$arrayofxaxis =
dol_sort_array($arrayofxaxis,
'position',
'asc', 0, 0, 1);
379$arrayofgroupby =
fillArrayOfGroupBy(
$object,
't', $langs->trans($newarrayoftype[$objecttype][
'label']), $arrayofgroupby, 0, $count);
380$arrayofgroupby =
dol_sort_array($arrayofgroupby,
'position',
'asc', 0, 0, 1);
384if ($action ==
'viewgraph') {
385 if (is_array($search_measures) && !count($search_measures)) {
386 setEventMessages($langs->trans(
"AtLeastOneMeasureIsRequired"),
null,
'warnings');
387 } elseif ($mode ==
'graph' && is_array($search_xaxis) && count($search_xaxis) > 1) {
388 setEventMessages($langs->trans(
"OnlyOneFieldForXAxisIsPossible"),
null,
'warnings');
389 $search_xaxis = array(0 => $search_xaxis[0]);
391 if (is_array($search_groupby) && count($search_groupby) >= 2) {
392 setEventMessages($langs->trans(
"ErrorOnlyOneFieldForGroupByIsPossible"),
null,
'warnings');
393 $search_groupby = array(0 => $search_groupby[0]);
395 if (is_array($search_xaxis) && !count($search_xaxis)) {
396 setEventMessages($langs->trans(
"AtLeastOneXAxisIsRequired"),
null,
'warnings');
397 } elseif ($mode ==
'graph' && $search_graph ==
'bars' && count($search_measures) > $MAXMEASURESINBARGRAPH) {
398 $langs->load(
"errors");
399 setEventMessages($langs->trans(
"GraphInBarsAreLimitedToNMeasures", $MAXMEASURESINBARGRAPH),
null,
'warnings');
400 $search_graph =
'lines';
406if (is_array($search_groupby) && count($search_groupby)) {
408 foreach ($search_groupby as $gkey => $gval) {
409 $gvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $gval);
411 if (preg_match(
'/\-year$/', $search_groupby[$gkey])) {
412 $tmpval = preg_replace(
'/\-year$/',
'', $search_groupby[$gkey]);
413 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y')";
414 } elseif (preg_match(
'/\-month$/', $search_groupby[$gkey])) {
415 $tmpval = preg_replace(
'/\-month$/',
'', $search_groupby[$gkey]);
416 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y-%m')";
417 } elseif (preg_match(
'/\-day$/', $search_groupby[$gkey])) {
418 $tmpval = preg_replace(
'/\-day$/',
'', $search_groupby[$gkey]);
419 $fieldtocount .=
'DATE_FORMAT('.$tmpval.
", '%Y-%m-%d')";
421 $fieldtocount = $search_groupby[$gkey];
424 $sql =
"SELECT DISTINCT ".$fieldtocount.
" as val";
426 if (strpos($fieldtocount,
'te') === 0) {
427 $tabletouse =
$object->table_element;
428 $tablealiastouse =
'te';
429 if (!empty($arrayofgroupby[$gval])) {
430 $tmpval = explode(
'.', $gval);
431 $tabletouse = $arrayofgroupby[$gval][
'table'];
432 $tablealiastouse = $tmpval[0];
437 $sql .=
" FROM ".MAIN_DB_PREFIX.$tabletouse.
"_extrafields as ".$tablealiastouse;
439 $tabletouse =
$object->table_element;
440 $tablealiastouse =
't';
441 if (!empty($arrayofgroupby[$gval])) {
442 $tmpval = explode(
'.', $gval);
443 $tabletouse = $arrayofgroupby[$gval][
'table'];
444 $tablealiastouse = $tmpval[0];
446 $sql .=
" FROM ".MAIN_DB_PREFIX.$tabletouse.
" as ".$tablealiastouse;
457 $sql .=
" LIMIT ".((int) ($MAXUNIQUEVALFORGROUP + 1));
460 $resql = $db->query($sql);
465 while ($obj = $db->fetch_object($resql)) {
466 if (is_null($obj->val)) {
467 $keytouse =
'__NULL__';
468 $valuetranslated = $langs->transnoentitiesnoconv(
"NotDefined");
469 } elseif ($obj->val ===
'') {
471 $valuetranslated = $langs->transnoentitiesnoconv(
"Empty");
473 $keytouse = (string) $obj->val;
474 $valuetranslated = $obj->val;
478 if (!empty(
$object->fields[$gvalwithoutprefix][
'arrayofkeyval'])) {
479 $valuetranslated =
$object->fields[$gvalwithoutprefix][
'arrayofkeyval'][$obj->val];
480 if (is_null($valuetranslated)) {
481 $valuetranslated = $langs->transnoentitiesnoconv(
"UndefinedKey");
483 $valuetranslated = $langs->trans($valuetranslated);
484 } elseif (preg_match(
'/integer:([^:]+):([^:]+)$/',
$object->fields[$gvalwithoutprefix][
'type'], $regs)) {
485 $classname = $regs[1];
486 $classpath = $regs[2];
488 if (class_exists($classname)) {
489 $tmpobject =
new $classname($db);
490 '@phan-var-force CommonObject $tmpobject';
491 $tmpobject->fetch($obj->val);
492 foreach ($tmpobject->fields as $fieldkey => $field) {
493 if ($field[
'showoncombobox']) {
494 $valuetranslated = $tmpobject->$fieldkey;
503 $arrayofvaluesforgroupby[
'g_'.$gkey][$keytouse] = $valuetranslated;
506 $tmpfield = explode(
'.', $gval);
507 if ($tmpfield[0] !=
't' || (is_array(
$object->fields[$tmpfield[1]]) && empty(
$object->fields[$tmpfield[1]][
'notnull']))) {
508 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");
510 $arrayofvaluesforgroupby[
'g_'.$gkey][
'__NULL__'] = $langs->transnoentitiesnoconv(
"NotDefined");
513 if (is_array($arrayofvaluesforgroupby[
'g_'.$gkey])) {
514 asort($arrayofvaluesforgroupby[
'g_'.$gkey]);
518 if (is_array($arrayofvaluesforgroupby[
'g_'.$gkey]) && count($arrayofvaluesforgroupby[
'g_'.$gkey]) > $MAXUNIQUEVALFORGROUP) {
519 $langs->load(
"errors");
521 if (strpos($fieldtocount,
'te') === 0) {
525 $keyforlabeloffield = $extrafields->attributes[
$object->table_element][
'label'][$gvalwithoutprefix];
526 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
527 } elseif (strpos($fieldtocount,
't__') === 0) {
529 if (preg_match(
'/^(.*)\.(.*)/', $gvalwithoutprefix, $reg)) {
536 $labeloffield = $arrayofgroupby[$fieldtocount][
'labelnohtml'];
538 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
542 if (preg_match(
'/^(.*)\-(year|month|day)/', $gvalwithoutprefix, $reg)) {
543 $gvalwithoutprefix = preg_replace(
'/\-(year|month|day)/',
'', $gvalwithoutprefix);
544 $keyforlabeloffield =
$object->fields[$gvalwithoutprefix][
'label'];
545 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield).
'-'.$reg[2];
547 $keyforlabeloffield =
$object->fields[$gvalwithoutprefix][
'label'];
548 $labeloffield = $langs->transnoentitiesnoconv($keyforlabeloffield);
552 setEventMessages($langs->trans(
"ErrorTooManyDifferentValueForSelectedGroupBy", $MAXUNIQUEVALFORGROUP, $labeloffield),
null,
'warnings');
553 $search_groupby = array();
563$endyear = $tmparray[
'year'];
564$endmonth = $tmparray[
'mon'];
566$startyear = $endyear - 2;
571if (!defined(
'MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
572 print
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'" autocomplete="off">';
573 print
'<input type="hidden" name="token" value="'.newToken().
'">';
574 print
'<input type="hidden" name="action" value="viewgraph">';
575 print
'<input type="hidden" name="tabfamily" value="'.$tabfamily.
'">';
579 $viewmode .=
'<div class="divadvancedsearchfield">';
580 $arrayofgraphs = array(
'bars' =>
'Bars',
'lines' =>
'Lines');
581 $viewmode .=
'<div class="inline-block opacitymedium"><span class="fas fa-chart-area paddingright" title="'.$langs->trans(
"Graph").
'"></span>'.$langs->trans(
"Graph").
'</div> ';
582 $viewmode .= $form->selectarray(
'search_graph', $arrayofgraphs, $search_graph, 0, 0, 0,
'', 1, 0, 0,
'',
'graphtype width100');
583 $viewmode .=
'</div>';
586 $massactionbutton =
'';
591 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);
594 foreach ($newarrayoftype as $tmpkey => $tmpval) {
595 $newarrayoftype[$tmpkey][
'label'] =
img_picto(
'', $tmpval[
'picto'],
'class="pictofixedwidth"').$langs->trans($tmpval[
'label']);
598 print
'<div class="liste_titre liste_titre_bydiv liste_titre_bydiv_inlineblock centpercent">';
601 print
'<div class="divadvancedsearchfield center floatnone">';
602 print
'<div class="inline-block"><span class="opacitymedium">'.$langs->trans(
"StatisticsOn").
'</span></div> ';
603 print $form->selectarray(
'objecttype', $newarrayoftype, $objecttype, 0, 0, 0,
'', 1, 0, 0,
'',
'minwidth200', 1,
'', 0, 1);
604 if (empty($conf->use_javascript_ajax)) {
605 print
'<input type="submit" class="button buttongen button-save nomargintop" name="changeobjecttype" value="'.$langs->trans(
"Refresh").
'">';
607 print
'<!-- js code to reload page with good object type -->
608 <script nonce="'.getNonce().
'" type="text/javascript">
609 jQuery(document).ready(function() {
610 jQuery("#objecttype").change(function() {
611 console.log("Reload for "+jQuery("#objecttype").val());
612 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')) :
'').
'";
617 print
'</div><div class="clearboth"></div>';
621 print
'<div class="divadvancedsearchfield">';
622 print $form->searchComponent(array(
$object->element =>
$object->fields), $search_component_params, array(), $search_component_params_hidden);
629 print
'<div class="divadvancedsearchfield clearboth">';
630 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>';
631 $simplearrayofmesures = array();
632 foreach ($arrayofmesures as $key => $val) {
633 $simplearrayofmesures[$key] = $arrayofmesures[$key][
'label'];
635 print $form->multiselectarray(
'search_measures', $simplearrayofmesures, $search_measures, 0, 0,
'minwidth300', 1, 0,
'',
'', $langs->trans(
"Measures"));
640 print
'<div class="divadvancedsearchfield">';
641 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>';
643 print $formother->selectXAxisField(
$object, $search_xaxis, $arrayofxaxis, $langs->trans(
"XAxis"),
'minwidth300 maxwidth400');
648 print
'<div class="divadvancedsearchfield">';
649 print
'<div class="inline-block opacitymedium"><span class="fas fa-ruler-horizontal paddingright pictofixedwidth" title="'.dol_escape_htmltag($langs->trans(
"GroupBy")).
'"></span></div>';
650 print $formother->selectGroupByField(
$object, $search_groupby, $arrayofgroupby,
'minwidth250 maxwidth300', $langs->trans(
"GroupBy"));
654 if ($mode ==
'grid') {
656 print
'<div class="divadvancedsearchfield">';
657 foreach (
$object->fields as $key => $val) {
658 if (empty($val[
'measure']) && (!isset($val[
'enabled']) ||
dol_eval($val[
'enabled'], 1, 1,
'1'))) {
659 if (in_array($key, array(
'id',
'rowid',
'entity',
'last_main_doc',
'extraparams'))) {
662 if (preg_match(
'/^fk_/', $key)) {
665 if (in_array($val[
'type'], array(
'html',
'text'))) {
668 if (in_array($val[
'type'], array(
'timestamp',
'date',
'datetime'))) {
669 $arrayofyaxis[
't.'.$key.
'-year'] = array(
670 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
')',
671 'position' => $val[
'position'],
672 'table' =>
$object->table_element
674 $arrayofyaxis[
't.'.$key.
'-month'] = array(
675 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
')',
676 'position' => $val[
'position'],
677 'table' =>
$object->table_element
679 $arrayofyaxis[
't.'.$key.
'-day'] = array(
680 'label' => $langs->trans($val[
'label']).
' ('.$YYYY.
'-'.$MM.
'-'.$DD.
')',
681 'position' => $val[
'position'],
682 'table' =>
$object->table_element
685 $arrayofyaxis[
't.'.$key] = array(
686 'label' => $val[
'label'],
687 'position' => (
int) $val[
'position'],
688 'table' =>
$object->table_element
694 if (
$object->isextrafieldmanaged) {
695 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
696 if (!empty($extrafields->attributes[
$object->table_element][
'totalizable'][$key]) && (!isset($extrafields->attributes[
$object->table_element][
'enabled'][$key]) ||
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'enabled'][$key], 1, 1,
'1'))) {
697 $arrayofyaxis[
'te.'.$key] = array(
698 'label' => $extrafields->attributes[
$object->table_element][
'label'][$key],
699 'position' => (
int) $extrafields->attributes[
$object->table_element][
'pos'][$key],
700 'table' =>
$object->table_element
706 $arrayofyaxislabel = array();
707 foreach ($arrayofyaxis as $key => $val) {
708 $arrayofyaxislabel[$key] = $val[
'label'];
710 print
'<div class="inline-block opacitymedium"><span class="fas fa-ruler-vertical paddingright" title="'.$langs->trans(
"YAxis").
'"></span>'.$langs->trans(
"YAxis").
'</div> ';
711 print $form->multiselectarray(
'search_yaxis', $arrayofyaxislabel, $search_yaxis, 0, 0,
'minwidth100', 1);
715 if ($mode ==
'graph') {
719 print
'<div class="divadvancedsearchfield">';
720 print
'<input type="submit" class="button buttongen button-save nomargintop" value="'.$langs->trans(
"Refresh").
'">';
728if (!empty($search_measures) && !empty($search_xaxis)) {
734 foreach ($search_xaxis as $key => $val) {
735 if (preg_match(
'/\-year$/', $val)) {
736 $tmpval = preg_replace(
'/\-year$/',
'', $val);
737 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y') as x_".$key.
', ';
738 } elseif (preg_match(
'/\-month$/', $val)) {
739 $tmpval = preg_replace(
'/\-month$/',
'', $val);
740 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m') as x_".$key.
', ';
741 } elseif (preg_match(
'/\-day$/', $val)) {
742 $tmpval = preg_replace(
'/\-day$/',
'', $val);
743 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d') as x_".$key.
', ';
745 $sql .= $val.
" as x_".$key.
", ";
748 if (!empty($search_groupby)) {
749 foreach ($search_groupby as $key => $val) {
750 if (preg_match(
'/\-year$/', $val)) {
751 $tmpval = preg_replace(
'/\-year$/',
'', $val);
752 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y') as g_".$key.
', ';
753 } elseif (preg_match(
'/\-month$/', $val)) {
754 $tmpval = preg_replace(
'/\-month$/',
'', $val);
755 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m') as g_".$key.
', ';
756 } elseif (preg_match(
'/\-day$/', $val)) {
757 $tmpval = preg_replace(
'/\-day$/',
'', $val);
758 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d') as g_".$key.
', ';
760 $sql .= $val.
" as g_".$key.
", ";
764 foreach ($search_measures as $key => $val) {
765 if ($val ==
't.count') {
766 $sql .=
"COUNT(t.".$fieldid.
") as y_".$key.
', ';
767 } elseif (preg_match(
'/\-sum$/', $val)) {
768 $tmpval = preg_replace(
'/\-sum$/',
'', $val);
769 $sql .=
"SUM(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
770 } elseif (preg_match(
'/\-average$/', $val)) {
771 $tmpval = preg_replace(
'/\-average$/',
'', $val);
772 $sql .=
"AVG(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
773 } elseif (preg_match(
'/\-min$/', $val)) {
774 $tmpval = preg_replace(
'/\-min$/',
'', $val);
775 $sql .=
"MIN(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
776 } elseif (preg_match(
'/\-max$/', $val)) {
777 $tmpval = preg_replace(
'/\-max$/',
'', $val);
778 $sql .=
"MAX(".$db->ifsql($tmpval.
' IS NULL',
'0', $tmpval).
") as y_".$key.
", ";
781 $sql = preg_replace(
'/,\s*$/',
'', $sql);
782 $sql .=
" FROM ".MAIN_DB_PREFIX.$object->table_element.
" as t";
784 if (
$object->isextrafieldmanaged) {
785 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as te ON te.fk_object = t.".$fieldid;
788 if (
$object->ismultientitymanaged) {
789 if (
$object->ismultientitymanaged == 1) {
792 $tmparray = explode(
'@',
$object->ismultientitymanaged);
793 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.$tmparray[1].
" as parenttableforentity ON t.".$tmparray[0].
" = parenttableforentity.rowid";
794 $sql .=
" AND parenttableforentity.entity IN (".getEntity($tmparray[1]).
")";
799 $listoftablesalreadyadded = array(
$object->table_element =>
$object->table_element);
803 foreach ($search_xaxis as $key => $val) {
804 if (!empty($arrayofxaxis[$val])) {
805 $tmpval = explode(
'.', $val);
808 foreach ($tmpforloop as $tmptable => $tmptablealias) {
809 if (! in_array($tmptable, $listoftablesalreadyadded)) {
810 $tmpforexplode = explode(
'__', $tmptablealias);
811 $endpart = end($tmpforexplode);
812 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
814 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
815 $listoftablesalreadyadded[$tmptable] = $tmptable;
817 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
818 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
819 $listoftablesalreadyadded[$tmptable] = $tmptable;
824 $errormessage =
'Found a key into search_xaxis not found into arrayofxaxis';
830 foreach ($search_groupby as $key => $val) {
831 if (!empty($arrayofgroupby[$val])) {
832 $tmpval = explode(
'.', $val);
835 foreach ($tmpforloop as $tmptable => $tmptablealias) {
836 if (! in_array($tmptable, $listoftablesalreadyadded)) {
837 $tmpforexplode = explode(
'__', $tmptablealias);
838 $endpart = end($tmpforexplode);
839 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
841 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
842 $listoftablesalreadyadded[$tmptable] = $tmptable;
844 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
845 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
846 $listoftablesalreadyadded[$tmptable] = $tmptable;
851 $errormessage =
'Found a key into search_groupby not found into arrayofgroupby';
857 foreach ($search_measures as $key => $val) {
858 if (!empty($arrayofmesures[$val])) {
859 $tmpval = explode(
'.', $val);
862 foreach ($tmpforloop as $tmptable => $tmptablealias) {
863 if (! in_array($tmptable, $listoftablesalreadyadded)) {
864 $tmpforexplode = explode(
'__', $tmptablealias);
865 $endpart = end($tmpforexplode);
866 $parenttableandfield = preg_replace(
'/__'.$endpart.
'$/',
'', $tmptablealias).
'.'.$endpart;
868 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
" as ".$db->sanitize($tmptablealias).
" ON ".$db->sanitize($parenttableandfield).
" = ".$db->sanitize($tmptablealias).
".rowid";
869 $listoftablesalreadyadded[$tmptable] = $tmptable;
871 if (preg_match(
'/^te/', $tmpval[0]) && preg_replace(
'/^t_/',
'te_', $tmptablealias) == $tmpval[0]) {
872 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$tmptable.
"_extrafields as ".$db->sanitize($tmpval[0]).
" ON ".$db->sanitize($tmpval[0]).
".fk_object = ".$db->sanitize($tmptablealias).
".rowid";
873 $listoftablesalreadyadded[$tmptable] = $tmptable;
878 $errormessage =
'Found a key into search_measures not found into arrayofmesures';
882 $sql .=
" WHERE 1 = 1";
883 if (
$object->ismultientitymanaged == 1) {
884 $sql .=
" AND t.entity IN (".getEntity(
$object->element).
")";
887 $sqlfilters = $search_component_params_hidden;
891 $sql .=
" GROUP BY ";
892 foreach ($search_xaxis as $key => $val) {
893 if (preg_match(
'/\-year$/', $val)) {
894 $tmpval = preg_replace(
'/\-year$/',
'', $val);
895 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
896 } elseif (preg_match(
'/\-month$/', $val)) {
897 $tmpval = preg_replace(
'/\-month$/',
'', $val);
898 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
899 } elseif (preg_match(
'/\-day$/', $val)) {
900 $tmpval = preg_replace(
'/\-day$/',
'', $val);
901 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
906 if (!empty($search_groupby)) {
907 foreach ($search_groupby as $key => $val) {
908 if (preg_match(
'/\-year$/', $val)) {
909 $tmpval = preg_replace(
'/\-year$/',
'', $val);
910 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
911 } elseif (preg_match(
'/\-month$/', $val)) {
912 $tmpval = preg_replace(
'/\-month$/',
'', $val);
913 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
914 } elseif (preg_match(
'/\-day$/', $val)) {
915 $tmpval = preg_replace(
'/\-day$/',
'', $val);
916 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
922 $sql = preg_replace(
'/,\s*$/',
'', $sql);
923 $sql .=
' ORDER BY ';
924 foreach ($search_xaxis as $key => $val) {
925 if (preg_match(
'/\-year$/', $val)) {
926 $tmpval = preg_replace(
'/\-year$/',
'', $val);
927 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
928 } elseif (preg_match(
'/\-month$/', $val)) {
929 $tmpval = preg_replace(
'/\-month$/',
'', $val);
930 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
931 } elseif (preg_match(
'/\-day$/', $val)) {
932 $tmpval = preg_replace(
'/\-day$/',
'', $val);
933 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
938 if (!empty($search_groupby)) {
939 foreach ($search_groupby as $key => $val) {
940 if (preg_match(
'/\-year$/', $val)) {
941 $tmpval = preg_replace(
'/\-year$/',
'', $val);
942 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y'), ";
943 } elseif (preg_match(
'/\-month$/', $val)) {
944 $tmpval = preg_replace(
'/\-month$/',
'', $val);
945 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m'), ";
946 } elseif (preg_match(
'/\-day$/', $val)) {
947 $tmpval = preg_replace(
'/\-day$/',
'', $val);
948 $sql .=
"DATE_FORMAT(".$tmpval.
", '%Y-%m-%d'), ";
954 $sql = preg_replace(
'/,\s*$/',
'', $sql);
957 if (!empty($customsql)) {
964 print
'<div class="warning">';
972foreach ($search_measures as $key => $val) {
973 $legend[] = $langs->trans($arrayofmesures[$val][
'label']);
976$useagroupby = (is_array($search_groupby) && count($search_groupby));
984 $resql = $db->query($sql);
986 print
'<div class="warning">';
994 while ($obj = $db->fetch_object($resql)) {
997 $xval = $search_xaxis[0];
998 $fieldforxkey =
'x_0';
999 $xlabel = $obj->$fieldforxkey;
1000 $xvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $xval);
1003 if (!empty(
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'])) {
1004 $xlabel =
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'][$obj->$fieldforxkey];
1006 $labeltouse = (($xlabel || $xlabel ==
'0') ?
dol_trunc($xlabel, 20,
'middle') : ($xlabel ===
'' ? $langs->transnoentitiesnoconv(
"Empty") : $langs->transnoentitiesnoconv(
"NotDefined")));
1008 if ($oldlabeltouse !==
'' && ($labeltouse != $oldlabeltouse)) {
1012 $oldlabeltouse = $labeltouse;
1025 foreach ($search_measures as $key => $val) {
1027 foreach ($search_groupby as $gkey) {
1030 foreach ($arrayofvaluesforgroupby[
'g_'.$gi] as $gvaluepossiblekey => $gvaluepossiblelabel) {
1031 $ykeysuffix = $gvaluepossiblelabel;
1032 $gvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $gval);
1034 $fieldfory =
'y_'.$key;
1035 $fieldforg =
'g_'.$gi;
1036 $fieldforybis =
'y_'.$key.
'_'.$ykeysuffix;
1040 if (!array_key_exists($xi, $data)) {
1041 $data[$xi] = array();
1044 if (!array_key_exists(
'label', $data[$xi])) {
1045 $data[$xi] = array();
1046 $data[$xi][
'label'] = $labeltouse;
1049 $objfieldforg = $obj->$fieldforg;
1050 if (is_null($objfieldforg)) {
1051 $objfieldforg =
'__NULL__';
1054 if ($gvaluepossiblekey ==
'0') {
1056 if ($objfieldforg ==
'0') {
1058 $data[$xi][$fieldforybis] = $obj->$fieldfory;
1059 } elseif (!isset($data[$xi][$fieldforybis])) {
1061 $data[$xi][$fieldforybis] =
'0';
1065 if ((
string) $objfieldforg === (
string) $gvaluepossiblekey) {
1067 $data[$xi][$fieldforybis] = $obj->$fieldfory;
1068 } elseif (!isset($data[$xi][$fieldforybis])) {
1070 $data[$xi][$fieldforybis] =
'0';
1079 $xval = $search_xaxis[0];
1080 $fieldforxkey =
'x_0';
1081 $xlabel = $obj->$fieldforxkey;
1082 $xvalwithoutprefix = preg_replace(
'/^[a-z]+\./',
'', $xval);
1085 if (!empty(
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'])) {
1086 $xlabel =
$object->fields[$xvalwithoutprefix][
'arrayofkeyval'][$obj->$fieldforxkey];
1089 $labeltouse = (($xlabel || $xlabel ==
'0') ?
dol_trunc($xlabel, 20,
'middle') : ($xlabel ===
'' ? $langs->transnoentitiesnoconv(
"Empty") : $langs->transnoentitiesnoconv(
"NotDefined")));
1090 $xarrayforallseries = array(
'label' => $labeltouse);
1091 foreach ($search_measures as $key => $val) {
1092 $fieldfory =
'y_'.$key;
1093 $xarrayforallseries[$fieldfory] = $obj->$fieldfory;
1095 $data[$xi] = $xarrayforallseries;
1100 $totalnbofrecord = count($data);
1105print
'<!-- Section to show the result -->'.
"\n";
1106print
'<div class="customreportsoutput'.($totalnbofrecord ?
'' :
' customreportsoutputnotdata').
'">';
1109if ($mode ==
'grid') {
1113if ($mode ==
'graph') {
1115 $HEIGHT = (empty($_SESSION[
'dol_screenheight']) ? 400 : $_SESSION[
'dol_screenheight'] - 500);
1119 $mesg = $px1->isGraphKo();
1123 $px1->SetData($data);
1126 $arrayoftypes = array();
1127 foreach ($search_measures as $key => $val) {
1128 $arrayoftypes[] = $search_graph;
1131 $px1->SetLegend($legend);
1132 $px1->setShowLegend($SHOWLEGEND);
1133 $px1->SetMinValue($px1->GetFloorMinValue());
1134 $px1->SetMaxValue($px1->GetCeilMaxValue());
1135 $px1->SetWidth($WIDTH);
1136 $px1->SetHeight($HEIGHT);
1137 $px1->SetYLabel($langs->trans(
"Y"));
1138 $px1->SetShading(3);
1139 $px1->SetHorizTickIncrement(1);
1140 $px1->SetCssPrefix(
"cssboxes");
1141 $px1->SetType($arrayoftypes);
1142 $px1->mode =
'depth';
1145 $dir = $conf->user->dir_temp;
1148 $filenamekey = $dir.
'/customreport_'.
$object->element.(empty($customreportkey) ?
'' : $customreportkey).
'.png';
1149 $fileurlkey = DOL_URL_ROOT.
'/viewimage.php?modulepart=user&file=customreport_'.
$object->element.(empty($customreportkey) ?
'' : $customreportkey).
'.png';
1151 $px1->draw($filenamekey, $fileurlkey);
1153 $texttoshow = $langs->trans(
"NoRecordFound");
1154 if (!GETPOSTISSET(
'search_measures') || !GETPOSTISSET(
'search_xaxis')) {
1155 $texttoshow = $langs->trans(
"SelectYourGraphOptionsFirst");
1158 print $px1->show($totalnbofrecord ? 0 : $texttoshow);
1162if ($sql && !defined(
'MAIN_CUSTOM_REPORT_KEEP_GRAPH_ONLY')) {
1164 print
'<br>'.info_admin($langs->trans(
"SQLUsedForExport").
':<br> '.$sql, 0, 0,
'1',
'',
'TechnicalInformation');
1169if (!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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.