index.php 30 KB

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