2004-10-20 23:06:45 +02:00
< ? php
2015-03-31 17:22:14 +02:00
/* Copyright ( C ) 2001 - 2004 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-12-05 19:31:32 +01:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-06-10 18:58:42 +02:00
* Copyright ( C ) 2005 - 2015 Regis Houssin < regis . houssin @ capnetworks . com >
2015-03-31 17:22:14 +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
2011-08-01 01:19:04 +02:00
* along with this program . If not , see < http :// 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
2009-05-16 09:01:34 +02:00
define ( 'NOCSRFCHECK' , 1 ); // This is 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"
2012-10-20 09:33:39 +02:00
$_GET [ 'mainmenu' ] = GETPOST ( 'mainmenu' , 'alpha' ) ? GETPOST ( 'mainmenu' , 'alpha' ) : 'home' ;
2012-03-19 14:06:21 +01:00
$action = GETPOST ( 'action' );
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
2016-01-18 15:56:51 +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 ;
}
2006-11-01 16:15:14 +01:00
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' ;
$zone = GETPOST ( 'areacode' );
$userid = GETPOST ( 'userid' );
$boxorder = GETPOST ( 'boxorder' );
$boxorder .= GETPOST ( 'boxcombo' );
$result = InfoBox :: saveboxorder ( $db , $zone , $boxorder , $userid );
}
2006-11-01 16:15:14 +01:00
2010-02-28 05:32:18 +01:00
2015-03-31 17:23:07 +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 ;
llxHeader ( '' , $title );
2003-02-11 14:24:02 +01:00
2016-01-18 11:35:45 +01:00
2016-02-07 13:10:36 +01:00
$resultboxes = FormOther :: getBoxesArea ( $user , " 0 " );
2016-01-18 11:35:45 +01:00
print load_fiche_titre ( $langs -> trans ( " HomeArea " ), $resultboxes [ 'selectboxlist' ], 'title_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
{
2011-07-08 17:35:08 +02:00
$conf -> global -> MAIN_MOTD = preg_replace ( '/<br(\s[\sa-zA-Z_="]*)?\/?>/i' , '<br>' , $conf -> global -> MAIN_MOTD );
if ( ! empty ( $conf -> global -> MAIN_MOTD ))
{
2013-07-07 13:17:48 +02:00
$i = 0 ;
while ( preg_match ( '/__\(([a-zA-Z|@]+)\)__/i' , $conf -> global -> MAIN_MOTD , $reg ) && $i < 100 )
{
$tmp = explode ( '|' , $reg [ 1 ]);
if ( ! empty ( $tmp [ 1 ])) $langs -> load ( $tmp [ 1 ]);
$conf -> global -> MAIN_MOTD = preg_replace ( '/__\(' . preg_quote ( $reg [ 1 ]) . '\)__/i' , $langs -> trans ( $tmp [ 0 ]), $conf -> global -> MAIN_MOTD );
$i ++ ;
}
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>' ;
print dol_htmlentitiesbr ( $conf -> global -> MAIN_MOTD );
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
2011-08-18 00:13:26 +02:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2005-08-12 00:57:29 +02:00
/*
2008-12-07 16:55:40 +01:00
* Informations area
2005-08-12 00:57:29 +02:00
*/
2016-02-07 13:10:36 +01:00
$boxinfo = '' ;
$boxinfo .= '<div class="box">' ;
$boxinfo .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " LoginInformation " )) . '" class="noborder boxtable" width="100%">' ;
$boxinfo .= '<tr class="liste_titre"><th class="liste_titre" colspan="2">' . $langs -> trans ( " Informations " ) . '</th></tr>' ;
$boxinfo .= '<tr ' . $bc [ false ] . '>' ;
$boxinfo .= '<td class="nowrap">' . $langs -> trans ( " User " ) . '</td><td>' . $user -> getNomUrl ( 0 ) . '</td></tr>' ;
$boxinfo .= '<tr ' . $bc [ true ] . '>' ;
$boxinfo .= '<td class="nowrap">' . $langs -> trans ( " PreviousConnexion " ) . '</td><td>' ;
if ( $user -> datepreviouslogin ) $boxinfo .= dol_print_date ( $user -> datepreviouslogin , " dayhour " , 'tzuser' );
else $boxinfo .= $langs -> trans ( " Unknown " );
$boxinfo .= '</td>' ;
$boxinfo .= " </tr> \n " ;
$boxinfo .= " </table> \n " ;
$boxinfo .= '</div>' ;
2016-02-07 14:22:52 +01:00
//print $boxinfo;
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
*/
2016-02-07 13:10:36 +01:00
$boxstat = '' ;
2005-12-02 14:33:20 +01:00
$langs -> load ( " commercial " );
2007-07-08 18:30:51 +02:00
$langs -> load ( " bills " );
2010-12-01 22:28:08 +01:00
$langs -> load ( " orders " );
2013-07-03 16:49:54 +02:00
$langs -> load ( " contracts " );
2010-12-01 22:28:08 +01:00
2013-07-19 15:29:40 +02:00
if ( empty ( $user -> societe_id ))
2005-08-12 23:45:18 +02:00
{
2016-02-07 13:10:36 +01:00
$boxstat .= '<div class="box">' ;
$boxstat .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " DolibarrStateBoard " )) . '" class="noborder boxtable" width="100%">' ;
$boxstat .= '<tr class="liste_titre">' ;
$boxstat .= '<th class="liste_titre">' . $langs -> trans ( " DolibarrStateBoard " ) . '</th>' ;
$boxstat .= '</tr>' ;
$boxstat .= '<tr class="impair"><td class="tdboxstats nohover">' ;
2011-07-08 17:35:08 +02:00
$var = true ;
2013-01-19 14:32:37 +01:00
$object = new stdClass ();
2011-12-06 23:38:54 +01:00
$parameters = array ();
$action = '' ;
$reshook = $hookmanager -> executeHooks ( 'addStatisticLine' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2016-03-25 17:15:08 +01:00
$boxstat .= $hookmanager -> resPrint ;
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 ),
! 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 ,
2014-10-25 17:22:03 +02:00
! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> activer ,
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 ),
2016-02-28 00:19:12 +01:00
! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> lire ,
! empty ( $conf -> projet -> enabled ) && $user -> rights -> projet -> lire
);
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 " ,
DOL_DOCUMENT_ROOT . " /adherents/class/adherent.class.php " ,
DOL_DOCUMENT_ROOT . " /product/class/product.class.php " ,
DOL_DOCUMENT_ROOT . " /product/class/service.class.php " ,
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 " ,
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 " ,
2016-02-28 00:19:12 +01:00
DOL_DOCUMENT_ROOT . " /expensereport/class/expensereport.class.php " ,
DOL_DOCUMENT_ROOT . " /projet/class/project.class.php "
);
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' ,
'Adherent' ,
'Product' ,
'Service' ,
2014-10-25 17:22:03 +02:00
'Propal' ,
'Commande' ,
'Facture' ,
'Contrat' ,
'CommandeFournisseur' ,
2015-08-17 05:29:12 +02:00
'FactureFournisseur' ,
2016-03-04 16:08:51 +01:00
'SupplierProposal' ,
'ExpenseReport' ,
2016-02-28 00:19:12 +01:00
'Project'
);
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' ,
'members' ,
'products' ,
'services' ,
2014-10-25 17:22:03 +02:00
'proposals' ,
'orders' ,
'invoices' ,
'Contracts' ,
'supplier_orders' ,
2015-08-17 05:29:12 +02:00
'supplier_invoices' ,
2016-03-04 16:08:51 +01:00
'askprice' ,
'expensereports' ,
2016-02-28 00:19:12 +01:00
'projects'
);
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' ,
'user' ,
'product' ,
'service' ,
2014-10-25 17:22:03 +02:00
'propal' ,
'order' ,
'bill' ,
'order' ,
'order' ,
2015-08-17 05:29:12 +02:00
'bill' ,
2016-03-04 16:08:51 +01:00
'propal' ,
2016-02-28 00:19:12 +01:00
'trip' ,
'project'
);
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 " ,
" 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 " ,
" SuppliersOrders " ,
2016-03-04 16:08:51 +01:00
" SuppliersInvoices " ,
" SupplierProposalShort " ,
2016-02-28 00:19:12 +01:00
" ExpenseReports " ,
" Projects "
);
2013-07-19 15:29:40 +02:00
// Dashboard Link lines
2015-10-23 13:52:51 +02:00
$links = array (
2015-12-05 19:38:45 +01:00
DOL_URL_ROOT . '/user/index.php' ,
2015-12-05 19:31:32 +01:00
DOL_URL_ROOT . '/societe/list.php?type=c' ,
DOL_URL_ROOT . '/societe/list.php?type=p' ,
DOL_URL_ROOT . '/societe/list.php?type=f' ,
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' ,
DOL_URL_ROOT . '/comm/propal/list.php?mainmenu=commercial' ,
DOL_URL_ROOT . '/commande/list.php?mainmenu=commercial' ,
DOL_URL_ROOT . '/compta/facture/list.php?mainmenu=accountancy' ,
DOL_URL_ROOT . '/contrat/list.php' ,
DOL_URL_ROOT . '/fourn/commande/list.php' ,
2016-03-04 16:08:51 +01:00
DOL_URL_ROOT . '/fourn/facture/list.php' ,
DOL_URL_ROOT . '/supplier_proposal/list.php' ,
2016-02-28 00:19:12 +01:00
DOL_URL_ROOT . '/expensereport/list.php?mainmenu=hrm' ,
DOL_URL_ROOT . '/projet/list.php?mainmenu=project'
);
2013-07-19 15:29:40 +02:00
// Translation lang files
2015-12-05 19:31:32 +01:00
$langfile = array ( " users " ,
" companies " ,
2013-07-19 15:29:40 +02:00
" prospects " ,
" suppliers " ,
" members " ,
" products " ,
" produts " ,
" propal " ,
" orders " ,
2016-03-04 16:08:51 +01:00
" bills " ,
" supplier_proposal " ,
2015-08-17 05:29:12 +02:00
" contracts " ,
2016-02-28 00:19:12 +01:00
" trips " ,
" projects "
);
2013-07-19 15:29:40 +02:00
// Loop and displays each line of table
foreach ( $keys as $key => $val )
{
if ( $conditions [ $key ])
{
$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 ;
}
else $board = $boardloaded [ $classe ];
$var =! $var ;
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 ]);
2016-02-07 13:10:36 +01:00
$boxstat .= '<a href="' . $links [ $key ] . '" class="boxstatsindicator thumbstat nobold nounderline">' ;
$boxstat .= '<div class="boxstats">' ;
$boxstat .= '<span class="boxstatstext">' . img_object ( " " , $icons [ $key ]) . ' ' . $text . '</span><br>' ;
$boxstat .= '<span class="boxstatsindicator">' . $board -> nb [ $val ] . '</span>' ;
$boxstat .= '</div>' ;
$boxstat .= '</a>' ;
2013-07-19 15:29:40 +02:00
}
}
}
2016-02-07 13:10:36 +01:00
$boxstat .= '</td></tr>' ;
$boxstat .= '</table>' ;
$boxstat .= '</div>' ;
2005-08-12 23:45:18 +02:00
}
2016-02-07 14:22:52 +01:00
//print $boxstat;
2005-08-12 23:45:18 +02:00
2011-08-18 00:13:26 +02:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">' ;
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
*/
2010-12-01 22:28:08 +01:00
$showweather = empty ( $conf -> global -> MAIN_DISABLE_METEO ) ? 1 : 0 ;
2015-02-15 15:01:28 +01:00
2015-02-16 23:49:07 +01:00
//Array that contains all WorkboardResponse classes to process them
2010-11-13 17:59:53 +01:00
$dashboardlines = array ();
2016-02-07 13:10:36 +01:00
$boxwork = '' ;
2016-02-07 14:22:52 +01:00
$boxwork .= '<div class="box">' ;
2016-02-07 13:10:36 +01:00
$boxwork .= '<table summary="' . dol_escape_htmltag ( $langs -> trans ( " WorkingBoard " )) . '" class="noborder boxtable" width="100%">' . " \n " ;
$boxwork .= '<tr class="liste_titre">' ;
$boxwork .= '<th class="liste_titre" colspan="2">' . $langs -> trans ( " DolibarrWorkBoard " ) . '</th>' ;
$boxwork .= '<th class="liste_titre" align="right">' . $langs -> trans ( " Number " ) . '</th>' ;
2016-03-25 15:24:57 +01:00
$boxwork .= '<th class="liste_titre" align="right">' . $form -> textwithpicto ( $langs -> trans ( " Late " ), $langs -> trans ( " LateDesc " )) . '</th>' ;
2016-02-07 13:10:36 +01:00
$boxwork .= '<th class="liste_titre"> </th>' ;
2016-01-18 12:57:24 +01:00
//print '<th class="liste_titre" width="20"> </th>';
2016-02-07 13:10:36 +01:00
if ( $showweather ) $boxwork .= '<th class="liste_titre hideonsmartphone" width="80"> </th>' ;
$boxwork .= '</tr>' . " \n " ;
2007-10-05 20:37:34 +02:00
2010-02-16 23:26:44 +01:00
// Do not include sections without management permission
2015-03-10 14:17:58 +01:00
require DOL_DOCUMENT_ROOT . '/core/class/workboardresponse.class.php' ;
2015-02-15 15:01:28 +01:00
2010-11-13 17:59:53 +01:00
// Number of actions to do (late)
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> agenda -> enabled ) && $user -> rights -> agenda -> myactions -> read )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new ActionComm ( $db );
2015-02-23 14:59:24 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2007-10-05 20:37:34 +02:00
}
2005-09-05 10:54:52 +02:00
2016-01-18 15:56:51 +01:00
// Number of project opened
if ( ! empty ( $conf -> projet -> enabled ) && $user -> rights -> projet -> lire )
2005-08-12 00:57:29 +02:00
{
2016-01-18 15:56:51 +01:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
$board = new Project ( $db );
2015-02-15 15:01:28 +01:00
2016-01-18 15:56:51 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2007-10-05 20:37:34 +02:00
}
2005-08-12 00:57:29 +02:00
2016-01-18 15:56:51 +01:00
// Number of tasks to do (late)
if ( ! empty ( $conf -> projet -> enabled ) && empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && $user -> rights -> projet -> lire )
2010-11-13 18:37:22 +01:00
{
2016-01-18 15:56:51 +01:00
include_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
$board = new Task ( $db );
$dashboardlines [] = $board -> load_board ( $user );
2010-11-13 18:37:22 +01:00
}
2010-11-13 17:59:53 +01:00
// Number of commercial proposals opened (expired)
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> propal -> enabled ) && $user -> rights -> propale -> lire )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new Propal ( $db );
2016-03-04 16:08:51 +01:00
$dashboardlines [] = $board -> load_board ( $user , " opened " );
// Number of commercial proposals CLOSED signed (billed)
$dashboardlines [] = $board -> load_board ( $user , " signed " );
}
// Number of commercial proposals opened (expired)
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 -> load_board ( $user , " opened " );
// Number of commercial proposals CLOSED signed (billed)
$dashboardlines [] = $board -> load_board ( $user , " signed " );
2007-10-05 20:37:34 +02:00
}
2005-08-12 00:57:29 +02:00
2016-01-18 15:56:51 +01:00
// Number of customer orders a deal
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 -> load_board ( $user );
}
// Number of suppliers orders a deal
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 );
$dashboardlines [] = $board -> load_board ( $user );
}
2010-11-13 17:59:53 +01:00
// Number of services enabled (delayed)
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> contrat -> enabled ) && $user -> rights -> contrat -> lire )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new Contrat ( $db );
2015-02-15 15:01:28 +01:00
$dashboardlines [] = $board -> load_board ( $user , " inactives " );
// Number of active services (expired)
$dashboardlines [] = $board -> load_board ( $user , " expired " );
2007-10-05 20:37:34 +02:00
}
2010-11-13 17:59:53 +01:00
// Number of invoices customers (has paid)
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new Facture ( $db );
2015-02-15 15:01:28 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2007-10-05 20:37:34 +02:00
}
2005-08-12 00:57:29 +02:00
2010-11-13 18:37:22 +01:00
// Number of supplier invoices (has paid)
2016-01-14 13:30:27 +01:00
if ( ! empty ( $conf -> supplier_invoice -> enabled ) && ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2010-11-13 18:37:22 +01:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
2010-11-13 18:37:22 +01:00
$board = new FactureFournisseur ( $db );
2015-02-15 15:01:28 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2010-11-13 18:37:22 +01:00
}
2010-11-13 17:59:53 +01:00
// Number of transactions to conciliate
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> banque -> enabled ) && $user -> rights -> banque -> lire && ! $user -> societe_id )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/bank/class/account.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new Account ( $db );
2016-03-06 12:39:59 +01:00
$nb = $board :: countAccountToReconcile ();
if ( $nb > 0 )
{
$dashboardlines [] = $board -> load_board ( $user );
}
2007-10-05 20:37:34 +02:00
}
2005-08-12 00:57:29 +02:00
2010-11-13 17:59:53 +01:00
// Number of cheque to send
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> banque -> enabled ) && $user -> rights -> banque -> lire && ! $user -> societe_id )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/cheque/class/remisecheque.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new RemiseCheque ( $db );
2015-02-15 15:01:28 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2007-10-05 20:37:34 +02:00
}
2005-08-12 00:57:29 +02:00
2010-11-13 17:59:53 +01:00
// Number of foundation members
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> adherent -> enabled ) && $user -> rights -> adherent -> lire && ! $user -> societe_id )
2007-10-05 20:37:34 +02:00
{
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php' ;
2011-07-08 17:35:08 +02:00
$board = new Adherent ( $db );
2015-02-15 15:01:28 +01:00
$dashboardlines [] = $board -> load_board ( $user );
2005-09-13 11:29:50 +02:00
}
2005-08-12 00:57:29 +02:00
2016-01-18 11:35:45 +01:00
// Number of expense reports to approve
if ( ! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> approve )
{
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
$dashboardlines [] = $board -> load_board ( $user , 'toapprove' );
}
2015-08-17 05:29:12 +02:00
// Number of expense reports to pay
2016-01-18 11:35:45 +01:00
if ( ! empty ( $conf -> expensereport -> enabled ) && $user -> rights -> expensereport -> to_paid )
2015-08-17 05:29:12 +02:00
{
include_once DOL_DOCUMENT_ROOT . '/expensereport/class/expensereport.class.php' ;
$board = new ExpenseReport ( $db );
2016-01-18 11:35:45 +01:00
$dashboardlines [] = $board -> load_board ( $user , 'topay' );
2015-08-17 05:29:12 +02:00
}
2010-11-13 17:59:53 +01:00
// Calculate total nb of late
$totallate = 0 ;
$var = true ;
2015-02-15 15:01:28 +01:00
2015-02-15 15:10:51 +01:00
//Remove any invalid response
2015-02-16 23:49:07 +01:00
//load_board can return an integer if failed or WorkboardResponse if OK
2015-03-20 15:19:42 +01:00
$valid_dashboardlines = array ();
foreach ( $dashboardlines as $tmp )
{
if ( $tmp instanceof WorkboardResponse ) $valid_dashboardlines [] = $tmp ;
}
2015-02-15 15:01:28 +01:00
$rowspan = count ( $valid_dashboardlines );
2015-11-21 00:43:35 +01:00
// We calculate $totallate. Must be defined before start of next loop because it is show in first fetch on next loop
2015-02-15 15:01:28 +01:00
foreach ( $valid_dashboardlines as $board )
2008-03-31 00:25:39 +02:00
{
2015-02-15 15:01:28 +01:00
if ( $board -> nbtodolate > 0 ) {
$totallate += $board -> nbtodolate ;
}
2015-11-21 00:43:35 +01:00
}
2015-02-15 15:01:28 +01:00
2015-11-21 00:43:35 +01:00
// Show dashboard
foreach ( $valid_dashboardlines as $board )
{
2010-11-13 17:59:53 +01:00
$var =! $var ;
2016-02-07 13:10:36 +01:00
$boxwork .= '<tr ' . $bc [ $var ] . '><td width="16">' . $board -> img . '</td><td>' . $board -> label . '</td>' ;
$boxwork .= '<td align="right"><a class="dashboardlineindicator" href="' . $board -> url . '"><span class="dashboardlineindicator">' . $board -> nbtodo . '</span></a></td>' ;
$boxwork .= '<td align="right">' ;
2015-12-14 21:38:04 +01:00
//if ($board->nbtodolate > 0)
//{
2016-01-18 12:57:24 +01:00
$textlate = $langs -> trans ( " Late " ) . ' = ' . $langs -> trans ( " DateReference " ) . ' > ' . $langs -> trans ( " DateToday " ) . ' ' . ( ceil ( $board -> warning_delay ) >= 0 ? '+' : '' ) . ceil ( $board -> warning_delay ) . ' ' . $langs -> trans ( " days " );
2016-02-07 13:10:36 +01:00
$boxwork .= '<a title="' . dol_escape_htmltag ( $textlate ) . '" class="dashboardlineindicatorlate' . ( $board -> nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok' ) . '" href="' . $board -> url . '"><span class="dashboardlineindicatorlate' . ( $board -> nbtodolate > 0 ? ' dashboardlineko' : ' dashboardlineok' ) . '">' ;
$boxwork .= $board -> nbtodolate ;
$boxwork .= '</span></a>' ;
2015-12-14 21:38:04 +01:00
//}
2016-02-07 13:10:36 +01:00
$boxwork .= '</td>' ;
$boxwork .= '<td align="left">' ;
if ( $board -> nbtodolate > 0 ) $boxwork .= img_picto ( $langs -> trans ( " NActionsLate " , $board -> nbtodolate ) . ' (>' . ceil ( $board -> warning_delay ) . ' ' . $langs -> trans ( " days " ) . ')' , " warning " );
else $boxwork .= ' ' ;
$boxwork .= '</td>' ;
2016-01-18 12:57:24 +01:00
/* print '<td class="nowrap" align="right">' ;
2010-11-13 17:59:53 +01:00
print ' (>' . ceil ( $board -> warning_delay ) . ' ' . $langs -> trans ( " days " ) . ')' ;
2016-01-18 12:57:24 +01:00
print '</td>' ; */
2016-01-18 15:56:51 +01:00
2010-11-13 17:59:53 +01:00
if ( $showweather )
{
2016-03-13 14:37:39 +01:00
$boxwork .= '<td class="nohover hideonsmartphone noborderbottom" rowspan="' . $rowspan . '" width="80" style="border-left: 1px solid #DDDDDD" align="center">' ;
2010-11-13 17:59:53 +01:00
$text = '' ;
2010-11-17 00:49:25 +01:00
if ( $totallate > 0 ) $text = $langs -> transnoentitiesnoconv ( " WarningYouHaveAtLeastOneTaskLate " ) . ' (' . $langs -> transnoentitiesnoconv ( " NActionsLate " , $totallate ) . ')' ;
2010-11-13 17:59:53 +01:00
$options = 'height="64px"' ;
if ( $rowspan <= 2 ) $options = 'height="24"' ; // Weather logo is smaller if dashboard has few elements
else if ( $rowspan <= 3 ) $options = 'height="48"' ; // Weather logo is smaller if dashboard has few elements
2016-02-07 13:10:36 +01:00
$boxwork .= showWeather ( $totallate , $text , $options );
$boxwork .= '</td>' ;
2010-11-13 17:59:53 +01:00
$showweather = 0 ;
}
2016-02-07 13:10:36 +01:00
$boxwork .= '</tr>' ;
$boxwork .= " \n " ;
2008-03-31 00:25:39 +02:00
}
2016-02-07 13:10:36 +01:00
$boxwork .= '</table>' ; // End table array of working board
2016-02-07 14:22:52 +01:00
$boxwork .= '</div>' ;
2016-02-07 13:10:36 +01:00
2016-02-07 14:22:52 +01:00
//print $boxwork;
2010-11-13 17:59:53 +01:00
2016-02-07 13:10:36 +01:00
print '</div></div></div><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
2016-02-07 13:10:36 +01:00
$boxlist .= '<table width="100%" class="notopnoleftnoright">' ;
$boxlist .= '<tr><td class="notopnoleftnoright">' . " \n " ;
$boxlist .= '<div class="fichehalfleft">' ;
2016-02-07 14:22:52 +01:00
$boxlist .= $boxinfo ;
$boxlist .= $boxstat ;
2016-02-07 13:10:36 +01:00
$boxlist .= $resultboxes [ 'boxlista' ];
$boxlist .= '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2016-02-07 14:22:52 +01:00
$boxlist .= $boxwork ;
2016-02-07 13:10:36 +01:00
$boxlist .= $resultboxes [ 'boxlistb' ];
$boxlist .= '</div></div>' ;
$boxlist .= " \n " ;
$boxlist .= " </td></tr> " ;
$boxlist .= " </table> " ;
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>';
2012-03-16 11:23:53 +01:00
$message .= info_admin ( $langs -> trans ( " WarningLockFileDoesNotExists " , DOL_DATA_ROOT ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ));
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>';
$message .= info_admin ( $langs -> transnoentities ( " WarningConfFileMustBeReadOnly " ) . ' ' . $langs -> trans ( " WarningUntilDirRemoved " , DOL_DOCUMENT_ROOT . " /install " ));
}
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
2011-12-12 01:39:55 +01:00
llxFooter ();
2009-08-24 21:29:52 +02:00
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
* @ return string Return img tag of weather
2010-11-13 17:59:53 +01:00
*/
function showWeather ( $totallate , $text , $options )
{
global $conf ;
$out = '' ;
$offset = 0 ;
2016-02-07 14:22:52 +01:00
$factor = 10 ; // By default
2010-11-13 17:59:53 +01:00
$level0 = $offset ; if ( ! empty ( $conf -> global -> MAIN_METEO_LEVEL0 )) $level0 = $conf -> global -> MAIN_METEO_LEVEL0 ;
2016-02-07 14:22:52 +01:00
$level1 = $offset + 1 * $factor ; if ( ! empty ( $conf -> global -> MAIN_METEO_LEVEL1 )) $level1 = $conf -> global -> MAIN_METEO_LEVEL1 ;
$level2 = $offset + 2 * $factor ; if ( ! empty ( $conf -> global -> MAIN_METEO_LEVEL2 )) $level2 = $conf -> global -> MAIN_METEO_LEVEL2 ;
$level3 = $offset + 3 * $factor ; if ( ! empty ( $conf -> global -> MAIN_METEO_LEVEL3 )) $level3 = $conf -> global -> MAIN_METEO_LEVEL3 ;
2010-11-13 17:59:53 +01:00
2016-02-13 07:53:50 +01:00
if ( $totallate <= $level0 ) $out .= img_weather ( $text , 'weather-clear.png' , $options );
if ( $totallate > $level0 && $totallate <= $level1 ) $out .= img_weather ( $text , 'weather-few-clouds.png' , $options );
if ( $totallate > $level1 && $totallate <= $level2 ) $out .= img_weather ( $text , 'weather-clouds.png' , $options );
if ( $totallate > $level2 && $totallate <= $level3 ) $out .= img_weather ( $text , 'weather-many-clouds.png' , $options );
if ( $totallate > $level3 ) $out .= img_weather ( $text , 'weather-storm.png' , $options );
2010-11-13 17:59:53 +01:00
return $out ;
}