index.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  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. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/index.php
  23. * \brief Dolibarr home page
  24. */
  25. define('NOCSRFCHECK', 1); // This is main home and login page. We must be able to go on it from another web site.
  26. require 'main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  28. // If not defined, we select menu "home"
  29. $_GET['mainmenu'] = GETPOST('mainmenu', 'aZ09') ?GETPOST('mainmenu', 'aZ09') : 'home';
  30. $action = GETPOST('action', 'aZ09');
  31. $hookmanager->initHooks(array('index'));
  32. /*
  33. * Actions
  34. */
  35. // Check if company name is defined (first install)
  36. if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM))
  37. {
  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. {
  43. header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
  44. exit;
  45. }
  46. if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled)
  47. {
  48. require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
  49. $zone = GETPOST('areacode', 'aZ09');
  50. $userid = GETPOST('userid', 'int');
  51. $boxorder = GETPOST('boxorder', 'aZ09');
  52. $boxorder .= GETPOST('boxcombo', 'aZ09');
  53. $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
  54. if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
  55. }
  56. /*
  57. * View
  58. */
  59. if (!is_object($form)) $form = new Form($db);
  60. // Title
  61. $title = $langs->trans("HomeArea").' - Dolibarr '.DOL_VERSION;
  62. if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $title = $langs->trans("HomeArea").' - '.$conf->global->MAIN_APPLICATION_TITLE;
  63. llxHeader('', $title);
  64. $resultboxes = FormOther::getBoxesArea($user, "0"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
  65. print load_fiche_titre('&nbsp;', $resultboxes['selectboxlist'], '', 0, '', 'titleforhome');
  66. if (!empty($conf->global->MAIN_MOTD))
  67. {
  68. $conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD);
  69. if (!empty($conf->global->MAIN_MOTD))
  70. {
  71. $substitutionarray = getCommonSubstitutionArray($langs);
  72. complete_substitutions_array($substitutionarray, $langs);
  73. $texttoshow = make_substitutions($conf->global->MAIN_MOTD, $substitutionarray, $langs);
  74. print "\n<!-- Start of welcome text -->\n";
  75. print '<table width="100%" class="notopnoleftnoright"><tr><td>';
  76. print dol_htmlentitiesbr($texttoshow);
  77. print '</td></tr></table><br>';
  78. print "\n<!-- End of welcome text -->\n";
  79. }
  80. }
  81. /*
  82. * Dashboard Dolibarr states (statistics)
  83. * Hidden for external users
  84. */
  85. $boxstatItems = array();
  86. $boxstatFromHook = '';
  87. // Load translation files required by page
  88. $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts'));
  89. // Load global statistics of objects
  90. if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
  91. {
  92. $object = new stdClass();
  93. $parameters = array();
  94. $action = '';
  95. $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  96. $boxstatFromHook = $hookmanager->resPrint;
  97. if (empty($reshook))
  98. {
  99. // Cle array returned by the method load_state_board for each line
  100. $keys = array(
  101. 'users',
  102. 'members',
  103. 'expensereports',
  104. 'holidays',
  105. 'customers',
  106. 'prospects',
  107. 'suppliers',
  108. 'contacts',
  109. 'products',
  110. 'services',
  111. 'projects',
  112. 'proposals',
  113. 'orders',
  114. 'invoices',
  115. 'donations',
  116. 'supplier_proposals',
  117. 'supplier_orders',
  118. 'supplier_invoices',
  119. 'contracts',
  120. 'interventions',
  121. 'ticket'
  122. );
  123. // Condition to be checked for each display line dashboard
  124. $conditions = array(
  125. 'users' => $user->rights->user->user->lire,
  126. 'members' => !empty($conf->adherent->enabled) && $user->rights->adherent->lire,
  127. 'customers' => !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
  128. 'prospects' => !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
  129. 'suppliers' => !empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
  130. 'contacts' => !empty($conf->societe->enabled) && $user->rights->societe->contact->lire,
  131. 'products' => !empty($conf->product->enabled) && $user->rights->produit->lire,
  132. 'services' => !empty($conf->service->enabled) && $user->rights->service->lire,
  133. 'proposals' => !empty($conf->propal->enabled) && $user->rights->propale->lire,
  134. 'orders' => !empty($conf->commande->enabled) && $user->rights->commande->lire,
  135. 'invoices' => !empty($conf->facture->enabled) && $user->rights->facture->lire,
  136. 'donations' => !empty($conf->don->enabled) && $user->rights->don->lire,
  137. 'contracts' => !empty($conf->contrat->enabled) && $user->rights->contrat->lire,
  138. 'interventions' => !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire,
  139. 'supplier_orders' => !empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS),
  140. 'supplier_invoices' => !empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS),
  141. 'supplier_proposals' => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS),
  142. 'projects' => !empty($conf->projet->enabled) && $user->rights->projet->lire,
  143. 'expensereports' => !empty($conf->expensereport->enabled) && $user->rights->expensereport->lire,
  144. 'holidays' => !empty($conf->holiday->enabled) && $user->rights->holiday->read,
  145. 'ticket' => !empty($conf->ticket->enabled) && $user->rights->ticket->read
  146. );
  147. // Class file containing the method load_state_board for each line
  148. $includes = array(
  149. 'users' => DOL_DOCUMENT_ROOT."/user/class/user.class.php",
  150. 'members' => DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
  151. 'customers' => DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
  152. 'prospects' => DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
  153. 'suppliers' => DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php",
  154. 'contacts' => DOL_DOCUMENT_ROOT."/contact/class/contact.class.php",
  155. 'products' => DOL_DOCUMENT_ROOT."/product/class/product.class.php",
  156. 'services' => DOL_DOCUMENT_ROOT."/product/class/product.class.php",
  157. 'proposals' => DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
  158. 'orders' => DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
  159. 'invoices' => DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
  160. 'donations' => DOL_DOCUMENT_ROOT."/don/class/don.class.php",
  161. 'contracts' => DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
  162. 'interventions' => DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php",
  163. 'supplier_orders' => DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
  164. 'supplier_invoices' => DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php",
  165. 'supplier_proposals' => DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php",
  166. 'projects' => DOL_DOCUMENT_ROOT."/projet/class/project.class.php",
  167. 'expensereports' => DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php",
  168. 'holidays' => DOL_DOCUMENT_ROOT."/holiday/class/holiday.class.php",
  169. 'ticket' => DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"
  170. );
  171. // Name class containing the method load_state_board for each line
  172. $classes = array(
  173. 'users' => 'User',
  174. 'members' => 'Adherent',
  175. 'customers' => 'Client',
  176. 'prospects' => 'Client',
  177. 'suppliers' => 'Fournisseur',
  178. 'contacts' => 'Contact',
  179. 'products' => 'Product',
  180. 'services' => 'ProductService',
  181. 'proposals' => 'Propal',
  182. 'orders' => 'Commande',
  183. 'invoices' => 'Facture',
  184. 'donations' => 'Don',
  185. 'contracts' => 'Contrat',
  186. 'interventions' => 'Fichinter',
  187. 'supplier_orders' => 'CommandeFournisseur',
  188. 'supplier_invoices' => 'FactureFournisseur',
  189. 'supplier_proposals' => 'SupplierProposal',
  190. 'projects' => 'Project',
  191. 'expensereports' => 'ExpenseReport',
  192. 'holidays' => 'Holiday',
  193. 'ticket' => 'Ticket',
  194. );
  195. // Translation keyword
  196. $titres = array(
  197. 'users' => "Users",
  198. 'members' => "Members",
  199. 'customers' => "ThirdPartyCustomersStats",
  200. 'prospects' => "ThirdPartyProspectsStats",
  201. 'suppliers' => "Suppliers",
  202. 'contacts' => "Contacts",
  203. 'products' => "Products",
  204. 'services' => "Services",
  205. 'proposals' => "CommercialProposalsShort",
  206. 'orders' => "CustomersOrders",
  207. 'invoices' => "BillsCustomers",
  208. 'donations' => "Donations",
  209. 'contracts' => "Contracts",
  210. 'interventions' => "Interventions",
  211. 'supplier_orders' => "SuppliersOrders",
  212. 'supplier_invoices' => "SuppliersInvoices",
  213. 'supplier_proposals' => "SupplierProposalShort",
  214. 'projects' => "Projects",
  215. 'expensereports' => "ExpenseReports",
  216. 'holidays' => "Holidays",
  217. 'ticket' => "Ticket",
  218. );
  219. // Dashboard Link lines
  220. $links = array(
  221. 'users' => DOL_URL_ROOT.'/user/list.php',
  222. 'members' => DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members',
  223. 'customers' => DOL_URL_ROOT.'/societe/list.php?type=c&mainmenu=companies',
  224. 'prospects' => DOL_URL_ROOT.'/societe/list.php?type=p&mainmenu=companies',
  225. 'suppliers' => DOL_URL_ROOT.'/societe/list.php?type=f&mainmenu=companies',
  226. 'contacts' => DOL_URL_ROOT.'/contact/list.php?mainmenu=companies',
  227. 'products' => DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products',
  228. 'services' => DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products',
  229. 'proposals' => DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial&leftmenu=propals',
  230. 'orders' => DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial&leftmenu=orders',
  231. 'invoices' => DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills',
  232. 'donations' => DOL_URL_ROOT.'/don/list.php?leftmenu=donations',
  233. 'contracts' => DOL_URL_ROOT.'/contrat/list.php?mainmenu=commercial&leftmenu=contracts',
  234. 'interventions' => DOL_URL_ROOT.'/fichinter/list.php?mainmenu=commercial&leftmenu=ficheinter',
  235. 'supplier_orders' => DOL_URL_ROOT.'/fourn/commande/list.php?mainmenu=commercial&leftmenu=orders_suppliers',
  236. 'supplier_invoices' => DOL_URL_ROOT.'/fourn/facture/list.php?mainmenu=billing&leftmenu=suppliers_bills',
  237. 'supplier_proposals' => DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=',
  238. 'projects' => DOL_URL_ROOT.'/projet/list.php?mainmenu=project',
  239. 'expensereports' => DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport',
  240. 'holidays' => DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm&leftmenu=holiday',
  241. 'ticket' => DOL_URL_ROOT.'/ticket/list.php?leftmenu=ticket'
  242. );
  243. // Translation lang files
  244. $langfile = array(
  245. 'customers' => "companies",
  246. 'contacts' => "companies",
  247. 'services' => "products",
  248. 'proposals' => "propal",
  249. 'invoices' => "bills",
  250. 'supplier_orders' => "orders",
  251. 'supplier_invoices' => "bills",
  252. 'supplier_proposals' => 'supplier_proposal',
  253. 'expensereports' => "trips",
  254. 'holidays' => "holiday",
  255. );
  256. // Loop and displays each line of table
  257. $boardloaded = array();
  258. foreach ($keys as $val)
  259. {
  260. if ($conditions[$val])
  261. {
  262. $boxstatItem = '';
  263. $class = $classes[$val];
  264. // Search in cache if load_state_board is already realized
  265. if (!isset($boardloaded[$class]) || !is_object($boardloaded[$class]))
  266. {
  267. include_once $includes[$val]; // Loading a class cost around 1Mb
  268. $board = new $class($db);
  269. $board->load_state_board();
  270. $boardloaded[$class] = $board;
  271. }
  272. else
  273. {
  274. $board = $boardloaded[$class];
  275. }
  276. $langs->load(empty($langfile[$val]) ? $val : $langfile[$val]);
  277. $text = $langs->trans($titres[$val]);
  278. $boxstatItem .= '<a href="'.$links[$val].'" class="boxstatsindicator thumbstat nobold nounderline">';
  279. $boxstatItem .= '<div class="boxstats">';
  280. $boxstatItem .= '<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.$text.'</span><br>';
  281. $boxstatItem .= '<span class="boxstatsindicator">'.img_object("", $board->picto, 'class="inline-block"').' '.($board->nb[$val] ? $board->nb[$val] : 0).'</span>';
  282. $boxstatItem .= '</div>';
  283. $boxstatItem .= '</a>';
  284. $boxstatItems[$val] = $boxstatItem;
  285. }
  286. }
  287. }
  288. }
  289. // Dolibarr Working Board with weather
  290. if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) {
  291. $showweather = (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0;
  292. //Array that contains all WorkboardResponse classes to process them
  293. $dashboardlines = array();
  294. // Do not include sections without management permission
  295. require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
  296. // Number of actions to do (late)
  297. if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read) {
  298. include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
  299. $board = new ActionComm($db);
  300. $dashboardlines[$board->element] = $board->load_board($user);
  301. }
  302. // Number of project opened
  303. if (!empty($conf->projet->enabled) && $user->rights->projet->lire) {
  304. include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  305. $board = new Project($db);
  306. $dashboardlines[$board->element] = $board->load_board($user);
  307. }
  308. // Number of tasks to do (late)
  309. if (!empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire) {
  310. include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  311. $board = new Task($db);
  312. $dashboardlines[$board->element] = $board->load_board($user);
  313. }
  314. // Number of commercial proposals open (expired)
  315. if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
  316. include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  317. $board = new Propal($db);
  318. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  319. // Number of commercial proposals CLOSED signed (billed)
  320. $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed");
  321. }
  322. // Number of commercial proposals open (expired)
  323. if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire) {
  324. include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  325. $board = new SupplierProposal($db);
  326. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  327. // Number of commercial proposals CLOSED signed (billed)
  328. $dashboardlines[$board->element.'_signed'] = $board->load_board($user, "signed");
  329. }
  330. // Number of customer orders a deal
  331. if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
  332. include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  333. $board = new Commande($db);
  334. $dashboardlines[$board->element] = $board->load_board($user);
  335. }
  336. // Number of suppliers orders a deal
  337. if (!empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire) {
  338. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  339. $board = new CommandeFournisseur($db);
  340. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  341. $dashboardlines[$board->element.'_awaiting'] = $board->load_board($user, 'awaiting');
  342. }
  343. // Number of contract / services enabled (delayed)
  344. if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) {
  345. include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  346. $board = new Contrat($db);
  347. $dashboardlines[$board->element.'_inactive'] = $board->load_board($user, "inactive");
  348. // Number of active services (expired)
  349. $dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
  350. }
  351. // Number of tickets open
  352. if (!empty($conf->ticket->enabled) && $user->rights->ticket->read) {
  353. include_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
  354. $board = new Ticket($db);
  355. $dashboardlines[$board->element.'_opened'] = $board->load_board($user, "opened");
  356. // Number of active services (expired)
  357. //$dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
  358. }
  359. // Number of invoices customers (paid)
  360. if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
  361. include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  362. $board = new Facture($db);
  363. $dashboardlines[$board->element] = $board->load_board($user);
  364. }
  365. // Number of supplier invoices (paid)
  366. if (!empty($conf->supplier_invoice->enabled) && !empty($user->rights->fournisseur->facture->lire)) {
  367. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  368. $board = new FactureFournisseur($db);
  369. $dashboardlines[$board->element] = $board->load_board($user);
  370. }
  371. // Number of transactions to conciliate
  372. if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid) {
  373. include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  374. $board = new Account($db);
  375. $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
  376. if ($nb > 0) {
  377. $dashboardlines[$board->element] = $board->load_board($user);
  378. }
  379. }
  380. // Number of cheque to send
  381. if (!empty($conf->banque->enabled) && $user->rights->banque->lire && !$user->socid && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT)) {
  382. include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
  383. $board = new RemiseCheque($db);
  384. $dashboardlines[$board->element] = $board->load_board($user);
  385. }
  386. // Number of foundation members
  387. if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire && !$user->socid) {
  388. include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  389. $board = new Adherent($db);
  390. $dashboardlines[$board->element.'_shift'] = $board->load_board($user, 'shift');
  391. $dashboardlines[$board->element.'_expired'] = $board->load_board($user, 'expired');
  392. }
  393. // Number of expense reports to approve
  394. if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->approve) {
  395. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  396. $board = new ExpenseReport($db);
  397. $dashboardlines[$board->element . '_toapprove'] = $board->load_board($user, 'toapprove');
  398. }
  399. // Number of expense reports to pay
  400. if (!empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid) {
  401. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  402. $board = new ExpenseReport($db);
  403. $dashboardlines[$board->element . '_topay'] = $board->load_board($user, 'topay');
  404. }
  405. // Number of holidays to approve
  406. if (!empty($conf->holiday->enabled) && $user->rights->holiday->approve) {
  407. include_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
  408. $board = new Holiday($db);
  409. $dashboardlines[$board->element] = $board->load_board($user);
  410. }
  411. $object = new stdClass();
  412. $parameters = array();
  413. $action = '';
  414. $reshook = $hookmanager->executeHooks('addOpenElementsDashboardLine', $parameters, $object,
  415. $action); // Note that $action and $object may have been modified by some hooks
  416. if ($reshook == 0) {
  417. $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray);
  418. }
  419. /* Open object dashboard */
  420. $dashboardgroup = array(
  421. 'action' =>
  422. array(
  423. 'groupName' => 'Agenda',
  424. 'stats' => array('action'),
  425. ),
  426. 'project' =>
  427. array(
  428. 'groupName' => 'Projects',
  429. 'globalStatsKey' => 'projects',
  430. 'stats' => array('project', 'project_task'),
  431. ),
  432. 'propal' =>
  433. array(
  434. 'groupName' => 'Proposals',
  435. 'globalStatsKey' => 'proposals',
  436. 'stats' =>
  437. array('propal_opened', 'propal_signed'),
  438. ),
  439. 'commande' =>
  440. array(
  441. 'groupName' => 'Orders',
  442. 'globalStatsKey' => 'orders',
  443. 'stats' =>
  444. array('commande'),
  445. ),
  446. 'facture' =>
  447. array(
  448. 'groupName' => 'Invoices',
  449. 'globalStatsKey' => 'invoices',
  450. 'stats' =>
  451. array('facture'),
  452. ),
  453. 'supplier_proposal' =>
  454. array(
  455. 'groupName' => 'SupplierProposals',
  456. 'globalStatsKey' => 'askprice',
  457. 'stats' =>
  458. array('supplier_proposal_opened', 'supplier_proposal_signed'),
  459. ),
  460. 'order_supplier' =>
  461. array(
  462. 'groupName' => 'SuppliersOrders',
  463. 'globalStatsKey' => 'supplier_orders',
  464. 'stats' =>
  465. array('order_supplier_opened', 'order_supplier_awaiting'),
  466. ),
  467. 'invoice_supplier' =>
  468. array(
  469. 'groupName' => 'BillsSuppliers',
  470. 'globalStatsKey' => 'supplier_invoices',
  471. 'stats' =>
  472. array('invoice_supplier'),
  473. ),
  474. 'contrat' =>
  475. array(
  476. 'groupName' => 'Contracts',
  477. 'globalStatsKey' => 'Contracts',
  478. 'stats' =>
  479. array('contrat_inactive', 'contrat_active'),
  480. ),
  481. 'ticket' =>
  482. array(
  483. 'groupName' => 'Tickets',
  484. 'globalStatsKey' => 'ticket',
  485. 'stats' =>
  486. array('ticket_opened'),
  487. ),
  488. 'bank_account' =>
  489. array(
  490. 'groupName' => 'BankAccount',
  491. 'stats' =>
  492. array('bank_account', 'chequereceipt'),
  493. ),
  494. 'member' =>
  495. array(
  496. 'groupName' => 'Members',
  497. 'globalStatsKey' => 'members',
  498. 'stats' =>
  499. array('member_shift', 'member_expired'),
  500. ),
  501. 'expensereport' =>
  502. array(
  503. 'groupName' => 'ExpenseReport',
  504. 'globalStatsKey' => 'expensereports',
  505. 'stats' =>
  506. array('expensereport_toapprove', 'expensereport_topay'),
  507. ),
  508. 'holiday' =>
  509. array(
  510. 'groupName' => 'Holidays',
  511. 'globalStatsKey' => 'holidays',
  512. 'stats' =>
  513. array('holiday'),
  514. ),
  515. );
  516. $object = new stdClass();
  517. $parameters = array(
  518. 'dashboardgroup' => $dashboardgroup
  519. );
  520. $reshook = $hookmanager->executeHooks('addOpenElementsDashboardGroup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  521. if ($reshook == 0) {
  522. $dashboardgroup = array_merge($dashboardgroup, $hookmanager->resArray);
  523. }
  524. // Calculate total nb of late
  525. $totallate = $totaltodo = 0;
  526. //Remove any invalid response
  527. //load_board can return an integer if failed or WorkboardResponse if OK
  528. $valid_dashboardlines = array();
  529. foreach ($dashboardlines as $infoKey => $tmp) {
  530. if ($tmp instanceof WorkboardResponse) {
  531. $valid_dashboardlines[$infoKey] = $tmp;
  532. }
  533. }
  534. // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
  535. foreach ($valid_dashboardlines as $board) {
  536. if ($board->nbtodolate > 0) {
  537. $totaltodo += $board->nbtodo;
  538. $totallate += $board->nbtodolate;
  539. }
  540. }
  541. $openedDashBoardSize = 'info-box-sm'; // use sm by default
  542. foreach ($dashboardgroup as $dashbordelement) {
  543. if (is_array($dashbordelement['stats']) && count($dashbordelement['stats']) > 2) {
  544. $openedDashBoardSize = ''; // use default info box size : big
  545. break;
  546. }
  547. }
  548. $totalLateNumber = $totallate;
  549. $totallatePercentage = ((!empty($totaltodo)) ? round($totallate / $totaltodo * 100, 2) : 0);
  550. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  551. $totallate = $totallatePercentage;
  552. }
  553. $boxwork = '';
  554. $boxwork .= '<div class="box">';
  555. $boxwork .= '<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard" width="100%">'."\n";
  556. $boxwork .= '<tr class="liste_titre">';
  557. $boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>';
  558. if ($showweather) {
  559. if ($totallate > 0) {
  560. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",
  561. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
  562. } else {
  563. $text = $langs->transnoentitiesnoconv("NoItemLate");
  564. }
  565. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  566. //$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
  567. $options = 'height="24px" style="float: right"';
  568. $boxwork .= showWeather($totallate, $text, $options, 'inline-block valignmiddle');
  569. }
  570. $boxwork .= '</th>';
  571. $boxwork .= '</tr>'."\n";
  572. // Show dashboard
  573. $nbworkboardempty = 0;
  574. $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array();
  575. if (!empty($valid_dashboardlines)) {
  576. $openedDashBoard = '';
  577. $boxwork .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
  578. foreach ($dashboardgroup as $groupKey => $groupElement) {
  579. $boards = array();
  580. if (empty($conf->global->MAIN_DISABLE_NEW_OPENED_DASH_BOARD)) {
  581. foreach ($groupElement['stats'] as $infoKey) {
  582. if (!empty($valid_dashboardlines[$infoKey])) {
  583. $boards[] = $valid_dashboardlines[$infoKey];
  584. $isIntopOpenedDashBoard[] = $infoKey;
  585. }
  586. }
  587. }
  588. if (!empty($boards)) {
  589. $groupName = $langs->trans($groupElement['groupName']);
  590. $groupKeyLowerCase = strtolower($groupKey);
  591. $nbTotalForGroup = 0;
  592. // global stats
  593. $globalStatsKey = false;
  594. if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])) { // can be filled by hook
  595. $globalStatsKey = $groupElement['globalStatsKey'];
  596. $groupElement['globalStats'] = array();
  597. if (is_array($keys) && in_array($globalStatsKey, $keys))
  598. {
  599. // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
  600. $keyIndex = array_search($globalStatsKey, $keys);
  601. $classe = $classes[$keyIndex];
  602. if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe]))
  603. {
  604. $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0;
  605. $nbTotal = doubleval($groupElement['globalStats']['total']);
  606. if ($nbTotal >= 10000) { $nbTotal = round($nbTotal / 1000, 2).'k'; }
  607. $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')';
  608. $groupElement['globalStats']['total'] = $nbTotal;
  609. $groupElement['globalStats']['link'] = $links[$keyIndex];
  610. }
  611. }
  612. }
  613. $openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">'."\n";
  614. $openedDashBoard .= ' <div class="info-box '.$openedDashBoardSize.'">'."\n";
  615. $openedDashBoard .= ' <span class="info-box-icon bg-infobox-'.$groupKeyLowerCase.'">'."\n";
  616. $openedDashBoard .= ' <i class="fa fa-dol-'.$groupKeyLowerCase.'"></i>'."\n";
  617. // Show the span for the total of record
  618. if (!empty($groupElement['globalStats'])) {
  619. $globalStatInTopOpenedDashBoard[] = $globalStatsKey;
  620. $openedDashBoard .= ' <span class="info-box-icon-text" title="'.$groupElement['globalStats']['text'].'">'.$nbTotal.'</span>'."\n";
  621. }
  622. $openedDashBoard .= ' </span>'."\n";
  623. $openedDashBoard .= ' <div class="info-box-content">'."\n";
  624. $openedDashBoard .= ' <span class="info-box-title" title="'.strip_tags($groupName).'">'.$groupName.'</span>'."\n";
  625. foreach ($boards as $board) {
  626. if (!empty($board->labelShort)) {
  627. $infoName = '<span title="'.$board->label.'">'.$board->labelShort.'</span>';
  628. } else {
  629. $infoName = $board->label;
  630. }
  631. $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate);
  632. $textLateTitle .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  633. $textLate = '';
  634. if ($board->nbtodolate > 0) {
  635. $textLate .= '<span title="'.dol_htmlentities($textLateTitle).'" class="classfortooltip badge badge-warning">';
  636. $textLate .= '<i class="fa fa-exclamation-triangle"></i> '.$board->nbtodolate;
  637. $textLate .= '</span>';
  638. }
  639. $openedDashBoard .= '<div class="info-box-line">';
  640. $nbtodClass = '';
  641. if ($board->nbtodo > 0) {
  642. $nbtodClass = 'badge badge-info';
  643. }
  644. $openedDashBoard .= ' <a href="'.$board->url.'" class="info-box-text info-box-text-a">'.$infoName.' : <span class="'.$nbtodClass.' classfortooltip" title="'.$board->label.'" >'.$board->nbtodo.'</span>';
  645. if ($textLate) {
  646. if ($board->url_late) {
  647. $openedDashBoard .= '</a>';
  648. $openedDashBoard .= ' <a href="'.$board->url_late.'" class="info-box-text info-box-text-a paddingleft">';
  649. } else {
  650. $openedDashBoard .= ' ';
  651. }
  652. $openedDashBoard .= $textLate;
  653. }
  654. $openedDashBoard .= '</a>'."\n";
  655. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  656. $openedDashBoard .= '<a href="'.$board->url.'" class="info-box-text">'.$langs->trans('Total').' : '.price($board->total).'</a>';
  657. }
  658. $openedDashBoard .= '</div>';
  659. }
  660. $openedDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
  661. $openedDashBoard .= ' </div><!-- /.info-box -->'."\n";
  662. $openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  663. $openedDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  664. $openedDashBoard .= "\n";
  665. }
  666. }
  667. if ($showweather && !empty($isIntopOpenedDashBoard)) {
  668. $appendClass = $conf->global->MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '';
  669. $weather = getWeatherStatus($totallate);
  670. $text = '';
  671. if ($totallate > 0) {
  672. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",
  673. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
  674. } else {
  675. $text = $langs->transnoentitiesnoconv("NoItemLate");
  676. }
  677. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  678. $weatherDashBoard = '<div class="box-flex-item '.$appendClass.'"><div class="box-flex-item-with-margin">'."\n";
  679. $weatherDashBoard .= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
  680. $weatherDashBoard .= ' <span class="info-box-icon">';
  681. $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
  682. $weatherDashBoard .= ' </span>'."\n";
  683. $weatherDashBoard .= ' <div class="info-box-content">'."\n";
  684. $weatherDashBoard .= ' <span class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</span>'."\n";
  685. if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  686. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate",
  687. price($totallatePercentage).'%').'</span>'."\n";
  688. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate',
  689. $totalLateNumber).'</span>'."\n";
  690. } else {
  691. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate",
  692. $totalLateNumber).'</span>'."\n";
  693. if ($totallatePercentage > 0) {
  694. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate',
  695. price($totallatePercentage).'%').'</span>'."\n";
  696. }
  697. }
  698. $weatherDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
  699. $weatherDashBoard .= ' </div><!-- /.info-box -->'."\n";
  700. $weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  701. $weatherDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  702. $weatherDashBoard .= "\n";
  703. $openedDashBoard = $weatherDashBoard.$openedDashBoard;
  704. }
  705. if (!empty($isIntopOpenedDashBoard)) {
  706. for ($i = 1; $i <= 10; $i++) {
  707. $openedDashBoard .= '<div class="box-flex-item filler"></div>';
  708. }
  709. }
  710. $nbworkboardcount = 0;
  711. foreach ($valid_dashboardlines as $infoKey => $board) {
  712. if (in_array($infoKey, $isIntopOpenedDashBoard)) {
  713. // skip if info is present on top
  714. continue;
  715. }
  716. if (empty($board->nbtodo)) {
  717. $nbworkboardempty++;
  718. }
  719. $nbworkboardcount++;
  720. $textlate = $langs->trans("NActionsLate", $board->nbtodolate);
  721. $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  722. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
  723. $boxwork .= '<div class="boxstatscontent">';
  724. $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>';
  725. $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>';
  726. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  727. $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.price($board->total).'</span></a>';
  728. }
  729. $boxwork .= '</div>';
  730. if ($board->nbtodolate > 0) {
  731. $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
  732. $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
  733. //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
  734. $boxwork .= img_picto($textlate, "warning_white",
  735. 'class="inline-block hideonsmartphone valigntextbottom"').'';
  736. $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
  737. $boxwork .= $board->nbtodolate;
  738. $boxwork .= '</span>';
  739. $boxwork .= '</a>';
  740. $boxwork .= '</div>';
  741. }
  742. $boxwork .= '</div></div>';
  743. $boxwork .= "\n";
  744. }
  745. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  746. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  747. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  748. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  749. $boxwork .= '</div>';
  750. $boxwork .= '</td></tr>';
  751. } else {
  752. $boxwork .= '<tr class="nohover">';
  753. $boxwork .= '<td class="nohover valignmiddle opacitymedium">';
  754. $boxwork .= $langs->trans("NoOpenedElementToProcess");
  755. $boxwork .= '</td>';
  756. $boxwork .= '</tr>';
  757. }
  758. $boxwork .= '</td></tr>';
  759. $boxwork .= '</table>'; // End table array of working board
  760. $boxwork .= '</div>';
  761. if (!empty($isIntopOpenedDashBoard)) {
  762. print '<div class="fichecenter">';
  763. print '<div class="opened-dash-board-wrap"><div class="box-flex-container">'.$openedDashBoard.'</div></div>';
  764. print '</div>';
  765. }
  766. }
  767. print '<div class="clearboth"></div>';
  768. print '<div class="fichecenter fichecenterbis">';
  769. /*
  770. * Show boxes
  771. */
  772. $boxlist .= '<div class="twocolumns">';
  773. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  774. if (!empty($nbworkboardcount))
  775. {
  776. $boxlist .= $boxwork;
  777. }
  778. $boxlist .= $resultboxes['boxlista'];
  779. $boxlist .= '</div>';
  780. if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
  781. {
  782. // Remove allready present info in new dash board
  783. if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) {
  784. foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) {
  785. if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) {
  786. unset($boxstatItems[$boxstatItemKey]);
  787. }
  788. }
  789. }
  790. if (!empty($boxstatFromHook) || !empty($boxstatItems)) {
  791. $boxstat .= '<!-- Database statistics -->'."\n";
  792. $boxstat .= '<div class="box">';
  793. $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom nohover widgetstats" width="100%">';
  794. $boxstat .= '<tr class="liste_titre box_titre">';
  795. $boxstat .= '<td class="liste_titre">';
  796. $boxstat .= '<div class="inline-block valignmiddle">'.$langs->trans("DolibarrStateBoard").'</div>';
  797. $boxstat .= '</td>';
  798. $boxstat .= '</tr>';
  799. $boxstat .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer">';
  800. $boxstat .= $boxstatFromHook;
  801. if (is_array($boxstatItems) && count($boxstatItems) > 0)
  802. {
  803. $boxstat .= implode('', $boxstatItems);
  804. }
  805. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  806. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  807. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  808. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  809. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  810. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  811. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  812. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  813. $boxstat .= '</td></tr>';
  814. $boxstat .= '</table>';
  815. $boxstat .= '</div>';
  816. }
  817. }
  818. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  819. $boxlist .= $boxstat;
  820. $boxlist .= $resultboxes['boxlistb'];
  821. $boxlist .= '</div>';
  822. $boxlist .= "\n";
  823. $boxlist .= '</div>';
  824. print $boxlist;
  825. print '</div>';
  826. /*
  827. * Show security warnings
  828. */
  829. // Security warning repertoire install existe (si utilisateur admin)
  830. if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING))
  831. {
  832. $message = '';
  833. // Check if install lock file is present
  834. $lockfile = DOL_DATA_ROOT.'/install.lock';
  835. if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install"))
  836. {
  837. $langs->load("errors");
  838. //if (! empty($message)) $message.='<br>';
  839. $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  840. }
  841. // Conf files must be in read only mode
  842. if (is_writable($conffile))
  843. {
  844. $langs->load("errors");
  845. //$langs->load("other");
  846. //if (! empty($message)) $message.='<br>';
  847. $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  848. }
  849. if ($message)
  850. {
  851. print $message;
  852. //$message.='<br>';
  853. //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  854. }
  855. }
  856. //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
  857. // End of page
  858. llxFooter();
  859. $db->close();
  860. /**
  861. * Show weather logo. Logo to show depends on $totallate and values for
  862. * $conf->global->MAIN_METEO_LEVELx
  863. *
  864. * @param int $totallate Nb of element late
  865. * @param string $text Text to show on logo
  866. * @param string $options More parameters on img tag
  867. * @param string $morecss More CSS
  868. * @return string Return img tag of weather
  869. */
  870. function showWeather($totallate, $text, $options, $morecss = '')
  871. {
  872. global $conf;
  873. $weather = getWeatherStatus($totallate);
  874. return img_weather($text, $weather->picto, $options, 0, $morecss);
  875. }
  876. /**
  877. * get weather level
  878. * $conf->global->MAIN_METEO_LEVELx
  879. *
  880. * @param int $totallate Nb of element late
  881. * @return string Return img tag of weather
  882. */
  883. function getWeatherStatus($totallate)
  884. {
  885. global $conf;
  886. $weather = new stdClass();
  887. $weather->picto = '';
  888. $offset = 0;
  889. $factor = 10; // By default
  890. $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
  891. $level0 = $offset;
  892. $weather->level = 0;
  893. if (!empty($conf->global->{$used_conf.'0'})) {
  894. $level0 = $conf->global->{$used_conf.'0'};
  895. }
  896. $level1 = $offset + 1 * $factor;
  897. if (!empty($conf->global->{$used_conf.'1'})) {
  898. $level1 = $conf->global->{$used_conf.'1'};
  899. }
  900. $level2 = $offset + 2 * $factor;
  901. if (!empty($conf->global->{$used_conf.'2'})) {
  902. $level2 = $conf->global->{$used_conf.'2'};
  903. }
  904. $level3 = $offset + 3 * $factor;
  905. if (!empty($conf->global->{$used_conf.'3'})) {
  906. $level3 = $conf->global->{$used_conf.'3'};
  907. }
  908. if ($totallate <= $level0) {
  909. $weather->picto = 'weather-clear.png';
  910. $weather->level = 0;
  911. }
  912. elseif ($totallate <= $level1) {
  913. $weather->picto = 'weather-few-clouds.png';
  914. $weather->level = 1;
  915. }
  916. elseif ($totallate <= $level2) {
  917. $weather->picto = 'weather-clouds.png';
  918. $weather->level = 2;
  919. }
  920. elseif ($totallate <= $level3) {
  921. $weather->picto = 'weather-many-clouds.png';
  922. $weather->level = 3;
  923. }
  924. else {
  925. $weather->picto = 'weather-storm.png';
  926. $weather->level = 4;
  927. }
  928. return $weather;
  929. }