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