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);
160 $obj = $this->
db->fetch_object(
$resql);
162 $this->
id = $obj->id;
163 $this->
rowid = $obj->id;
164 $this->box_id = $obj->box_id;
165 $this->position = $obj->position;
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 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">';
227 $out .=
' colspan="'.$nbcol.
'"';
230 if (!empty($conf->use_javascript_ajax)) {
232 $out .=
'<div class="tdoverflowmax400 maxwidth250onsmartphone float">';
234 if (!empty($head[
'text'])) {
235 $s =
dol_trunc($head[
'text'], isset($head[
'limit']) ? $head[
'limit'] : $MAXLENGTHBOX);
238 if (!empty($conf->use_javascript_ajax)) {
243 if (!empty($conf->use_javascript_ajax)) {
245 if (!empty($head[
'sublink'])) {
246 $sublink .=
'<a href="'.$head[
'sublink'].
'"'.(empty($head[
'target']) ?
'' :
' target="'.$head[
'target'].
'"').
'>';
248 if (!empty($head[
'subpicto'])) {
249 $sublink .=
img_picto($head[
'subtext'], $head[
'subpicto'],
'class="opacitymedium marginleftonly '.(empty($head[
'subclass']) ?
'' : $head[
'subclass']).
'" id="idsubimg'.$this->boxcode.
'"');
251 if (!empty($head[
'sublink'])) {
256 $out .=
'<div class="nocellnopadd boxclose floatright nowraponall">';
259 $out .=
img_picto($langs->trans(
"MoveBox", $this->box_id),
'grip_title',
'class="opacitymedium boxhandle hideonsmartphone cursormove marginleftonly"');
260 $out .=
img_picto($langs->trans(
"CloseBox", $this->box_id),
'close_title',
'class="opacitymedium boxclose cursorpointer marginleftonly" rel="x:y" id="imgclose'.$this->box_id.
'"');
261 $label = $head[
'text'];
263 if (!empty($head[
'graph'])) {
264 $label .=
' <span class="opacitymedium fa fa-bar-chart"></span>';
266 $out .=
'<input type="hidden" id="boxlabelentry'.$this->box_id.
'" value="'.
dol_escape_htmltag($label).
'">';
278 for ($i = 0, $n = $nblines; $i < $n; $i++) {
279 if (isset($contents[$i])) {
281 if (isset($contents[$i][0][
'tr'])) {
282 $out .=
'<tr '.$contents[$i][0][
'tr'].
'>';
284 $out .=
'<tr class="oddeven">';
288 $nbcolthisline = count($contents[$i]);
289 for ($j = 0; $j < $nbcolthisline; $j++) {
292 if (!empty($contents[$i][$j][
'td'])) {
293 $tdparam .=
' '.$contents[$i][$j][
'td'];
296 $text = isset($contents[$i][$j][
'text']) ? $contents[$i][$j][
'text'] :
'';
297 $textwithnotags = preg_replace(
'/<([^>]+)>/i',
'', $text);
298 $text2 = isset($contents[$i][$j][
'text2']) ? $contents[$i][$j][
'text2'] :
'';
299 $text2withnotags = preg_replace(
'/<([^>]+)>/i',
'', $text2);
301 $textnoformat = isset($contents[$i][$j][
'textnoformat']) ? $contents[$i][$j][
'textnoformat'] :
'';
303 if (empty($contents[$i][$j][
'tooltip'])) {
304 $contents[$i][$j][
'tooltip'] =
"";
306 $tooltip = isset($contents[$i][$j][
'tooltip']) ? $contents[$i][$j][
'tooltip'] :
'';
308 $out .=
'<td'.$tdparam.
'>'.
"\n";
311 if (!empty($contents[$i][$j][
'url']) && empty($contents[$i][$j][
'logo'])) {
312 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'"';
313 if (!empty($tooltip)) {
314 $out .=
' title="'.dol_escape_htmltag($langs->trans(
"Show").
' '.$tooltip, 1).
'" class="classfortooltip"';
317 $out .= isset($contents[$i][$j][
'target']) ?
' target="'.$contents[$i][$j][
'target'].
'"' :
'';
322 if (!empty($contents[$i][$j][
'logo'])) {
323 $logo = preg_replace(
"/^object_/i",
"", $contents[$i][$j][
'logo']);
324 $out .=
'<a href="'.$contents[$i][$j][
'url'].
'">';
325 $out .=
img_object($langs->trans(
"Show").
' '.$tooltip, $logo,
'class="classfortooltip"');
328 $maxlength = $MAXLENGTHBOX;
329 if (isset($contents[$i][$j][
'maxlength'])) {
330 $maxlength = $contents[$i][$j][
'maxlength'];
334 $textwithnotags =
dol_trunc($textwithnotags, $maxlength);
336 if (preg_match(
'/^<(img|div|span)/i', $text) || !empty($contents[$i][$j][
'asis'])) {
339 $out .= $textwithnotags;
343 if (!empty($contents[$i][$j][
'url'])) {
347 if (preg_match(
'/^<(img|div|span)/i', $text2) || !empty($contents[$i][$j][
'asis2'])) {
350 $out .= $text2withnotags;
353 if (!empty($textnoformat)) {
354 $out .=
"\n".$textnoformat.
"\n";
365 if (!empty($head[
'text']) || !empty($head[
'sublink']) || !empty($head[
'subpicto']) || $nblines) {
366 $out .=
"</table>\n";
370 if (empty($head[
'text']) && empty($head[
'sublink']) && empty($head[
'subpicto']) && !$nblines) {
376 $out .=
"<!-- Box ".get_class($this).
" end -->\n\n";
377 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
381 dol_syslog(get_class($this).
'::showBoxCached');
382 $out =
"<!-- Box ".get_class($this).
" from cache -->";
405 global $conf, $langs, $db;
410 $iscoreorexternal = array();
416 $dirwidget = array(
'/core/boxes/');
417 if (is_array($forcedirwidget)) {
418 $dirwidget = $forcedirwidget;
421 foreach ($dirwidget as $reldir) {
426 if (!is_dir($newdir)) {
430 $handle = opendir($newdir);
431 if (is_resource($handle)) {
432 while (($file = readdir($handle)) !==
false) {
434 if (is_readable($newdir.
'/'.$file) && preg_match(
'/^(.+)\.php/', $file, $reg)) {
435 if (preg_match(
'/\.back$/', $file)) {
441 $modName = ucfirst($reg[1]);
443 if (in_array($modName, $modules)) {
444 $langs->load(
"errors");
445 print
'<div class="error">'.$langs->trans(
"Error").
' : '.$langs->trans(
"ErrorDuplicateWidget", $modName,
"").
'</div>';
448 include_once $newdir.
'/'.$file;
450 print $e->getMessage();
455 $fullpath[$i] = $dir.
'/'.$file;
456 $relpath[$i] = preg_replace(
'/^\//',
'', $reldir).
'/'.$file;
457 $iscoreorexternal[$i] = ($reldir ==
'/core/boxes/' ?
'internal' :
'external');
458 $modules[$i] = $modName;
459 $orders[$i] = $part1;
474 foreach ($orders as $key => $value) {
475 $modName = $modules[$key];
476 if (empty($modName)) {
480 if (!class_exists($modName)) {
481 print
'Error: A widget file was found but its class "'.$modName.
'" was not found.'.
"<br>\n";
485 $objMod =
new $modName($db);
486 if (is_object($objMod)) {
489 $disabledbymodule = 0;
493 if (preg_match(
'/NORUN$/i', $files[$key])) {
498 $widget[$j][
'picto'] = (empty($objMod->picto) ? (empty($objMod->boximg) ?
img_object(
'',
'generic') : $objMod->boximg) :
img_object(
'', $objMod->picto));
499 $widget[$j][
'file'] = $files[$key];
500 $widget[$j][
'fullpath'] = $fullpath[$key];
501 $widget[$j][
'relpath'] = $relpath[$key];
502 $widget[$j][
'iscoreorexternal'] = $iscoreorexternal[$key];
503 $widget[$j][
'version'] = empty($objMod->version) ?
'' : $objMod->version;
504 $widget[$j][
'status'] =
img_picto($langs->trans(
"Active"),
'tick');
505 if ($disabledbyname > 0 || $disabledbymodule > 1) {
506 $widget[$j][
'status'] =
'';
509 $text =
'<b>'.$langs->trans(
"Description").
':</b><br>';
510 $text .= $objMod->boxlabel.
'<br>';
511 $text .=
'<br><b>'.$langs->trans(
"Status").
':</b><br>';
512 if ($disabledbymodule == 2) {
513 $text .= $langs->trans(
"WidgetDisabledAsModuleDisabled", $module).
'<br>';
516 $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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.