index.php 26 KB

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