index.php 32 KB

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