index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2017 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 <http://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($langs->trans("HomeArea"),$resultboxes['selectboxlist'],'title_home');
  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. print '<div class="fichecenter"><div class="fichethirdleft">';
  82. /*
  83. * Dashboard Dolibarr states (statistics)
  84. * Hidden for external users
  85. */
  86. $boxstat='';
  87. // Load translation files required by page
  88. $langs->loadLangs(array('commercial', 'bills', 'orders', 'contracts'));
  89. if (empty($user->societe_id))
  90. {
  91. $boxstat.='<div class="box">';
  92. $boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable boxtablenobottom nohover" width="100%">';
  93. $boxstat.='<tr class="liste_titre">';
  94. $boxstat.='<th class="liste_titre">'.$langs->trans("DolibarrStateBoard").'</th>';
  95. $boxstat.='</tr>';
  96. $boxstat.='<tr class="impair"><td class="tdboxstats nohover flexcontainer">';
  97. $object=new stdClass();
  98. $parameters=array();
  99. $action='';
  100. $reshook=$hookmanager->executeHooks('addStatisticLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  101. $boxstat.=$hookmanager->resPrint;
  102. if (empty($reshook))
  103. {
  104. // Condition to be checked for each display line dashboard
  105. $conditions=array(
  106. $user->rights->user->user->lire,
  107. ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
  108. ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
  109. ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
  110. ! empty($conf->societe->enabled) && $user->rights->societe->contact->lire,
  111. ! empty($conf->adherent->enabled) && $user->rights->adherent->lire,
  112. ! empty($conf->product->enabled) && $user->rights->produit->lire,
  113. ! empty($conf->service->enabled) && $user->rights->service->lire,
  114. ! empty($conf->propal->enabled) && $user->rights->propale->lire,
  115. ! empty($conf->commande->enabled) && $user->rights->commande->lire,
  116. ! empty($conf->facture->enabled) && $user->rights->facture->lire,
  117. ! empty($conf->contrat->enabled) && $user->rights->contrat->lire,
  118. ! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire,
  119. ! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS),
  120. ! empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS),
  121. ! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS),
  122. ! empty($conf->projet->enabled) && $user->rights->projet->lire,
  123. ! empty($conf->expensereport->enabled) && $user->rights->expensereport->lire,
  124. ! empty($conf->don->enabled) && $user->rights->don->lire
  125. );
  126. // Class file containing the method load_state_board for each line
  127. $includes=array(
  128. DOL_DOCUMENT_ROOT."/user/class/user.class.php",
  129. DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
  130. DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
  131. DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php",
  132. DOL_DOCUMENT_ROOT."/contact/class/contact.class.php",
  133. DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
  134. DOL_DOCUMENT_ROOT."/product/class/product.class.php",
  135. DOL_DOCUMENT_ROOT."/product/class/product.class.php",
  136. DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
  137. DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
  138. DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
  139. DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php",
  140. DOL_DOCUMENT_ROOT."/fichinter/class/fichinter.class.php",
  141. DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php",
  142. DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php",
  143. DOL_DOCUMENT_ROOT."/supplier_proposal/class/supplier_proposal.class.php",
  144. DOL_DOCUMENT_ROOT."/projet/class/project.class.php",
  145. DOL_DOCUMENT_ROOT."/expensereport/class/expensereport.class.php",
  146. DOL_DOCUMENT_ROOT."/don/class/don.class.php"
  147. );
  148. // Name class containing the method load_state_board for each line
  149. $classes=array('User',
  150. 'Client',
  151. 'Client',
  152. 'Fournisseur',
  153. 'Contact',
  154. 'Adherent',
  155. 'Product',
  156. 'Product',
  157. 'Propal',
  158. 'Commande',
  159. 'Facture',
  160. 'Contrat',
  161. 'Fichinter',
  162. 'CommandeFournisseur',
  163. 'FactureFournisseur',
  164. 'SupplierProposal',
  165. 'Project',
  166. 'ExpenseReport',
  167. 'Don'
  168. );
  169. // Cle array returned by the method load_state_board for each line
  170. $keys=array('users',
  171. 'customers',
  172. 'prospects',
  173. 'suppliers',
  174. 'contacts',
  175. 'members',
  176. 'products',
  177. 'services',
  178. 'proposals',
  179. 'orders',
  180. 'invoices',
  181. 'Contracts',
  182. 'fichinters',
  183. 'supplier_orders',
  184. 'supplier_invoices',
  185. 'askprice',
  186. 'projects',
  187. 'expensereports',
  188. 'donations'
  189. );
  190. // Dashboard Icon lines
  191. $icons=array('user',
  192. 'company',
  193. 'company',
  194. 'company',
  195. 'contact',
  196. 'user',
  197. 'product',
  198. 'service',
  199. 'propal',
  200. 'order',
  201. 'bill',
  202. 'order',
  203. 'order',
  204. 'order',
  205. 'bill',
  206. 'propal',
  207. 'projectpub',
  208. 'trip',
  209. 'generic'
  210. );
  211. // Translation keyword
  212. $titres=array("Users",
  213. "ThirdPartyCustomersStats",
  214. "ThirdPartyProspectsStats",
  215. "Suppliers",
  216. "Contacts",
  217. "Members",
  218. "Products",
  219. "Services",
  220. "CommercialProposalsShort",
  221. "CustomersOrders",
  222. "BillsCustomers",
  223. "Contracts",
  224. "Interventions",
  225. "SuppliersOrders",
  226. "SuppliersInvoices",
  227. "SupplierProposalShort",
  228. "Projects",
  229. "ExpenseReports",
  230. "Donations"
  231. );
  232. // Dashboard Link lines
  233. $links=array(
  234. DOL_URL_ROOT.'/user/list.php',
  235. DOL_URL_ROOT.'/societe/list.php?type=c&mainmenu=companies',
  236. DOL_URL_ROOT.'/societe/list.php?type=p&mainmenu=companies',
  237. DOL_URL_ROOT.'/societe/list.php?type=f&mainmenu=companies',
  238. DOL_URL_ROOT.'/contact/list.php?mainmenu=companies',
  239. DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members',
  240. DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products',
  241. DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products',
  242. DOL_URL_ROOT.'/comm/propal/list.php?mainmenu=commercial&leftmenu=propals',
  243. DOL_URL_ROOT.'/commande/list.php?mainmenu=commercial&leftmenu=orders',
  244. DOL_URL_ROOT.'/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills',
  245. DOL_URL_ROOT.'/contrat/list.php?mainmenu=commercial&leftmenu=contracts',
  246. DOL_URL_ROOT.'/fichinter/list.php?mainmenu=commercial&leftmenu=ficheinter',
  247. DOL_URL_ROOT.'/fourn/commande/list.php?mainmenu=commercial&leftmenu=orders_suppliers',
  248. DOL_URL_ROOT.'/fourn/facture/list.php?mainmenu=billing&leftmenu=suppliers_bills',
  249. DOL_URL_ROOT.'/supplier_proposal/list.php?mainmenu=commercial&leftmenu=',
  250. DOL_URL_ROOT.'/projet/list.php?mainmenu=project',
  251. DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport',
  252. DOL_URL_ROOT.'/don/list.php?leftmenu=donations'
  253. );
  254. // Translation lang files
  255. $langfile=array("users",
  256. "companies",
  257. "prospects",
  258. "suppliers",
  259. "companies",
  260. "members",
  261. "products",
  262. "products",
  263. "propal",
  264. "orders",
  265. "bills",
  266. "contracts",
  267. "interventions",
  268. "bills",
  269. "bills",
  270. "supplier_proposal",
  271. "projects",
  272. "trips",
  273. "donations"
  274. );
  275. // Loop and displays each line of table
  276. foreach ($keys as $key=>$val)
  277. {
  278. if ($conditions[$key])
  279. {
  280. $classe=$classes[$key];
  281. // Search in cache if load_state_board is already realized
  282. if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe]))
  283. {
  284. include_once $includes[$key]; // Loading a class cost around 1Mb
  285. $board=new $classe($db);
  286. $board->load_state_board($user);
  287. $boardloaded[$classe]=$board;
  288. }
  289. else
  290. {
  291. $board=$boardloaded[$classe];
  292. }
  293. if (!empty($langfile[$key])) $langs->load($langfile[$key]);
  294. $text=$langs->trans($titres[$key]);
  295. //$sep=($conf->dol_use_jmobile?'<br>':' ');
  296. $boxstat.='<a href="'.$links[$key].'" class="boxstatsindicator thumbstat nobold nounderline">';
  297. $boxstat.='<div class="boxstats">';
  298. $boxstat.='<span class="boxstatstext" title="'.dol_escape_htmltag($text).'">'.$text.'</span><br>';
  299. $boxstat.='<span class="boxstatsindicator">'.img_object("",$icons[$key],'class="inline-block"').' '.($board->nb[$val]?$board->nb[$val]:0).'</span>';
  300. $boxstat.='</div>';
  301. $boxstat.='</a>';
  302. }
  303. }
  304. }
  305. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  306. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  307. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  308. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  309. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  310. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  311. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  312. $boxstat.='<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>';
  313. $boxstat.='</td></tr>';
  314. $boxstat.='</table>';
  315. $boxstat.='</div>';
  316. }
  317. //print $boxstat;
  318. print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
  319. /*
  320. * Dolibarr Working Board with weather
  321. */
  322. $showweather=(empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METEO == 2) ? 1 : 0;
  323. //Array that contains all WorkboardResponse classes to process them
  324. $dashboardlines=array();
  325. // Do not include sections without management permission
  326. require_once DOL_DOCUMENT_ROOT.'/core/class/workboardresponse.class.php';
  327. // Number of actions to do (late)
  328. if (! empty($conf->agenda->enabled) && $user->rights->agenda->myactions->read)
  329. {
  330. include_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
  331. $board=new ActionComm($db);
  332. $dashboardlines[] = $board->load_board($user);
  333. }
  334. // Number of project opened
  335. if (! empty($conf->projet->enabled) && $user->rights->projet->lire)
  336. {
  337. include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  338. $board=new Project($db);
  339. $dashboardlines[] = $board->load_board($user);
  340. }
  341. // Number of tasks to do (late)
  342. if (! empty($conf->projet->enabled) && empty($conf->global->PROJECT_HIDE_TASKS) && $user->rights->projet->lire)
  343. {
  344. include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  345. $board=new Task($db);
  346. $dashboardlines[] = $board->load_board($user);
  347. }
  348. // Number of commercial proposals opened (expired)
  349. if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
  350. {
  351. include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
  352. $board=new Propal($db);
  353. $dashboardlines[] = $board->load_board($user,"opened");
  354. // Number of commercial proposals CLOSED signed (billed)
  355. $dashboardlines[] = $board->load_board($user,"signed");
  356. }
  357. // Number of commercial proposals opened (expired)
  358. if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire)
  359. {
  360. include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php';
  361. $board=new SupplierProposal($db);
  362. $dashboardlines[] = $board->load_board($user,"opened");
  363. // Number of commercial proposals CLOSED signed (billed)
  364. $dashboardlines[] = $board->load_board($user,"signed");
  365. }
  366. // Number of customer orders a deal
  367. if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
  368. {
  369. include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
  370. $board=new Commande($db);
  371. $dashboardlines[] = $board->load_board($user);
  372. }
  373. // Number of suppliers orders a deal
  374. if (! empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire)
  375. {
  376. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
  377. $board=new CommandeFournisseur($db);
  378. $dashboardlines[] = $board->load_board($user);
  379. }
  380. // Number of services enabled (delayed)
  381. if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
  382. {
  383. include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  384. $board=new Contrat($db);
  385. $dashboardlines[] = $board->load_board($user,"inactives");
  386. // Number of active services (expired)
  387. $dashboardlines[] = $board->load_board($user,"expired");
  388. }
  389. // Number of invoices customers (has paid)
  390. if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
  391. {
  392. include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  393. $board=new Facture($db);
  394. $dashboardlines[] = $board->load_board($user);
  395. }
  396. // Number of supplier invoices (has paid)
  397. if (! empty($conf->supplier_invoice->enabled) && ! empty($user->rights->fournisseur->facture->lire))
  398. {
  399. include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
  400. $board=new FactureFournisseur($db);
  401. $dashboardlines[] = $board->load_board($user);
  402. }
  403. // Number of transactions to conciliate
  404. if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id)
  405. {
  406. include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
  407. $board=new Account($db);
  408. $nb = $board::countAccountToReconcile(); // Get nb of account to reconciliate
  409. if ($nb > 0)
  410. {
  411. $dashboardlines[] = $board->load_board($user);
  412. }
  413. }
  414. // Number of cheque to send
  415. if (! empty($conf->banque->enabled) && $user->rights->banque->lire && ! $user->societe_id && empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT))
  416. {
  417. include_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php';
  418. $board=new RemiseCheque($db);
  419. $dashboardlines[] = $board->load_board($user);
  420. }
  421. // Number of foundation members
  422. if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire && ! $user->societe_id)
  423. {
  424. include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
  425. $board=new Adherent($db);
  426. $dashboardlines[] = $board->load_board($user);
  427. }
  428. // Number of expense reports to approve
  429. if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->approve)
  430. {
  431. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  432. $board=new ExpenseReport($db);
  433. $dashboardlines[] = $board->load_board($user,'toapprove');
  434. }
  435. // Number of expense reports to pay
  436. if (! empty($conf->expensereport->enabled) && $user->rights->expensereport->to_paid)
  437. {
  438. include_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
  439. $board=new ExpenseReport($db);
  440. $dashboardlines[] = $board->load_board($user,'topay');
  441. }
  442. $object=new stdClass();
  443. $parameters=array();
  444. $action='';
  445. $reshook=$hookmanager->executeHooks('addOpenElementsDashboardLine',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
  446. if ($reshook == 0) {
  447. $dashboardlines = array_merge($dashboardlines, $hookmanager->resArray);
  448. }
  449. // Calculate total nb of late
  450. $totallate=$totaltodo=0;
  451. //Remove any invalid response
  452. //load_board can return an integer if failed or WorkboardResponse if OK
  453. $valid_dashboardlines=array();
  454. foreach($dashboardlines as $tmp)
  455. {
  456. if ($tmp instanceof WorkboardResponse) $valid_dashboardlines[] = $tmp;
  457. }
  458. // We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
  459. foreach($valid_dashboardlines as $board)
  460. {
  461. if ($board->nbtodolate > 0) {
  462. if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totaltodo += $board->nbtodo;
  463. $totallate += $board->nbtodolate;
  464. }
  465. }
  466. //var_dump($totallate, $totaltodo);
  467. if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) && !empty($totaltodo)) $totallate = round($totallate / $totaltodo * 100, 2);
  468. //var_dump($totallate);
  469. $boxwork='';
  470. $boxwork.='<div class="box">';
  471. $boxwork.='<table summary="'.dol_escape_htmltag($langs->trans("WorkingBoard")).'" class="noborder boxtable boxtablenobottom boxworkingboard" width="100%">'."\n";
  472. $boxwork.='<tr class="liste_titre">';
  473. $boxwork.='<th class="liste_titre">'.$langs->trans("DolibarrWorkBoard").'</th>';
  474. $boxwork.='</tr>'."\n";
  475. if ($showweather)
  476. {
  477. $boxwork.='<tr class="nohover">';
  478. $boxwork.='<td class="nohover'.($conf->global->MAIN_DISABLE_METEO == 2 ?' hideonsmartphone' : '').' center valignmiddle">';
  479. $text='';
  480. if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate.(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '%' : '')).')';
  481. else $text=$langs->transnoentitiesnoconv("NoItemLate");
  482. $text.='. '.$langs->transnoentitiesnoconv("LateDesc");
  483. //$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
  484. $options='height="64px"';
  485. $boxwork.=showWeather($totallate,$text,$options);
  486. $boxwork.='</td>';
  487. $boxwork.='</tr>';
  488. }
  489. // Show dashboard
  490. $nbworkboardempty=0;
  491. if (! empty($valid_dashboardlines))
  492. {
  493. $boxwork.='<tr class="nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">';
  494. foreach($valid_dashboardlines as $board)
  495. {
  496. if (empty($board->nbtodo)) $nbworkboardempty++;
  497. $textlate = $langs->trans("NActionsLate",$board->nbtodolate);
  498. $textlate.= ' ('.$langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($board->warning_delay) >= 0 ? '+' : '').ceil($board->warning_delay).' '.$langs->trans("days").')';
  499. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">';
  500. $boxwork .= '<div class="boxstatscontent">';
  501. $sep=($conf->dol_use_jmobile?'<br>':' ');
  502. $boxwork .= '<span class="boxstatstext" title="'.dol_escape_htmltag($board->label).'">'.$board->img.' '.$board->label.'</span><br>';
  503. $boxwork .= '<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.$board->nbtodo.'</span></a>';
  504. if ($board->total > 0 && ! empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX))
  505. {
  506. $boxwork .= '&nbsp;/&nbsp;<a class="valignmiddle dashboardlineindicator" href="'.$board->url.'"><span class="dashboardlineindicator'.(($board->nbtodo == 0)?' dashboardlineok':'').'">'.price($board->total) .'</span></a>';
  507. }
  508. $boxwork .= '</div>';
  509. if ($board->nbtodolate > 0)
  510. {
  511. $boxwork .= '<div class="dashboardlinelatecoin nowrap">';
  512. $boxwork .= '<a title="'.dol_escape_htmltag($textlate).'" class="valignmiddle dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'" href="'.((!$board->url_late) ? $board->url : $board->url_late ).'">';
  513. //$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
  514. $boxwork .= img_picto($textlate, "warning_white", 'class="inline-block hideonsmartphone valigntextbottom"').'';
  515. $boxwork .= '<span class="dashboardlineindicatorlate'.($board->nbtodolate>0?' dashboardlineko':' dashboardlineok').'">';
  516. $boxwork .= $board->nbtodolate;
  517. $boxwork .= '</span>';
  518. $boxwork .= '</a>';
  519. $boxwork .= '</div>';
  520. }
  521. $boxwork.='</div></div>';
  522. $boxwork .="\n";
  523. }
  524. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  525. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  526. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  527. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  528. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  529. $boxwork .='<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>';
  530. $boxwork .='</div>';
  531. $boxwork .='</td></tr>';
  532. }
  533. else
  534. {
  535. $boxwork.='<tr class="nohover">';
  536. $boxwork.='<td class="nohover valignmiddle opacitymedium">';
  537. $boxwork.=$langs->trans("NoOpenedElementToProcess");
  538. $boxwork.='</td>';
  539. $boxwork.='</tr>';
  540. }
  541. $boxwork.='</td></tr>';
  542. $boxwork.='</table>'; // End table array of working board
  543. $boxwork.='</div>';
  544. print '</div></div></div><div class="clearboth"></div>';
  545. print '<div class="fichecenter fichecenterbis">';
  546. /*
  547. * Show boxes
  548. */
  549. $boxlist.='<div class="twocolumns">';
  550. $boxlist.='<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
  551. $boxlist.=$boxwork;
  552. $boxlist.=$resultboxes['boxlista'];
  553. $boxlist.= '</div>';
  554. $boxlist.= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
  555. $boxlist.=$boxstat;
  556. $boxlist.=$resultboxes['boxlistb'];
  557. $boxlist.= '</div>';
  558. $boxlist.= "\n";
  559. $boxlist.='</div>';
  560. print $boxlist;
  561. print '</div>';
  562. /*
  563. * Show security warnings
  564. */
  565. // Security warning repertoire install existe (si utilisateur admin)
  566. if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING))
  567. {
  568. $message='';
  569. // Check if install lock file is present
  570. $lockfile=DOL_DATA_ROOT.'/install.lock';
  571. if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install"))
  572. {
  573. $langs->load("errors");
  574. //if (! empty($message)) $message.='<br>';
  575. $message.=info_admin($langs->trans("WarningLockFileDoesNotExists",DOL_DATA_ROOT).' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  576. }
  577. // Conf files must be in read only mode
  578. if (is_writable($conffile))
  579. {
  580. $langs->load("errors");
  581. //$langs->load("other");
  582. //if (! empty($message)) $message.='<br>';
  583. $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth');
  584. }
  585. if ($message)
  586. {
  587. print $message;
  588. //$message.='<br>';
  589. //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  590. }
  591. }
  592. //print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
  593. // End of page
  594. llxFooter();
  595. $db->close();
  596. /**
  597. * Show weather logo. Logo to show depends on $totallate and values for
  598. * $conf->global->MAIN_METEO_LEVELx
  599. *
  600. * @param int $totallate Nb of element late
  601. * @param string $text Text to show on logo
  602. * @param string $options More parameters on img tag
  603. * @return string Return img tag of weather
  604. */
  605. function showWeather($totallate, $text, $options)
  606. {
  607. global $conf;
  608. $out='';
  609. $offset=0;
  610. $factor=10; // By default
  611. $used_conf = !empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL';
  612. $level0=$offset;
  613. if (! empty($conf->global->{$used_conf.'0'})) {
  614. $level0=$conf->global->{$used_conf.'0'};
  615. }
  616. $level1=$offset+1*$factor;
  617. if (! empty($conf->global->{$used_conf.'1'})) {
  618. $level1=$conf->global->{$used_conf.'1'};
  619. }
  620. $level2=$offset+2*$factor;
  621. if (! empty($conf->global->{$used_conf.'2'})) {
  622. $level2=$conf->global->{$used_conf.'2'};
  623. }
  624. $level3=$offset+3*$factor;
  625. if (! empty($conf->global->{$used_conf.'3'})) {
  626. $level3=$conf->global->{$used_conf.'3'};
  627. }
  628. if ($totallate <= $level0) $out.=img_weather($text,'weather-clear.png',$options);
  629. elseif ($totallate > $level0 && $totallate <= $level1) $out.=img_weather($text,'weather-few-clouds.png',$options);
  630. elseif ($totallate > $level1 && $totallate <= $level2) $out.=img_weather($text,'weather-clouds.png',$options);
  631. elseif ($totallate > $level2 && $totallate <= $level3) $out.=img_weather($text,'weather-many-clouds.png',$options);
  632. elseif ($totallate > $level3) $out.=img_weather($text,'weather-storm.png',$options);
  633. return $out;
  634. }