index.php 26 KB

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