PageRenderTime 59ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/index.php

https://github.com/asterix14/dolibarr
PHP | 602 lines | 416 code | 87 blank | 99 comment | 87 complexity | 16a10875eac1950099370976ed8cc73a MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
  5. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/index.php
  22. * \brief Dolibarr home page
  23. */
  24. define('NOCSRFCHECK',1); // This is login page. We must be able to go on it from another web site.
  25. require("./main.inc.php");
  26. require_once(DOL_DOCUMENT_ROOT."/boxes.php");
  27. // If not defined, we select menu "home"
  28. if (! isset($_GET["mainmenu"])) $_GET["mainmenu"]="home";
  29. /*
  30. * Actions
  31. */
  32. // Check if company name is defined (first install)
  33. if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM))
  34. {
  35. header("Location: ".DOL_URL_ROOT."/admin/company.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
  36. exit;
  37. }
  38. /*
  39. * View
  40. */
  41. // If smartphone mode, we do not show main page, we show only menu
  42. if (preg_match('/^smartphone/',$conf->smart_menu) && isset($conf->browser->phone))
  43. {
  44. $limitmenuto=GETPOST('limitmenuto')?GETPOST('limitmenuto'):0;
  45. $limitmenuto=1; // A virer
  46. // Load the smartphone menu manager
  47. $result=@include_once(DOL_DOCUMENT_ROOT ."/core/menus/smartphone/".$conf->smart_menu);
  48. if (! $result) // If failed to include, we try with standard
  49. {
  50. $conf->smart_menu='smartphone_backoffice.php';
  51. include_once(DOL_DOCUMENT_ROOT ."/core/menus/smartphone/".$conf->smart_menu);
  52. }
  53. $menusmart = new MenuSmart($db);
  54. include_once(DOL_DOCUMENT_ROOT.'/theme/phones/smartphone/tpl/menu.tpl.php');
  55. exit;
  56. }
  57. llxHeader();
  58. print_fiche_titre($langs->trans("HomeArea"));
  59. if (! empty($conf->global->MAIN_MOTD))
  60. {
  61. $conf->global->MAIN_MOTD=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$conf->global->MAIN_MOTD);
  62. if (! empty($conf->global->MAIN_MOTD))
  63. {
  64. print "\n<!-- Start of welcome text -->\n";
  65. print '<table width="100%" class="notopnoleftnoright"><tr><td>';
  66. print dol_htmlentitiesbr($conf->global->MAIN_MOTD);
  67. print '</td></tr></table><br>';
  68. print "\n<!-- End of welcome text -->\n";
  69. }
  70. }
  71. print '<div class="fichecenter"><div class="fichethirdleft">';
  72. /*
  73. * Informations area
  74. */
  75. print '<table class="noborder" width="100%">';
  76. print '<tr class="liste_titre"><th class="liste_titre" colspan="2">'.$langs->trans("Informations").'</th></tr>';
  77. print '<tr '.$bc[false].'>';
  78. print '<td nowrap="nowrap">'.$langs->trans("User").'</td><td>'.$user->getNomUrl(0).'</td></tr>';
  79. print '<tr '.$bc[true].'>';
  80. print '<td nowrap="nowrap">'.$langs->trans("PreviousConnexion").'</td><td>';
  81. if ($user->datepreviouslogin) print dol_print_date($user->datepreviouslogin,"dayhour");
  82. else print $langs->trans("Unknown");
  83. print '</td>';
  84. print "</tr>\n";
  85. print "</table>\n";
  86. /*
  87. * Dashboard Dolibarr states (statistics)
  88. * Hidden for external users
  89. */
  90. $langs->load("commercial");
  91. $langs->load("bills");
  92. $langs->load("orders");
  93. if ($user->societe_id == 0)
  94. {
  95. print '<br>';
  96. print '<table class="noborder" width="100%">';
  97. print '<tr class="liste_titre">';
  98. print '<th class="liste_titre" colspan="2">'.$langs->trans("DolibarrStateBoard").'</th>';
  99. print '<th class="liste_titre" align="right">&nbsp;</th>';
  100. print '</tr>';
  101. $var=true;
  102. // Condition to be checked for each display line dashboard
  103. $conditions=array(
  104. ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
  105. ! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
  106. ! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
  107. ! empty($conf->adherent->enabled) && $user->rights->adherent->lire,
  108. ! empty($conf->product->enabled) && $user->rights->produit->lire,
  109. ! empty($conf->service->enabled) && $user->rights->service->lire,
  110. ! empty($conf->propal->enabled) && $user->rights->propale->lire,
  111. ! empty($conf->commande->enabled) && $user->rights->commande->lire,
  112. ! empty($conf->facture->enabled) && $user->rights->facture->lire,
  113. ! empty($conf->societe->enabled) && $user->rights->contrat->activer);
  114. // Class file containing the method load_state_board for each line
  115. $includes=array(DOL_DOCUMENT_ROOT."/societe/class/client.class.php",
  116. DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php",
  117. DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php",
  118. DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php",
  119. DOL_DOCUMENT_ROOT."/product/class/product.class.php",
  120. DOL_DOCUMENT_ROOT."/product/class/service.class.php",
  121. DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php",
  122. DOL_DOCUMENT_ROOT."/commande/class/commande.class.php",
  123. DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php",
  124. DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
  125. // Name class containing the method load_state_board for each line
  126. $classes=array('Client',
  127. 'Prospect',
  128. 'Fournisseur',
  129. 'Adherent',
  130. 'Product',
  131. 'Service',
  132. 'Propal',
  133. 'Commande',
  134. 'Facture',
  135. 'Contrat');
  136. // Cle array returned by the method load_state_board for each line
  137. $keys=array('customers',
  138. 'prospects',
  139. 'suppliers',
  140. 'members',
  141. 'products',
  142. 'services',
  143. 'proposals',
  144. 'orders',
  145. 'invoices',
  146. 'Contracts');
  147. // Dashboard Icon lines
  148. $icons=array('company',
  149. 'company',
  150. 'company',
  151. 'user',
  152. 'product',
  153. 'service',
  154. 'propal',
  155. 'order',
  156. 'bill',
  157. 'order');
  158. // Translation keyword
  159. $titres=array("Customers",
  160. "Prospects",
  161. "Suppliers",
  162. "Members",
  163. "Products",
  164. "Services",
  165. "CommercialProposals",
  166. "CustomersOrders",
  167. "BillsCustomers",
  168. "Contracts");
  169. // Dashboard Link lines
  170. $links=array(DOL_URL_ROOT.'/comm/list.php',
  171. DOL_URL_ROOT.'/comm/prospect/list.php',
  172. DOL_URL_ROOT.'/fourn/liste.php',
  173. DOL_URL_ROOT.'/adherents/liste.php?statut=1&amp;mainmenu=members',
  174. DOL_URL_ROOT.'/product/liste.php?type=0&amp;mainmenu=products',
  175. DOL_URL_ROOT.'/product/liste.php?type=1&amp;mainmenu=products',
  176. DOL_URL_ROOT.'/comm/propal.php?mainmenu=commercial',
  177. DOL_URL_ROOT.'/commande/liste.php?mainmenu=commercial',
  178. DOL_URL_ROOT.'/compta/facture.php?mainmenu=accountancy',
  179. DOL_URL_ROOT.'/contrat/liste.php');
  180. // Translation lang files
  181. $langfile=array("bills",
  182. "prospects",
  183. "suppliers",
  184. "members",
  185. "products",
  186. "produts",
  187. "propal",
  188. "orders",
  189. "bills",
  190. "Contracts");
  191. //print memory_get_usage()."<br>";
  192. // Loop and displays each line of table
  193. foreach ($keys as $key=>$val)
  194. {
  195. if ($conditions[$key])
  196. {
  197. $classe=$classes[$key];
  198. // Search in cache if load_state_board is already realized
  199. if (! isset($boardloaded[$classe]) || ! is_object($boardloaded[$classe]))
  200. {
  201. include_once($includes[$key]);
  202. $board=new $classe($db);
  203. $board->load_state_board($user);
  204. $boardloaded[$classe]=$board;
  205. }
  206. else $board=$boardloaded[$classe];
  207. $var=!$var;
  208. if ($langfile[$key]) $langs->load($langfile[$key]);
  209. $title=$langs->trans($titres[$key]);
  210. print '<tr '.$bc[$var].'><td width="16">'.img_object($title,$icons[$key]).'</td>';
  211. print '<td>'.$title.'</td>';
  212. print '<td align="right"><a href="'.$links[$key].'">'.$board->nb[$val].'</a></td>';
  213. print '</tr>';
  214. //print $includes[$key].' '.memory_get_usage()."<br>";
  215. }
  216. }
  217. print '</table>';
  218. }
  219. print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
  220. /*
  221. * Dolibarr Working Board with weather
  222. */
  223. $showweather=empty($conf->global->MAIN_DISABLE_METEO)?1:0;
  224. $rowspan=0;
  225. $dashboardlines=array();
  226. print '<table class="noborder" width="100%">';
  227. print '<tr class="liste_titre">';
  228. print '<th class="liste_titre"colspan="2">'.$langs->trans("DolibarrWorkBoard").'</th>';
  229. print '<th class="liste_titre"align="right">'.$langs->trans("Number").'</th>';
  230. print '<th class="liste_titre"align="right">'.$langs->trans("Late").'</th>';
  231. print '<th class="liste_titre">&nbsp;</th>';
  232. print '<th class="liste_titre"width="20">&nbsp;</th>';
  233. if ($showweather) print '<th class="liste_titre" width="80">&nbsp;</th>';
  234. print '</tr>';
  235. //
  236. // Do not include sections without management permission
  237. //
  238. // Number of actions to do (late)
  239. if ($conf->agenda->enabled && $user->rights->agenda->myactions->read)
  240. {
  241. include_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php");
  242. $board=new ActionComm($db);
  243. $board->load_board($user);
  244. $board->warning_delay=$conf->actions->warning_delay/60/60/24;
  245. $board->label=$langs->trans("ActionsToDo");
  246. $board->url=DOL_URL_ROOT.'/comm/action/listactions.php?status=todo&mainmenu=agenda';
  247. $board->img=img_object($langs->trans("Actions"),"action");
  248. $rowspan++;
  249. $dashboardlines[]=$board;
  250. }
  251. // Number of customer orders a deal
  252. if ($conf->commande->enabled && $user->rights->commande->lire)
  253. {
  254. include_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
  255. $board=new Commande($db);
  256. $board->load_board($user);
  257. $board->warning_delay=$conf->commande->client->warning_delay/60/60/24;
  258. $board->label=$langs->trans("OrdersToProcess");
  259. $board->url=DOL_URL_ROOT.'/commande/liste.php?viewstatut=-2';
  260. $board->img=img_object($langs->trans("Orders"),"order");
  261. $rowspan++;
  262. $dashboardlines[]=$board;
  263. }
  264. // Number of suppliers orders a deal
  265. if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire)
  266. {
  267. include_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php");
  268. $board=new CommandeFournisseur($db);
  269. $board->load_board($user);
  270. $board->warning_delay=$conf->commande->fournisseur->warning_delay/60/60/24;
  271. $board->label=$langs->trans("SuppliersOrdersToProcess");
  272. $board->url=DOL_URL_ROOT.'/fourn/commande/index.php';
  273. $board->img=img_object($langs->trans("Orders"),"order");
  274. $rowspan++;
  275. $dashboardlines[]=$board;
  276. }
  277. // Number of commercial proposals opened (expired)
  278. if ($conf->propal->enabled && $user->rights->propale->lire)
  279. {
  280. $langs->load("propal");
  281. include_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  282. $board=new Propal($db);
  283. $board->load_board($user,"opened");
  284. $board->warning_delay=$conf->propal->cloture->warning_delay/60/60/24;
  285. $board->label=$langs->trans("PropalsToClose");
  286. $board->url=DOL_URL_ROOT.'/comm/propal.php?viewstatut=1';
  287. $board->img=img_object($langs->trans("Propals"),"propal");
  288. $rowspan++;
  289. $dashboardlines[]=$board;
  290. }
  291. // Number of commercial proposals CLOSED signed (billed)
  292. if ($conf->propal->enabled && $user->rights->propale->lire)
  293. {
  294. $langs->load("propal");
  295. include_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
  296. $board=new Propal($db);
  297. $board->load_board($user,"signed");
  298. $board->warning_delay=$conf->propal->facturation->warning_delay/60/60/24;
  299. $board->label=$langs->trans("PropalsToBill");
  300. $board->url=DOL_URL_ROOT.'/comm/propal.php?viewstatut=2';
  301. $board->img=img_object($langs->trans("Propals"),"propal");
  302. $rowspan++;
  303. $dashboardlines[]=$board;
  304. }
  305. // Number of services enabled (delayed)
  306. if ($conf->contrat->enabled && $user->rights->contrat->lire)
  307. {
  308. $langs->load("contracts");
  309. include_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
  310. $board=new Contrat($db);
  311. $board->load_board($user,"inactives");
  312. $board->warning_delay=$conf->contrat->services->inactifs->warning_delay/60/60/24;
  313. $board->label=$langs->trans("BoardNotActivatedServices");
  314. $board->url=DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=0';
  315. $board->img=img_object($langs->trans("Contract"),"contract");
  316. $rowspan++;
  317. $dashboardlines[]=$board;
  318. }
  319. // Number of active services (expired)
  320. if ($conf->contrat->enabled && $user->rights->contrat->lire)
  321. {
  322. $langs->load("contracts");
  323. include_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
  324. $board=new Contrat($db);
  325. $board->load_board($user,"expired");
  326. $board->warning_delay=$conf->contrat->services->expires->warning_delay/60/60/24;
  327. $board->label=$langs->trans("BoardRunningServices");
  328. $board->url=DOL_URL_ROOT.'/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired';
  329. $board->img=img_object($langs->trans("Contract"),"contract");
  330. $rowspan++;
  331. $dashboardlines[]=$board;
  332. }
  333. // Number of invoices customers (has paid)
  334. if ($conf->facture->enabled && $user->rights->facture->lire)
  335. {
  336. $langs->load("bills");
  337. include_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
  338. $board=new Facture($db);
  339. $board->load_board($user);
  340. $board->warning_delay=$conf->facture->client->warning_delay/60/60/24;
  341. $board->label=$langs->trans("CustomerBillsUnpaid");
  342. $board->url=DOL_URL_ROOT.'/compta/facture/impayees.php';
  343. $board->img=img_object($langs->trans("Bills"),"bill");
  344. $rowspan++;
  345. $dashboardlines[]=$board;
  346. }
  347. // Number of supplier invoices (has paid)
  348. if ($conf->fournisseur->enabled && $conf->facture->enabled && $user->rights->facture->lire)
  349. {
  350. $langs->load("bills");
  351. include_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.facture.class.php");
  352. $board=new FactureFournisseur($db);
  353. $board->load_board($user);
  354. $board->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24;
  355. $board->label=$langs->trans("SupplierBillsToPay");
  356. $board->url=DOL_URL_ROOT.'/fourn/facture/index.php?filtre=paye:0';
  357. $board->img=img_object($langs->trans("Bills"),"bill");
  358. $rowspan++;
  359. $dashboardlines[]=$board;
  360. }
  361. // Number of transactions to conciliate
  362. if ($conf->banque->enabled && $user->rights->banque->lire && ! $user->societe_id)
  363. {
  364. $langs->load("banks");
  365. include_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
  366. $board=new Account($db);
  367. $found=$board->load_board($user);
  368. if ($found > 0)
  369. {
  370. $board->warning_delay=$conf->bank->rappro->warning_delay/60/60/24;
  371. $board->label=$langs->trans("TransactionsToConciliate");
  372. $board->url=DOL_URL_ROOT.'/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
  373. $board->img=img_object($langs->trans("TransactionsToConciliate"),"payment");
  374. $rowspan++;
  375. $dashboardlines[]=$board;
  376. }
  377. }
  378. // Number of cheque to send
  379. if ($conf->banque->enabled && $user->rights->banque->lire && ! $user->societe_id)
  380. {
  381. $langs->load("banks");
  382. include_once(DOL_DOCUMENT_ROOT."/compta/paiement/cheque/class/remisecheque.class.php");
  383. $board=new RemiseCheque($db);
  384. $board->load_board($user);
  385. $board->warning_delay=$conf->bank->cheque->warning_delay/60/60/24;
  386. $board->label=$langs->trans("BankChecksToReceipt");
  387. $board->url=DOL_URL_ROOT.'/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=accountancy';
  388. $board->img=img_object($langs->trans("BankChecksToReceipt"),"payment");
  389. $rowspan++;
  390. $dashboardlines[]=$board;
  391. }
  392. // Number of foundation members
  393. if ($conf->adherent->enabled && $user->rights->adherent->lire && ! $user->societe_id)
  394. {
  395. $langs->load("members");
  396. include_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
  397. $board=new Adherent($db);
  398. $board->load_board($user);
  399. $board->warning_delay=$conf->adherent->cotisation->warning_delay/60/60/24;
  400. $board->label=$langs->trans("MembersWithSubscriptionToReceive");
  401. $board->url=DOL_URL_ROOT.'/adherents/liste.php?mainmenu=members&statut=1';
  402. $board->img=img_object($langs->trans("Members"),"user");
  403. $rowspan++;
  404. $dashboardlines[]=$board;
  405. }
  406. // Calculate total nb of late
  407. $totallate=0;
  408. foreach($dashboardlines as $key => $board)
  409. {
  410. if ($board->nbtodolate > 0) $totallate+=$board->nbtodolate;
  411. }
  412. // Show dashboard
  413. $var=true;
  414. foreach($dashboardlines as $key => $board)
  415. {
  416. $var=!$var;
  417. print '<tr '.$bc[$var].'><td width="16">'.$board->img.'</td><td>'.$board->label.'</td>';
  418. print '<td align="right"><a href="'.$board->url.'">'.$board->nbtodo.'</a></td>';
  419. print '<td align="right">';
  420. print '<a href="'.$board->url.'">';
  421. print $board->nbtodolate;
  422. print '</a></td>';
  423. print '<td align="left">';
  424. if ($board->nbtodolate > 0) print img_picto($langs->trans("NActionsLate",$board->nbtodolate),"warning");
  425. else print '&nbsp;';
  426. print '</td>';
  427. print '<td nowrap="nowrap" align="right">';
  428. print ' (>'.ceil($board->warning_delay).' '.$langs->trans("days").')';
  429. print '</td>';
  430. if ($showweather)
  431. {
  432. print '<td rowspan="'.$rowspan.'" width="80" style="border-left: 1px solid #DDDDDD" align="center">';
  433. $text='';
  434. if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')';
  435. $options='height="64px"';
  436. if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements
  437. else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements
  438. print showWeather($totallate,$text,$options);
  439. //print showWeather(0,'');
  440. //print showWeather(40,$text);
  441. print '</td>';
  442. $showweather=0;
  443. }
  444. print '</tr>';
  445. print "\n";
  446. }
  447. print '</table>'; // End table array
  448. print '</div></div></div><div class="fichecenter"><br>';
  449. /*
  450. * Show boxes
  451. */
  452. printBoxesArea($user,"0");
  453. print '</div>';
  454. /*
  455. * Show security warnings
  456. */
  457. // Security warning repertoire install existe (si utilisateur admin)
  458. if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING))
  459. {
  460. $message='';
  461. // Check if install lock file is present
  462. $lockfile=DOL_DATA_ROOT.'/install.lock';
  463. if (! empty($lockfile) && ! file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT."/install"))
  464. {
  465. $langs->load("errors");
  466. //if (! empty($message)) $message.='<br>';
  467. $message.=info_admin($langs->trans("WarningInstallDirExists",DOL_DOCUMENT_ROOT."/install").' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  468. }
  469. // Conf files must be in read only mode
  470. if (is_writable($conffile))
  471. {
  472. $langs->load("errors");
  473. //$langs->load("other");
  474. //if (! empty($message)) $message.='<br>';
  475. $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  476. }
  477. if ($message)
  478. {
  479. print $message;
  480. //$message.='<br>';
  481. //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  482. }
  483. }
  484. $db->close();
  485. llxFooter();
  486. /**
  487. * Show weather logo. Logo to show depends on $totallate and values for
  488. * $conf->global->MAIN_METEO_OFFSET
  489. * $conf->global->MAIN_METEO_GAP
  490. *
  491. * @param int $totallate Nb of element late
  492. * @param string $text Text to show on logo
  493. * @param string $options More parameters on img tag
  494. * @return string Return img tag of weather
  495. */
  496. function showWeather($totallate,$text,$options)
  497. {
  498. global $conf;
  499. $out='';
  500. $offset=0;
  501. $cursor=10; // By default
  502. //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
  503. //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
  504. $level0=$offset; if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
  505. $level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
  506. $level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
  507. $level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
  508. if ($totallate <= $level0) $out.=img_picto_common($text,'weather/weather-clear.png',$options);
  509. if ($totallate > $level0 && $totallate <= $level1) $out.=img_picto_common($text,'weather/weather-few-clouds.png',$options);
  510. if ($totallate > $level1 && $totallate <= $level2) $out.=img_picto_common($text,'weather/weather-clouds.png',$options);
  511. if ($totallate > $level2 && $totallate <= $level3) $out.=img_picto_common($text,'weather/weather-many-clouds.png',$options);
  512. if ($totallate > $level3) $out.=img_picto_common($text,'weather/weather-storm.png',$options);
  513. return $out;
  514. }
  515. ?>