index.php 32 KB

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