index.php 27 KB

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