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 >
2017-10-26 13:09:11 +02:00
* Copyright ( C ) 2004 - 2017 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 >
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
2019-01-27 11:55:16 +01:00
define ( 'NOCSRFCHECK' , 1 ); // This is main home and login page. We must be able to go on it from another web site.
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"
2017-05-10 00:44:54 +02:00
$_GET [ 'mainmenu' ] = GETPOST ( 'mainmenu' , 'aZ09' ) ? GETPOST ( 'mainmenu' , 'aZ09' ) : 'home' ;
2019-01-27 11:55:16 +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)
if ( ! isset ( $conf -> global -> MAIN_INFO_SOCIETE_NOM ) || empty ( $conf -> global -> MAIN_INFO_SOCIETE_NOM ))
{
2012-09-27 23:57:10 +02:00
header ( " Location: " . DOL_URL_ROOT . " /admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete " );
2011-02-19 18:21:29 +01:00
exit ;
}
2016-07-23 13:20:34 +02: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
{
header ( " Location: " . DOL_URL_ROOT . " /admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete " );
exit ;
}
2014-07-29 00:50:57 +02:00
if ( GETPOST ( 'addbox' )) // Add box (when submit is done from a form when ajax disabled)
{
require_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php' ;
2017-05-10 11:47:34 +02:00
$zone = GETPOST ( 'areacode' , 'aZ09' );
$userid = GETPOST ( 'userid' , 'int' );
$boxorder = GETPOST ( 'boxorder' , 'aZ09' );
$boxorder .= GETPOST ( 'boxcombo' , 'aZ09' );
2014-07-29 00:50:57 +02:00
2019-01-27 11:55:16 +01:00
$result = InfoBox :: saveboxorder ( $db , $zone , $boxorder , $userid );
2017-03-09 13:22:43 +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
2016-03-01 00:59:42 +01:00
if ( ! is_object ( $form )) $form = new Form ( $db );
2014-01-26 18:30:45 +01:00
// Title
$title = $langs -> trans ( " HomeArea " ) . ' - Dolibarr ' . DOL_VERSION ;
if ( ! empty ( $conf -> global -> MAIN_APPLICATION_TITLE )) $title = $langs -> trans ( " HomeArea " ) . ' - ' . $conf -> global -> MAIN_APPLICATION_TITLE ;
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-01-27 11:55:16 +01:00
$resultboxes = FormOther :: getBoxesArea ( $user , " 0 " ); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
2016-01-18 11:35:45 +01:00
2019-09-28 06:02:25 +02:00
print load_fiche_titre ( $langs -> trans ( " HomeArea " ), $resultboxes [ 'selectboxlist' ], 'home' );
2005-08-12 00:57:29 +02:00
2008-06-14 12:39:00 +02:00
if ( ! empty ( $conf -> global -> MAIN_MOTD ))
2004-07-26 16:38:34 +02:00
{
2019-01-27 11:55:16 +01:00
$conf -> global -> MAIN_MOTD = preg_replace ( '/<br(\s[\sa-zA-Z_="]*)?\/?>/i' , '<br>' , $conf -> global -> MAIN_MOTD );
2011-07-08 17:35:08 +02:00
if ( ! empty ( $conf -> global -> MAIN_MOTD ))
{
2017-06-01 01:53:55 +02:00
$substitutionarray = getCommonSubstitutionArray ( $langs );
complete_substitutions_array ( $substitutionarray , $langs );
$texttoshow = make_substitutions ( $conf -> global -> MAIN_MOTD , $substitutionarray , $langs );
2013-07-02 21:53:34 +02:00
2011-07-08 17:35:08 +02:00
print " \n <!-- Start of welcome text --> \n " ;
print '<table width="100%" class="notopnoleftnoright"><tr><td>' ;
2017-06-01 01:53:55 +02:00
print dol_htmlentitiesbr ( $texttoshow );
2011-07-08 17:35:08 +02:00
print '</td></tr></table><br>' ;
print " \n <!-- End of welcome text --> \n " ;
}
2004-07-26 16:38:34 +02:00
}
2005-08-12 00:57:29 +02:00
2019-07-29 17:12:41 +02:00
2005-08-12 00:57:29 +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
2019-10-31 20:46:31 +01:00
if ( empty ( $user -> socid ) && empty ( $conf -> global -> MAIN_DISABLE_GLOBAL_BOXSTATS ))
2005-08-12 23:45:18 +02:00
{
2013-01-19 14:32:37 +01:00
$object = new stdClass ();
2011-12-06 23:38:54 +01:00
$parameters = array ();
$action = '' ;
2019-01-27 11:55:16 +01:00
$reshook = $hookmanager -> executeHooks ( 'addStatisticLine' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2019-09-22 20:59:28 +02:00
$boxstatFromHook = $hookmanager -> resPrint ;
2017-06-01 01:53:55 +02:00
2013-07-19 15:29:40 +02:00
if ( empty ( $reshook ))
{
// Condition to be checked for each display line dashboard
$conditions = array (
2015-12-05 19:31:32 +01:00
$user -> rights -> user -> user -> lire ,
2016-01-14 12:49:23 +01:00
! empty ( $conf -> societe -> enabled ) && $user -> rights -> societe -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS_STATS ),
! empty ( $conf -> societe -> enabled ) && $user -> rights -> societe -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS_STATS ),
2013-07-19 15:29:40 +02:00
! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_SUPPLIERS_STATS ),
2016-04-23 13:06:46 +02:00
! empty ( $conf -> societe -> enabled ) && $user -> rights -> societe -> contact -> lire ,
2013-07-19 15:29:40 +02:00
! empty ( $conf -> adherent -> enabled ) && $user -> rights -> adherent -> lire ,
! empty ( $conf -> product -> enabled ) && $user -> rights -> produit -> lire ,
! empty ( $conf -> service -> enabled ) && $user -> rights -> service -> lire ,
! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> lire ,
! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire ,
! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire ,
2016-12-03 18:20:57 +01:00
! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire ,
2016-04-23 13:16:19 +02:00
! empty ( $conf -> ficheinter -> enabled ) && $user -> rights -> ficheinter -> lire ,
2016-01-14 13:30:27 +01:00
! empty ( $conf -> supplier_order -> enabled ) && $user -> rights -> fournisseur -> commande -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS ),
! empty ( $conf -> supplier_invoice -> enabled ) && $user -> rights -> fournisseur -> facture -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS ),
2016-03-04 16:08:51 +01:00
! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> lire && empty ( $conf -> global -> SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS ),
2017-01-26 18:08:00 +01:00
! empty ( $conf -> projet -> enabled ) && $user -> rights -> projet -> lire ,
2017-03-07 22:31:34 +01:00
! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> lire ,
2019-05-18 16:40:14 +02:00
! empty ( $conf -> holiday -> enabled ) && $user -> rights -> holiday -> read ,
2017-03-07 22:31:34 +01:00
! empty ( $conf -> don -> enabled ) && $user -> rights -> don -> lire
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Class file containing the method load_state_board for each line
2015-12-05 19:31:32 +01:00
$includes = array (
DOL_DOCUMENT_ROOT . " /user/class/user.class.php " ,
DOL_DOCUMENT_ROOT . " /societe/class/client.class.php " ,
DOL_DOCUMENT_ROOT . " /societe/class/client.class.php " ,
DOL_DOCUMENT_ROOT . " /fourn/class/fournisseur.class.php " ,
2016-04-23 13:06:46 +02:00
DOL_DOCUMENT_ROOT . " /contact/class/contact.class.php " ,
2015-12-05 19:31:32 +01:00
DOL_DOCUMENT_ROOT . " /adherents/class/adherent.class.php " ,
DOL_DOCUMENT_ROOT . " /product/class/product.class.php " ,
2017-06-06 07:57:03 +02:00
DOL_DOCUMENT_ROOT . " /product/class/product.class.php " ,
2015-12-05 19:31:32 +01:00
DOL_DOCUMENT_ROOT . " /comm/propal/class/propal.class.php " ,
DOL_DOCUMENT_ROOT . " /commande/class/commande.class.php " ,
DOL_DOCUMENT_ROOT . " /compta/facture/class/facture.class.php " ,
DOL_DOCUMENT_ROOT . " /contrat/class/contrat.class.php " ,
2016-04-23 13:16:19 +02:00
DOL_DOCUMENT_ROOT . " /fichinter/class/fichinter.class.php " ,
2015-12-05 19:31:32 +01:00
DOL_DOCUMENT_ROOT . " /fourn/class/fournisseur.commande.class.php " ,
DOL_DOCUMENT_ROOT . " /fourn/class/fournisseur.facture.class.php " ,
2016-03-04 16:08:51 +01:00
DOL_DOCUMENT_ROOT . " /supplier_proposal/class/supplier_proposal.class.php " ,
2017-06-01 01:53:55 +02:00
DOL_DOCUMENT_ROOT . " /projet/class/project.class.php " ,
2017-03-07 22:31:34 +01:00
DOL_DOCUMENT_ROOT . " /expensereport/class/expensereport.class.php " ,
2019-05-18 16:40:14 +02:00
DOL_DOCUMENT_ROOT . " /holiday/class/holiday.class.php " ,
2017-03-07 22:31:34 +01:00
DOL_DOCUMENT_ROOT . " /don/class/don.class.php "
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Name class containing the method load_state_board for each line
2015-12-05 19:31:32 +01:00
$classes = array ( 'User' ,
'Client' ,
2015-05-06 23:13:07 +02:00
'Client' ,
2013-07-19 15:29:40 +02:00
'Fournisseur' ,
2016-04-23 13:06:46 +02:00
'Contact' ,
2013-07-19 15:29:40 +02:00
'Adherent' ,
'Product' ,
2017-02-28 12:35:55 +01:00
'Product' ,
2014-10-25 17:22:03 +02:00
'Propal' ,
'Commande' ,
'Facture' ,
'Contrat' ,
2016-04-23 13:16:19 +02:00
'Fichinter' ,
2014-10-25 17:22:03 +02:00
'CommandeFournisseur' ,
2015-08-17 05:29:12 +02:00
'FactureFournisseur' ,
2016-03-04 16:08:51 +01:00
'SupplierProposal' ,
2017-01-26 18:08:00 +01:00
'Project' ,
2017-03-07 22:31:34 +01:00
'ExpenseReport' ,
2019-05-18 16:40:14 +02:00
'Holiday' ,
2017-03-07 22:31:34 +01:00
'Don'
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Cle array returned by the method load_state_board for each line
2015-12-05 19:31:32 +01:00
$keys = array ( 'users' ,
'customers' ,
2013-07-19 15:29:40 +02:00
'prospects' ,
'suppliers' ,
2016-04-23 13:06:46 +02:00
'contacts' ,
2013-07-19 15:29:40 +02:00
'members' ,
'products' ,
2019-05-18 16:40:14 +02:00
'services' ,
2014-10-25 17:22:03 +02:00
'proposals' ,
'orders' ,
'invoices' ,
'Contracts' ,
2016-04-23 13:16:19 +02:00
'fichinters' ,
2014-10-25 17:22:03 +02:00
'supplier_orders' ,
2015-08-17 05:29:12 +02:00
'supplier_invoices' ,
2016-03-04 16:08:51 +01:00
'askprice' ,
2017-01-26 18:08:00 +01:00
'projects' ,
2017-03-07 22:31:34 +01:00
'expensereports' ,
2019-10-13 08:20:37 +02:00
'holiday' ,
2017-03-07 22:31:34 +01:00
'donations'
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Dashboard Icon lines
2015-12-05 19:31:32 +01:00
$icons = array ( 'user' ,
'company' ,
2013-07-19 15:29:40 +02:00
'company' ,
'company' ,
2016-04-23 13:06:46 +02:00
'contact' ,
2013-07-19 15:29:40 +02:00
'user' ,
'product' ,
'service' ,
2014-10-25 17:22:03 +02:00
'propal' ,
'order' ,
'bill' ,
'order' ,
'order' ,
2016-04-23 13:16:19 +02:00
'order' ,
2015-08-17 05:29:12 +02:00
'bill' ,
2016-03-04 16:08:51 +01:00
'propal' ,
2017-03-21 13:39:42 +01:00
'projectpub' ,
2017-03-07 22:31:34 +01:00
'trip' ,
2019-05-18 16:40:14 +02:00
'holiday' ,
2017-03-07 22:31:34 +01:00
'generic'
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Translation keyword
2015-12-05 19:31:32 +01:00
$titres = array ( " Users " ,
" ThirdPartyCustomersStats " ,
2013-07-19 15:29:40 +02:00
" ThirdPartyProspectsStats " ,
" Suppliers " ,
2016-04-23 13:06:46 +02:00
" Contacts " ,
2013-07-19 15:29:40 +02:00
" Members " ,
" Products " ,
" Services " ,
2013-07-25 10:20:41 +02:00
" CommercialProposalsShort " ,
2013-07-19 15:29:40 +02:00
" CustomersOrders " ,
" BillsCustomers " ,
2014-10-25 17:22:03 +02:00
" Contracts " ,
2016-04-23 13:16:19 +02:00
" Interventions " ,
2014-10-25 17:22:03 +02:00
" SuppliersOrders " ,
2016-03-04 16:08:51 +01:00
" SuppliersInvoices " ,
" SupplierProposalShort " ,
2017-01-26 18:08:00 +01:00
" Projects " ,
2017-03-07 22:31:34 +01:00
" ExpenseReports " ,
2019-05-18 16:40:14 +02:00
" Holidays " ,
2017-03-07 22:31:34 +01:00
" Donations "
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Dashboard Link lines
2015-10-23 13:52:51 +02:00
$links = array (
2018-04-06 00:36:52 +02:00
DOL_URL_ROOT . '/user/list.php' ,
2017-10-16 20:16:30 +02:00
DOL_URL_ROOT . '/societe/list.php?type=c&mainmenu=companies' ,
DOL_URL_ROOT . '/societe/list.php?type=p&mainmenu=companies' ,
DOL_URL_ROOT . '/societe/list.php?type=f&mainmenu=companies' ,
DOL_URL_ROOT . '/contact/list.php?mainmenu=companies' ,
2015-12-05 19:31:32 +01:00
DOL_URL_ROOT . '/adherents/list.php?statut=1&mainmenu=members' ,
DOL_URL_ROOT . '/product/list.php?type=0&mainmenu=products' ,
DOL_URL_ROOT . '/product/list.php?type=1&mainmenu=products' ,
2017-10-16 20:20:55 +02:00
DOL_URL_ROOT . '/comm/propal/list.php?mainmenu=commercial&leftmenu=propals' ,
DOL_URL_ROOT . '/commande/list.php?mainmenu=commercial&leftmenu=orders' ,
2018-09-06 14:49:48 +02:00
DOL_URL_ROOT . '/compta/facture/list.php?mainmenu=billing&leftmenu=customers_bills' ,
2017-10-16 20:20:55 +02:00
DOL_URL_ROOT . '/contrat/list.php?mainmenu=commercial&leftmenu=contracts' ,
DOL_URL_ROOT . '/fichinter/list.php?mainmenu=commercial&leftmenu=ficheinter' ,
DOL_URL_ROOT . '/fourn/commande/list.php?mainmenu=commercial&leftmenu=orders_suppliers' ,
2018-09-06 14:49:48 +02:00
DOL_URL_ROOT . '/fourn/facture/list.php?mainmenu=billing&leftmenu=suppliers_bills' ,
2017-10-16 20:20:55 +02:00
DOL_URL_ROOT . '/supplier_proposal/list.php?mainmenu=commercial&leftmenu=' ,
2017-01-26 18:08:00 +01:00
DOL_URL_ROOT . '/projet/list.php?mainmenu=project' ,
2017-10-22 01:30:25 +02:00
DOL_URL_ROOT . '/expensereport/list.php?mainmenu=hrm&leftmenu=expensereport' ,
2019-05-18 16:40:14 +02:00
DOL_URL_ROOT . '/holiday/list.php?mainmenu=hrm&leftmenu=holiday' ,
2017-03-07 22:31:34 +01:00
DOL_URL_ROOT . '/don/list.php?leftmenu=donations'
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Translation lang files
2019-10-27 17:01:23 +01:00
$langfile = array (
" users " ,
" companies " ,
" prospects " ,
" suppliers " ,
" companies " ,
" members " ,
" products " ,
" products " ,
" propal " ,
" orders " ,
" bills " ,
" contracts " ,
" interventions " ,
" bills " ,
" bills " ,
" supplier_proposal " ,
" projects " ,
" trips " ,
" holiday " ,
" donations " ,
2016-02-28 00:19:12 +01:00
);
2013-07-19 15:29:40 +02:00
// Loop and displays each line of table
2019-08-02 12:22:26 +02:00
$boardloaded = array ();
2013-07-19 15:29:40 +02:00
foreach ( $keys as $key => $val )
{
if ( $conditions [ $key ])
{
2019-09-22 20:59:28 +02:00
$boxstatItem = '' ;
2013-07-19 15:29:40 +02:00
$classe = $classes [ $key ];
// Search in cache if load_state_board is already realized
if ( ! isset ( $boardloaded [ $classe ]) || ! is_object ( $boardloaded [ $classe ]))
{
include_once $includes [ $key ]; // Loading a class cost around 1Mb
$board = new $classe ( $db );
$board -> load_state_board ( $user );
$boardloaded [ $classe ] = $board ;
}
2017-06-01 01:53:55 +02:00
else
2017-02-28 12:35:55 +01:00
{
$board = $boardloaded [ $classe ];
}
2013-07-19 15:29:40 +02:00
2017-06-01 01:53:55 +02:00
2015-06-10 18:58:42 +02:00
if ( ! empty ( $langfile [ $key ])) $langs -> load ( $langfile [ $key ]);
2014-01-26 18:30:45 +01:00
$text = $langs -> trans ( $titres [ $key ]);
2019-09-22 20:59:28 +02:00
$boxstatItem .= '<a href="' . $links [ $key ] . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstatItem .= '<div class="boxstats">' ;
$boxstatItem .= '<span class="boxstatstext" title="' . dol_escape_htmltag ( $text ) . '">' . $text . '</span><br>' ;
$boxstatItem .= '<span class="boxstatsindicator">' . img_object ( " " , $icons [ $key ], 'class="inline-block"' ) . ' ' . ( $board -> nb [ $val ] ? $board -> nb [ $val ] : 0 ) . '</span>' ;
$boxstatItem .= '</div>' ;
$boxstatItem .= '</a>' ;
$boxstatItems [ $val ] = $boxstatItem ;
2013-07-19 15:29:40 +02:00
}
}
}
2005-08-12 23:45:18 +02:00
}
2019-07-29 17:12:41 +02:00
2005-08-12 00:57:29 +02:00
/*
2010-11-13 17:59:53 +01:00
* Dolibarr Working Board with weather
2005-08-12 00:57:29 +02:00
*/
2019-08-29 14:12:07 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_GLOBAL_WORKBOARD )) {
$showweather = ( empty ( $conf -> global -> MAIN_DISABLE_METEO ) || $conf -> global -> MAIN_DISABLE_METEO == 2 ) ? 1 : 0 ;
2015-02-15 15:01:28 +01:00
2019-10-27 17:01:23 +01:00
//Array that contains all WorkboardResponse classes to process them
2019-08-29 14:12:07 +02:00
$dashboardlines = array ();
2010-11-13 17:59:53 +01:00
2019-10-27 17:01:23 +01:00
// Do not include sections without management permission
2019-08-29 14:12:07 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php' ;
2015-02-15 15:01:28 +01:00
2019-10-27 17:01:23 +01:00
// Number of actions to do (late)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> agenda -> enabled ) && $user -> rights -> agenda -> myactions -> read ) {
include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
$board = new ActionComm ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2005-09-05 10:54:52 +02:00
2019-10-27 17:01:23 +01:00
// Number of project opened
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> projet -> enabled ) && $user -> rights -> projet -> lire ) {
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$board = new Project ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of tasks to do (late)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> projet -> enabled ) && empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && $user -> rights -> projet -> lire ) {
include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
$board = new Task ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2010-11-13 18:37:22 +01:00
2019-10-27 17:01:23 +01:00
// Number of commercial proposals opened (expired)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> lire ) {
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 " );
}
2016-03-04 16:08:51 +01:00
2019-10-27 17:01:23 +01:00
// Number of commercial proposals opened (expired)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> supplier_proposal -> enabled ) && $user -> rights -> supplier_proposal -> lire ) {
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 " );
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of customer orders a deal
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire ) {
include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
$board = new Commande ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2016-01-18 15:56:51 +01:00
2019-10-27 17:01:23 +01:00
// Number of suppliers orders a deal
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> supplier_order -> enabled ) && $user -> rights -> fournisseur -> commande -> lire ) {
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
$board = new CommandeFournisseur ( $db );
2019-09-10 22:10:20 +02:00
$dashboardlines [ $board -> element . '_opened' ] = $board -> load_board ( $user , " opened " );
$dashboardlines [ $board -> element . '_awaiting' ] = $board -> load_board ( $user , 'awaiting' );
2019-08-29 14:12:07 +02:00
}
2016-01-18 15:56:51 +01:00
2019-10-27 17:01:23 +01:00
// Number of services enabled (delayed)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire ) {
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 " );
}
2019-10-27 17:01:23 +01:00
// Number of invoices customers (has paid)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire ) {
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
$board = new Facture ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of supplier invoices (has paid)
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> supplier_invoice -> enabled ) && ! empty ( $user -> rights -> fournisseur -> facture -> lire )) {
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
$board = new FactureFournisseur ( $db );
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
2010-11-13 18:37:22 +01:00
2019-10-27 17:01:23 +01:00
// Number of transactions to conciliate
2019-10-31 20:46:31 +01:00
if ( ! empty ( $conf -> banque -> enabled ) && $user -> rights -> banque -> lire && ! $user -> socid ) {
2019-08-29 14:12:07 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
$board = new Account ( $db );
$nb = $board :: countAccountToReconcile (); // Get nb of account to reconciliate
if ( $nb > 0 ) {
$dashboardlines [ $board -> element ] = $board -> load_board ( $user );
}
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of cheque to send
2019-10-31 20:46:31 +01:00
if ( ! empty ( $conf -> banque -> enabled ) && $user -> rights -> banque -> lire && ! $user -> socid && empty ( $conf -> global -> BANK_DISABLE_CHECK_DEPOSIT )) {
2019-08-29 14:12:07 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php' ;
$board = new RemiseCheque ( $db );
$dashboardlines [ 'RemiseCheque' ] = $board -> load_board ( $user );
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of foundation members
2019-10-31 20:46:31 +01:00
if ( ! empty ( $conf -> adherent -> enabled ) && $user -> rights -> adherent -> lire && ! $user -> socid ) {
2019-08-29 14:12:07 +02:00
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
$board = new Adherent ( $db );
$dashboardlines [ 'Adherent' ] = $board -> load_board ( $user );
}
2005-08-12 00:57:29 +02:00
2019-10-27 17:01:23 +01:00
// Number of expense reports to approve
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> approve ) {
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
$dashboardlines [ 'ExpenseReport' ] = $board -> load_board ( $user , 'toapprove' );
}
2016-01-18 11:35:45 +01:00
2019-10-27 17:01:23 +01:00
// Number of expense reports to pay
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> to_paid ) {
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
$dashboardlines [ 'ExpenseReport' ] = $board -> load_board ( $user , 'topay' );
}
2015-08-17 05:29:12 +02:00
2019-10-27 17:01:23 +01:00
// Number of holidays to approve
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> holiday -> enabled ) && $user -> rights -> holiday -> approve ) {
include_once DOL_DOCUMENT_ROOT . '/holiday/class/holiday.class.php' ;
$board = new Holiday ( $db );
$dashboardlines [ 'Holiday' ] = $board -> load_board ( $user );
}
2019-05-18 16:40:14 +02:00
2019-08-29 14:12:07 +02:00
$object = new stdClass ();
$parameters = array ();
$action = '' ;
$reshook = $hookmanager -> executeHooks ( 'addOpenElementsDashboardLine' , $parameters , $object ,
$action ); // Note that $action and $object may have been modified by some hooks
if ( $reshook == 0 ) {
$dashboardlines = array_merge ( $dashboardlines , $hookmanager -> resArray );
}
2017-12-06 12:31:00 +01:00
2019-08-29 14:12:07 +02:00
/* grouping dashboard stats */
$dashboardgroup = array (
'action' =>
array (
'groupName' => 'Agenda' ,
'stats' => array ( 'action' ),
),
'project' =>
array (
'groupName' => 'Projects' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'projects' ,
2019-08-29 14:12:07 +02:00
'stats' => array ( 'project' , 'project_task' ),
),
'propal' =>
array (
'groupName' => 'Proposals' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'proposals' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'propal_opened' , 'propal_signed' ),
),
'commande' =>
array (
'groupName' => 'Orders' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'orders' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'commande' ),
),
'facture' =>
array (
'groupName' => 'Invoices' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'invoices' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'facture' ),
),
'contrat' =>
array (
'groupName' => 'Contracts' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'Contracts' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'contrat_inactive' , 'contrat_active' ),
),
'supplier_proposal' =>
array (
'groupName' => 'SupplierProposals' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'askprice' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'supplier_proposal_opened' , 'supplier_proposal_signed' ),
),
'order_supplier' =>
array (
'groupName' => 'SuppliersOrders' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'supplier_orders' ,
2019-08-29 14:12:07 +02:00
'stats' =>
2019-09-10 22:10:20 +02:00
array ( 'order_supplier_opened' , 'order_supplier_awaiting' ),
2019-08-29 14:12:07 +02:00
),
'invoice_supplier' =>
array (
'groupName' => 'BillsSuppliers' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'supplier_invoices' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'invoice_supplier' ),
),
'bank_account' =>
array (
'groupName' => 'BankAccount' ,
'stats' =>
array ( 'bank_account' , 'RemiseCheque' ),
),
'Adherent' =>
array (
'groupName' => 'Members' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'members' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'Adherent' ),
),
'ExpenseReport' =>
array (
'groupName' => 'ExpenseReport' ,
2019-09-22 11:57:33 +02:00
'globalStatsKey' => 'expensereports' ,
2019-08-29 14:12:07 +02:00
'stats' =>
array ( 'ExpenseReport' ),
),
'Holiday' =>
array (
'groupName' => 'Holidays' ,
2019-09-22 20:59:28 +02:00
'globalStatsKey' => 'holidays' ,
2019-08-29 14:12:07 +02:00
'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 );
}
2019-08-01 12:33:19 +02:00
2019-10-27 17:01:23 +01:00
// Calculate total nb of late
2019-08-29 14:12:07 +02:00
$totallate = $totaltodo = 0 ;
2015-02-15 15:01:28 +01:00
2019-10-27 17:01:23 +01:00
//Remove any invalid response
//load_board can return an integer if failed or WorkboardResponse if OK
2019-08-29 14:12:07 +02:00
$valid_dashboardlines = array ();
foreach ( $dashboardlines as $infoKey => $tmp ) {
if ( $tmp instanceof WorkboardResponse ) {
$valid_dashboardlines [ $infoKey ] = $tmp ;
}
}
2015-02-15 15:01:28 +01:00
2019-10-27 17:01:23 +01:00
// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
2019-08-29 14:12:07 +02:00
foreach ( $valid_dashboardlines as $board ) {
if ( $board -> nbtodolate > 0 ) {
$totaltodo += $board -> nbtodo ;
$totallate += $board -> nbtodolate ;
}
2015-02-15 15:01:28 +01:00
}
2019-08-02 12:22:26 +02:00
2019-08-29 14:12:07 +02:00
$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 ;
}
2019-08-13 15:54:32 +02:00
}
2019-08-29 14:12:07 +02:00
$totalLateNumber = $totallate ;
2019-09-03 17:50:09 +02:00
$totallatePercentage = (( ! empty ( $totaltodo )) ? round ( $totallate / $totaltodo * 100 , 2 ) : 0 );
2019-08-29 14:12:07 +02:00
if ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE )) {
$totallate = $totallatePercentage ;
}
2019-08-02 12:22:26 +02:00
2019-08-29 14:12:07 +02:00
$boxwork = '' ;
$boxwork .= '<div class="box">' ;
$boxwork .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " WorkingBoard " )) . '" class="noborder boxtable boxtablenobottom boxworkingboard" width="100%">' . " \n " ;
$boxwork .= '<tr class="liste_titre">' ;
$boxwork .= '<th class="liste_titre"><div class="inline-block valignmiddle">' . $langs -> trans ( " DolibarrWorkBoard " ) . '</div>' ;
if ( $showweather ) {
if ( $totallate > 0 ) {
$text = $langs -> transnoentitiesnoconv ( " WarningYouHaveAtLeastOneTaskLate " ) . ' (' . $langs -> transnoentitiesnoconv ( " NActionsLate " ,
$totallate . ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? '%' : '' )) . ')' ;
} 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 " ;
2017-03-03 16:55:22 +01:00
2019-10-27 17:01:23 +01:00
// Show dashboard
2019-08-29 14:12:07 +02:00
$nbworkboardempty = 0 ;
2019-09-22 13:46:11 +02:00
$isIntopOpenedDashBoard = $globalStatInTopOpenedDashBoard = array ();
2019-08-29 14:12:07 +02:00
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 ();
2019-10-08 16:31:40 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLE_NEW_OPENED_DASH_BOARD )) {
2019-08-29 14:12:07 +02:00
foreach ( $groupElement [ 'stats' ] as $infoKey ) {
if ( ! empty ( $valid_dashboardlines [ $infoKey ])) {
$boards [] = $valid_dashboardlines [ $infoKey ];
$isIntopOpenedDashBoard [] = $infoKey ;
}
}
}
if ( ! empty ( $boards )) {
$groupName = $langs -> trans ( $groupElement [ 'groupName' ]);
$groupKeyLowerCase = strtolower ( $groupKey );
2019-09-22 11:57:33 +02:00
$nbTotalForGroup = 0 ;
// global stats
$globalStatsKey = false ;
if ( ! empty ( $groupElement [ 'globalStatsKey' ]) && empty ( $groupElement [ 'globalStats' ])){ // can be filled by hook
$globalStatsKey = $groupElement [ 'globalStatsKey' ];
$groupElement [ 'globalStats' ] = array ();
if ( in_array ( $globalStatsKey , $keys ))
{
// get key index of stats used in $includes, $classes, $keys, $icons, $titres, $links
$keyIndex = array_search ( $globalStatsKey , $keys );
$classe = $classes [ $keyIndex ];
if ( isset ( $boardloaded [ $classe ]) && is_object ( $boardloaded [ $classe ]))
{
$groupElement [ 'globalStats' ][ 'total' ] = $boardloaded [ $classe ] -> nb [ $globalStatsKey ] ? $boardloaded [ $classe ] -> nb [ $globalStatsKey ] : 0 ;
$nbTotal = doubleval ( $groupElement [ 'globalStats' ][ 'total' ]);
2019-09-22 12:05:13 +02:00
if ( $nbTotal >= 10000 ){ $nbTotal = round ( $nbTotal / 1000 , 2 ) . 'k' ; }
2019-09-22 11:57:33 +02:00
$groupElement [ 'globalStats' ][ 'text' ] = $langs -> trans ( 'Total' ) . ' : ' . $langs -> trans ( $titres [ $keyIndex ]) . ' (' . $groupElement [ 'globalStats' ][ 'total' ] . ')' ;
$groupElement [ 'globalStats' ][ 'total' ] = $nbTotal ;
$groupElement [ 'globalStats' ][ 'link' ] = $links [ $keyIndex ];
}
}
}
2019-08-29 14:12:07 +02:00
2019-09-22 20:59:28 +02:00
$openedDashBoard .= '<div class="box-flex-item">' . " \n " ;
$openedDashBoard .= ' <div class="info-box ' . $openedDashBoardSize . '">' . " \n " ;
2019-09-22 11:57:33 +02:00
$openedDashBoard .= ' <span class="info-box-icon bg-infoxbox-' . $groupKeyLowerCase . '">' . " \n " ;
$openedDashBoard .= ' <i class="fa fa-dol-' . $groupKeyLowerCase . '"></i>' . " \n " ;
2019-08-29 14:12:07 +02:00
2019-09-22 11:57:33 +02:00
if ( ! empty ( $groupElement [ 'globalStats' ])){
2019-09-22 20:59:28 +02:00
$globalStatInTopOpenedDashBoard [] = $globalStatsKey ;
2019-09-22 11:57:33 +02:00
$openedDashBoard .= ' <span class="info-box-icon-text" title="' . $groupElement [ 'globalStats' ][ 'text' ] . '">' . $nbTotal . '</span>' . " \n " ;
}
$openedDashBoard .= ' </span>' . " \n " ;
2019-08-29 14:12:07 +02:00
$openedDashBoard .= ' <div class="info-box-content">' . " \n " ;
2019-09-22 11:57:33 +02:00
$openedDashBoard .= ' <span class="info-box-title" title="' . strip_tags ( $groupName ) . '">' . $groupName . '</span>' . " \n " ;
2019-08-29 14:12:07 +02:00
foreach ( $boards as $board ) {
if ( ! empty ( $board -> labelShort )) {
$infoName = '<span title="' . $board -> label . '">' . $board -> labelShort . '</span>' ;
} else {
$infoName = $board -> label ;
}
$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 " ) . ')' ;
$textLate = '' ;
if ( $board -> nbtodolate > 0 ) {
$textLate .= ' <span title="' . dol_htmlentities ( $textLateTitle ) . '" class="classfortooltip badge badge-danger">' ;
$textLate .= '<i class="fa fa-exclamation-triangle"></i> ' . $board -> nbtodolate ;
$textLate .= '</span>' ;
}
$nbtodClass = '' ;
if ( $board -> nbtodo > 0 ) {
$nbtodClass = 'badge badge-info' ;
}
$openedDashBoard .= ' <a href="' . $board -> url . '" class="info-box-text">' . $infoName . ' : <span class="' . $nbtodClass . ' classfortooltip" title="' . $board -> label . '" >' . $board -> nbtodo . '</span>' . $textLate . '</a>' . " \n " ;
if ( $board -> total > 0 && ! empty ( $conf -> global -> MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX )) {
$openedDashBoard .= '<a href="' . $board -> url . '" class="info-box-text">' . $langs -> trans ( 'Total' ) . ' : ' . price ( $board -> total ) . '</a>' ;
}
}
$openedDashBoard .= ' </div><!-- /.info-box-content -->' . " \n " ;
$openedDashBoard .= ' </div><!-- /.info-box -->' . " \n " ;
$openedDashBoard .= '</div><!-- /.box-flex-item -->' . " \n " ;
$openedDashBoard .= " \n " ;
}
}
2019-08-01 15:18:42 +02:00
2019-08-29 14:12:07 +02:00
if ( $showweather && ! empty ( $isIntopOpenedDashBoard )) {
$appendClass = $conf -> global -> MAIN_DISABLE_METEO == 2 ? ' hideonsmartphone' : '' ;
$weather = getWeatherStatus ( $totallate );
$text = '' ;
if ( $totallate > 0 ) {
$text = $langs -> transnoentitiesnoconv ( " WarningYouHaveAtLeastOneTaskLate " ) . ' (' . $langs -> transnoentitiesnoconv ( " NActionsLate " ,
$totallate . ( ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? '%' : '' )) . ')' ;
} else {
$text = $langs -> transnoentitiesnoconv ( " NoItemLate " );
}
$text .= '. ' . $langs -> transnoentitiesnoconv ( " LateDesc " );
$weatherDashBoard = '<div class="box-flex-item ' . $appendClass . '">' . " \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 " ;
$weatherDashBoard .= ' <span class="info-box-title">' . $langs -> trans ( 'GlobalOpenedElemView' ) . '</span>' . " \n " ;
if ( $totallatePercentage > 0 && ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE )) {
$weatherDashBoard .= ' <span class="info-box-number">' . $langs -> transnoentitiesnoconv ( " NActionsLate " ,
price ( $totallatePercentage ) . '%' ) . '</span>' . " \n " ;
$weatherDashBoard .= ' <span class="progress-description">' . $langs -> trans ( 'NActionsLate' ,
$totalLateNumber ) . '</span>' . " \n " ;
} else {
$weatherDashBoard .= ' <span class="info-box-number">' . $langs -> transnoentitiesnoconv ( " NActionsLate " ,
$totalLateNumber ) . '</span>' . " \n " ;
if ( $totallatePercentage > 0 ) {
$weatherDashBoard .= ' <span class="progress-description">' . $langs -> trans ( 'NActionsLate' ,
price ( $totallatePercentage ) . '%' ) . '</span>' . " \n " ;
}
}
$weatherDashBoard .= ' </div><!-- /.info-box-content -->' . " \n " ;
$weatherDashBoard .= ' </div><!-- /.info-box -->' . " \n " ;
$weatherDashBoard .= '</div><!-- /.box-flex-item -->' . " \n " ;
$weatherDashBoard .= " \n " ;
$openedDashBoard = $weatherDashBoard . $openedDashBoard ;
}
2017-03-23 19:26:28 +01:00
2019-08-29 14:12:07 +02:00
if ( ! empty ( $isIntopOpenedDashBoard )) {
for ( $i = 1 ; $i <= 10 ; $i ++ ) {
$openedDashBoard .= '<div class="box-flex-item filler"></div>' ;
}
}
2019-08-02 14:51:32 +02:00
2019-08-29 14:12:07 +02:00
$nbworkboardcount = 0 ;
foreach ( $valid_dashboardlines as $infoKey => $board ) {
if ( in_array ( $infoKey , $isIntopOpenedDashBoard )) {
// skip if info is present on top
continue ;
}
2019-08-02 14:51:32 +02:00
2019-08-29 14:12:07 +02:00
if ( empty ( $board -> nbtodo )) {
$nbworkboardempty ++ ;
}
$nbworkboardcount ++ ;
2019-08-02 14:51:32 +02:00
2019-08-29 14:12:07 +02:00
$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">' ;
$boxwork .= '<span class="boxstatstext" title="' . dol_escape_htmltag ( $board -> label ) . '">' . $board -> img . ' ' . $board -> label . '</span><br>' ;
$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>' ;
}
2017-03-23 19:26:28 +01:00
$boxwork .= '</div>' ;
2019-08-29 14:12:07 +02:00
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"').'';
$boxwork .= img_picto ( $textlate , " warning_white " ,
'class="inline-block hideonsmartphone valigntextbottom"' ) . '' ;
$boxwork .= '<span class="dashboardlineindicatorlate' . ( $board -> nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok' ) . '">' ;
$boxwork .= $board -> nbtodolate ;
$boxwork .= '</span>' ;
$boxwork .= '</a>' ;
$boxwork .= '</div>' ;
}
$boxwork .= '</div></div>' ;
$boxwork .= " \n " ;
2017-03-23 19:26:28 +01:00
}
2017-06-01 01:53:55 +02:00
2019-08-29 14:12:07 +02:00
$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>' ;
2019-02-03 14:29:45 +01:00
2019-08-29 14:12:07 +02:00
$boxwork .= '</div>' ;
$boxwork .= '</td></tr>' ;
} else {
$boxwork .= '<tr class="nohover">' ;
$boxwork .= '<td class="nohover valignmiddle opacitymedium">' ;
$boxwork .= $langs -> trans ( " NoOpenedElementToProcess " );
$boxwork .= '</td>' ;
$boxwork .= '</tr>' ;
}
2008-03-31 00:25:39 +02:00
2019-08-29 14:12:07 +02:00
$boxwork .= '</td></tr>' ;
2017-03-23 19:26:28 +01:00
2019-08-29 14:12:07 +02:00
$boxwork .= '</table>' ; // End table array of working board
$boxwork .= '</div>' ;
2016-02-07 13:10:36 +01:00
2019-08-29 14:12:07 +02:00
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
/*
2008-12-07 16:55:40 +01:00
* Show boxes
2003-02-13 17:58:48 +01:00
*/
2008-12-07 16:55:40 +01:00
2018-01-16 16:15:49 +01:00
$boxlist .= '<div class="twocolumns">' ;
2016-02-07 13:10:36 +01:00
2018-02-08 15:11:05 +01:00
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">' ;
2019-08-01 15:18:42 +02:00
if ( ! empty ( $nbworkboardcount ))
{
$boxlist .= $boxwork ;
}
2016-02-07 13:10:36 +01:00
$boxlist .= $resultboxes [ 'boxlista' ];
2018-01-16 16:15:49 +01:00
$boxlist .= '</div>' ;
2019-09-22 20:59:28 +02:00
2019-10-31 20:46:31 +01:00
if ( empty ( $user -> socid ) && empty ( $conf -> global -> MAIN_DISABLE_GLOBAL_BOXSTATS ))
2019-09-22 20:59:28 +02:00
{
// Remove allready present info in new dash board
if ( ! empty ( $conf -> global -> MAIN_INCLUDE_GLOBAL_STATS_IN_OPENED_DASHBOARD ) && is_array ( $boxstatItems ) && count ( $boxstatItems ) > 0 ){
2019-09-22 21:09:02 +02:00
foreach ( $boxstatItems as $boxstatItemKey => $boxstatItemHtml ) {
2019-09-22 20:59:28 +02:00
if ( in_array ( $boxstatItemKey , $globalStatInTopOpenedDashBoard )) {
unset ( $boxstatItems [ $boxstatItemKey ]);
}
}
}
if ( ! empty ( $boxstatFromHook ) || ! empty ( $boxstatItems )){
$boxstat .= '<div class="box">' ;
$boxstat .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " DolibarrStateBoard " )) . '" class="noborder boxtable boxtablenobottom nohover" width="100%">' ;
$boxstat .= '<tr class="liste_titre">' ;
$boxstat .= '<th class="liste_titre">' ;
$boxstat .= '<div class="inline-block valignmiddle">' . $langs -> trans ( " DolibarrStateBoard " ) . '</div>' ;
$boxstat .= '</th>' ;
$boxstat .= '</tr>' ;
$boxstat .= '<tr class="nobottom nohover"><td class="tdboxstats nohover flexcontainer">' ;
$boxstat .= $boxstatFromHook ;
if ( is_array ( $boxstatItems ) && count ( $boxstatItems ) > 0 )
{
$boxstat .= implode ( '' , $boxstatItems );
}
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '<a class="boxstatsindicator thumbstat nobold nounderline"><div class="boxstatsempty"></div></a>' ;
$boxstat .= '</td></tr>' ;
$boxstat .= '</table>' ;
$boxstat .= '</div>' ;
}
}
2018-02-08 15:11:05 +01:00
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">' ;
2016-02-07 13:10:36 +01:00
2018-01-17 13:55:53 +01:00
$boxlist .= $boxstat ;
2016-02-07 13:10:36 +01:00
$boxlist .= $resultboxes [ 'boxlistb' ];
2018-01-16 16:15:49 +01:00
$boxlist .= '</div>' ;
2016-02-07 13:10:36 +01:00
$boxlist .= " \n " ;
2018-01-16 16:15:49 +01:00
$boxlist .= '</div>' ;
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
2016-02-07 13:10:36 +01:00
2009-08-24 21:29:52 +02:00
/*
* Show security warnings
*/
// Security warning repertoire install existe (si utilisateur admin)
if ( $user -> admin && empty ( $conf -> global -> MAIN_REMOVE_INSTALL_WARNING ))
{
2011-07-08 17:35:08 +02:00
$message = '' ;
2011-08-04 14:07:29 +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 " ))
2011-07-08 17:35:08 +02:00
{
2011-10-29 23:52:05 +02:00
$langs -> load ( " errors " );
2011-07-08 17:35:08 +02:00
//if (! empty($message)) $message.='<br>';
2019-01-27 11:55:16 +01:00
$message .= info_admin ( $langs -> trans ( " WarningLockFileDoesNotExists " , DOL_DATA_ROOT ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ), 0 , 0 , '1' , 'clearboth' );
2011-07-08 17:35:08 +02:00
}
// Conf files must be in read only mode
2011-07-30 12:23:24 +02:00
if ( is_writable ( $conffile ))
2011-07-08 17:35:08 +02:00
{
$langs -> load ( " errors " );
2011-10-29 23:52:05 +02:00
//$langs->load("other");
2011-07-08 17:35:08 +02:00
//if (! empty($message)) $message.='<br>';
2018-01-26 23:29:49 +01:00
$message .= info_admin ( $langs -> transnoentities ( " WarningConfFileMustBeReadOnly " ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ), 0 , 0 , '1' , 'clearboth' );
2011-07-08 17:35:08 +02:00
}
if ( $message )
{
print $message ;
//$message.='<br>';
//print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
}
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
{
global $conf ;
2019-10-27 17:01:23 +01:00
$weather = getWeatherStatus ( $totallate );
2019-08-02 12:22:26 +02:00
return img_weather ( $text , $weather -> picto , $options , 0 , $morecss );
}
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
* @ return string Return img tag of weather
*/
function getWeatherStatus ( $totallate )
{
global $conf ;
$weather = new stdClass ();
$weather -> picto = '' ;
$offset = 0 ;
$factor = 10 ; // By default
$used_conf = ! empty ( $conf -> global -> MAIN_USE_METEO_WITH_PERCENTAGE ) ? 'MAIN_METEO_PERCENTAGE_LEVEL' : 'MAIN_METEO_LEVEL' ;
$level0 = $offset ;
$weather -> level = 0 ;
if ( ! empty ( $conf -> global -> { $used_conf . '0' })) {
$level0 = $conf -> global -> { $used_conf . '0' };
}
$level1 = $offset + 1 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '1' })) {
$level1 = $conf -> global -> { $used_conf . '1' };
}
$level2 = $offset + 2 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '2' })) {
$level2 = $conf -> global -> { $used_conf . '2' };
}
$level3 = $offset + 3 * $factor ;
if ( ! empty ( $conf -> global -> { $used_conf . '3' })) {
$level3 = $conf -> global -> { $used_conf . '3' };
}
if ( $totallate <= $level0 ){
$weather -> picto = 'weather-clear.png' ;
$weather -> level = 0 ;
}
elseif ( $totallate <= $level1 ){
$weather -> picto = 'weather-few-clouds.png' ;
$weather -> level = 1 ;
}
elseif ( $totallate <= $level2 ){
$weather -> picto = 'weather-clouds.png' ;
$weather -> level = 2 ;
}
elseif ( $totallate <= $level3 ){
$weather -> picto = 'weather-many-clouds.png' ;
$weather -> level = 3 ;
}
else {
$weather -> picto = 'weather-storm.png' ;
$weather -> level = 4 ;
}
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
}