50 public $info_box_head = array();
55 public $info_box_contents = array();
75 public $hidden =
false;
131 public $widgettype =
'';
168 $sql =
"SELECT b.rowid as id, b.box_id, b.position, b.box_order, b.fk_user";
169 $sql .=
" FROM ".MAIN_DB_PREFIX.
"boxes as b";
170 $sql .=
" WHERE b.entity = ".$conf->entity;
171 $sql .=
" AND b.rowid = ".((int) $rowid);
173 dol_syslog(get_class($this).
"::fetch rowid=".((
int) $rowid));
175 $resql = $this->db->query($sql);
177 $obj = $this->db->fetch_object($resql);
179 $this->
id = $obj->id;
180 $this->
rowid = $obj->id;
181 $this->box_id = $obj->box_id;
183 $this->box_order = $obj->box_order;
184 $this->fk_user = $obj->fk_user;
202 public function showBox($head, $contents, $nooutput = 0)
204 global $langs, $user, $conf;
206 if (!empty($this->hidden)) {
207 return "\n<!-- Box ".get_class($this).
" hidden -->\n";
210 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
215 $cachedir = DOL_DATA_ROOT.
'/users/temp/widgets';
216 $fileid = get_class($this).
'id-'.$this->box_id.
'-e'.$conf->entity.
'-u'.$user->id.
'-s'.$user->socid.
'.cache';
217 $filename =
'/box-'.$fileid;
226 if (isset($contents[0])) {
227 $nbcol = count($contents[0]);
229 $nblines = count($contents);
231 $out .=
"\n<!-- Box ".get_class($this).
" start -->\n";
233 $out .=
'<div class="box divboxtable boxdraggable" id="boxto_'.$this->box_id.
'">'.
"\n";
234 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto']) || $nblines) {
235 $out .=
'<table summary="boxtable'.$this->box_id.
'" class="noborder boxtable centpercent">'.
"\n";
239 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto'])) {
240 $out .=
'<tr class="liste_titre box_titre">';
242 if (!empty($head[
'nbcol'])) {
243 $nbcol = $head[
'nbcol'];
246 $out .=
' colspan="'.$nbcol.
'"';
249 if (!empty($conf->use_javascript_ajax)) {
251 $out .=
'<div class="tdoverflowmax400 maxwidth250onsmartphone float">';
253 if (!empty($head[
'text'])) {
254 $s =
dol_trunc($head[
'text'], isset($head[
'limit']) ? $head[
'limit'] : $MAXLENGTHBOX);
257 if (!empty($conf->use_javascript_ajax)) {
262 if (!empty($conf->use_javascript_ajax)) {
264 if (!empty($head[
'sublink'])) {
265 $sublink .=
'<a href="'.$head[
'sublink'].
'"'.(empty($head[
'target']) ?
'' :
' target="'.$head[
'target'].
'"').
'>';
267 if (!empty($head[
'subpicto'])) {
268 $sublink .=
img_picto($head[
'subtext'], $head[
'subpicto'],
'class="opacitymedium marginleftonly '.(empty($head[
'subclass']) ?
'' : $head[
'subclass']).
'" id="idsubimg'.$this->boxcode.
'"');
270 if (!empty($head[
'sublink'])) {
275 $out .=
'<div class="nocellnopadd boxclose floatright nowraponall">';
278 $out .=
img_picto($langs->trans(
"MoveBox", $this->box_id),
'grip_title',
'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"');
279 $out .=
img_picto($langs->trans(
"CloseBox", $this->box_id),
'close_title',
'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.
'"');
280 $label = $head[
'text'];
282 if (!empty($head[
'graph'])) {
283 $label .=
' <span class="opacitymedium fas fa-chart-bar"></span>';
285 $out .=
'<input type="hidden" id="boxlabelentry'.$this->box_id.
'" value="'.
dol_escape_htmltag($label).
'">';
297 foreach (array_keys($contents) as $i) {
298 if (isset($contents[$i]) && is_array($contents[$i])) {
300 if (isset($contents[$i][0][
'tr'])) {
301 $out .=
'<tr '.$contents[$i][0][
'tr'].
'>';
303 $out .=
'<tr class="oddeven">';
307 $nbcolthisline = count($contents[$i]);
308 foreach (array_keys($contents[$i]) as $j) {
311 if (!empty($contents[$i][$j][
'td'])) {
312 $tdparam .=
' '.$contents[$i][$j][
'td'];
315 $text = isset($contents[$i][$j][
'text']) ? $contents[$i][$j][
'text'] :
'';
316 $textwithnotags = preg_replace(
'/<([^>]+)>/i',
'', $text);
317 $text2 = isset($contents[$i][$j][
'text2']) ? $contents[$i][$j][
'text2'] :
'';
318 $text2withnotags = preg_replace(
'/<([^>]+)>/i',
'', $text2);
320 $textnoformat = isset($contents[$i][$j][
'textnoformat']) ? $contents[$i][$j][
'textnoformat'] :
'';
322 if (empty($contents[$i][$j][
'tooltip'])) {
323 $contents[$i][$j][
'tooltip'] =
"";
325 $tooltip = isset($contents[$i][$j][
'tooltip']) ? $contents[$i][$j][
'tooltip'] :
'';
327 $out .=
'<td'.$tdparam.
'>'.
"\n";
330 if (!empty($contents[$i][$j][
'url']) && empty($contents[$i][$j][
'logo'])) {
331 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'"';
332 if (!empty($tooltip)) {
333 $out .=
' title="'.dol_escape_htmltag($langs->trans(
"Show").
' '.$tooltip, 1).
'" class="classfortooltip"';
336 $out .= isset($contents[$i][$j][
'target']) ?
' target="'.$contents[$i][$j][
'target'].
'"' :
'';
341 if (!empty($contents[$i][$j][
'logo'])) {
342 $logo = preg_replace(
"/^object_/i",
"", $contents[$i][$j][
'logo']);
343 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'">';
344 $out .=
img_object($langs->trans(
"Show").
' '.$tooltip, $logo,
'class="classfortooltip"');
347 $maxlength = $MAXLENGTHBOX;
348 if (isset($contents[$i][$j][
'maxlength'])) {
349 $maxlength = $contents[$i][$j][
'maxlength'];
353 $textwithnotags =
dol_trunc($textwithnotags, $maxlength);
355 if (preg_match(
'/^<(img|div|span)/i', $text) || !empty($contents[$i][$j][
'asis'])) {
358 $out .= $textwithnotags;
362 if (!empty($contents[$i][$j][
'url'])) {
366 if (preg_match(
'/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j][
'asis2'])) {
369 $out .= $text2withnotags;
372 if (!empty($textnoformat)) {
373 $out .=
"\n".$textnoformat.
"\n";
384 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto']) || $nblines) {
385 $out .=
"</table>\n";
389 if (empty($head[
'text']) && empty($head[
'sublink']) && empty($head[
'subpicto']) && !$nblines) {
395 $out .=
"<!-- Box ".get_class($this).
" end -->\n\n";
400 dol_syslog(get_class($this).
'::showBoxCached');
401 $out =
"<!-- Box ".get_class($this).
" from cache -->";
429 $iscoreorexternal = array();
435 $dirwidget = array(
'/core/boxes/');
436 if (is_array($forcedirwidget)) {
437 $dirwidget = $forcedirwidget;
440 foreach ($dirwidget as $reldir) {
445 if (!is_dir($newdir)) {
449 $handle = opendir($newdir);
450 if (is_resource($handle)) {
451 while (($file = readdir($handle)) !==
false) {
453 if (is_readable($newdir.
'/'.$file) && preg_match(
'/^(.+)\.php/', $file, $reg)) {
454 if (preg_match(
'/\.back$/', $file) || preg_match(
'/^(.+)\.disabled\.php/', $file)) {
460 $modName = ucfirst($reg[1]);
462 if (in_array($modName, $modules)) {
463 $langs->load(
"errors");
464 print
'<div class="error">'.$langs->trans(
"Error").
' : '.$langs->trans(
"ErrorDuplicateWidget", $modName,
"").
'</div>';
467 include_once $newdir.
'/'.$file;
469 print $e->getMessage();
474 $fullpath[$i] = $dir.
'/'.$file;
475 $relpath[$i] = preg_replace(
'/^\//',
'', $reldir).
'/'.$file;
476 $iscoreorexternal[$i] = ($reldir ==
'/core/boxes/' ?
'internal' :
'external');
477 $modules[$i] = $modName;
478 $orders[$i] = $part1;
494 foreach ($orders as $key => $value) {
495 $modName = $modules[$key];
496 if (empty($modName)) {
500 if (!class_exists($modName)) {
501 print
'Error: A widget file was found but its class "'.$modName.
'" was not found.'.
"<br>\n";
505 $objMod =
new $modName($db);
506 if (is_object($objMod)) {
509 $disabledbymodule = 0;
513 if (preg_match(
'/NORUN$/i', $files[$key])) {
518 $widget[$j][
'picto'] = (empty($objMod->picto) ? (empty($objMod->boximg) ?
img_object(
'',
'generic') : $objMod->boximg) :
img_object(
'', $objMod->picto));
519 $widget[$j][
'file'] = $files[$key];
520 $widget[$j][
'fullpath'] = $fullpath[$key];
521 $widget[$j][
'relpath'] = $relpath[$key];
522 $widget[$j][
'iscoreorexternal'] = $iscoreorexternal[$key];
523 $widget[$j][
'version'] = empty($objMod->version) ?
'' : $objMod->version;
524 $widget[$j][
'status'] =
img_picto($langs->trans(
"Active"),
'tick');
525 if ($disabledbyname > 0 || $disabledbymodule > 1) {
526 $widget[$j][
'status'] =
'';
529 $text =
'<b>'.$langs->trans(
"Description").
':</b><br>';
530 $text .= $objMod->boxlabel.
'<br>';
531 $text .=
'<br><b>'.$langs->trans(
"Status").
':</b><br>';
532 if ($disabledbymodule == 2) {
533 $text .= $langs->trans(
"WidgetDisabledAsModuleDisabled", $module).
'<br>';
536 $widget[$j][
'info'] = $text;
showBox($head, $contents, $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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
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 TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e rowid