59 public $hidden =
false;
115 public $widgettype =
'';
152 $sql =
"SELECT b.rowid as id, b.box_id, b.position, b.box_order, b.fk_user";
153 $sql .=
" FROM ".MAIN_DB_PREFIX.
"boxes as b";
154 $sql .=
" WHERE b.entity = ".$conf->entity;
155 $sql .=
" AND b.rowid = ".((int) $rowid);
156 dol_syslog(get_class($this).
"::fetch rowid=".$rowid);
158 $resql = $this->db->query($sql);
160 $obj = $this->db->fetch_object($resql);
162 $this->
id = $obj->id;
163 $this->
rowid = $obj->id;
164 $this->box_id = $obj->box_id;
166 $this->box_order = $obj->box_order;
167 $this->fk_user = $obj->fk_user;
185 public function showBox($head =
null, $contents =
null, $nooutput = 0)
187 global $langs, $user, $conf;
189 if (!empty($this->hidden)) {
190 return '\n<!-- Box ".get_class($this)." hidden -->\n';
193 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
198 $cachedir = DOL_DATA_ROOT.
'/boxes/temp';
199 $fileid = get_class($this).
'id-'.$this->box_id.
'-e'.$conf->entity.
'-u'.$user->id.
'-s'.$user->socid.
'.cache';
200 $filename =
'/box-'.$fileid;
209 if (isset($contents[0])) {
210 $nbcol = count($contents[0]);
212 $nblines = count($contents);
214 $out .=
"\n<!-- Box ".get_class($this).
" start -->\n";
216 $out .=
'<div class="box divboxtable boxdraggable" id="boxto_'.$this->box_id.
'">'.
"\n";
218 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto']) || $nblines) {
219 $out .=
'<table summary="boxtable'.$this->box_id.
'" width="100%" class="noborder boxtable">'.
"\n";
223 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto'])) {
224 $out .=
'<tr class="liste_titre box_titre">';
226 if (!empty($head[
'nbcol'])) {
227 $nbcol = $head[
'nbcol'];
230 $out .=
' colspan="'.$nbcol.
'"';
233 if (!empty($conf->use_javascript_ajax)) {
235 $out .=
'<div class="tdoverflowmax400 maxwidth250onsmartphone float">';
237 if (!empty($head[
'text'])) {
238 $s =
dol_trunc($head[
'text'], isset($head[
'limit']) ? $head[
'limit'] : $MAXLENGTHBOX);
241 if (!empty($conf->use_javascript_ajax)) {
246 if (!empty($conf->use_javascript_ajax)) {
248 if (!empty($head[
'sublink'])) {
249 $sublink .=
'<a href="'.$head[
'sublink'].
'"'.(empty($head[
'target']) ?
'' :
' target="'.$head[
'target'].
'"').
'>';
251 if (!empty($head[
'subpicto'])) {
252 $sublink .=
img_picto($head[
'subtext'], $head[
'subpicto'],
'class="opacitymedium marginleftonly '.(empty($head[
'subclass']) ?
'' : $head[
'subclass']).
'" id="idsubimg'.$this->boxcode.
'"');
254 if (!empty($head[
'sublink'])) {
259 $out .=
'<div class="nocellnopadd boxclose floatright nowraponall">';
262 $out .=
img_picto($langs->trans(
"MoveBox", $this->box_id),
'grip_title',
'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"');
263 $out .=
img_picto($langs->trans(
"CloseBox", $this->box_id),
'close_title',
'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.
'"');
264 $label = $head[
'text'];
266 if (!empty($head[
'graph'])) {
267 $label .=
' <span class="opacitymedium fas fa-chart-bar"></span>';
269 $out .=
'<input type="hidden" id="boxlabelentry'.$this->box_id.
'" value="'.
dol_escape_htmltag($label).
'">';
281 for ($i = 0, $n = $nblines; $i < $n; $i++) {
282 if (isset($contents[$i])) {
284 if (isset($contents[$i][0][
'tr'])) {
285 $out .=
'<tr '.$contents[$i][0][
'tr'].
'>';
287 $out .=
'<tr class="oddeven">';
291 $nbcolthisline = count($contents[$i]);
292 for ($j = 0; $j < $nbcolthisline; $j++) {
295 if (!empty($contents[$i][$j][
'td'])) {
296 $tdparam .=
' '.$contents[$i][$j][
'td'];
299 $text = isset($contents[$i][$j][
'text']) ? $contents[$i][$j][
'text'] :
'';
300 $textwithnotags = preg_replace(
'/<([^>]+)>/i',
'', $text);
301 $text2 = isset($contents[$i][$j][
'text2']) ? $contents[$i][$j][
'text2'] :
'';
302 $text2withnotags = preg_replace(
'/<([^>]+)>/i',
'', $text2);
304 $textnoformat = isset($contents[$i][$j][
'textnoformat']) ? $contents[$i][$j][
'textnoformat'] :
'';
306 if (empty($contents[$i][$j][
'tooltip'])) {
307 $contents[$i][$j][
'tooltip'] =
"";
309 $tooltip = isset($contents[$i][$j][
'tooltip']) ? $contents[$i][$j][
'tooltip'] :
'';
311 $out .=
'<td'.$tdparam.
'>'.
"\n";
314 if (!empty($contents[$i][$j][
'url']) && empty($contents[$i][$j][
'logo'])) {
315 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'"';
316 if (!empty($tooltip)) {
317 $out .=
' title="'.dol_escape_htmltag($langs->trans(
"Show").
' '.$tooltip, 1).
'" class="classfortooltip"';
320 $out .= isset($contents[$i][$j][
'target']) ?
' target="'.$contents[$i][$j][
'target'].
'"' :
'';
325 if (!empty($contents[$i][$j][
'logo'])) {
326 $logo = preg_replace(
"/^object_/i",
"", $contents[$i][$j][
'logo']);
327 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'">';
328 $out .=
img_object($langs->trans(
"Show").
' '.$tooltip, $logo,
'class="classfortooltip"');
331 $maxlength = $MAXLENGTHBOX;
332 if (isset($contents[$i][$j][
'maxlength'])) {
333 $maxlength = $contents[$i][$j][
'maxlength'];
337 $textwithnotags =
dol_trunc($textwithnotags, $maxlength);
339 if (preg_match(
'/^<(img|div|span)/i', $text) || !empty($contents[$i][$j][
'asis'])) {
342 $out .= $textwithnotags;
346 if (!empty($contents[$i][$j][
'url'])) {
350 if (preg_match(
'/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j][
'asis2'])) {
353 $out .= $text2withnotags;
356 if (!empty($textnoformat)) {
357 $out .=
"\n".$textnoformat.
"\n";
368 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto']) || $nblines) {
369 $out .=
"</table>\n";
373 if (empty($head[
'text']) && empty($head[
'sublink']) && empty($head[
'subpicto']) && !$nblines) {
379 $out .=
"<!-- Box ".get_class($this).
" end -->\n\n";
384 dol_syslog(get_class($this).
'::showBoxCached');
385 $out =
"<!-- Box ".get_class($this).
" from cache -->";
408 global $conf, $langs, $db;
413 $iscoreorexternal = array();
419 $dirwidget = array(
'/core/boxes/');
420 if (is_array($forcedirwidget)) {
421 $dirwidget = $forcedirwidget;
424 foreach ($dirwidget as $reldir) {
429 if (!is_dir($newdir)) {
433 $handle = opendir($newdir);
434 if (is_resource($handle)) {
435 while (($file = readdir($handle)) !==
false) {
437 if (is_readable($newdir.
'/'.$file) && preg_match(
'/^(.+)\.php/', $file, $reg)) {
438 if (preg_match(
'/\.back$/', $file) || preg_match(
'/^(.+)\.disabled\.php/', $file)) {
444 $modName = ucfirst($reg[1]);
446 if (in_array($modName, $modules)) {
447 $langs->load(
"errors");
448 print
'<div class="error">'.$langs->trans(
"Error").
' : '.$langs->trans(
"ErrorDuplicateWidget", $modName,
"").
'</div>';
451 include_once $newdir.
'/'.$file;
453 print $e->getMessage();
458 $fullpath[$i] = $dir.
'/'.$file;
459 $relpath[$i] = preg_replace(
'/^\//',
'', $reldir).
'/'.$file;
460 $iscoreorexternal[$i] = ($reldir ==
'/core/boxes/' ?
'internal' :
'external');
461 $modules[$i] = $modName;
462 $orders[$i] = $part1;
478 foreach ($orders as $key => $value) {
479 $modName = $modules[$key];
480 if (empty($modName)) {
484 if (!class_exists($modName)) {
485 print
'Error: A widget file was found but its class "'.$modName.
'" was not found.'.
"<br>\n";
489 $objMod =
new $modName($db);
490 if (is_object($objMod)) {
493 $disabledbymodule = 0;
497 if (preg_match(
'/NORUN$/i', $files[$key])) {
502 $widget[$j][
'picto'] = (empty($objMod->picto) ? (empty($objMod->boximg) ?
img_object(
'',
'generic') : $objMod->boximg) :
img_object(
'', $objMod->picto));
503 $widget[$j][
'file'] = $files[$key];
504 $widget[$j][
'fullpath'] = $fullpath[$key];
505 $widget[$j][
'relpath'] = $relpath[$key];
506 $widget[$j][
'iscoreorexternal'] = $iscoreorexternal[$key];
507 $widget[$j][
'version'] = empty($objMod->version) ?
'' : $objMod->version;
508 $widget[$j][
'status'] =
img_picto($langs->trans(
"Active"),
'tick');
509 if ($disabledbyname > 0 || $disabledbymodule > 1) {
510 $widget[$j][
'status'] =
'';
513 $text =
'<b>'.$langs->trans(
"Description").
':</b><br>';
514 $text .= $objMod->boxlabel.
'<br>';
515 $text .=
'<br><b>'.$langs->trans(
"Status").
':</b><br>';
516 if ($disabledbymodule == 2) {
517 $text .= $langs->trans(
"WidgetDisabledAsModuleDisabled", $module).
'<br>';
520 $widget[$j][
'info'] = $text;
showBox($head=null, $contents=null, $nooutput=0)
Standard method to show a box (usage by boxes not mandatory, a box can still use its own showBox func...
fetch($rowid)
Load a box line from its rowid.
error()
Return last error message.
__construct($db, $param='')
Constructor.
static getWidgetsList($forcedirwidget=null)
Return list of widget.
dol_filecache($directory, $filename, $object)
Store object in file.
dol_readcachefile($directory, $filename)
Read object from cachefile.
dol_cache_refresh($directory, $filename, $cachetime)
Test if Refresh needed.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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...
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e rowid