dolibarr  17.0.4
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
7  * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
29 define('CSRFCHECK_WITH_TOKEN', 1); // We force need to use a token to login when making a POST
30 
31 require 'main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
33 
34 // If not defined, we select menu "home"
35 $_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ? GETPOST('mainmenu', 'aZ09') : 'home';
36 $action = GETPOST('action', 'aZ09');
37 
38 $hookmanager->initHooks(array('index'));
39 
40 
41 /*
42  * Actions
43  */
44 
45 // Check if company name is defined (first install)
46 if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) {
47  header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
48  exit;
49 }
50 if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled
51  header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
52  exit;
53 }
54 if (GETPOST('addbox')) { // Add box (when submit is done from a form when ajax disabled)
55  require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
56  $zone = GETPOST('areacode', 'int');
57  $userid = GETPOST('userid', 'int');
58  $boxorder = GETPOST('boxorder', 'aZ09');
59  $boxorder .= GETPOST('boxcombo', 'aZ09');
60 
61  $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
62  if ($result > 0) {
63  setEventMessages($langs->trans("BoxAdded"), null);
64  }
65 }
66 
67 
68 /*
69  * View
70  */
71 
72 if (!isset($form) || !is_object($form)) {
73  $form = new Form($db);
74 }
75 
76 // Title
77 $title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION;
78 if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
79  $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE;
80 }
81 
82 llxHeader('', $title);
83 
84 
85 $resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
86 
87 
88 print load_fiche_titre('&nbsp;', $resultboxes['selectboxlist'], '', 0, '', 'titleforhome');
89 
90 if (!empty($conf->global->MAIN_MOTD)) {
91  $conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD);
92  if (!empty($conf->global->MAIN_MOTD)) {
93  $substitutionarray = getCommonSubstitutionArray($langs);
94  complete_substitutions_array($substitutionarray, $langs);
95  $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs);
96 
97  print "\n<!-- Start of welcome text -->\n";
98  print '<table width="100%" class="notopnoleftnoright"><tr><td>';
99  print dol_htmlentitiesbr($texttoshow);
100  print '</td></tr></table><br>';
101  print "\n<!-- End of welcome text -->\n";
102  }
103 }
104 
105 /*
106  * Show security warnings
107  */
108 
109 // Security warning if install.lock file is missing or if conf file is writable
110 if (empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) {
111  $message = '';
112 
113  // Check if install lock file is present
114  $lockfile = DOL_DATA_ROOT.'/install.lock';
115  if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install")) {
116  $langs->load("errors");
117  //if (!empty($message)) $message.='<br>';
118  $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
119  }
120 
121  // Conf files must be in read only mode
122  if (is_writable($conffile)) {
123  $langs->load("errors");
124  //$langs->load("other");
125  //if (!empty($message)) $message.='<br>';
126  $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
127  }
128 
129  if ($message) {
130  print $message.'<br>';
131  //$message.='<br>';
132  //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
133  }
134 }
135 
136 /*
137  * Dashboard Dolibarr states (statistics)
138  * Hidden for external users
139  */
140 
141 $boxstatItems = array();
142 $boxstatFromHook = '';
143 
144 // Load translation files required by page
145 $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts'));
146 
147 // Dolibarr Working Board with weather
148 if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
149  $showweather = (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0;
150 
151  //Array that contains all WorkboardResponse classes to process them
152  $dashboardlines = array();
153 
154  // Do not include sections without management permission
155  require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
156 
157  // Number of actions to do (late)
158  if (isModEnabled('agenda') && empty($conf->global->MAIN_DISABLE_BLOCK_AGENDA) && $user->hasRight('agenda', 'myactions', 'read')) {
159  include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
160  $board = new ActionComm($db);
161  $dashboardlines[$board->element] = $board->load_board($user);
162  }
163 
164  // Number of project opened
165  if (isModEnabled('project') && empty($conf->global->MAIN_DISABLE_BLOCK_PROJECT) && $user->hasRight('projet', 'lire')) {
166  include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
167  $board = new Project($db);
168  $dashboardlines[$board->element] = $board->load_board($user);
169  }
170 
171  // Number of tasks to do (late)
172  if (isModEnabled('project') && empty($conf->global->MAIN_DISABLE_BLOCK_PROJECT) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->hasRight('projet', 'lire')) {
173  include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
174  $board = new Task($db);
175  $dashboardlines[$board->element] = $board->load_board($user);
176  }
177 
178  // Number of commercial customer proposals open (expired)
179  if (isModEnabled('propal') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('propal', 'read')) {
180  include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
181  $board = new Propal($db);
182  $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
183  // Number of commercial proposals CLOSED signed (billed)
184  $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed");
185  }
186 
187  // Number of supplier proposals open (expired)
188  if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('supplier_proposal', 'lire')) {
189  $langs->load("supplier_proposal");
190  include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
191  $board = new SupplierProposal($db);
192  $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
193  // Number of commercial proposals CLOSED signed (billed)
194  $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed");
195  }
196 
197  // Number of sales orders a deal
198  if (isModEnabled('commande') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('commande', 'lire')) {
199  include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
200  $board = new Commande($db);
201  $dashboardlines[$board->element] = $board->load_board($user);
202  }
203 
204  // Number of suppliers orders a deal
205  if (isModEnabled('supplier_order') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('fournisseur', 'commande', 'lire')) {
206  include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
207  $board = new CommandeFournisseur($db);
208  $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
209  $dashboardlines[$board->element.'_awaiting'] = $board->load_board($user, 'awaiting');
210  }
211 
212  // Number of contract / services enabled (delayed)
213  if (isModEnabled('contrat') && empty($conf->global->MAIN_DISABLE_BLOCK_CONTRACT) && $user->hasRight('contrat', 'lire')) {
214  include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
215  $board = new Contrat($db);
216  $dashboardlines[$board->element.'_inactive'] = $board->load_board($user, "inactive");
217  // Number of active services (expired)
218  $dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
219  }
220 
221  // Number of tickets open
222  if (isModEnabled('ticket') && empty($conf->global->MAIN_DISABLE_BLOCK_TICKET) && $user->hasRight('ticket', 'read')) {
223  include_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
224  $board = new Ticket($db);
225  $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
226  // Number of active services (expired)
227  //$dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
228  }
229 
230  // Number of invoices customers (paid)
231  if (isModEnabled('facture') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('facture', 'lire')) {
232  include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
233  $board = new Facture($db);
234  $dashboardlines[$board->element] = $board->load_board($user);
235  }
236 
237  // Number of supplier invoices (paid)
238  if (isModEnabled('supplier_invoice') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('fournisseur', 'facture', 'lire')) {
239  include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
240  $board = new FactureFournisseur($db);
241  $dashboardlines[$board->element] = $board->load_board($user);
242  }
243 
244  // Number of transactions to conciliate
245  if (isModEnabled('banque') && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->hasRight('banque', 'lire') && !$user->socid) {
246  include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
247  $board = new Account($db);
248  $nb = $board->countAccountToReconcile(); // Get nb of account to reconciliate
249  if ($nb > 0) {
250  $dashboardlines[$board->element] = $board->load_board($user);
251  }
252  }
253 
254 
255  // Number of cheque to send
256  if (isModEnabled('banque') && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->hasRight('banque', 'lire') && !$user->socid) {
257  if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
258  include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
259  $board = new RemiseCheque($db);
260  $dashboardlines[$board->element] = $board->load_board($user);
261  }
262  if (isModEnabled('prelevement')) {
263  include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
264  $board = new BonPrelevement($db);
265  $dashboardlines[$board->element . '_direct_debit'] = $board->load_board($user, 'direct_debit');
266  }
267  if (isModEnabled('paymentbybanktransfer')) {
268  include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
269  $board = new BonPrelevement($db);
270  $dashboardlines[$board->element . '_credit_transfer'] = $board->load_board($user, 'credit_transfer');
271  }
272  }
273 
274  // Number of foundation members
275  if (isModEnabled('adherent') && empty($conf->global->MAIN_DISABLE_BLOCK_ADHERENT) && $user->hasRight('adherent', 'lire') && !$user->socid) {
276  include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
277  $board = new Adherent($db);
278  $dashboardlines[$board->element.'_shift'] = $board->load_board($user, 'shift');
279  $dashboardlines[$board->element.'_expired'] = $board->load_board($user, 'expired');
280  }
281 
282  // Number of expense reports to approve
283  if (isModEnabled('expensereport') && empty($conf->global->MAIN_DISABLE_BLOCK_EXPENSEREPORT) && $user->hasRight('expensereport', 'approve')) {
284  include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
285  $board = new ExpenseReport($db);
286  $dashboardlines[$board->element.'_toapprove'] = $board->load_board($user, 'toapprove');
287  }
288 
289  // Number of expense reports to pay
290  if (isModEnabled('expensereport') && empty($conf->global->MAIN_DISABLE_BLOCK_EXPENSEREPORT) && $user->hasRight('expensereport', 'to_paid')) {
291  include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
292  $board = new ExpenseReport($db);
293  $dashboardlines[$board->element.'_topay'] = $board->load_board($user, 'topay');
294  }
295 
296  // Number of holidays to approve
297  if (isModEnabled('holiday') && empty($conf->global->MAIN_DISABLE_BLOCK_HOLIDAY) && $user->hasRight('holiday', 'approve')) {
298  include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
299  $board = new Holiday($db);
300  $dashboardlines[$board->element] = $board->load_board($user);
301  }
302 
303  $object = new stdClass();
304  $parameters = array();
305  $action = '';
306  $reshook = $hookmanager->executeHooks(
307  'addOpenElementsDashboardLine',
308  $parameters,
309  $object,
310  $action
311  ); // Note that $action and $object may have been modified by some hooks
312  if ($reshook == 0) {
313  $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray);
314  }
315 
316  /* Open object dashboard */
317  $dashboardgroup = array(
318  'action' =>
319  array(
320  'groupName' => 'Agenda',
321  'stats' => array('action'),
322  ),
323  'project' =>
324  array(
325  'groupName' => 'Projects',
326  'globalStatsKey' => 'projects',
327  'stats' => array('project', 'project_task'),
328  ),
329  'propal' =>
330  array(
331  'groupName' => 'Proposals',
332  'globalStatsKey' => 'proposals',
333  'stats' =>
334  array('propal_opened', 'propal_signed'),
335  ),
336  'commande' =>
337  array(
338  'groupName' => 'Orders',
339  'globalStatsKey' => 'orders',
340  'stats' =>
341  array('commande'),
342  ),
343  'facture' =>
344  array(
345  'groupName' => 'Invoices',
346  'globalStatsKey' => 'invoices',
347  'stats' =>
348  array('facture'),
349  ),
350  'supplier_proposal' =>
351  array(
352  'lang' => 'supplier_proposal',
353  'groupName' => 'SupplierProposals',
354  'globalStatsKey' => 'askprice',
355  'stats' =>
356  array('supplier_proposal_opened', 'supplier_proposal_signed'),
357  ),
358  'order_supplier' =>
359  array(
360  'groupName' => 'SuppliersOrders',
361  'globalStatsKey' => 'supplier_orders',
362  'stats' =>
363  array('order_supplier_opened', 'order_supplier_awaiting'),
364  ),
365  'invoice_supplier' =>
366  array(
367  'groupName' => 'BillsSuppliers',
368  'globalStatsKey' => 'supplier_invoices',
369  'stats' =>
370  array('invoice_supplier'),
371  ),
372  'contrat' =>
373  array(
374  'groupName' => 'Contracts',
375  'globalStatsKey' => 'Contracts',
376  'stats' =>
377  array('contrat_inactive', 'contrat_active'),
378  ),
379  'ticket' =>
380  array(
381  'groupName' => 'Tickets',
382  'globalStatsKey' => 'ticket',
383  'stats' =>
384  array('ticket_opened'),
385  ),
386  'bank_account' =>
387  array(
388  'groupName' => 'BankAccount',
389  'stats' =>
390  array('bank_account', 'chequereceipt', 'widthdraw_direct_debit', 'widthdraw_credit_transfer'),
391  ),
392  'member' =>
393  array(
394  'groupName' => 'Members',
395  'globalStatsKey' => 'members',
396  'stats' =>
397  array('member_shift', 'member_expired'),
398  ),
399  'expensereport' =>
400  array(
401  'groupName' => 'ExpenseReport',
402  'globalStatsKey' => 'expensereports',
403  'stats' =>
404  array('expensereport_toapprove', 'expensereport_topay'),
405  ),
406  'holiday' =>
407  array(
408  'groupName' => 'Holidays',
409  'globalStatsKey' => 'holidays',
410  'stats' =>
411  array('holiday'),
412  ),
413  );
414 
415  $object = new stdClass();
416  $parameters = array(
417  'dashboardgroup' => $dashboardgroup
418  );
419  $reshook = $hookmanager->executeHooks('addOpenElementsDashboardGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
420  if ($reshook == 0) {
421  $dashboardgroup = array_merge($dashboardgroup, $hookmanager->resArray);
422  }
423 
424 
425  // Calculate total nb of late
426  $totallate = $totaltodo = 0;
427 
428  //Remove any invalid response
429  //load_board can return an integer if failed, or WorkboardResponse if OK
430  $valid_dashboardlines = array();
431  foreach ($dashboardlines as $workboardid => $tmp) {
432  if ($tmp instanceof WorkboardResponse) {
433  $tmp->id = $workboardid; // Complete the object to add its id into its name
434  $valid_dashboardlines[$workboardid] = $tmp;
435  }
436  }
437 
438  // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
439  foreach ($valid_dashboardlines as $board) {
440  if (is_numeric($board->nbtodo) && is_numeric($board->nbtodolate) && $board->nbtodolate > 0) {
441  $totaltodo += $board->nbtodo;
442  $totallate += $board->nbtodolate;
443  }
444  }
445 
446  $openedDashBoardSize = 'info-box-sm'; // use sm by default
447  foreach ($dashboardgroup as $dashbordelement) {
448  if (is_array($dashbordelement['stats']) && count($dashbordelement['stats']) > 2) {
449  $openedDashBoardSize = ''; // use default info box size : big
450  break;
451  }
452  }
453 
454  $totalLateNumber = $totallate;
455  $totallatePercentage = ((!empty($totaltodo)) ? round($totallate / $totaltodo * 100, 2) : 0);
456  if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
457  $totallate = $totallatePercentage;
458  }
459 
460  $boxwork = '';
461  $boxwork .= '<div class="box">';
462  $boxwork .= '<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard centpercent">'."\n";
463  $boxwork .= '<tr class="liste_titre">';
464  $boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>';
465  if ($showweather) {
466  if ($totallate > 0) {
467  $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
468  "NActionsLate",
469  $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
470  ).')';
471  } else {
472  $text = $langs->transnoentitiesnoconv("NoItemLate");
473  }
474  $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
475  //$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
476  $options = 'height="24px" style="float: right"';
477  $boxwork .= showWeather($totallate, $text, $options, 'inline-block valignmiddle');
478  }
479  $boxwork .= '</th>';
480  $boxwork .= '</tr>'."\n";
481 
482  // Show dashboard
483  $nbworkboardempty = 0;
484  $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array();
485  if (!empty($valid_dashboardlines)) {
486  $openedDashBoard = '';
487 
488  $boxwork .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
489 
490  foreach ($dashboardgroup as $groupKey => $groupElement) {
491  $boards = array();
492 
493  // Scan $groupElement and save the one with 'stats' that lust be used for Open object dashboard
494  if (empty($conf->global->MAIN_DISABLE_NEW_OPENED_DASH_BOARD)) {
495  foreach ($groupElement['stats'] as $infoKey) {
496  if (!empty($valid_dashboardlines[$infoKey])) {
497  $boards[] = $valid_dashboardlines[$infoKey];
498  $isIntopOpenedDashBoard[] = $infoKey;
499  }
500  }
501  }
502 
503  if (!empty($boards)) {
504  if (!empty($groupElement['lang'])) {
505  $langs->load($groupElement['lang']);
506  }
507  $groupName = $langs->trans($groupElement['groupName']);
508  $groupKeyLowerCase = strtolower($groupKey);
509 
510  // global stats
511  $globalStatsKey = false;
512  if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])) { // can be filled by hook
513  $globalStatsKey = $groupElement['globalStatsKey'];
514  $groupElement['globalStats'] = array();
515  }
516 
517  $openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">'."\n";
518  $openedDashBoard .= ' <div class="info-box '.$openedDashBoardSize.'">'."\n";
519  $openedDashBoard .= ' <span class="info-box-icon bg-infobox-'.$groupKeyLowerCase.'">'."\n";
520  $openedDashBoard .= ' <i class="fa fa-dol-'.$groupKeyLowerCase.'"></i>'."\n";
521 
522  // Show the span for the total of record
523  if (!empty($groupElement['globalStats'])) {
524  $globalStatInTopOpenedDashBoard[] = $globalStatsKey;
525  $openedDashBoard .= '<span class="info-box-icon-text" title="'.$groupElement['globalStats']['text'].'">'.$nbTotal.'</span>';
526  }
527 
528  $openedDashBoard .= '</span>'."\n";
529  $openedDashBoard .= '<div class="info-box-content">'."\n";
530 
531  $openedDashBoard .= '<div class="info-box-title" title="'.strip_tags($groupName).'">'.$groupName.'</div>'."\n";
532  $openedDashBoard .= '<div class="info-box-lines">'."\n";
533 
534  foreach ($boards as $board) {
535  $openedDashBoard .= '<div class="info-box-line">';
536 
537  if (!empty($board->labelShort)) {
538  $infoName = '<span class="marginrightonly" title="'.$board->label.'">'.$board->labelShort.'</span>';
539  } else {
540  $infoName = '<span class="marginrightonly">'.$board->label.'</span>';
541  }
542 
543  $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate);
544  $textLateTitle .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil(empty($board->warning_delay) ? 0 : $board->warning_delay) >= 0 ? '+' : '').ceil(empty($board->warning_delay) ? 0 : $board->warning_delay).' '.$langs->trans("days").')';
545 
546  if ($board->id == 'bank_account') {
547  $textLateTitle .= '<br><span class="opacitymedium">'.$langs->trans("IfYouDontReconcileDisableProperty", $langs->transnoentitiesnoconv("Conciliable")).'</span>';
548  }
549 
550  $textLate = '';
551  if ($board->nbtodolate > 0) {
552  $textLate .= '<span title="'.dol_escape_htmltag($textLateTitle).'" class="classfortooltip badge badge-warning">';
553  $textLate .= '<i class="fa fa-exclamation-triangle"></i> '.$board->nbtodolate;
554  $textLate .= '</span>';
555  }
556 
557  $nbtodClass = '';
558  if ($board->nbtodo > 0) {
559  $nbtodClass = 'badge badge-info';
560  } else {
561  $nbtodClass = 'opacitymedium';
562  }
563 
564  // Forge the line to show into the open object box
565  $labeltoshow = $board->label.' ('.$board->nbtodo.')';
566  if ($board->total > 0) {
567  $labeltoshow .= ' - '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
568  }
569  $openedDashBoard .= '<a href="'.$board->url.'" class="info-box-text info-box-text-a">'.$infoName.'<span class="classfortooltip'.($nbtodClass ? ' '.$nbtodClass : '').'" title="'.$labeltoshow.'" >';
570  $openedDashBoard .= $board->nbtodo;
571  if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
572  $openedDashBoard .= ' : '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
573  }
574  $openedDashBoard .= '</span>';
575  if ($textLate) {
576  if ($board->url_late) {
577  $openedDashBoard .= '</a>';
578  $openedDashBoard .= ' <a href="'.$board->url_late.'" class="info-box-text info-box-text-a paddingleft">';
579  } else {
580  $openedDashBoard .= ' ';
581  }
582  $openedDashBoard .= $textLate;
583  }
584  $openedDashBoard .= '</a>'."\n";
585  $openedDashBoard .= '</div>'."\n";
586  }
587 
588  // TODO Add hook here to add more "info-box-line"
589 
590  $openedDashBoard .= ' </div><!-- /.info-box-lines --></div><!-- /.info-box-content -->'."\n";
591  $openedDashBoard .= ' </div><!-- /.info-box -->'."\n";
592  $openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
593  $openedDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
594  $openedDashBoard .= "\n";
595  }
596  }
597 
598  if ($showweather && !empty($isIntopOpenedDashBoard)) {
599  $appendClass = (!empty($conf->global->MAIN_DISABLE_METEO) && $conf->global->MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '');
600  $weather = getWeatherStatus($totallate);
601 
602  $text = '';
603  if ($totallate > 0) {
604  $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
605  "NActionsLate",
606  $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
607  ).')';
608  } else {
609  $text = $langs->transnoentitiesnoconv("NoItemLate");
610  }
611  $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
612 
613  $weatherDashBoard = '<div class="box-flex-item '.$appendClass.'"><div class="box-flex-item-with-margin">'."\n";
614  $weatherDashBoard .= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
615  $weatherDashBoard .= ' <span class="info-box-icon">';
616  $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
617  $weatherDashBoard .= ' </span>'."\n";
618  $weatherDashBoard .= ' <div class="info-box-content">'."\n";
619  $weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n";
620 
621  if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
622  $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
623  "NActionsLate",
624  price($totallatePercentage).'%'
625  ).'</span>'."\n";
626  $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
627  'NActionsLate',
628  $totalLateNumber
629  ).'</span>'."\n";
630  } else {
631  $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
632  "NActionsLate",
633  $totalLateNumber
634  ).'</span>'."\n";
635  if ($totallatePercentage > 0) {
636  $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
637  'NActionsLate',
638  price($totallatePercentage).'%'
639  ).'</span>'."\n";
640  }
641  }
642 
643  $weatherDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
644  $weatherDashBoard .= ' </div><!-- /.info-box -->'."\n";
645  $weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
646  $weatherDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
647  $weatherDashBoard .= "\n";
648 
649  $openedDashBoard = $weatherDashBoard.$openedDashBoard;
650  }
651 
652  if (!empty($isIntopOpenedDashBoard)) {
653  for ($i = 1; $i <= 10; $i++) {
654  $openedDashBoard .= '<div class="box-flex-item filler"></div>';
655  }
656  }
657 
658  $nbworkboardcount = 0;
659  foreach ($valid_dashboardlines as $infoKey => $board) {
660  if (in_array($infoKey, $isIntopOpenedDashBoard)) {
661  // skip if info is present on top
662  continue;
663  }
664 
665  if (empty($board->nbtodo)) {
666  $nbworkboardempty++;
667  }
668  $nbworkboardcount++;
669 
670 
671  $textlate = $langs->trans("NActionsLate", $board->nbtodolate);
672  $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
673 
674 
675  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
676  $boxwork .= '<div class="boxstatscontent">';
677  $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' <span>'.$board->label.'</span></span><br>';
678  $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>';
679  if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
680  $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.price($board->total).'</span></a>';
681  }
682  $boxwork .= '</div>';
683  if ($board->nbtodolate > 0) {
684  $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
685  $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
686  //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"');
687  $boxwork .= img_picto(
688  $textlate,
689  "warning_white",
690  'class="inline-block hideonsmartphone valigntextbottom"'
691  );
692  $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
693  $boxwork .= $board->nbtodolate;
694  $boxwork .= '</span>';
695  $boxwork .= '</a>';
696  $boxwork .= '</div>';
697  }
698  $boxwork .= '</div></div>';
699  $boxwork .= "\n";
700  }
701 
702  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
703  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
704  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
705  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
706 
707  $boxwork .= '</div>';
708  $boxwork .= '</td></tr>';
709  } else {
710  $boxwork .= '<tr class="nohover">';
711  $boxwork .= '<td class="nohover valignmiddle opacitymedium">';
712  $boxwork .= $langs->trans("NoOpenedElementToProcess");
713  $boxwork .= '</td>';
714  $boxwork .= '</tr>';
715  }
716 
717  $boxwork .= '</td></tr>';
718 
719  $boxwork .= '</table>'; // End table array of working board
720  $boxwork .= '</div>';
721 
722  if (!empty($isIntopOpenedDashBoard)) {
723  print '<div class="fichecenter">';
724  print '<div class="opened-dash-board-wrap"><div class="box-flex-container">'.$openedDashBoard.'</div></div>';
725  print '</div>';
726  }
727 }
728 
729 
730 print '<div class="clearboth"></div>';
731 
732 print '<div class="fichecenter fichecenterbis">';
733 
734 
735 /*
736  * Show widgets (boxes)
737  */
738 
739 $boxlist = '<div class="twocolumns">';
740 
741 $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
742 if (!empty($nbworkboardcount)) {
743  $boxlist .= $boxwork;
744 }
745 
746 $boxlist .= $resultboxes['boxlista'];
747 
748 $boxlist .= '</div>';
749 
750 $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
751 
752 $boxlist .= $resultboxes['boxlistb'];
753 
754 $boxlist .= '</div>';
755 $boxlist .= "\n";
756 
757 $boxlist .= '</div>';
758 
759 
760 print $boxlist;
761 
762 print '</div>';
763 
764 //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
765 
766 // End of page
767 llxFooter();
768 $db->close();
769 
770 
781 function showWeather($totallate, $text, $options, $morecss = '')
782 {
783  global $conf;
784 
785  $weather = getWeatherStatus($totallate);
786  return img_weather($text, $weather->picto, $options, 0, $morecss);
787 }
788 
789 
797 function getWeatherStatus($totallate)
798 {
799  global $conf;
800 
801  $weather = new stdClass();
802  $weather->picto = '';
803 
804  $offset = 0;
805  $factor = 10; // By default
806 
807  $used_conf = empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_LEVEL' : 'MAIN_METEO_PERCENTAGE_LEVEL';
808 
809  $level0 = $offset;
810  $weather->level = 0;
811  if (!empty($conf->global->{$used_conf.'0'})) {
812  $level0 = $conf->global->{$used_conf.'0'};
813  }
814  $level1 = $offset + 1 * $factor;
815  if (!empty($conf->global->{$used_conf.'1'})) {
816  $level1 = $conf->global->{$used_conf.'1'};
817  }
818  $level2 = $offset + 2 * $factor;
819  if (!empty($conf->global->{$used_conf.'2'})) {
820  $level2 = $conf->global->{$used_conf.'2'};
821  }
822  $level3 = $offset + 3 * $factor;
823  if (!empty($conf->global->{$used_conf.'3'})) {
824  $level3 = $conf->global->{$used_conf.'3'};
825  }
826 
827  if ($totallate <= $level0) {
828  $weather->picto = 'weather-clear.png';
829  $weather->level = 0;
830  } elseif ($totallate <= $level1) {
831  $weather->picto = 'weather-few-clouds.png';
832  $weather->level = 1;
833  } elseif ($totallate <= $level2) {
834  $weather->picto = 'weather-clouds.png';
835  $weather->level = 2;
836  } elseif ($totallate <= $level3) {
837  $weather->picto = 'weather-many-clouds.png';
838  $weather->level = 3;
839  } else {
840  $weather->picto = 'weather-storm.png';
841  $weather->level = 4;
842  }
843 
844  return $weather;
845 }
Class to manage bank accounts.
Class to manage agenda events (actions)
Class to manage members of a foundation.
Class to manage withdrawal receipts.
Class to manage predefined suppliers products.
Class to manage customers orders.
Class to manage contracts.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
static getBoxesArea($user, $areacode)
Get array with HTML tabs with boxes of a particular area including personalized choices of user.
Class of the module paid holiday.
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Class to manage projects.
Class to manage proposals.
Class to manage cheque delivery receipts.
Class to manage price ask supplier.
Class to manage tasks.
Definition: task.class.php:38
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
showWeather($totallate, $text, $options, $morecss='')
Show weather logo.
Definition: index.php:781
getWeatherStatus($totallate)
get weather level $conf->global->MAIN_METEO_LEVELx
Definition: index.php:797
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Class to generate the form for creating a new ticket.
llxFooter()
Footer empty.
Definition: index.php:71
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63