index.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845
  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 if install.lock file is missing or if conf file is writable
  87. if (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.'<br>';
  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 (isModEnabled('agenda') && empty($conf->global->MAIN_DISABLE_BLOCK_AGENDA) && $user->hasRight('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 (isModEnabled('project') && empty($conf->global->MAIN_DISABLE_BLOCK_PROJECT) && $user->hasRight('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 (isModEnabled('project') && empty($conf->global->MAIN_DISABLE_BLOCK_PROJECT) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->hasRight('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 customer proposals open (expired)
  143. if (isModEnabled('propal') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('propal', 'read')) {
  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 supplier proposals open (expired)
  151. if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('supplier_proposal', 'lire')) {
  152. $langs->load("supplier_proposal");
  153. include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  154. $board = new SupplierProposal($db);
  155. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  156. // Number of commercial proposals CLOSED signed (billed)
  157. $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed");
  158. }
  159. // Number of sales orders a deal
  160. if (isModEnabled('commande') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('commande', 'lire')) {
  161. include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  162. $board = new Commande($db);
  163. $dashboardlines[$board->element] = $board->load_board($user);
  164. }
  165. // Number of suppliers orders a deal
  166. if (isModEnabled('supplier_order') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('fournisseur', 'commande', 'lire')) {
  167. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  168. $board = new CommandeFournisseur($db);
  169. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  170. $dashboardlines[$board->element.'_awaiting'] = $board->load_board($user, 'awaiting');
  171. }
  172. // Number of contract / services enabled (delayed)
  173. if (isModEnabled('contrat') && empty($conf->global->MAIN_DISABLE_BLOCK_CONTRACT) && $user->hasRight('contrat', 'lire')) {
  174. include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  175. $board = new Contrat($db);
  176. $dashboardlines[$board->element.'_inactive'] = $board->load_board($user, "inactive");
  177. // Number of active services (expired)
  178. $dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
  179. }
  180. // Number of tickets open
  181. if (isModEnabled('ticket') && empty($conf->global->MAIN_DISABLE_BLOCK_TICKET) && $user->hasRight('ticket', 'read')) {
  182. include_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
  183. $board = new Ticket($db);
  184. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  185. // Number of active services (expired)
  186. //$dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
  187. }
  188. // Number of invoices customers (paid)
  189. if (isModEnabled('facture') && empty($conf->global->MAIN_DISABLE_BLOCK_CUSTOMER) && $user->hasRight('facture', 'lire')) {
  190. include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  191. $board = new Facture($db);
  192. $dashboardlines[$board->element] = $board->load_board($user);
  193. }
  194. // Number of supplier invoices (paid)
  195. if (isModEnabled('supplier_invoice') && empty($conf->global->MAIN_DISABLE_BLOCK_SUPPLIER) && $user->hasRight('fournisseur', 'facture', 'lire')) {
  196. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  197. $board = new FactureFournisseur($db);
  198. $dashboardlines[$board->element] = $board->load_board($user);
  199. }
  200. // Number of transactions to conciliate
  201. if (isModEnabled('banque') && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->hasRight('banque', 'lire') && !$user->socid) {
  202. include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  203. $board = new Account($db);
  204. $nb = $board->countAccountToReconcile(); // Get nb of account to reconciliate
  205. if ($nb > 0) {
  206. $dashboardlines[$board->element] = $board->load_board($user);
  207. }
  208. }
  209. // Number of cheque to send
  210. if (isModEnabled('banque') && empty($conf->global->MAIN_DISABLE_BLOCK_BANK) && $user->hasRight('banque', 'lire') && !$user->socid) {
  211. if (empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
  212. include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php';
  213. $board = new RemiseCheque($db);
  214. $dashboardlines[$board->element] = $board->load_board($user);
  215. }
  216. if (isModEnabled('prelevement')) {
  217. include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  218. $board = new BonPrelevement($db);
  219. $dashboardlines[$board->element . '_direct_debit'] = $board->load_board($user, 'direct_debit');
  220. }
  221. if (isModEnabled('paymentbybanktransfer')) {
  222. include_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
  223. $board = new BonPrelevement($db);
  224. $dashboardlines[$board->element . '_credit_transfer'] = $board->load_board($user, 'credit_transfer');
  225. }
  226. }
  227. // Number of foundation members
  228. if (isModEnabled('adherent') && empty($conf->global->MAIN_DISABLE_BLOCK_ADHERENT) && $user->hasRight('adherent', 'lire') && !$user->socid) {
  229. include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  230. $board = new Adherent($db);
  231. $dashboardlines[$board->element.'_shift'] = $board->load_board($user, 'shift');
  232. $dashboardlines[$board->element.'_expired'] = $board->load_board($user, 'expired');
  233. }
  234. // Number of expense reports to approve
  235. if (isModEnabled('expensereport') && empty($conf->global->MAIN_DISABLE_BLOCK_EXPENSEREPORT) && $user->hasRight('expensereport', 'approve')) {
  236. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  237. $board = new ExpenseReport($db);
  238. $dashboardlines[$board->element.'_toapprove'] = $board->load_board($user, 'toapprove');
  239. }
  240. // Number of expense reports to pay
  241. if (isModEnabled('expensereport') && empty($conf->global->MAIN_DISABLE_BLOCK_EXPENSEREPORT) && $user->hasRight('expensereport', 'to_paid')) {
  242. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  243. $board = new ExpenseReport($db);
  244. $dashboardlines[$board->element.'_topay'] = $board->load_board($user, 'topay');
  245. }
  246. // Number of holidays to approve
  247. if (isModEnabled('holiday') && empty($conf->global->MAIN_DISABLE_BLOCK_HOLIDAY) && $user->hasRight('holiday', 'approve')) {
  248. include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  249. $board = new Holiday($db);
  250. $dashboardlines[$board->element] = $board->load_board($user);
  251. }
  252. $object = new stdClass();
  253. $parameters = array();
  254. $action = '';
  255. $reshook = $hookmanager->executeHooks(
  256. 'addOpenElementsDashboardLine',
  257. $parameters,
  258. $object,
  259. $action
  260. ); // Note that $action and $object may have been modified by some hooks
  261. if ($reshook == 0) {
  262. $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray);
  263. }
  264. /* Open object dashboard */
  265. $dashboardgroup = array(
  266. 'action' =>
  267. array(
  268. 'groupName' => 'Agenda',
  269. 'stats' => array('action'),
  270. ),
  271. 'project' =>
  272. array(
  273. 'groupName' => 'Projects',
  274. 'globalStatsKey' => 'projects',
  275. 'stats' => array('project', 'project_task'),
  276. ),
  277. 'propal' =>
  278. array(
  279. 'groupName' => 'Proposals',
  280. 'globalStatsKey' => 'proposals',
  281. 'stats' =>
  282. array('propal_opened', 'propal_signed'),
  283. ),
  284. 'commande' =>
  285. array(
  286. 'groupName' => 'Orders',
  287. 'globalStatsKey' => 'orders',
  288. 'stats' =>
  289. array('commande'),
  290. ),
  291. 'facture' =>
  292. array(
  293. 'groupName' => 'Invoices',
  294. 'globalStatsKey' => 'invoices',
  295. 'stats' =>
  296. array('facture'),
  297. ),
  298. 'supplier_proposal' =>
  299. array(
  300. 'lang' => 'supplier_proposal',
  301. 'groupName' => 'SupplierProposals',
  302. 'globalStatsKey' => 'askprice',
  303. 'stats' =>
  304. array('supplier_proposal_opened', 'supplier_proposal_signed'),
  305. ),
  306. 'order_supplier' =>
  307. array(
  308. 'groupName' => 'SuppliersOrders',
  309. 'globalStatsKey' => 'supplier_orders',
  310. 'stats' =>
  311. array('order_supplier_opened', 'order_supplier_awaiting'),
  312. ),
  313. 'invoice_supplier' =>
  314. array(
  315. 'groupName' => 'BillsSuppliers',
  316. 'globalStatsKey' => 'supplier_invoices',
  317. 'stats' =>
  318. array('invoice_supplier'),
  319. ),
  320. 'contrat' =>
  321. array(
  322. 'groupName' => 'Contracts',
  323. 'globalStatsKey' => 'Contracts',
  324. 'stats' =>
  325. array('contrat_inactive', 'contrat_active'),
  326. ),
  327. 'ticket' =>
  328. array(
  329. 'groupName' => 'Tickets',
  330. 'globalStatsKey' => 'ticket',
  331. 'stats' =>
  332. array('ticket_opened'),
  333. ),
  334. 'bank_account' =>
  335. array(
  336. 'groupName' => 'BankAccount',
  337. 'stats' =>
  338. array('bank_account', 'chequereceipt', 'widthdraw_direct_debit', 'widthdraw_credit_transfer'),
  339. ),
  340. 'member' =>
  341. array(
  342. 'groupName' => 'Members',
  343. 'globalStatsKey' => 'members',
  344. 'stats' =>
  345. array('member_shift', 'member_expired'),
  346. ),
  347. 'expensereport' =>
  348. array(
  349. 'groupName' => 'ExpenseReport',
  350. 'globalStatsKey' => 'expensereports',
  351. 'stats' =>
  352. array('expensereport_toapprove', 'expensereport_topay'),
  353. ),
  354. 'holiday' =>
  355. array(
  356. 'groupName' => 'Holidays',
  357. 'globalStatsKey' => 'holidays',
  358. 'stats' =>
  359. array('holiday'),
  360. ),
  361. );
  362. $object = new stdClass();
  363. $parameters = array(
  364. 'dashboardgroup' => $dashboardgroup
  365. );
  366. $reshook = $hookmanager->executeHooks('addOpenElementsDashboardGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  367. if ($reshook == 0) {
  368. $dashboardgroup = array_merge($dashboardgroup, $hookmanager->resArray);
  369. }
  370. // Calculate total nb of late
  371. $totallate = $totaltodo = 0;
  372. //Remove any invalid response
  373. //load_board can return an integer if failed, or WorkboardResponse if OK
  374. $valid_dashboardlines = array();
  375. foreach ($dashboardlines as $workboardid => $tmp) {
  376. if ($tmp instanceof WorkboardResponse) {
  377. $tmp->id = $workboardid; // Complete the object to add its id into its name
  378. $valid_dashboardlines[$workboardid] = $tmp;
  379. }
  380. }
  381. // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
  382. foreach ($valid_dashboardlines as $board) {
  383. if ($board->nbtodolate > 0) {
  384. $totaltodo += $board->nbtodo;
  385. $totallate += $board->nbtodolate;
  386. }
  387. }
  388. $openedDashBoardSize = 'info-box-sm'; // use sm by default
  389. foreach ($dashboardgroup as $dashbordelement) {
  390. if (is_array($dashbordelement['stats']) && count($dashbordelement['stats']) > 2) {
  391. $openedDashBoardSize = ''; // use default info box size : big
  392. break;
  393. }
  394. }
  395. $totalLateNumber = $totallate;
  396. $totallatePercentage = ((!empty($totaltodo)) ? round($totallate / $totaltodo * 100, 2) : 0);
  397. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  398. $totallate = $totallatePercentage;
  399. }
  400. $boxwork = '';
  401. $boxwork .= '<div class="box">';
  402. $boxwork .= '<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard centpercent">'."\n";
  403. $boxwork .= '<tr class="liste_titre">';
  404. $boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>';
  405. if ($showweather) {
  406. if ($totallate > 0) {
  407. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
  408. "NActionsLate",
  409. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
  410. ).')';
  411. } else {
  412. $text = $langs->transnoentitiesnoconv("NoItemLate");
  413. }
  414. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  415. //$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
  416. $options = 'height="24px" style="float: right"';
  417. $boxwork .= showWeather($totallate, $text, $options, 'inline-block valignmiddle');
  418. }
  419. $boxwork .= '</th>';
  420. $boxwork .= '</tr>'."\n";
  421. // Show dashboard
  422. $nbworkboardempty = 0;
  423. $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array();
  424. if (!empty($valid_dashboardlines)) {
  425. $openedDashBoard = '';
  426. $boxwork .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
  427. foreach ($dashboardgroup as $groupKey => $groupElement) {
  428. $boards = array();
  429. // Scan $groupElement and save the one with 'stats' that lust be used for Open object dashboard
  430. if (empty($conf->global->MAIN_DISABLE_NEW_OPENED_DASH_BOARD)) {
  431. foreach ($groupElement['stats'] as $infoKey) {
  432. if (!empty($valid_dashboardlines[$infoKey])) {
  433. $boards[] = $valid_dashboardlines[$infoKey];
  434. $isIntopOpenedDashBoard[] = $infoKey;
  435. }
  436. }
  437. }
  438. if (!empty($boards)) {
  439. if (!empty($groupElement['lang'])) {
  440. $langs->load($groupElement['lang']);
  441. }
  442. $groupName = $langs->trans($groupElement['groupName']);
  443. $groupKeyLowerCase = strtolower($groupKey);
  444. // global stats
  445. $globalStatsKey = false;
  446. if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])) { // can be filled by hook
  447. $globalStatsKey = $groupElement['globalStatsKey'];
  448. $groupElement['globalStats'] = array();
  449. }
  450. $openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">'."\n";
  451. $openedDashBoard .= ' <div class="info-box '.$openedDashBoardSize.'">'."\n";
  452. $openedDashBoard .= ' <span class="info-box-icon bg-infobox-'.$groupKeyLowerCase.'">'."\n";
  453. $openedDashBoard .= ' <i class="fa fa-dol-'.$groupKeyLowerCase.'"></i>'."\n";
  454. // Show the span for the total of record
  455. if (!empty($groupElement['globalStats'])) {
  456. $globalStatInTopOpenedDashBoard[] = $globalStatsKey;
  457. $openedDashBoard .= '<span class="info-box-icon-text" title="'.$groupElement['globalStats']['text'].'">'.$nbTotal.'</span>';
  458. }
  459. $openedDashBoard .= '</span>'."\n";
  460. $openedDashBoard .= '<div class="info-box-content">'."\n";
  461. $openedDashBoard .= '<div class="info-box-title" title="'.strip_tags($groupName).'">'.$groupName.'</div>'."\n";
  462. $openedDashBoard .= '<div class="info-box-lines">'."\n";
  463. foreach ($boards as $board) {
  464. $openedDashBoard .= '<div class="info-box-line">';
  465. if (!empty($board->labelShort)) {
  466. $infoName = '<span class="marginrightonly" title="'.$board->label.'">'.$board->labelShort.'</span>';
  467. } else {
  468. $infoName = '<span class="marginrightonly">'.$board->label.'</span>';
  469. }
  470. $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate);
  471. $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").')';
  472. if ($board->id == 'bank_account') {
  473. $textLateTitle .= '<br><span class="opacitymedium">'.$langs->trans("IfYouDontReconcileDisableProperty", $langs->transnoentitiesnoconv("Conciliable")).'</span>';
  474. }
  475. $textLate = '';
  476. if ($board->nbtodolate > 0) {
  477. $textLate .= '<span title="'.dol_escape_htmltag($textLateTitle).'" class="classfortooltip badge badge-warning">';
  478. $textLate .= '<i class="fa fa-exclamation-triangle"></i> '.$board->nbtodolate;
  479. $textLate .= '</span>';
  480. }
  481. $nbtodClass = '';
  482. if ($board->nbtodo > 0) {
  483. $nbtodClass = 'badge badge-info';
  484. } else {
  485. $nbtodClass = 'opacitymedium';
  486. }
  487. // Forge the line to show into the open object box
  488. $labeltoshow = $board->label.' ('.$board->nbtodo.')';
  489. if ($board->total > 0) {
  490. $labeltoshow .= ' - '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
  491. }
  492. $openedDashBoard .= '<a href="'.$board->url.'" class="info-box-text info-box-text-a">'.$infoName.'<span class="classfortooltip'.($nbtodClass ? ' '.$nbtodClass : '').'" title="'.$labeltoshow.'" >';
  493. $openedDashBoard .= $board->nbtodo;
  494. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  495. $openedDashBoard .= ' : '.price($board->total, 0, $langs, 1, -1, -1, $conf->currency);
  496. }
  497. $openedDashBoard .= '</span>';
  498. if ($textLate) {
  499. if ($board->url_late) {
  500. $openedDashBoard .= '</a>';
  501. $openedDashBoard .= ' <a href="'.$board->url_late.'" class="info-box-text info-box-text-a paddingleft">';
  502. } else {
  503. $openedDashBoard .= ' ';
  504. }
  505. $openedDashBoard .= $textLate;
  506. }
  507. $openedDashBoard .= '</a>'."\n";
  508. $openedDashBoard .= '</div>'."\n";
  509. }
  510. // TODO Add hook here to add more "info-box-line"
  511. $openedDashBoard .= ' </div><!-- /.info-box-lines --></div><!-- /.info-box-content -->'."\n";
  512. $openedDashBoard .= ' </div><!-- /.info-box -->'."\n";
  513. $openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  514. $openedDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  515. $openedDashBoard .= "\n";
  516. }
  517. }
  518. if ($showweather && !empty($isIntopOpenedDashBoard)) {
  519. $appendClass = (!empty($conf->global->MAIN_DISABLE_METEO) && $conf->global->MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '');
  520. $weather = getWeatherStatus($totallate);
  521. $text = '';
  522. if ($totallate > 0) {
  523. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv(
  524. "NActionsLate",
  525. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')
  526. ).')';
  527. } else {
  528. $text = $langs->transnoentitiesnoconv("NoItemLate");
  529. }
  530. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  531. $weatherDashBoard = '<div class="box-flex-item '.$appendClass.'"><div class="box-flex-item-with-margin">'."\n";
  532. $weatherDashBoard .= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
  533. $weatherDashBoard .= ' <span class="info-box-icon">';
  534. $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
  535. $weatherDashBoard .= ' </span>'."\n";
  536. $weatherDashBoard .= ' <div class="info-box-content">'."\n";
  537. $weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n";
  538. if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  539. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
  540. "NActionsLate",
  541. price($totallatePercentage).'%'
  542. ).'</span>'."\n";
  543. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
  544. 'NActionsLate',
  545. $totalLateNumber
  546. ).'</span>'."\n";
  547. } else {
  548. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv(
  549. "NActionsLate",
  550. $totalLateNumber
  551. ).'</span>'."\n";
  552. if ($totallatePercentage > 0) {
  553. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans(
  554. 'NActionsLate',
  555. price($totallatePercentage).'%'
  556. ).'</span>'."\n";
  557. }
  558. }
  559. $weatherDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
  560. $weatherDashBoard .= ' </div><!-- /.info-box -->'."\n";
  561. $weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  562. $weatherDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  563. $weatherDashBoard .= "\n";
  564. $openedDashBoard = $weatherDashBoard.$openedDashBoard;
  565. }
  566. if (!empty($isIntopOpenedDashBoard)) {
  567. for ($i = 1; $i <= 10; $i++) {
  568. $openedDashBoard .= '<div class="box-flex-item filler"></div>';
  569. }
  570. }
  571. $nbworkboardcount = 0;
  572. foreach ($valid_dashboardlines as $infoKey => $board) {
  573. if (in_array($infoKey, $isIntopOpenedDashBoard)) {
  574. // skip if info is present on top
  575. continue;
  576. }
  577. if (empty($board->nbtodo)) {
  578. $nbworkboardempty++;
  579. }
  580. $nbworkboardcount++;
  581. $textlate = $langs->trans("NActionsLate", $board->nbtodolate);
  582. $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  583. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
  584. $boxwork .= '<div class="boxstatscontent">';
  585. $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' <span>'.$board->label.'</span></span><br>';
  586. $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>';
  587. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  588. $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.price($board->total).'</span></a>';
  589. }
  590. $boxwork .= '</div>';
  591. if ($board->nbtodolate > 0) {
  592. $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
  593. $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
  594. //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
  595. $boxwork .= img_picto(
  596. $textlate,
  597. "warning_white",
  598. 'class="inline-block hideonsmartphone valigntextbottom"'
  599. ).'';
  600. $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
  601. $boxwork .= $board->nbtodolate;
  602. $boxwork .= '</span>';
  603. $boxwork .= '</a>';
  604. $boxwork .= '</div>';
  605. }
  606. $boxwork .= '</div></div>';
  607. $boxwork .= "\n";
  608. }
  609. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  610. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  611. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  612. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  613. $boxwork .= '</div>';
  614. $boxwork .= '</td></tr>';
  615. } else {
  616. $boxwork .= '<tr class="nohover">';
  617. $boxwork .= '<td class="nohover valignmiddle opacitymedium">';
  618. $boxwork .= $langs->trans("NoOpenedElementToProcess");
  619. $boxwork .= '</td>';
  620. $boxwork .= '</tr>';
  621. }
  622. $boxwork .= '</td></tr>';
  623. $boxwork .= '</table>'; // End table array of working board
  624. $boxwork .= '</div>';
  625. if (!empty($isIntopOpenedDashBoard)) {
  626. print '<div class="fichecenter">';
  627. print '<div class="opened-dash-board-wrap"><div class="box-flex-container">'.$openedDashBoard.'</div></div>';
  628. print '</div>';
  629. }
  630. }
  631. print '<div class="clearboth"></div>';
  632. print '<div class="fichecenter fichecenterbis">';
  633. /*
  634. * Show widgets (boxes)
  635. */
  636. $boxlist = '<div class="twocolumns">';
  637. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  638. if (!empty($nbworkboardcount)) {
  639. $boxlist .= $boxwork;
  640. }
  641. $boxlist .= $resultboxes['boxlista'];
  642. $boxlist .= '</div>';
  643. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  644. $boxlist .= $resultboxes['boxlistb'];
  645. $boxlist .= '</div>';
  646. $boxlist .= "\n";
  647. $boxlist .= '</div>';
  648. print $boxlist;
  649. print '</div>';
  650. //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
  651. // End of page
  652. llxFooter();
  653. $db->close();
  654. /**
  655. * Show weather logo. Logo to show depends on $totallate and values for
  656. * $conf->global->MAIN_METEO_LEVELx
  657. *
  658. * @param int $totallate Nb of element late
  659. * @param string $text Text to show on logo
  660. * @param string $options More parameters on img tag
  661. * @param string $morecss More CSS
  662. * @return string Return img tag of weather
  663. */
  664. function showWeather($totallate, $text, $options, $morecss = '')
  665. {
  666. global $conf;
  667. $weather = getWeatherStatus($totallate);
  668. return img_weather($text, $weather->picto, $options, 0, $morecss);
  669. }
  670. /**
  671. * get weather level
  672. * $conf->global->MAIN_METEO_LEVELx
  673. *
  674. * @param int $totallate Nb of element late
  675. * @return stdClass Return img tag of weather
  676. */
  677. function getWeatherStatus($totallate)
  678. {
  679. global $conf;
  680. $weather = new stdClass();
  681. $weather->picto = '';
  682. $offset = 0;
  683. $factor = 10; // By default
  684. $used_conf = empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_LEVEL' : 'MAIN_METEO_PERCENTAGE_LEVEL';
  685. $level0 = $offset;
  686. $weather->level = 0;
  687. if (!empty($conf->global->{$used_conf.'0'})) {
  688. $level0 = $conf->global->{$used_conf.'0'};
  689. }
  690. $level1 = $offset + 1 * $factor;
  691. if (!empty($conf->global->{$used_conf.'1'})) {
  692. $level1 = $conf->global->{$used_conf.'1'};
  693. }
  694. $level2 = $offset + 2 * $factor;
  695. if (!empty($conf->global->{$used_conf.'2'})) {
  696. $level2 = $conf->global->{$used_conf.'2'};
  697. }
  698. $level3 = $offset + 3 * $factor;
  699. if (!empty($conf->global->{$used_conf.'3'})) {
  700. $level3 = $conf->global->{$used_conf.'3'};
  701. }
  702. if ($totallate <= $level0) {
  703. $weather->picto = 'weather-clear.png';
  704. $weather->level = 0;
  705. } elseif ($totallate <= $level1) {
  706. $weather->picto = 'weather-few-clouds.png';
  707. $weather->level = 1;
  708. } elseif ($totallate <= $level2) {
  709. $weather->picto = 'weather-clouds.png';
  710. $weather->level = 2;
  711. } elseif ($totallate <= $level3) {
  712. $weather->picto = 'weather-many-clouds.png';
  713. $weather->level = 3;
  714. } else {
  715. $weather->picto = 'weather-storm.png';
  716. $weather->level = 4;
  717. }
  718. return $weather;
  719. }