index.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  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 (!isset($form) || !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. $classkeyforcache = $class;
  266. if ($classkeyforcache == 'ProductService') $classkeyforcache = 'Product'; // ProductService use same load_state_board than Product
  267. if (!isset($boardloaded[$classkeyforcache]) || !is_object($boardloaded[$classkeyforcache]))
  268. {
  269. include_once $includes[$val]; // Loading a class cost around 1Mb
  270. $board = new $class($db);
  271. $board->load_state_board();
  272. $boardloaded[$class] = $board;
  273. } else {
  274. $board = $boardloaded[$classkeyforcache];
  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 $workboardid => $tmp) {
  530. if ($tmp instanceof WorkboardResponse) {
  531. $tmp->id = $workboardid; // Complete the object to add its id into its name
  532. $valid_dashboardlines[$workboardid] = $tmp;
  533. }
  534. }
  535. // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
  536. foreach ($valid_dashboardlines as $board) {
  537. if ($board->nbtodolate > 0) {
  538. $totaltodo += $board->nbtodo;
  539. $totallate += $board->nbtodolate;
  540. }
  541. }
  542. $openedDashBoardSize = 'info-box-sm'; // use sm by default
  543. foreach ($dashboardgroup as $dashbordelement) {
  544. if (is_array($dashbordelement['stats']) && count($dashbordelement['stats']) > 2) {
  545. $openedDashBoardSize = ''; // use default info box size : big
  546. break;
  547. }
  548. }
  549. $totalLateNumber = $totallate;
  550. $totallatePercentage = ((!empty($totaltodo)) ? round($totallate / $totaltodo * 100, 2) : 0);
  551. if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  552. $totallate = $totallatePercentage;
  553. }
  554. $boxwork = '';
  555. $boxwork .= '<div class="box">';
  556. $boxwork .= '<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard" width="100%">'."\n";
  557. $boxwork .= '<tr class="liste_titre">';
  558. $boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">'.$langs->trans("DolibarrWorkBoard").'</div>';
  559. if ($showweather) {
  560. if ($totallate > 0) {
  561. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",
  562. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
  563. } else {
  564. $text = $langs->transnoentitiesnoconv("NoItemLate");
  565. }
  566. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  567. //$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
  568. $options = 'height="24px" style="float: right"';
  569. $boxwork .= showWeather($totallate, $text, $options, 'inline-block valignmiddle');
  570. }
  571. $boxwork .= '</th>';
  572. $boxwork .= '</tr>'."\n";
  573. // Show dashboard
  574. $nbworkboardempty = 0;
  575. $isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array();
  576. if (!empty($valid_dashboardlines)) {
  577. $openedDashBoard = '';
  578. $boxwork .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
  579. foreach ($dashboardgroup as $groupKey => $groupElement) {
  580. $boards = array();
  581. if (empty($conf->global->MAIN_DISABLE_NEW_OPENED_DASH_BOARD)) {
  582. foreach ($groupElement['stats'] as $infoKey) {
  583. if (!empty($valid_dashboardlines[$infoKey])) {
  584. $boards[] = $valid_dashboardlines[$infoKey];
  585. $isIntopOpenedDashBoard[] = $infoKey;
  586. }
  587. }
  588. }
  589. if (!empty($boards)) {
  590. $groupName = $langs->trans($groupElement['groupName']);
  591. $groupKeyLowerCase = strtolower($groupKey);
  592. $nbTotalForGroup = 0;
  593. // global stats
  594. $globalStatsKey = false;
  595. if (!empty($groupElement['globalStatsKey']) && empty($groupElement['globalStats'])) { // can be filled by hook
  596. $globalStatsKey = $groupElement['globalStatsKey'];
  597. $groupElement['globalStats'] = array();
  598. if (is_array($keys) && in_array($globalStatsKey, $keys))
  599. {
  600. // get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
  601. $keyIndex = array_search($globalStatsKey, $keys);
  602. $classe = $classes[$keyIndex];
  603. if (isset($boardloaded[$classe]) && is_object($boardloaded[$classe]))
  604. {
  605. $groupElement['globalStats']['total'] = $boardloaded[$classe]->nb[$globalStatsKey] ? $boardloaded[$classe]->nb[$globalStatsKey] : 0;
  606. $nbTotal = doubleval($groupElement['globalStats']['total']);
  607. if ($nbTotal >= 10000) { $nbTotal = round($nbTotal / 1000, 2).'k'; }
  608. $groupElement['globalStats']['text'] = $langs->trans('Total').' : '.$langs->trans($titres[$keyIndex]).' ('.$groupElement['globalStats']['total'].')';
  609. $groupElement['globalStats']['total'] = $nbTotal;
  610. $groupElement['globalStats']['link'] = $links[$keyIndex];
  611. }
  612. }
  613. }
  614. $openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">'."\n";
  615. $openedDashBoard .= ' <div class="info-box '.$openedDashBoardSize.'">'."\n";
  616. $openedDashBoard .= ' <span class="info-box-icon bg-infobox-'.$groupKeyLowerCase.'">'."\n";
  617. $openedDashBoard .= ' <i class="fa fa-dol-'.$groupKeyLowerCase.'"></i>'."\n";
  618. // Show the span for the total of record
  619. if (!empty($groupElement['globalStats'])) {
  620. $globalStatInTopOpenedDashBoard[] = $globalStatsKey;
  621. $openedDashBoard .= '<span class="info-box-icon-text" title="'.$groupElement['globalStats']['text'].'">'.$nbTotal.'</span>';
  622. }
  623. $openedDashBoard .= '</span>'."\n";
  624. $openedDashBoard .= '<div class="info-box-content">'."\n";
  625. $openedDashBoard .= '<div class="info-box-title" title="'.strip_tags($groupName).'">'.$groupName.'</div>'."\n";
  626. $openedDashBoard .= '<div class="info-box-lines">'."\n";
  627. foreach ($boards as $board) {
  628. $openedDashBoard .= '<div class="info-box-line">';
  629. if (!empty($board->labelShort)) {
  630. $infoName = '<span title="'.$board->label.'">'.$board->labelShort.'</span>';
  631. } else {
  632. $infoName = $board->label;
  633. }
  634. $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate);
  635. $textLateTitle .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  636. if ($board->id == 'bank_account') {
  637. $textLateTitle .= '<br><span class="opacitymedium">'.$langs->trans("IfYouDontReconcileDisableProperty", $langs->transnoentitiesnoconv("Conciliable")).'</span>';
  638. }
  639. $textLate = '';
  640. if ($board->nbtodolate > 0) {
  641. $textLate .= '<span title="'.dol_escape_htmltag($textLateTitle).'" class="classfortooltip badge badge-warning">';
  642. $textLate .= '<i class="fa fa-exclamation-triangle"></i> '.$board->nbtodolate;
  643. $textLate .= '</span>';
  644. }
  645. $nbtodClass = '';
  646. if ($board->nbtodo > 0) {
  647. $nbtodClass = 'badge badge-info';
  648. }
  649. $openedDashBoard .= ' <a href="'.$board->url.'" class="info-box-text info-box-text-a">'.$infoName.' : <span class="'.$nbtodClass.' classfortooltip" title="'.$board->label.'" >'.$board->nbtodo.'</span>';
  650. if ($textLate) {
  651. if ($board->url_late) {
  652. $openedDashBoard .= '</a>';
  653. $openedDashBoard .= ' <a href="'.$board->url_late.'" class="info-box-text info-box-text-a paddingleft">';
  654. } else {
  655. $openedDashBoard .= ' ';
  656. }
  657. $openedDashBoard .= $textLate;
  658. }
  659. $openedDashBoard .= '</a>'."\n";
  660. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  661. $openedDashBoard .= '<a href="'.$board->url.'" class="info-box-text">'.$langs->trans('Total').' : '.price($board->total).'</a>';
  662. }
  663. $openedDashBoard .= '</div>'."\n";
  664. }
  665. // TODO Add hook here to add more "info-box-line"
  666. $openedDashBoard .= ' </div><!-- /.info-box-lines --></div><!-- /.info-box-content -->'."\n";
  667. $openedDashBoard .= ' </div><!-- /.info-box -->'."\n";
  668. $openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  669. $openedDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  670. $openedDashBoard .= "\n";
  671. }
  672. }
  673. if ($showweather && !empty($isIntopOpenedDashBoard)) {
  674. $appendClass = $conf->global->MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '';
  675. $weather = getWeatherStatus($totallate);
  676. $text = '';
  677. if ($totallate > 0) {
  678. $text = $langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",
  679. $totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
  680. } else {
  681. $text = $langs->transnoentitiesnoconv("NoItemLate");
  682. }
  683. $text .= '. '.$langs->transnoentitiesnoconv("LateDesc");
  684. $weatherDashBoard = '<div class="box-flex-item '.$appendClass.'"><div class="box-flex-item-with-margin">'."\n";
  685. $weatherDashBoard .= ' <div class="info-box '.$openedDashBoardSize.' info-box-weather info-box-weather-level'.$weather->level.'">'."\n";
  686. $weatherDashBoard .= ' <span class="info-box-icon">';
  687. $weatherDashBoard .= img_weather('', $weather->level, '', 0, 'valignmiddle width50');
  688. $weatherDashBoard .= ' </span>'."\n";
  689. $weatherDashBoard .= ' <div class="info-box-content">'."\n";
  690. $weatherDashBoard .= ' <div class="info-box-title">'.$langs->trans('GlobalOpenedElemView').'</div>'."\n";
  691. if ($totallatePercentage > 0 && !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
  692. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate",
  693. price($totallatePercentage).'%').'</span>'."\n";
  694. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate',
  695. $totalLateNumber).'</span>'."\n";
  696. } else {
  697. $weatherDashBoard .= ' <span class="info-box-number">'.$langs->transnoentitiesnoconv("NActionsLate",
  698. $totalLateNumber).'</span>'."\n";
  699. if ($totallatePercentage > 0) {
  700. $weatherDashBoard .= ' <span class="progress-description">'.$langs->trans('NActionsLate',
  701. price($totallatePercentage).'%').'</span>'."\n";
  702. }
  703. }
  704. $weatherDashBoard .= ' </div><!-- /.info-box-content -->'."\n";
  705. $weatherDashBoard .= ' </div><!-- /.info-box -->'."\n";
  706. $weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->'."\n";
  707. $weatherDashBoard .= '</div><!-- /.box-flex-item -->'."\n";
  708. $weatherDashBoard .= "\n";
  709. $openedDashBoard = $weatherDashBoard.$openedDashBoard;
  710. }
  711. if (!empty($isIntopOpenedDashBoard)) {
  712. for ($i = 1; $i <= 10; $i++) {
  713. $openedDashBoard .= '<div class="box-flex-item filler"></div>';
  714. }
  715. }
  716. $nbworkboardcount = 0;
  717. foreach ($valid_dashboardlines as $infoKey => $board) {
  718. if (in_array($infoKey, $isIntopOpenedDashBoard)) {
  719. // skip if info is present on top
  720. continue;
  721. }
  722. if (empty($board->nbtodo)) {
  723. $nbworkboardempty++;
  724. }
  725. $nbworkboardcount++;
  726. $textlate = $langs->trans("NActionsLate", $board->nbtodolate);
  727. $textlate .= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  728. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
  729. $boxwork .= '<div class="boxstatscontent">';
  730. $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' <span>'.$board->label.'</span></span><br>';
  731. $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.$board->nbtodo.'</span></a>';
  732. if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) {
  733. $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0) ? ' dashboardlineok' : '').'">'.price($board->total).'</span></a>';
  734. }
  735. $boxwork .= '</div>';
  736. if ($board->nbtodolate > 0) {
  737. $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
  738. $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late).'">';
  739. //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
  740. $boxwork .= img_picto($textlate, "warning_white",
  741. 'class="inline-block hideonsmartphone valigntextbottom"').'';
  742. $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok').'">';
  743. $boxwork .= $board->nbtodolate;
  744. $boxwork .= '</span>';
  745. $boxwork .= '</a>';
  746. $boxwork .= '</div>';
  747. }
  748. $boxwork .= '</div></div>';
  749. $boxwork .= "\n";
  750. }
  751. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  752. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  753. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  754. $boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  755. $boxwork .= '</div>';
  756. $boxwork .= '</td></tr>';
  757. } else {
  758. $boxwork .= '<tr class="nohover">';
  759. $boxwork .= '<td class="nohover valignmiddle opacitymedium">';
  760. $boxwork .= $langs->trans("NoOpenedElementToProcess");
  761. $boxwork .= '</td>';
  762. $boxwork .= '</tr>';
  763. }
  764. $boxwork .= '</td></tr>';
  765. $boxwork .= '</table>'; // End table array of working board
  766. $boxwork .= '</div>';
  767. if (!empty($isIntopOpenedDashBoard)) {
  768. print '<div class="fichecenter">';
  769. print '<div class="opened-dash-board-wrap"><div class="box-flex-container">'.$openedDashBoard.'</div></div>';
  770. print '</div>';
  771. }
  772. }
  773. print '<div class="clearboth"></div>';
  774. print '<div class="fichecenter fichecenterbis">';
  775. /*
  776. * Show boxes
  777. */
  778. $boxlist .= '<div class="twocolumns">';
  779. $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  780. if (!empty($nbworkboardcount))
  781. {
  782. $boxlist .= $boxwork;
  783. }
  784. $boxlist .= $resultboxes['boxlista'];
  785. $boxlist .= '</div>';
  786. if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
  787. {
  788. // Remove allready present info in new dash board
  789. if (!empty($conf->global->MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD) && is_array($boxstatItems) && count($boxstatItems) > 0) {
  790. foreach ($boxstatItems as $boxstatItemKey => $boxstatItemHtml) {
  791. if (in_array($boxstatItemKey, $globalStatInTopOpenedDashBoard)) {
  792. unset($boxstatItems[$boxstatItemKey]);
  793. }
  794. }
  795. }
  796. if (!empty($boxstatFromHook) || !empty($boxstatItems)) {
  797. $boxstat .= '<!-- Database statistics -->'."\n";
  798. $boxstat .= '<div class="box">';
  799. $boxstat .= '<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom nohover widgetstats" width="100%">';
  800. $boxstat .= '<tr class="liste_titre box_titre">';
  801. $boxstat .= '<td>';
  802. $boxstat .= '<div class="inline-block valignmiddle">'.$langs->trans("DolibarrStateBoard").'</div>';
  803. $boxstat .= '</td>';
  804. $boxstat .= '</tr>';
  805. $boxstat .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer">';
  806. $boxstat .= $boxstatFromHook;
  807. if (is_array($boxstatItems) && count($boxstatItems) > 0)
  808. {
  809. $boxstat .= implode('', $boxstatItems);
  810. }
  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 .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  814. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  815. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  816. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  817. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  818. $boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  819. $boxstat .= '</td></tr>';
  820. $boxstat .= '</table>';
  821. $boxstat .= '</div>';
  822. }
  823. }
  824. $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  825. $boxlist .= $boxstat;
  826. $boxlist .= $resultboxes['boxlistb'];
  827. $boxlist .= '</div>';
  828. $boxlist .= "\n";
  829. $boxlist .= '</div>';
  830. print $boxlist;
  831. print '</div>';
  832. /*
  833. * Show security warnings
  834. */
  835. // Security warning repertoire install existe (si utilisateur admin)
  836. if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING))
  837. {
  838. $message = '';
  839. // Check if install lock file is present
  840. $lockfile = DOL_DATA_ROOT.'/install.lock';
  841. if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install"))
  842. {
  843. $langs->load("errors");
  844. //if (! empty($message)) $message.='<br>';
  845. $message .= info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  846. }
  847. // Conf files must be in read only mode
  848. if (is_writable($conffile))
  849. {
  850. $langs->load("errors");
  851. //$langs->load("other");
  852. //if (! empty($message)) $message.='<br>';
  853. $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  854. }
  855. if ($message)
  856. {
  857. print $message;
  858. //$message.='<br>';
  859. //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  860. }
  861. }
  862. //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
  863. // End of page
  864. llxFooter();
  865. $db->close();
  866. /**
  867. * Show weather logo. Logo to show depends on $totallate and values for
  868. * $conf->global->MAIN_METEO_LEVELx
  869. *
  870. * @param int $totallate Nb of element late
  871. * @param string $text Text to show on logo
  872. * @param string $options More parameters on img tag
  873. * @param string $morecss More CSS
  874. * @return string Return img tag of weather
  875. */
  876. function showWeather($totallate, $text, $options, $morecss = '')
  877. {
  878. global $conf;
  879. $weather = getWeatherStatus($totallate);
  880. return img_weather($text, $weather->picto, $options, 0, $morecss);
  881. }
  882. /**
  883. * get weather level
  884. * $conf->global->MAIN_METEO_LEVELx
  885. *
  886. * @param int $totallate Nb of element late
  887. * @return string Return img tag of weather
  888. */
  889. function getWeatherStatus($totallate)
  890. {
  891. global $conf;
  892. $weather = new stdClass();
  893. $weather->picto = '';
  894. $offset = 0;
  895. $factor = 10; // By default
  896. $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
  897. $level0 = $offset;
  898. $weather->level = 0;
  899. if (!empty($conf->global->{$used_conf.'0'})) {
  900. $level0 = $conf->global->{$used_conf.'0'};
  901. }
  902. $level1 = $offset + 1 * $factor;
  903. if (!empty($conf->global->{$used_conf.'1'})) {
  904. $level1 = $conf->global->{$used_conf.'1'};
  905. }
  906. $level2 = $offset + 2 * $factor;
  907. if (!empty($conf->global->{$used_conf.'2'})) {
  908. $level2 = $conf->global->{$used_conf.'2'};
  909. }
  910. $level3 = $offset + 3 * $factor;
  911. if (!empty($conf->global->{$used_conf.'3'})) {
  912. $level3 = $conf->global->{$used_conf.'3'};
  913. }
  914. if ($totallate <= $level0) {
  915. $weather->picto = 'weather-clear.png';
  916. $weather->level = 0;
  917. }
  918. elseif ($totallate <= $level1) {
  919. $weather->picto = 'weather-few-clouds.png';
  920. $weather->level = 1;
  921. }
  922. elseif ($totallate <= $level2) {
  923. $weather->picto = 'weather-clouds.png';
  924. $weather->level = 2;
  925. }
  926. elseif ($totallate <= $level3) {
  927. $weather->picto = 'weather-many-clouds.png';
  928. $weather->level = 3;
  929. }
  930. else {
  931. $weather->picto = 'weather-storm.png';
  932. $weather->level = 4;
  933. }
  934. return $weather;
  935. }