2004-10-20 23:06:45 +02:00
< ? php
2017-06-06 07:57:03 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2020-04-28 01:04:37 +02:00
* Copyright ( C ) 2004 - 2020 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ inodbox . com >
2017-06-06 07:57:03 +02:00
* Copyright ( C ) 2011 - 2012 Juanjo Menent < jmenent @ 2 byte . es >
* Copyright ( C ) 2015 Marcos García < marcosgdf @ gmail . com >
2021-06-21 10:42:20 +02:00
* Copyright ( C ) 2021 Frédéric France < frederic . france @ netlogic . fr >
2002-04-29 21:47:03 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2002-04-29 21:47:03 +02:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2002-04-29 19:53:37 +02:00
*/
2005-01-03 20:21:51 +01:00
/**
2008-11-19 19:19:51 +01:00
* \file htdocs / index . php
2008-12-07 16:55:40 +01:00
* \brief Dolibarr home page
2008-11-16 19:55:00 +01:00
*/
2005-01-03 20:21:51 +01:00
2021-03-16 11:58:03 +01:00
2021-10-25 22:07:31 +02:00
define ( 'CSRFCHECK_WITH_TOKEN' , 1 ); // We force need to use a token to login when making a POST
2009-05-16 08:31:59 +02:00
2012-08-23 01:43:44 +02:00
require 'main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
2002-04-29 19:53:37 +02:00
2008-12-07 16:55:40 +01:00
// If not defined, we select menu "home"
2021-01-02 20:04:40 +01:00
$_GET [ 'mainmenu' ] = GETPOST ( 'mainmenu' , 'aZ09' ) ? GETPOST ( 'mainmenu' , 'aZ09' ) : 'home' ;
2019-11-14 12:09:46 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
2005-01-03 20:21:51 +01:00
2012-03-02 14:51:16 +01:00
$hookmanager -> initHooks ( array ( 'index' ));
2011-12-06 23:38:54 +01:00
2011-02-19 18:21:29 +01:00
2008-12-07 16:55:40 +01:00
/*
* Actions
*/
2006-11-01 16:15:14 +01:00
2011-02-19 18:21:29 +01:00
// Check if company name is defined (first install)
2021-01-02 20:04:40 +01:00
if ( ! isset ( $conf -> global -> MAIN_INFO_SOCIETE_NOM ) || empty ( $conf -> global -> MAIN_INFO_SOCIETE_NOM )) {
2020-09-07 10:18:17 +02:00
header ( " Location: " . DOL_URL_ROOT . " /admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete " );
exit ;
2011-02-19 18:21:29 +01:00
}
2021-01-02 20:04:40 +01:00
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
2020-09-07 10:18:17 +02:00
header ( " Location: " . DOL_URL_ROOT . " /admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete " );
exit ;
2016-07-23 13:20:34 +02:00
}
2021-01-02 20:04:40 +01:00
if ( GETPOST ( 'addbox' )) { // Add box (when submit is done from a form when ajax disabled)
2014-07-29 00:50:57 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php' ;
2021-06-11 15:21:24 +02:00
$zone = GETPOST ( 'areacode' , 'int' );
2019-11-14 12:09:46 +01:00
$userid = GETPOST ( 'userid' , 'int' );
$boxorder = GETPOST ( 'boxorder' , 'aZ09' );
$boxorder .= GETPOST ( 'boxcombo' , 'aZ09' );
2014-07-29 00:50:57 +02:00
2019-11-14 12:09:46 +01:00
$result = InfoBox :: saveboxorder ( $db , $zone , $boxorder , $userid );
2021-01-02 20:04:40 +01:00
if ( $result > 0 ) {
setEventMessages ( $langs -> trans ( " BoxAdded " ), null );
}
2014-07-29 00:50:57 +02:00
}
2006-11-01 16:15:14 +01:00
/*
2008-12-07 16:55:40 +01:00
* View
2008-11-16 19:55:00 +01:00
*/
2005-01-03 20:21:51 +01:00
2021-01-02 20:04:40 +01:00
if ( ! isset ( $form ) || ! is_object ( $form )) {
$form = new Form ( $db );
}
2016-03-01 00:59:42 +01:00
2014-01-26 18:30:45 +01:00
// Title
2019-11-14 12:09:46 +01:00
$title = $langs -> trans ( " HomeArea " ) . ' - Dolibarr ' . DOL_VERSION ;
2021-01-02 20:04:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) {
$title = $langs -> trans ( " HomeArea " ) . ' - ' . $conf -> global -> MAIN_APPLICATION_TITLE ;
}
2014-01-26 18:30:45 +01:00
2019-01-27 11:55:16 +01:00
llxHeader ( '' , $title );
2003-02-11 14:24:02 +01:00
2017-06-01 01:53:55 +02:00
2019-11-14 12:09:46 +01:00
$resultboxes = FormOther :: getBoxesArea ( $user , " 0 " ); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
2016-01-18 11:35:45 +01:00
2020-05-20 22:45:43 +02:00
print load_fiche_titre ( ' ' , $resultboxes [ 'selectboxlist' ], '' , 0 , '' , 'titleforhome' );
2005-08-12 00:57:29 +02:00
2021-01-02 20:04:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_MOTD )) {
2020-09-07 10:18:17 +02:00
$conf -> global -> MAIN_MOTD = preg_replace ( '/<br(\s[\sa-zA-Z_="]*)?\/?>/i' , '<br>' , $conf -> global -> MAIN_MOTD );
2021-01-02 20:04:40 +01:00
if ( ! empty ( $conf -> global -> MAIN_MOTD )) {
2020-09-07 10:18:17 +02:00
$substitutionarray = getCommonSubstitutionArray ( $langs );
complete_substitutions_array ( $substitutionarray , $langs );
$texttoshow = make_substitutions ( $conf -> global -> MAIN_MOTD , $substitutionarray , $langs );
print " \n <!-- Start of welcome text --> \n " ;
print '<table width="100%" class="notopnoleftnoright"><tr><td>' ;
print dol_htmlentitiesbr ( $texttoshow );
print '</td></tr></table><br>' ;
print " \n <!-- End of welcome text --> \n " ;
}
2004-07-26 16:38:34 +02:00
}
2021-06-21 10:42:20 +02:00
/*
* Show security warnings
*/
// Security warning repertoire install existe (si utilisateur admin)
if ( $user -> admin && empty ( $conf -> global -> MAIN_REMOVE_INSTALL_WARNING )) {
$message = '' ;
2005-08-12 00:57:29 +02:00
2021-06-21 10:42:20 +02:00
// Check if install lock file is present
$lockfile = DOL_DATA_ROOT . '/install.lock' ;
if ( ! empty ( $lockfile ) && ! file_exists ( $lockfile ) && is_dir ( DOL_DOCUMENT_ROOT . " /install " )) {
$langs -> load ( " errors " );
//if (! empty($message)) $message.='<br>';
$message .= info_admin ( $langs -> trans ( " WarningLockFileDoesNotExists " , DOL_DATA_ROOT ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ), 0 , 0 , '1' , 'clearboth' );
}
// Conf files must be in read only mode
if ( is_writable ( $conffile )) {
$langs -> load ( " errors " );
//$langs->load("other");
//if (! empty($message)) $message.='<br>';
$message .= info_admin ( $langs -> transnoentities ( " WarningConfFileMustBeReadOnly " ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ), 0 , 0 , '1' , 'clearboth' );
}
if ( $message ) {
print $message ;
//$message.='<br>';
//print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
}
}
2019-07-29 17:12:41 +02:00
2005-08-12 23:45:18 +02:00
/*
2010-02-16 23:26:44 +01:00
* Dashboard Dolibarr states ( statistics )
2009-08-23 02:15:30 +02:00
* Hidden for external users
2005-08-12 23:45:18 +02:00
*/
2019-09-22 20:59:28 +02:00
$boxstatItems = array ();
$boxstatFromHook = '' ;
2016-02-07 13:10:36 +01:00
2018-05-26 16:03:19 +02:00
// Load translation files required by page
2018-05-26 15:41:32 +02:00
$langs -> loadLangs ( array ( 'commercial' , 'bills' , 'orders' , 'contracts' ));
2010-12-01 22:28:08 +01:00
2020-01-26 19:38:19 +01:00
// Dolibarr Working Board with weather
2019-08-29 14:12:07 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_GLOBAL_WORKBOARD )) {
2020-09-07 10:18:17 +02:00
$showweather = ( empty ( $conf -> global -> MAIN_DISABLE_METEO ) || $conf -> global -> MAIN_DISABLE_METEO == 2 ) ? 1 : 0 ;
//Array that contains all WorkboardResponse classes to process them
$dashboardlines = array ();
// Do not include sections without management permission
require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php' ;
// Number of actions to do (late)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> agenda -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_AGENDA ) && $user -> rights -> agenda -> myactions -> read ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
$board = new ActionComm ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
// Number of project opened
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> projet -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_PROJECT ) && $user -> rights -> projet -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$board = new Project ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
// Number of tasks to do (late)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> projet -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_PROJECT ) && empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && $user -> rights -> projet -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
$board = new Task ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2021-08-22 05:25:13 +02:00
// Number of commercial customer proposals open (expired)
if ( ! empty ( $conf -> propal -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_CUSTOMER ) && $user -> rights -> propale -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
$board = new Propal ( $db );
$dashboardlines [ $board -> element . '_opened' ] = $board -> load_board ( $user , " opened " );
// Number of commercial proposals CLOSED signed (billed)
$dashboardlines [ $board -> element . '_signed' ] = $board -> load_board ( $user , " signed " );
}
2021-09-05 01:14:42 +02:00
// Number of supplier proposals open (expired)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_SUPPLIER ) && $user -> rights -> supplier_proposal -> lire ) {
2021-09-05 01:14:42 +02:00
$langs -> load ( " supplier_proposal " );
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php' ;
$board = new SupplierProposal ( $db );
$dashboardlines [ $board -> element . '_opened' ] = $board -> load_board ( $user , " opened " );
// Number of commercial proposals CLOSED signed (billed)
$dashboardlines [ $board -> element . '_signed' ] = $board -> load_board ( $user , " signed " );
}
// Number of customer orders a deal
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_CUSTOMER ) && $user -> rights -> commande -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
$board = new Commande ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
// Number of suppliers orders a deal
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> supplier_order -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_SUPPLIER ) && $user -> rights -> fournisseur -> commande -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
$board = new CommandeFournisseur ( $db );
$dashboardlines [ $board -> element . '_opened' ] = $board -> load_board ( $user , " opened " );
$dashboardlines [ $board -> element . '_awaiting' ] = $board -> load_board ( $user , 'awaiting' );
}
// Number of contract / services enabled (delayed)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_CONTRACT ) && $user -> rights -> contrat -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
$board = new Contrat ( $db );
$dashboardlines [ $board -> element . '_inactive' ] = $board -> load_board ( $user , " inactive " );
// Number of active services (expired)
$dashboardlines [ $board -> element . '_active' ] = $board -> load_board ( $user , " active " );
}
// Number of tickets open
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> ticket -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_TICKET ) && $user -> rights -> ticket -> read ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/ticket/class/ticket.class.php' ;
$board = new Ticket ( $db );
$dashboardlines [ $board -> element . '_opened' ] = $board -> load_board ( $user , " opened " );
// Number of active services (expired)
//$dashboardlines[$board->element.'_active'] = $board->load_board($user, "active");
}
// Number of invoices customers (paid)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_CUSTOMER ) && $user -> rights -> facture -> lire ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
$board = new Facture ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
// Number of supplier invoices (paid)
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> supplier_invoice -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_SUPPLIER ) && ! empty ( $user -> rights -> fournisseur -> facture -> lire )) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
$board = new FactureFournisseur ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
// Number of transactions to conciliate
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> banque -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_BANK ) && $user -> rights -> banque -> lire && ! $user -> socid ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$board = new Account ( $db );
2020-09-19 23:30:29 +02:00
$nb = $board -> countAccountToReconcile (); // Get nb of account to reconciliate
2020-09-07 10:18:17 +02:00
if ( $nb > 0 ) {
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
}
2022-01-09 19:48:38 +01:00
2020-09-07 10:18:17 +02:00
// Number of cheque to send
2022-01-09 19:48:38 +01:00
if ( ! empty ( $conf -> banque -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_BANK ) && $user -> rights -> banque -> lire && ! $user -> socid ) {
if ( empty ( $conf -> global -> BANK_DISABLE_CHECK_DEPOSIT )) {
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php' ;
$board = new RemiseCheque ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
if ( ! empty ( $conf -> prelevement -> enabled )) {
include_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php' ;
$board = new BonPrelevement ( $db );
$dashboardlines [ $board -> element . '_direct_debit' ] = $board -> load_board ( $user , 'direct_debit' );
}
if ( ! empty ( $conf -> paymentbybanktransfer -> enabled )) {
include_once DOL_DOCUMENT_ROOT . '/compta/prelevement/class/bonprelevement.class.php' ;
$board = new BonPrelevement ( $db );
$dashboardlines [ $board -> element . '_credit_transfer' ] = $board -> load_board ( $user , 'credit_transfer' );
}
2020-09-07 10:18:17 +02:00
}
// Number of foundation members
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> adherent -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_ADHERENT ) && $user -> rights -> adherent -> lire && ! $user -> socid ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
$board = new Adherent ( $db );
$dashboardlines [ $board -> element . '_shift' ] = $board -> load_board ( $user , 'shift' );
$dashboardlines [ $board -> element . '_expired' ] = $board -> load_board ( $user , 'expired' );
}
// Number of expense reports to approve
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> expensereport -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_EXPENSEREPORT ) && $user -> rights -> expensereport -> approve ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
2020-09-08 21:27:28 +02:00
$dashboardlines [ $board -> element . '_toapprove' ] = $board -> load_board ( $user , 'toapprove' );
2020-09-07 10:18:17 +02:00
}
// Number of expense reports to pay
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> expensereport -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_EXPENSEREPORT ) && $user -> rights -> expensereport -> to_paid ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
2020-09-08 21:27:28 +02:00
$dashboardlines [ $board -> element . '_topay' ] = $board -> load_board ( $user , 'topay' );
2020-09-07 10:18:17 +02:00
}
// Number of holidays to approve
2021-08-22 05:25:13 +02:00
if ( ! empty ( $conf -> holiday -> enabled ) && empty ( $conf -> global -> MAIN_DISABLE_BLOCK_HOLIDAY ) && $user -> rights -> holiday -> approve ) {
2020-09-07 10:18:17 +02:00
include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php' ;
$board = new Holiday ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
$object = new stdClass ();
$parameters = array ();
$action = '' ;
2021-01-02 20:04:40 +01:00
$reshook = $hookmanager -> executeHooks (
'addOpenElementsDashboardLine' ,
$parameters ,
$object ,
$action
); // Note that $action and $object may have been modified by some hooks
2020-09-07 10:18:17 +02:00
if ( $reshook == 0 ) {
$dashboardlines = array_merge ( $dashboardlines , $hookmanager -> resArray );
}
/* Open object dashboard */
$dashboardgroup = array (
'action' =>
array (
'groupName' => 'Agenda' ,
'stats' => array ( 'action' ),
),
'project' =>
array (
'groupName' => 'Projects' ,
'globalStatsKey' => 'projects' ,
'stats' => array ( 'project' , 'project_task' ),
),
'propal' =>
array (
'groupName' => 'Proposals' ,
'globalStatsKey' => 'proposals' ,
'stats' =>
array ( 'propal_opened' , 'propal_signed' ),
),
'commande' =>
array (
'groupName' => 'Orders' ,
'globalStatsKey' => 'orders' ,
'stats' =>
array ( 'commande' ),
),
'facture' =>
array (
'groupName' => 'Invoices' ,
'globalStatsKey' => 'invoices' ,
'stats' =>
array ( 'facture' ),
),
'supplier_proposal' =>
array (
2021-09-29 17:14:37 +02:00
'lang' => 'supplier_proposal' ,
2020-09-07 10:18:17 +02:00
'groupName' => 'SupplierProposals' ,
'globalStatsKey' => 'askprice' ,
'stats' =>
array ( 'supplier_proposal_opened' , 'supplier_proposal_signed' ),
),
'order_supplier' =>
array (
'groupName' => 'SuppliersOrders' ,
'globalStatsKey' => 'supplier_orders' ,
'stats' =>
array ( 'order_supplier_opened' , 'order_supplier_awaiting' ),
),
'invoice_supplier' =>
array (
'groupName' => 'BillsSuppliers' ,
'globalStatsKey' => 'supplier_invoices' ,
'stats' =>
array ( 'invoice_supplier' ),
),
'contrat' =>
array (
'groupName' => 'Contracts' ,
'globalStatsKey' => 'Contracts' ,
'stats' =>
array ( 'contrat_inactive' , 'contrat_active' ),
),
'ticket' =>
array (
'groupName' => 'Tickets' ,
'globalStatsKey' => 'ticket' ,
'stats' =>
array ( 'ticket_opened' ),
),
'bank_account' =>
array (
'groupName' => 'BankAccount' ,
'stats' =>
2022-01-09 19:48:38 +01:00
array ( 'bank_account' , 'chequereceipt' , 'widthdraw_direct_debit' , 'widthdraw_credit_transfer' ),
2020-09-07 10:18:17 +02:00
),
'member' =>
array (
'groupName' => 'Members' ,
'globalStatsKey' => 'members' ,
'stats' =>
array ( 'member_shift' , 'member_expired' ),
),
'expensereport' =>
array (
'groupName' => 'ExpenseReport' ,
'globalStatsKey' => 'expensereports' ,
'stats' =>
array ( 'expensereport_toapprove' , 'expensereport_topay' ),
),
'holiday' =>
array (
'groupName' => 'Holidays' ,
'globalStatsKey' => 'holidays' ,
'stats' =>
array ( 'holiday' ),
),
);
$object = new stdClass ();
$parameters = array (
'dashboardgroup' => $dashboardgroup
);
$reshook = $hookmanager -> executeHooks ( 'addOpenElementsDashboardGroup' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook == 0 ) {
$dashboardgroup = array_merge ( $dashboardgroup , $hookmanager -> resArray );
}
// Calculate total nb of late
$totallate = $totaltodo = 0 ;
//Remove any invalid response
2022-01-09 19:48:38 +01:00
//load_board can return an integer if failed, or WorkboardResponse if OK
2020-09-07 10:18:17 +02:00
$valid_dashboardlines = array ();
2020-11-28 18:34:13 +01:00
foreach ( $dashboardlines as $workboardid => $tmp ) {
2020-09-07 10:18:17 +02:00
if ( $tmp instanceof WorkboardResponse ) {
2020-12-01 02:41:19 +01:00
$tmp -> id = $workboardid ; // Complete the object to add its id into its name
2020-11-28 18:34:13 +01:00
$valid_dashboardlines [ $workboardid ] = $tmp ;
2020-09-07 10:18:17 +02:00
}
}
// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
foreach ( $valid_dashboardlines as $board ) {
if ( $board -> nbtodolate > 0 ) {
$totaltodo += $board -> nbtodo ;
$totallate += $board -> nbtodolate ;
}
}
$openedDashBoardSize = 'info-box-sm' ; // use sm by default
foreach ( $dashboardgroup as $dashbordelement ) {
if ( is_array ( $dashbordelement [ 'stats' ]) && count ( $dashbordelement [ 'stats' ]) > 2 ) {
$openedDashBoardSize = '' ; // use default info box size : big
break ;
}
}
$totalLateNumber = $totallate ;
$totallatePercentage = (( ! empty ( $totaltodo )) ? round ( $totallate / $totaltodo * 100 , 2 ) : 0 );
if ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE )) {
$totallate = $totallatePercentage ;
}
$boxwork = '' ;
$boxwork .= '<div class="box">' ;
2021-06-11 14:54:18 +02:00
$boxwork .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " WorkingBoard " )) . '" class="noborder boxtable boxtablenobottom boxworkingboard centpercent">' . " \n " ;
2020-09-07 10:18:17 +02:00
$boxwork .= '<tr class="liste_titre">' ;
$boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">' . $langs -> trans ( " DolibarrWorkBoard " ) . '</div>' ;
if ( $showweather ) {
if ( $totallate > 0 ) {
2021-01-02 20:04:40 +01:00
$text = $langs -> transnoentitiesnoconv ( " WarningYouHaveAtLeastOneTaskLate " ) . ' (' . $langs -> transnoentitiesnoconv (
" NActionsLate " ,
$totallate . ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? '%' : '' )
) . ')' ;
2020-09-07 10:18:17 +02:00
} else {
$text = $langs -> transnoentitiesnoconv ( " NoItemLate " );
}
$text .= '. ' . $langs -> transnoentitiesnoconv ( " LateDesc " );
//$text.=$form->textwithpicto('',$langs->trans("LateDesc"));
$options = 'height="24px" style="float: right"' ;
$boxwork .= showWeather ( $totallate , $text , $options , 'inline-block valignmiddle' );
}
$boxwork .= '</th>' ;
$boxwork .= '</tr>' . " \n " ;
// Show dashboard
$nbworkboardempty = 0 ;
$isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array ();
if ( ! empty ( $valid_dashboardlines )) {
$openedDashBoard = '' ;
$boxwork .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer centpercent"><div style="display: flex: flex-wrap: wrap">' ;
foreach ( $dashboardgroup as $groupKey => $groupElement ) {
$boards = array ();
2022-01-09 19:48:38 +01:00
// Scan $groupElement and save the one with 'stats' that lust be used for Open object dashboard
2020-09-07 10:18:17 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_NEW_OPENED_DASH_BOARD )) {
foreach ( $groupElement [ 'stats' ] as $infoKey ) {
if ( ! empty ( $valid_dashboardlines [ $infoKey ])) {
$boards [] = $valid_dashboardlines [ $infoKey ];
$isIntopOpenedDashBoard [] = $infoKey ;
}
}
}
if ( ! empty ( $boards )) {
2021-09-29 17:14:37 +02:00
if ( ! empty ( $groupElement [ 'lang' ])) {
$langs -> load ( $groupElement [ 'lang' ]);
}
2020-09-07 10:18:17 +02:00
$groupName = $langs -> trans ( $groupElement [ 'groupName' ]);
$groupKeyLowerCase = strtolower ( $groupKey );
// global stats
$globalStatsKey = false ;
if ( ! empty ( $groupElement [ 'globalStatsKey' ]) && empty ( $groupElement [ 'globalStats' ])) { // can be filled by hook
$globalStatsKey = $groupElement [ 'globalStatsKey' ];
$groupElement [ 'globalStats' ] = array ();
2021-03-14 08:50:17 +01:00
if ( isset ( $keys ) && is_array ( $keys ) && in_array ( $globalStatsKey , $keys )) {
2020-09-07 10:18:17 +02:00
// get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
$keyIndex = array_search ( $globalStatsKey , $keys );
2020-12-29 15:59:39 +01:00
$classe = ( ! empty ( $classes [ $keyIndex ]) ? $classes [ $keyIndex ] : '' );
2021-01-02 20:04:40 +01:00
if ( isset ( $boardloaded [ $classe ]) && is_object ( $boardloaded [ $classe ])) {
2020-09-07 10:18:17 +02:00
$groupElement [ 'globalStats' ][ 'total' ] = $boardloaded [ $classe ] -> nb [ $globalStatsKey ] ? $boardloaded [ $classe ] -> nb [ $globalStatsKey ] : 0 ;
2021-05-20 09:22:55 +02:00
$nbTotal = floatval ( $groupElement [ 'globalStats' ][ 'total' ]);
2021-01-02 20:04:40 +01:00
if ( $nbTotal >= 10000 ) {
$nbTotal = round ( $nbTotal / 1000 , 2 ) . 'k' ;
}
2020-09-07 10:18:17 +02:00
$groupElement [ 'globalStats' ][ 'text' ] = $langs -> trans ( 'Total' ) . ' : ' . $langs -> trans ( $titres [ $keyIndex ]) . ' (' . $groupElement [ 'globalStats' ][ 'total' ] . ')' ;
$groupElement [ 'globalStats' ][ 'total' ] = $nbTotal ;
2022-01-09 19:48:38 +01:00
//$groupElement['globalStats']['link'] = $links[$keyIndex];
2020-09-07 10:18:17 +02:00
}
}
}
$openedDashBoard .= '<div class="box-flex-item"><div class="box-flex-item-with-margin">' . " \n " ;
$openedDashBoard .= ' <div class="info-box ' . $openedDashBoardSize . '">' . " \n " ;
$openedDashBoard .= ' <span class="info-box-icon bg-infobox-' . $groupKeyLowerCase . '">' . " \n " ;
$openedDashBoard .= ' <i class="fa fa-dol-' . $groupKeyLowerCase . '"></i>' . " \n " ;
// Show the span for the total of record
if ( ! empty ( $groupElement [ 'globalStats' ])) {
$globalStatInTopOpenedDashBoard [] = $globalStatsKey ;
2020-10-22 22:45:27 +02:00
$openedDashBoard .= '<span class="info-box-icon-text" title="' . $groupElement [ 'globalStats' ][ 'text' ] . '">' . $nbTotal . '</span>' ;
2020-09-07 10:18:17 +02:00
}
2020-10-22 22:45:27 +02:00
$openedDashBoard .= '</span>' . " \n " ;
$openedDashBoard .= '<div class="info-box-content">' . " \n " ;
2020-09-07 10:18:17 +02:00
2020-10-22 22:45:27 +02:00
$openedDashBoard .= '<div class="info-box-title" title="' . strip_tags ( $groupName ) . '">' . $groupName . '</div>' . " \n " ;
$openedDashBoard .= '<div class="info-box-lines">' . " \n " ;
2020-09-07 10:18:17 +02:00
foreach ( $boards as $board ) {
2020-10-22 22:45:27 +02:00
$openedDashBoard .= '<div class="info-box-line">' ;
2020-09-07 10:18:17 +02:00
if ( ! empty ( $board -> labelShort )) {
2021-11-07 17:27:37 +01:00
$infoName = '<span class="marginrightonly" title="' . $board -> label . '">' . $board -> labelShort . '</span>' ;
2020-09-07 10:18:17 +02:00
} else {
2021-11-07 17:27:37 +01:00
$infoName = '<span class="marginrightonly">' . $board -> label . '</span>' ;
2020-09-07 10:18:17 +02:00
}
$textLateTitle = $langs -> trans ( " NActionsLate " , $board -> nbtodolate );
$textLateTitle .= ' (' . $langs -> trans ( " Late " ) . ' = ' . $langs -> trans ( " DateReference " ) . ' > ' . $langs -> trans ( " DateToday " ) . ' ' . ( ceil ( $board -> warning_delay ) >= 0 ? '+' : '' ) . ceil ( $board -> warning_delay ) . ' ' . $langs -> trans ( " days " ) . ')' ;
2020-11-28 18:34:13 +01:00
if ( $board -> id == 'bank_account' ) {
$textLateTitle .= '<br><span class="opacitymedium">' . $langs -> trans ( " IfYouDontReconcileDisableProperty " , $langs -> transnoentitiesnoconv ( " Conciliable " )) . '</span>' ;
}
2020-09-07 10:18:17 +02:00
$textLate = '' ;
if ( $board -> nbtodolate > 0 ) {
2020-11-28 18:34:13 +01:00
$textLate .= '<span title="' . dol_escape_htmltag ( $textLateTitle ) . '" class="classfortooltip badge badge-warning">' ;
2020-09-07 10:18:17 +02:00
$textLate .= '<i class="fa fa-exclamation-triangle"></i> ' . $board -> nbtodolate ;
$textLate .= '</span>' ;
}
$nbtodClass = '' ;
if ( $board -> nbtodo > 0 ) {
$nbtodClass = 'badge badge-info' ;
2021-11-08 14:01:15 +01:00
} else {
$nbtodClass = 'opacitymedium' ;
2020-09-07 10:18:17 +02:00
}
2022-01-09 19:48:38 +01:00
// Forge the line to show into the open object box
$labeltoshow = $board -> label . ' (' . $board -> nbtodo . ')' ;
if ( $board -> total > 0 ) {
$labeltoshow .= ' - ' . price ( $board -> total , 0 , $langs , 1 , - 1 , - 1 , $conf -> currency );
}
$openedDashBoard .= '<a href="' . $board -> url . '" class="info-box-text info-box-text-a">' . $infoName . '<span class="classfortooltip' . ( $nbtodClass ? ' ' . $nbtodClass : '' ) . '" title="' . $labeltoshow . '" >' ;
$openedDashBoard .= $board -> nbtodo ;
if ( $board -> total > 0 && ! empty ( $conf -> global -> MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX )) {
$openedDashBoard .= ' : ' . price ( $board -> total , 0 , $langs , 1 , - 1 , - 1 , $conf -> currency );
}
$openedDashBoard .= '</span>' ;
2020-09-07 10:18:17 +02:00
if ( $textLate ) {
if ( $board -> url_late ) {
$openedDashBoard .= '</a>' ;
$openedDashBoard .= ' <a href="' . $board -> url_late . '" class="info-box-text info-box-text-a paddingleft">' ;
} else {
$openedDashBoard .= ' ' ;
}
$openedDashBoard .= $textLate ;
}
$openedDashBoard .= '</a>' . " \n " ;
2020-10-22 22:45:27 +02:00
$openedDashBoard .= '</div>' . " \n " ;
2020-09-07 10:18:17 +02:00
}
2020-10-22 22:45:27 +02:00
// TODO Add hook here to add more "info-box-line"
$openedDashBoard .= ' </div><!-- /.info-box-lines --></div><!-- /.info-box-content -->' . " \n " ;
2020-09-07 10:18:17 +02:00
$openedDashBoard .= ' </div><!-- /.info-box -->' . " \n " ;
$openedDashBoard .= '</div><!-- /.box-flex-item-with-margin -->' . " \n " ;
$openedDashBoard .= '</div><!-- /.box-flex-item -->' . " \n " ;
$openedDashBoard .= " \n " ;
}
}
if ( $showweather && ! empty ( $isIntopOpenedDashBoard )) {
2021-01-16 21:06:12 +01:00
$appendClass = ( ! empty ( $conf -> global -> MAIN_DISABLE_METEO ) && $conf -> global -> MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '' );
2020-09-07 10:18:17 +02:00
$weather = getWeatherStatus ( $totallate );
$text = '' ;
if ( $totallate > 0 ) {
2021-01-02 20:04:40 +01:00
$text = $langs -> transnoentitiesnoconv ( " WarningYouHaveAtLeastOneTaskLate " ) . ' (' . $langs -> transnoentitiesnoconv (
" NActionsLate " ,
$totallate . ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? '%' : '' )
) . ')' ;
2020-09-07 10:18:17 +02:00
} else {
$text = $langs -> transnoentitiesnoconv ( " NoItemLate " );
}
$text .= '. ' . $langs -> transnoentitiesnoconv ( " LateDesc " );
$weatherDashBoard = '<div class="box-flex-item ' . $appendClass . '"><div class="box-flex-item-with-margin">' . " \n " ;
$weatherDashBoard .= ' <div class="info-box ' . $openedDashBoardSize . ' info-box-weather info-box-weather-level' . $weather -> level . '">' . " \n " ;
$weatherDashBoard .= ' <span class="info-box-icon">' ;
$weatherDashBoard .= img_weather ( '' , $weather -> level , '' , 0 , 'valignmiddle width50' );
$weatherDashBoard .= ' </span>' . " \n " ;
$weatherDashBoard .= ' <div class="info-box-content">' . " \n " ;
2020-10-22 22:45:27 +02:00
$weatherDashBoard .= ' <div class="info-box-title">' . $langs -> trans ( 'GlobalOpenedElemView' ) . '</div>' . " \n " ;
2020-09-07 10:18:17 +02:00
if ( $totallatePercentage > 0 && ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE )) {
2021-01-02 20:04:40 +01:00
$weatherDashBoard .= ' <span class="info-box-number">' . $langs -> transnoentitiesnoconv (
" NActionsLate " ,
price ( $totallatePercentage ) . '%'
) . '</span>' . " \n " ;
$weatherDashBoard .= ' <span class="progress-description">' . $langs -> trans (
'NActionsLate' ,
$totalLateNumber
) . '</span>' . " \n " ;
2020-09-07 10:18:17 +02:00
} else {
2021-01-02 20:04:40 +01:00
$weatherDashBoard .= ' <span class="info-box-number">' . $langs -> transnoentitiesnoconv (
" NActionsLate " ,
$totalLateNumber
) . '</span>' . " \n " ;
2020-09-07 10:18:17 +02:00
if ( $totallatePercentage > 0 ) {
2021-01-02 20:04:40 +01:00
$weatherDashBoard .= ' <span class="progress-description">' . $langs -> trans (
'NActionsLate' ,
price ( $totallatePercentage ) . '%'
) . '</span>' . " \n " ;
2020-09-07 10:18:17 +02:00
}
}
$weatherDashBoard .= ' </div><!-- /.info-box-content -->' . " \n " ;
$weatherDashBoard .= ' </div><!-- /.info-box -->' . " \n " ;
$weatherDashBoard .= '</div><!-- /.box-flex-item-with-margin -->' . " \n " ;
$weatherDashBoard .= '</div><!-- /.box-flex-item -->' . " \n " ;
$weatherDashBoard .= " \n " ;
$openedDashBoard = $weatherDashBoard . $openedDashBoard ;
}
if ( ! empty ( $isIntopOpenedDashBoard )) {
for ( $i = 1 ; $i <= 10 ; $i ++ ) {
$openedDashBoard .= '<div class="box-flex-item filler"></div>' ;
}
}
$nbworkboardcount = 0 ;
foreach ( $valid_dashboardlines as $infoKey => $board ) {
if ( in_array ( $infoKey , $isIntopOpenedDashBoard )) {
// skip if info is present on top
continue ;
}
if ( empty ( $board -> nbtodo )) {
$nbworkboardempty ++ ;
}
$nbworkboardcount ++ ;
$textlate = $langs -> trans ( " NActionsLate " , $board -> nbtodolate );
$textlate .= ' (' . $langs -> trans ( " Late " ) . ' = ' . $langs -> trans ( " DateReference " ) . ' > ' . $langs -> trans ( " DateToday " ) . ' ' . ( ceil ( $board -> warning_delay ) >= 0 ? '+' : '' ) . ceil ( $board -> warning_delay ) . ' ' . $langs -> trans ( " days " ) . ')' ;
$boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats130 boxstatsborder">' ;
$boxwork .= '<div class="boxstatscontent">' ;
2020-09-21 12:55:06 +02:00
$boxwork .= '<span class="boxstatstext" title="' . dol_escape_htmltag ( $board -> label ) . '">' . $board -> img . ' <span>' . $board -> label . '</span></span><br>' ;
2020-09-07 10:18:17 +02:00
$boxwork .= '<a class="valignmiddle dashboardlineindicator" href="' . $board -> url . '"><span class="dashboardlineindicator' . (( $board -> nbtodo == 0 ) ? ' dashboardlineok' : '' ) . '">' . $board -> nbtodo . '</span></a>' ;
if ( $board -> total > 0 && ! empty ( $conf -> global -> MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX )) {
$boxwork .= ' / <a class="valignmiddle dashboardlineindicator" href="' . $board -> url . '"><span class="dashboardlineindicator' . (( $board -> nbtodo == 0 ) ? ' dashboardlineok' : '' ) . '">' . price ( $board -> total ) . '</span></a>' ;
}
$boxwork .= '</div>' ;
if ( $board -> nbtodolate > 0 ) {
$boxwork .= '<div class="dashboardlinelatecoin nowrap">' ;
$boxwork .= '<a title="' . dol_escape_htmltag ( $textlate ) . '" class="valignmiddle dashboardlineindicatorlate' . ( $board -> nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok' ) . '" href="' . (( ! $board -> url_late ) ? $board -> url : $board -> url_late ) . '">' ;
//$boxwork .= img_picto($textlate, "warning_white", 'class="valigntextbottom"').'';
2021-01-02 20:04:40 +01:00
$boxwork .= img_picto (
$textlate ,
" warning_white " ,
'class="inline-block hideonsmartphone valigntextbottom"'
) . '' ;
2020-09-07 10:18:17 +02:00
$boxwork .= '<span class="dashboardlineindicatorlate' . ( $board -> nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok' ) . '">' ;
$boxwork .= $board -> nbtodolate ;
$boxwork .= '</span>' ;
$boxwork .= '</a>' ;
$boxwork .= '</div>' ;
}
$boxwork .= '</div></div>' ;
$boxwork .= " \n " ;
}
$boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>' ;
$boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>' ;
$boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>' ;
$boxwork .= '<div class="boxstatsindicator thumbstat150 nobold nounderline"><div class="boxstats150empty"></div></div>' ;
$boxwork .= '</div>' ;
$boxwork .= '</td></tr>' ;
} else {
$boxwork .= '<tr class="nohover">' ;
$boxwork .= '<td class="nohover valignmiddle opacitymedium">' ;
$boxwork .= $langs -> trans ( " NoOpenedElementToProcess " );
$boxwork .= '</td>' ;
$boxwork .= '</tr>' ;
}
$boxwork .= '</td></tr>' ;
$boxwork .= '</table>' ; // End table array of working board
$boxwork .= '</div>' ;
if ( ! empty ( $isIntopOpenedDashBoard )) {
print '<div class="fichecenter">' ;
print '<div class="opened-dash-board-wrap"><div class="box-flex-container">' . $openedDashBoard . '</div></div>' ;
print '</div>' ;
}
2019-08-02 14:51:32 +02:00
}
2019-07-29 17:12:41 +02:00
2019-08-29 14:12:07 +02:00
2019-07-29 17:12:41 +02:00
print '<div class="clearboth"></div>' ;
2010-11-13 17:59:53 +01:00
2016-02-07 13:10:36 +01:00
print '<div class="fichecenter fichecenterbis">' ;
2010-11-13 17:59:53 +01:00
2002-04-29 19:53:37 +02:00
2003-02-13 17:58:48 +01:00
/*
2020-12-02 15:16:20 +01:00
* Show widgets ( boxes )
2003-02-13 17:58:48 +01:00
*/
2008-12-07 16:55:40 +01:00
2020-12-29 15:59:39 +01:00
$boxlist = '<div class="twocolumns">' ;
2016-02-07 13:10:36 +01:00
2020-02-02 19:34:09 +01:00
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">' ;
2021-01-02 20:04:40 +01:00
if ( ! empty ( $nbworkboardcount )) {
2020-02-02 19:34:09 +01:00
$boxlist .= $boxwork ;
2019-08-01 15:18:42 +02:00
}
2016-02-07 13:10:36 +01:00
2020-02-02 19:34:09 +01:00
$boxlist .= $resultboxes [ 'boxlista' ];
2016-02-07 13:10:36 +01:00
2020-02-02 19:34:09 +01:00
$boxlist .= '</div>' ;
2018-01-16 16:15:49 +01:00
2019-11-14 12:09:46 +01:00
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">' ;
2016-02-07 13:10:36 +01:00
2019-11-14 12:09:46 +01:00
$boxlist .= $resultboxes [ 'boxlistb' ];
2016-02-07 13:10:36 +01:00
2019-11-14 12:09:46 +01:00
$boxlist .= '</div>' ;
$boxlist .= " \n " ;
2016-02-07 13:10:36 +01:00
2019-11-14 12:09:46 +01:00
$boxlist .= '</div>' ;
2018-01-16 16:15:49 +01:00
2016-02-07 13:10:36 +01:00
print $boxlist ;
2005-02-27 17:45:59 +01:00
2011-08-18 00:13:26 +02:00
print '</div>' ;
2009-08-24 21:29:52 +02:00
2013-01-16 15:54:07 +01:00
//print 'mem='.memory_get_usage().' - '.memory_get_peak_usage();
2013-01-15 17:06:53 +01:00
2018-08-04 15:58:05 +02:00
// End of page
2011-12-12 01:39:55 +01:00
llxFooter ();
2003-02-13 17:58:48 +01:00
$db -> close ();
2002-04-29 19:53:37 +02:00
2010-11-13 17:59:53 +01:00
/**
* Show weather logo . Logo to show depends on $totallate and values for
2016-02-07 14:22:52 +01:00
* $conf -> global -> MAIN_METEO_LEVELx
2011-07-08 17:35:08 +02:00
*
* @ param int $totallate Nb of element late
* @ param string $text Text to show on logo
* @ param string $options More parameters on img tag
2019-02-20 06:01:13 +01:00
* @ param string $morecss More CSS
2011-07-08 17:35:08 +02:00
* @ return string Return img tag of weather
2010-11-13 17:59:53 +01:00
*/
2019-02-20 06:01:13 +01:00
function showWeather ( $totallate , $text , $options , $morecss = '' )
2010-11-13 17:59:53 +01:00
{
2020-09-07 10:18:17 +02:00
global $conf ;
2010-11-13 17:59:53 +01:00
2020-09-07 10:18:17 +02:00
$weather = getWeatherStatus ( $totallate );
return img_weather ( $text , $weather -> picto , $options , 0 , $morecss );
2019-08-02 12:22:26 +02:00
}
2017-06-01 01:53:55 +02:00
2017-10-26 13:09:11 +02:00
2019-08-02 12:22:26 +02:00
/**
* get weather level
* $conf -> global -> MAIN_METEO_LEVELx
*
* @ param int $totallate Nb of element late
2021-01-02 16:23:09 +01:00
* @ return stdClass Return img tag of weather
2019-08-02 12:22:26 +02:00
*/
function getWeatherStatus ( $totallate )
{
global $conf ;
$weather = new stdClass ();
$weather -> picto = '' ;
2019-11-14 12:09:46 +01:00
$offset = 0 ;
$factor = 10 ; // By default
2019-08-02 12:22:26 +02:00
2021-06-11 14:54:18 +02:00
$used_conf = empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? 'MAIN_METEO_LEVEL' : 'MAIN_METEO_PERCENTAGE_LEVEL' ;
2019-08-02 12:22:26 +02:00
2019-11-14 12:09:46 +01:00
$level0 = $offset ;
$weather -> level = 0 ;
if ( ! empty ( $conf -> global -> { $used_conf . '0' })) {
$level0 = $conf -> global -> { $used_conf . '0' };
2019-08-02 12:22:26 +02:00
}
2019-11-14 12:09:46 +01:00
$level1 = $offset + 1 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '1' })) {
$level1 = $conf -> global -> { $used_conf . '1' };
2019-08-02 12:22:26 +02:00
}
2019-11-14 12:09:46 +01:00
$level2 = $offset + 2 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '2' })) {
$level2 = $conf -> global -> { $used_conf . '2' };
2019-08-02 12:22:26 +02:00
}
2019-11-14 12:09:46 +01:00
$level3 = $offset + 3 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '3' })) {
$level3 = $conf -> global -> { $used_conf . '3' };
2019-08-02 12:22:26 +02:00
}
2019-11-14 12:09:46 +01:00
if ( $totallate <= $level0 ) {
2019-08-02 12:22:26 +02:00
$weather -> picto = 'weather-clear.png' ;
2019-11-14 12:09:46 +01:00
$weather -> level = 0 ;
2021-01-02 20:04:40 +01:00
} elseif ( $totallate <= $level1 ) {
2019-08-02 12:22:26 +02:00
$weather -> picto = 'weather-few-clouds.png' ;
2019-11-14 12:09:46 +01:00
$weather -> level = 1 ;
2021-01-02 20:04:40 +01:00
} elseif ( $totallate <= $level2 ) {
2019-08-02 12:22:26 +02:00
$weather -> picto = 'weather-clouds.png' ;
2019-11-14 12:09:46 +01:00
$weather -> level = 2 ;
2021-01-02 20:04:40 +01:00
} elseif ( $totallate <= $level3 ) {
2019-08-02 12:22:26 +02:00
$weather -> picto = 'weather-many-clouds.png' ;
2019-11-14 12:09:46 +01:00
$weather -> level = 3 ;
2021-01-02 20:04:40 +01:00
} else {
2019-08-02 12:22:26 +02:00
$weather -> picto = 'weather-storm.png' ;
2019-11-14 12:09:46 +01:00
$weather -> level = 4 ;
2019-08-02 12:22:26 +02:00
}
2010-11-13 17:59:53 +01:00
2019-08-02 12:22:26 +02:00
return $weather ;
2010-11-13 17:59:53 +01:00
}