dolibarr  16.0.5
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 repertoire install existe (si utilisateur admin)
110 if ($user->admin && 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;
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', 'lire')) {
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 customer 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 (!empty($conf->prelevement->enabled)) {
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 (!empty($conf->paymentbybanktransfer->enabled)) {
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 ($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  if (isset($keys) && is_array($keys) && in_array($globalStatsKey, $keys)) {
517  // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
518  $keyIndex = array_search($globalStatsKey, $keys);
519 
520  $classe = (!empty($classes[$keyIndex]) ? $classes[$keyIndex] : '');
521  if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe])) {
522  $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0;
523  $nbTotal = floatval($groupElement['globalStats']['total']);
524  if ($nbTotal >= 10000) {
525  $nbTotal = round($nbTotal / 1000, 2).'k';
526  }
527  $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')';
528  $groupElement['globalStats']['total'] = $nbTotal;
529  //$groupElement['globalStats']['link'] = $links[$keyIndex];
530  }
531  }
532  }
533 
534  $openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">'."\n";
535  $openedDashBoard .= ' <div class="info-box '.$openedDashBoardSize.'">'."\n";
536  $openedDashBoard .= ' <span class="info-box-icon bg-infobox-'.$groupKeyLowerCase.'">'."\n";
537  $openedDashBoard .= ' <i class="fa fa-dol-'.$groupKeyLowerCase.'"></i>'."\n";
538 
539  // Show the span for the total of record
540  if (!empty($groupElement['globalStats'])) {
541  $globalStatInTopOpenedDashBoard[] = $globalStatsKey;
542  $openedDashBoard .= '<span class="info-box-icon-text" title="'.$groupElement['globalStats']['text'].'">'.$nbTotal.'</span>';
543  }
544 
545  $openedDashBoard .= '</span>'."\n";
546  $openedDashBoard .= '<div class="info-box-content">'."\n";
547 
548  $openedDashBoard .= '<div class="info-box-title" title="'.strip_tags($groupName).'">'.$groupName.'</div>'."\n";
549  $openedDashBoard .= '<div class="info-box-lines">'."\n";
550 
551  foreach ($boards as $board) {
552  $openedDashBoard .= '<div class="info-box-line">';
553 
554  if (!empty($board->labelShort)) {
555  $infoName = '<span class="marginrightonly" title="'.$board->label.'">'.$board->labelShort.'</span>';
556  } else {
557  $infoName = '<span class="marginrightonly">'.$board->label.'</span>';
558  }
559 
560  $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate);
561  $textLateTitle .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
562 
563  if ($board->id == 'bank_account') {
564  $textLateTitle .= '<br><span class="opacitymedium">'.$langs->trans("IfYouDontReconcileDisableProperty", $langs->transnoentitiesnoconv("Conciliable")).'</span>';
565  }
566 
567  $textLate = '';
568  if ($board->nbtodolate > 0) {
569  $textLate .= '<span title="'.dol_escape_htmltag($textLateTitle).'" class="classfortooltip badge badge-warning">';
570  $textLate .= '<i class="fa fa-exclamation-triangle"></i> '.$board->nbtodolate;
571  $textLate .= '</span>';
572  }
573 
574  $nbtodClass = '';
575  if ($board->nbtodo > 0) {
576  $nbtodClass = 'badge badge-info';
577  } else {
578  $nbtodClass = 'opacitymedium';
579  }
580 
581  // Forge the line to show into the open object box
582  $labeltoshow = $board->label.' ('.$board->nbtodo.')';
583  if ($board->total > 0) {
584  $labeltoshow .= ' - '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
585  }
586  $openedDashBoard .= '<a href="'.$board->url.'" class="info-box-text info-box-text-a">'.$infoName.'<span class="classfortooltip'.($nbtodClass ? ' '.$nbtodClass : '').'" title="'.$labeltoshow.'" >';
587  $openedDashBoard .= $board->nbtodo;
588  if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
589  $openedDashBoard .= ' : '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
590  }
591  $openedDashBoard .= '</span>';
592  if ($textLate) {
593  if ($board->url_late) {
594  $openedDashBoard .= '</a>';
595  $openedDashBoard .= ' <a href="'.$board->url_late.'" class="info-box-text info-box-text-a paddingleft">';
596  } else {
597  $openedDashBoard .= ' ';
598  }
599  $openedDashBoard .= $textLate;
600  }
601  $openedDashBoard .= '</a>'."\n";
602  $openedDashBoard .= '</div>'."\n";
603  }
604 
605  // TODO Add hook here to add more "info-box-line"
606 
607  $openedDashBoard .= ' </div><!-- /.info-box-lines --></div><!-- /.info-box-content -->'."\n";
608  $openedDashBoard .= ' </div><!-- /.info-box -->'."\n";
609  $openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
610  $openedDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
611  $openedDashBoard .= "\n";
612  }
613  }
614 
615  if ($showweather && !empty($isIntopOpenedDashBoard)) {
616  $appendClass = (!empty($conf->global->MAIN_DISABLE_METEO) && $conf->global->MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '');
617  $weather = getWeatherStatus($totallate);
618 
619  $text = '';
620  if ($totallate > 0) {
621  $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
622  "NActionsLate",
623  $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
624  ).')';
625  } else {
626  $text = $langs->transnoentitiesnoconv("NoItemLate");
627  }
628  $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
629 
630  $weatherDashBoard = '<div class="box-flex-item '.$appendClass.'"><div class="box-flex-item-with-margin">'."\n";
631  $weatherDashBoard .= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
632  $weatherDashBoard .= ' <span class="info-box-icon">';
633  $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
634  $weatherDashBoard .= ' </span>'."\n";
635  $weatherDashBoard .= ' <div class="info-box-content">'."\n";
636  $weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n";
637 
638  if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
639  $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
640  "NActionsLate",
641  price($totallatePercentage).'%'
642  ).'</span>'."\n";
643  $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
644  'NActionsLate',
645  $totalLateNumber
646  ).'</span>'."\n";
647  } else {
648  $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
649  "NActionsLate",
650  $totalLateNumber
651  ).'</span>'."\n";
652  if ($totallatePercentage > 0) {
653  $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
654  'NActionsLate',
655  price($totallatePercentage).'%'
656  ).'</span>'."\n";
657  }
658  }
659 
660  $weatherDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
661  $weatherDashBoard .= ' </div><!-- /.info-box -->'."\n";
662  $weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
663  $weatherDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
664  $weatherDashBoard .= "\n";
665 
666  $openedDashBoard = $weatherDashBoard.$openedDashBoard;
667  }
668 
669  if (!empty($isIntopOpenedDashBoard)) {
670  for ($i = 1; $i <= 10; $i++) {
671  $openedDashBoard .= '<div class="box-flex-item filler"></div>';
672  }
673  }
674 
675  $nbworkboardcount = 0;
676  foreach ($valid_dashboardlines as $infoKey => $board) {
677  if (in_array($infoKey, $isIntopOpenedDashBoard)) {
678  // skip if info is present on top
679  continue;
680  }
681 
682  if (empty($board->nbtodo)) {
683  $nbworkboardempty++;
684  }
685  $nbworkboardcount++;
686 
687 
688  $textlate = $langs->trans("NActionsLate", $board->nbtodolate);
689  $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
690 
691 
692  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
693  $boxwork .= '<div class="boxstatscontent">';
694  $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' <span>'.$board->label.'</span></span><br>';
695  $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>';
696  if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
697  $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.price($board->total).'</span></a>';
698  }
699  $boxwork .= '</div>';
700  if ($board->nbtodolate > 0) {
701  $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
702  $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
703  //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
704  $boxwork .= img_picto(
705  $textlate,
706  "warning_white",
707  'class="inline-block hideonsmartphone valigntextbottom"'
708  ).'';
709  $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
710  $boxwork .= $board->nbtodolate;
711  $boxwork .= '</span>';
712  $boxwork .= '</a>';
713  $boxwork .= '</div>';
714  }
715  $boxwork .= '</div></div>';
716  $boxwork .= "\n";
717  }
718 
719  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
720  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
721  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
722  $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
723 
724  $boxwork .= '</div>';
725  $boxwork .= '</td></tr>';
726  } else {
727  $boxwork .= '<tr class="nohover">';
728  $boxwork .= '<td class="nohover valignmiddle opacitymedium">';
729  $boxwork .= $langs->trans("NoOpenedElementToProcess");
730  $boxwork .= '</td>';
731  $boxwork .= '</tr>';
732  }
733 
734  $boxwork .= '</td></tr>';
735 
736  $boxwork .= '</table>'; // End table array of working board
737  $boxwork .= '</div>';
738 
739  if (!empty($isIntopOpenedDashBoard)) {
740  print '<div class="fichecenter">';
741  print '<div class="opened-dash-board-wrap"><div class="box-flex-container">'.$openedDashBoard.'</div></div>';
742  print '</div>';
743  }
744 }
745 
746 
747 print '<div class="clearboth"></div>';
748 
749 print '<div class="fichecenter fichecenterbis">';
750 
751 
752 /*
753  * Show widgets (boxes)
754  */
755 
756 $boxlist = '<div class="twocolumns">';
757 
758 $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
759 if (!empty($nbworkboardcount)) {
760  $boxlist .= $boxwork;
761 }
762 
763 $boxlist .= $resultboxes['boxlista'];
764 
765 $boxlist .= '</div>';
766 
767 $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
768 
769 $boxlist .= $resultboxes['boxlistb'];
770 
771 $boxlist .= '</div>';
772 $boxlist .= "\n";
773 
774 $boxlist .= '</div>';
775 
776 
777 print $boxlist;
778 
779 print '</div>';
780 
781 //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
782 
783 // End of page
784 llxFooter();
785 $db->close();
786 
787 
798 function showWeather($totallate, $text, $options, $morecss = '')
799 {
800  global $conf;
801 
802  $weather = getWeatherStatus($totallate);
803  return img_weather($text, $weather->picto, $options, 0, $morecss);
804 }
805 
806 
814 function getWeatherStatus($totallate)
815 {
816  global $conf;
817 
818  $weather = new stdClass();
819  $weather->picto = '';
820 
821  $offset = 0;
822  $factor = 10; // By default
823 
824  $used_conf = empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_LEVEL' : 'MAIN_METEO_PERCENTAGE_LEVEL';
825 
826  $level0 = $offset;
827  $weather->level = 0;
828  if (!empty($conf->global->{$used_conf.'0'})) {
829  $level0 = $conf->global->{$used_conf.'0'};
830  }
831  $level1 = $offset + 1 * $factor;
832  if (!empty($conf->global->{$used_conf.'1'})) {
833  $level1 = $conf->global->{$used_conf.'1'};
834  }
835  $level2 = $offset + 2 * $factor;
836  if (!empty($conf->global->{$used_conf.'2'})) {
837  $level2 = $conf->global->{$used_conf.'2'};
838  }
839  $level3 = $offset + 3 * $factor;
840  if (!empty($conf->global->{$used_conf.'3'})) {
841  $level3 = $conf->global->{$used_conf.'3'};
842  }
843 
844  if ($totallate <= $level0) {
845  $weather->picto = 'weather-clear.png';
846  $weather->level = 0;
847  } elseif ($totallate <= $level1) {
848  $weather->picto = 'weather-few-clouds.png';
849  $weather->level = 1;
850  } elseif ($totallate <= $level2) {
851  $weather->picto = 'weather-clouds.png';
852  $weather->level = 2;
853  } elseif ($totallate <= $level3) {
854  $weather->picto = 'weather-many-clouds.png';
855  $weather->level = 3;
856  } else {
857  $weather->picto = 'weather-storm.png';
858  $weather->level = 4;
859  }
860 
861  return $weather;
862 }
make_substitutions
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Definition: functions.lib.php:7839
Project
Class to manage projects.
Definition: project.class.php:35
ActionComm
Class to manage agenda events (actions)
Definition: actioncomm.class.php:38
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
FactureFournisseur
Class to manage suppliers invoices.
Definition: fournisseur.facture.class.php:53
Task
Class to manage tasks.
Definition: task.class.php:37
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
InfoBox\saveboxorder
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Definition: infobox.class.php:224
Facture
Class to manage invoices.
Definition: facture.class.php:60
getWeatherStatus
getWeatherStatus($totallate)
get weather level $conf->global->MAIN_METEO_LEVELx
Definition: index.php:814
WorkboardResponse
Definition: workboardresponse.class.php:25
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
BonPrelevement
Class to manage withdrawal receipts.
Definition: bonprelevement.class.php:43
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
Holiday
Class of the module paid holiday.
Definition: holiday.class.php:34
Commande
Class to manage customers orders.
Definition: commande.class.php:46
getCommonSubstitutionArray
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Definition: functions.lib.php:7275
Adherent
Class to manage members of a foundation.
Definition: adherent.class.php:46
llxHeader
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
showWeather
showWeather($totallate, $text, $options, $morecss='')
Show weather logo.
Definition: index.php:798
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
Contrat
Class to manage contracts.
Definition: contrat.class.php:43
CommandeFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.commande.class.php:47
RemiseCheque
Class to manage cheque delivery receipts.
Definition: remisecheque.class.php:34
img_weather
img_weather($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $morecss='')
Show weather picto.
Definition: functions.lib.php:4231
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_htmlentitiesbr
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...
Definition: functions.lib.php:6991
ExpenseReport
Class to manage Trips and Expenses.
Definition: expensereport.class.php:36
Ticket
Class to generate the form for creating a new ticket.
Definition: html.formticket.class.php:31
price
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.
Definition: functions.lib.php:5541
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
Propal
Class to manage proposals.
Definition: propal.class.php:52
SupplierProposal
Class to manage price ask supplier.
Definition: supplier_proposal.class.php:50
FormOther\getBoxesArea
static getBoxesArea($user, $areacode)
Get array with HTML tabs with boxes of a particular area including personalized choices of user.
Definition: html.formother.class.php:1173
Account
Class to manage bank accounts.
Definition: account.class.php:38
complete_substitutions_array
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...
Definition: functions.lib.php:7961
if
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
Definition: journals_list.php:25