2004-10-19 22:35:36 +02:00
< ? php
2006-12-23 11:48:26 +01:00
/* Copyright ( C ) 2003 - 2006 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2012-02-11 00:11:49 +01:00
* Copyright ( c ) 2004 - 2012 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-08-14 21:23:14 +02:00
* Copyright ( C ) 2012 Marcos García < marcosgdf @ gmail . com >
2013-12-19 15:43:22 +01:00
* Copyright ( C ) 2013 Juanjo Menent < jmenent @ 2 byte . es >
2018-05-27 09:40:17 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2020-04-29 09:15:27 +02:00
* Copyright ( C ) 2020 Maxime DEMAREST < maxime @ indelog . fr >
2003-11-23 18:53:22 +01: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
2003-11-23 18:53:22 +01: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 />.
2003-11-23 18:53:22 +01:00
*/
2004-12-04 20:07:24 +01:00
/**
2008-09-07 23:36:42 +02:00
* \file htdocs / compta / facture / stats / index . php
* \ingroup facture
* \brief Page des stats factures
*/
2004-12-04 20:07:24 +01:00
2012-08-22 23:24:21 +02:00
require '../../../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php' ;
2020-04-29 09:15:27 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facturestats.class.php' ;
2022-08-29 12:03:05 +02:00
if ( isModEnabled ( 'categorie' )) {
2021-02-23 21:09:01 +01:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
}
2004-12-04 20:07:24 +01:00
2020-04-10 10:59:32 +02:00
$WIDTH = DolGraph :: getDefaultGraphSizeForStats ( 'width' );
$HEIGHT = DolGraph :: getDefaultGraphSizeForStats ( 'height' );
2005-02-06 17:08:01 +01:00
2020-04-25 13:49:44 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'bills' , 'companies' , 'other' ));
2021-09-23 02:38:53 +02:00
$mode = GETPOST ( " mode " ) ? GETPOST ( " mode " ) : 'customer' ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' && ! $user -> rights -> facture -> lire ) {
accessforbidden ();
}
2021-10-23 07:13:08 +02:00
if ( $mode == 'supplier' && empty ( $user -> rights -> fournisseur -> facture -> lire )) {
2021-02-23 21:09:01 +01:00
accessforbidden ();
}
2012-02-11 00:11:49 +01:00
2020-11-29 20:27:40 +01:00
$object_status = GETPOST ( 'object_status' , 'intcomma' );
2020-04-29 09:15:27 +02:00
$typent_id = GETPOST ( 'typent_id' , 'int' );
$categ_id = GETPOST ( 'categ_id' , 'categ_id' );
2016-11-03 19:39:54 +01:00
2020-04-10 10:59:32 +02:00
$userid = GETPOST ( 'userid' , 'int' );
$socid = GETPOST ( 'socid' , 'int' );
2020-05-04 15:19:45 +02:00
$custcats = GETPOST ( 'custcats' , 'array' );
2011-06-13 15:42:51 +02:00
// Security check
2021-02-23 21:09:01 +01:00
if ( $user -> socid > 0 ) {
2020-10-31 14:32:18 +01:00
$action = '' ;
$socid = $user -> socid ;
2003-11-24 09:50:17 +01:00
}
2003-11-23 18:53:22 +01:00
2020-04-10 10:59:32 +02:00
$nowyear = strftime ( " %Y " , dol_now ());
2020-11-29 20:27:40 +01:00
$year = GETPOST ( 'year' ) > 0 ? GETPOST ( 'year' , 'int' ) : $nowyear ;
2021-06-14 01:11:39 +02:00
$startyear = $year - ( empty ( $conf -> global -> MAIN_STATS_GRAPHS_SHOW_N_YEARS ) ? 2 : max ( 1 , min ( 10 , $conf -> global -> MAIN_STATS_GRAPHS_SHOW_N_YEARS )));
2020-04-10 10:59:32 +02:00
$endyear = $year ;
2008-09-08 09:32:03 +02:00
2008-09-07 23:36:42 +02:00
/*
* View
*/
2022-08-29 12:03:05 +02:00
if ( isModEnabled ( 'categorie' )) {
2021-02-23 21:09:01 +01:00
$langs -> load ( 'categories' );
}
2020-04-10 10:59:32 +02:00
$form = new Form ( $db );
2020-04-29 09:15:27 +02:00
$formcompany = new FormCompany ( $db );
$formother = new FormOther ( $db );
2011-06-13 16:17:44 +02:00
2003-11-23 18:53:22 +01:00
llxHeader ();
2020-04-25 13:49:44 +02:00
$picto = 'bill' ;
$title = $langs -> trans ( " BillsStatistics " );
$dir = $conf -> facture -> dir_temp ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'supplier' ) {
2020-04-25 13:49:44 +02:00
$picto = 'supplier_invoice' ;
2020-04-10 10:59:32 +02:00
$title = $langs -> trans ( " BillsStatisticsSuppliers " );
$dir = $conf -> fournisseur -> facture -> dir_temp ;
2008-09-08 09:32:03 +02:00
}
2003-11-23 18:53:22 +01:00
2020-04-25 13:49:44 +02:00
print load_fiche_titre ( $title , '' , $picto );
2008-09-07 23:36:42 +02:00
2012-02-19 18:34:22 +01:00
dol_mkdir ( $dir );
2008-09-07 23:36:42 +02:00
2020-04-29 09:15:27 +02:00
$stats = new FactureStats ( $db , $socid , $mode , ( $userid > 0 ? $userid : 0 ), ( $typent_id > 0 ? $typent_id : 0 ), ( $categ_id > 0 ? $categ_id : 0 ));
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
if ( $object_status != '' && $object_status >= 0 ) {
2021-03-22 12:00:41 +01:00
$stats -> where .= ' AND f.fk_statut IN (' . $db -> sanitize ( $object_status ) . ')' ;
2021-02-23 21:09:01 +01:00
}
2020-10-31 14:32:18 +01:00
if ( is_array ( $custcats ) && ! empty ( $custcats )) {
2022-05-06 16:15:52 +02:00
$stats -> from .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_societe as cat ON (f.fk_soc = cat.fk_soc)' ;
2021-03-22 12:00:41 +01:00
$stats -> where .= ' AND cat.fk_categorie IN (' . $db -> sanitize ( implode ( ',' , $custcats )) . ')' ;
2020-10-31 14:32:18 +01:00
}
2016-11-03 19:39:54 +01:00
}
2021-02-23 21:09:01 +01:00
if ( $mode == 'supplier' ) {
if ( $object_status != '' && $object_status >= 0 ) {
2021-03-22 12:00:41 +01:00
$stats -> where .= ' AND f.fk_statut IN (' . $db -> sanitize ( $object_status ) . ')' ;
2021-02-23 21:09:01 +01:00
}
2020-10-31 14:32:18 +01:00
if ( is_array ( $custcats ) && ! empty ( $custcats )) {
2021-10-14 15:55:12 +02:00
$stats -> from .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie_fournisseur as cat ON (f.fk_soc = cat.fk_soc)' ;
2021-10-16 12:53:57 +02:00
$stats -> where .= ' AND cat.fk_categorie IN (' . $db -> sanitize ( implode ( ',' , $custcats )) . ')' ;
2020-10-31 14:32:18 +01:00
}
2016-11-03 19:39:54 +01:00
}
2008-09-07 23:36:42 +02:00
2008-09-08 14:51:29 +02:00
// Build graphic number of object
2008-11-17 00:43:10 +01:00
// $data = array(array('Lib',val1,val2,val3),...)
2019-01-27 11:55:16 +01:00
$data = $stats -> getNbByMonthWithPrevYear ( $endyear , $startyear );
2008-09-07 23:36:42 +02:00
//var_dump($data);
2004-12-04 20:07:24 +01:00
2008-09-08 14:51:29 +02:00
$filenamenb = $dir . " /invoicesnbinyear- " . $year . " .png " ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
2021-10-14 15:56:01 +02:00
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstats&file=invoicesnbinyear-' . $year . '.png' ;
2021-02-23 21:09:01 +01:00
}
if ( $mode == 'supplier' ) {
2021-10-14 15:56:01 +02:00
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=billstatssupplier&file=invoicesnbinyear-' . $year . '.png' ;
2021-02-23 21:09:01 +01:00
}
2008-09-07 23:36:42 +02:00
2011-12-17 15:55:49 +01:00
$px1 = new DolGraph ();
$mesg = $px1 -> isGraphKo ();
2021-02-23 21:09:01 +01:00
if ( ! $mesg ) {
2011-12-17 15:55:49 +01:00
$px1 -> SetData ( $data );
2021-03-01 20:37:16 +01:00
$i = $startyear ;
$legend = array ();
2021-02-23 21:09:01 +01:00
while ( $i <= $endyear ) {
2020-04-10 10:59:32 +02:00
$legend [] = $i ;
2008-09-07 23:36:42 +02:00
$i ++ ;
}
2011-12-17 15:55:49 +01:00
$px1 -> SetLegend ( $legend );
$px1 -> SetMaxValue ( $px1 -> GetCeilMaxValue ());
$px1 -> SetWidth ( $WIDTH );
$px1 -> SetHeight ( $HEIGHT );
$px1 -> SetYLabel ( $langs -> trans ( " NumberOfBills " ));
$px1 -> SetShading ( 3 );
$px1 -> SetHorizTickIncrement ( 1 );
2020-04-10 10:59:32 +02:00
$px1 -> mode = 'depth' ;
2011-12-17 15:55:49 +01:00
$px1 -> SetTitle ( $langs -> trans ( " NumberOfBillsByMonth " ));
2019-01-27 11:55:16 +01:00
$px1 -> draw ( $filenamenb , $fileurlnb );
2008-09-07 23:36:42 +02:00
}
2008-09-08 14:51:29 +02:00
// Build graphic amount of object
2019-01-27 11:55:16 +01:00
$data = $stats -> getAmountByMonthWithPrevYear ( $endyear , $startyear );
2008-09-07 23:36:42 +02:00
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
2004-12-04 20:07:24 +01:00
2008-09-08 14:51:29 +02:00
$filenameamount = $dir . " /invoicesamountinyear- " . $year . " .png " ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=billstats&file=invoicesamountinyear-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=billstatssupplier&file=invoicesamountinyear-' . $year . '.png' ;
}
2003-11-23 18:53:22 +01:00
2011-12-17 15:55:49 +01:00
$px2 = new DolGraph ();
$mesg = $px2 -> isGraphKo ();
2021-02-23 21:09:01 +01:00
if ( ! $mesg ) {
2011-12-17 15:55:49 +01:00
$px2 -> SetData ( $data );
2021-03-01 20:37:16 +01:00
$i = $startyear ;
$legend = array ();
2021-02-23 21:09:01 +01:00
while ( $i <= $endyear ) {
2020-04-10 10:59:32 +02:00
$legend [] = $i ;
2008-01-02 14:08:27 +01:00
$i ++ ;
}
2011-12-17 15:55:49 +01:00
$px2 -> SetLegend ( $legend );
$px2 -> SetMaxValue ( $px2 -> GetCeilMaxValue ());
2019-01-27 11:55:16 +01:00
$px2 -> SetMinValue ( min ( 0 , $px2 -> GetFloorMinValue ()));
2011-12-17 15:55:49 +01:00
$px2 -> SetWidth ( $WIDTH );
$px2 -> SetHeight ( $HEIGHT );
$px2 -> SetYLabel ( $langs -> trans ( " AmountOfBills " ));
$px2 -> SetShading ( 3 );
$px2 -> SetHorizTickIncrement ( 1 );
2020-04-10 10:59:32 +02:00
$px2 -> mode = 'depth' ;
2011-12-17 15:55:49 +01:00
$px2 -> SetTitle ( $langs -> trans ( " AmountOfBillsByMonthHT " ));
2019-01-27 11:55:16 +01:00
$px2 -> draw ( $filenameamount , $fileurlamount );
2004-06-08 22:26:55 +02:00
}
2008-09-07 23:36:42 +02:00
2012-08-15 01:20:53 +02:00
$data = $stats -> getAverageByMonthWithPrevYear ( $endyear , $startyear );
2012-02-11 00:11:49 +01:00
2021-10-22 22:15:59 +02:00
if ( empty ( $user -> rights -> societe -> client -> voir ) || $user -> socid ) {
2020-10-31 14:32:18 +01:00
$filename_avg = $dir . '/ordersaverage-' . $user -> id . '-' . $year . '.png' ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
$fileurl_avg = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersaverage-' . $user -> id . '-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurl_avg = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-' . $user -> id . '-' . $year . '.png' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$filename_avg = $dir . '/ordersaverage-' . $year . '.png' ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
$fileurl_avg = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersaverage-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurl_avg = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-' . $year . '.png' ;
}
2012-02-11 00:11:49 +01:00
}
$px3 = new DolGraph ();
$mesg = $px3 -> isGraphKo ();
2021-02-23 21:09:01 +01:00
if ( ! $mesg ) {
2020-10-31 14:32:18 +01:00
$px3 -> SetData ( $data );
2021-03-01 20:37:16 +01:00
$i = $startyear ;
$legend = array ();
2021-02-23 21:09:01 +01:00
while ( $i <= $endyear ) {
2020-10-31 14:32:18 +01:00
$legend [] = $i ;
$i ++ ;
}
$px3 -> SetLegend ( $legend );
$px3 -> SetYLabel ( $langs -> trans ( " AmountAverage " ));
$px3 -> SetMaxValue ( $px3 -> GetCeilMaxValue ());
$px3 -> SetMinValue ( $px3 -> GetFloorMinValue ());
$px3 -> SetWidth ( $WIDTH );
$px3 -> SetHeight ( $HEIGHT );
$px3 -> SetShading ( 3 );
$px3 -> SetHorizTickIncrement ( 1 );
$px3 -> mode = 'depth' ;
$px3 -> SetTitle ( $langs -> trans ( " AmountAverage " ));
$px3 -> draw ( $filename_avg , $fileurl_avg );
2012-02-11 00:11:49 +01:00
}
// Show array
$data = $stats -> getAllByYear ();
2020-04-10 10:59:32 +02:00
$arrayyears = array ();
foreach ( $data as $val ) {
2020-10-31 14:32:18 +01:00
$arrayyears [ $val [ 'year' ]] = $val [ 'year' ];
2012-02-11 00:11:49 +01:00
}
2021-02-23 21:09:01 +01:00
if ( ! count ( $arrayyears )) {
$arrayyears [ $nowyear ] = $nowyear ;
}
2012-02-11 00:11:49 +01:00
2020-04-10 10:59:32 +02:00
$h = 0 ;
2012-02-11 00:11:49 +01:00
$head = array ();
2021-09-23 02:38:53 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/compta/facture/stats/index.php?mode=' . urlencode ( $mode );
2012-02-11 00:11:49 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ByMonthYear " );
$head [ $h ][ 2 ] = 'byyear' ;
$h ++ ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
$type = 'invoice_stats' ;
}
if ( $mode == 'supplier' ) {
$type = 'supplier_invoice_stats' ;
}
2012-02-12 23:29:31 +01:00
2019-01-27 11:55:16 +01:00
complete_head_from_modules ( $conf , $langs , null , $head , $h , $type );
2012-02-12 23:29:31 +01:00
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'byyear' , $langs -> trans ( " Statistics " ), - 1 );
2008-09-08 09:32:03 +02:00
2017-10-14 02:30:33 +02:00
// We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier.
2021-09-23 02:38:53 +02:00
$filter = '' ;
if ( $mode == 'customer' ) {
$filter = 's.client in (1,2,3)' ;
}
if ( $mode == 'supplier' ) {
$filter = 's.fournisseur = 1' ;
2015-07-18 14:48:59 +02:00
}
2013-04-04 19:42:21 +02:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2012-07-26 17:45:08 +02:00
2019-10-26 18:13:20 +02:00
// Show filter box
print '<form name="stats" method="POST" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
2020-03-14 03:02:49 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-26 18:13:20 +02:00
print '<input type="hidden" name="mode" value="' . $mode . '">' ;
2020-03-14 03:02:49 +01:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2019-10-26 18:13:20 +02:00
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">' . $langs -> trans ( " Filter " ) . '</td></tr>' ;
// Company
print '<tr><td>' . $langs -> trans ( " ThirdParty " ) . '</td><td>' ;
2021-06-14 01:11:39 +02:00
print img_picto ( '' , 'company' , 'class="pictofixedwidth"' );
2021-09-23 02:38:53 +02:00
print $form -> select_company ( $socid , 'socid' , $filter , 1 , 0 , 0 , array (), 0 , 'widthcentpercentminusx maxwidth300' );
2019-10-26 18:13:20 +02:00
print '</td></tr>' ;
2020-05-12 03:36:33 +02:00
2020-04-29 09:15:27 +02:00
// ThirdParty Type
print '<tr><td>' . $langs -> trans ( " ThirdPartyType " ) . '</td><td>' ;
$sortparam_typent = ( empty ( $conf -> global -> SOCIETE_SORT_ON_TYPEENT ) ? 'ASC' : $conf -> global -> SOCIETE_SORT_ON_TYPEENT ); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label.
2021-02-04 09:52:16 +01:00
print $form -> selectarray ( " typent_id " , $formcompany -> typent_array ( 0 ), $typent_id , 1 , 0 , 0 , '' , 0 , 0 , 0 , $sortparam_typent , '' , 1 );
2021-02-23 21:09:01 +01:00
if ( $user -> admin ) {
print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-04-29 09:15:27 +02:00
print '</td></tr>' ;
2020-05-12 03:36:33 +02:00
2020-04-29 09:15:27 +02:00
// Category
2022-08-29 12:03:05 +02:00
if ( isModEnabled ( 'categorie' )) {
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
2020-10-31 14:32:18 +01:00
$cat_type = Categorie :: TYPE_CUSTOMER ;
$cat_label = $langs -> trans ( " Category " ) . ' ' . lcfirst ( $langs -> trans ( " Customer " ));
2020-05-12 03:36:33 +02:00
}
2021-02-23 21:09:01 +01:00
if ( $mode == 'supplier' ) {
2020-10-31 14:32:18 +01:00
$cat_type = Categorie :: TYPE_SUPPLIER ;
$cat_label = $langs -> trans ( " Category " ) . ' ' . lcfirst ( $langs -> trans ( " Supplier " ));
2020-05-12 03:36:33 +02:00
}
print '<tr><td>' . $cat_label . '</td><td>' ;
2021-10-14 11:58:21 +02:00
$cate_arbo = $form -> select_all_categories ( $cat_type , null , 'parent' , null , null , 1 );
2021-06-14 01:11:39 +02:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' );
print $form -> multiselectarray ( 'custcats' , $cate_arbo , GETPOST ( 'custcats' , 'array' ), 0 , 0 , 'widthcentpercentminusx maxwidth300' );
2020-05-12 03:36:33 +02:00
//print $formother->select_categories($cat_type, $categ_id, 'categ_id', true);
print '</td></tr>' ;
2020-04-29 09:15:27 +02:00
}
2020-05-12 03:36:33 +02:00
2019-10-26 18:13:20 +02:00
// User
print '<tr><td>' . $langs -> trans ( " CreatedBy " ) . '</td><td>' ;
2021-06-14 01:11:39 +02:00
print img_picto ( '' , 'user' , 'class="pictofixedwidth"' );
print $form -> select_dolusers ( $userid , 'userid' , 1 , '' , 0 , '' , '' , 0 , 0 , 0 , '' , 0 , '' , 'widthcentpercentminusx maxwidth300' );
2019-10-26 18:13:20 +02:00
print '</td></tr>' ;
// Status
2021-06-14 01:11:39 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
2021-02-23 21:09:01 +01:00
if ( $mode == 'customer' ) {
2020-10-31 14:32:18 +01:00
$liststatus = array ( '0' => $langs -> trans ( " BillStatusDraft " ), '1' => $langs -> trans ( " BillStatusNotPaid " ), '2' => $langs -> trans ( " BillStatusPaid " ), '1,2' => $langs -> trans ( " BillStatusNotPaid " ) . ' / ' . $langs -> trans ( " BillStatusPaid " ), '3' => $langs -> trans ( " BillStatusCanceled " ));
print $form -> selectarray ( 'object_status' , $liststatus , $object_status , 1 );
2019-10-26 18:13:20 +02:00
}
2021-02-23 21:09:01 +01:00
if ( $mode == 'supplier' ) {
2020-10-31 14:32:18 +01:00
$liststatus = array ( '0' => $langs -> trans ( " BillStatusDraft " ), '1' => $langs -> trans ( " BillStatusNotPaid " ), '2' => $langs -> trans ( " BillStatusPaid " ));
print $form -> selectarray ( 'object_status' , $liststatus , $object_status , 1 );
2019-10-26 18:13:20 +02:00
}
print '</td></tr>' ;
// Year
print '<tr><td>' . $langs -> trans ( " Year " ) . '</td><td>' ;
2021-02-23 21:09:01 +01:00
if ( ! in_array ( $year , $arrayyears )) {
$arrayyears [ $year ] = $year ;
}
if ( ! in_array ( $nowyear , $arrayyears )) {
$arrayyears [ $nowyear ] = $nowyear ;
}
2019-10-26 18:13:20 +02:00
arsort ( $arrayyears );
2021-12-07 02:35:46 +01:00
print $form -> selectarray ( 'year' , $arrayyears , $year , 0 , 0 , 0 , '' , 0 , 0 , 0 , '' , 'width75' );
2019-10-26 18:13:20 +02:00
print '</td></tr>' ;
2021-06-14 01:11:39 +02:00
print '<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="' . $langs -> trans ( " Refresh " ) . '"></td></tr>' ;
2019-10-26 18:13:20 +02:00
print '</table>' ;
print '</form>' ;
print '<br><br>' ;
2011-06-13 16:17:44 +02:00
2018-10-26 15:46:17 +02:00
print '<div class="div-table-responsive-no-min">' ;
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2015-10-09 20:00:43 +02:00
print '<tr class="liste_titre" height="24">' ;
2019-12-12 10:31:08 +01:00
print '<td class="center">' . $langs -> trans ( " Year " ) . '</td>' ;
2019-02-04 13:51:39 +01:00
print '<td class="right">' . $langs -> trans ( " NumberOfBills " ) . '</td>' ;
print '<td class="right">%</td>' ;
print '<td class="right">' . $langs -> trans ( " AmountTotal " ) . '</td>' ;
print '<td class="right">%</td>' ;
print '<td class="right">' . $langs -> trans ( " AmountAverage " ) . '</td>' ;
print '<td class="right">%</td>' ;
2008-09-08 09:32:03 +02:00
print '</tr>' ;
2020-04-10 10:59:32 +02:00
$oldyear = 0 ;
2021-02-23 21:09:01 +01:00
foreach ( $data as $val ) {
2008-09-08 09:32:03 +02:00
$year = $val [ 'year' ];
2021-02-23 21:09:01 +01:00
while ( $year && $oldyear > $year + 1 ) { // If we have empty year
2008-09-08 09:32:03 +02:00
$oldyear -- ;
2017-09-08 13:23:12 +02:00
2017-05-10 16:41:19 +02:00
print '<tr class="oddeven" height="24">' ;
2020-04-10 10:59:32 +02:00
print '<td align="center"><a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $oldyear . '&mode=' . $mode . ( $socid > 0 ? '&socid=' . $socid : '' ) . ( $userid > 0 ? '&userid=' . $userid : '' ) . '">' . $oldyear . '</a></td>' ;
2019-02-04 13:51:39 +01:00
print '<td class="right">0</td>' ;
print '<td class="right"></td>' ;
2021-06-26 00:18:46 +02:00
print '<td class="right amount">0</td>' ;
2019-02-04 13:51:39 +01:00
print '<td class="right"></td>' ;
2021-06-26 00:18:46 +02:00
print '<td class="right amount">0</td>' ;
2019-02-04 13:51:39 +01:00
print '<td class="right"></td>' ;
2008-09-08 09:32:03 +02:00
print '</tr>' ;
2008-09-07 23:36:42 +02:00
}
2017-09-08 13:23:12 +02:00
2017-05-10 16:41:19 +02:00
print '<tr class="oddeven" height="24">' ;
2020-04-10 10:59:32 +02:00
print '<td align="center"><a href="' . $_SERVER [ " PHP_SELF " ] . '?year=' . $year . '&mode=' . $mode . ( $socid > 0 ? '&socid=' . $socid : '' ) . ( $userid > 0 ? '&userid=' . $userid : '' ) . '">' . $year . '</a></td>' ;
2019-02-04 13:51:39 +01:00
print '<td class="right">' . $val [ 'nb' ] . '</td>' ;
2021-12-08 14:36:34 +01:00
print '<td class="right opacitylow" style="' . (( empty ( $val [ 'nb_diff' ]) || $val [ 'nb_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . ( ! empty ( $val [ 'nb_diff' ]) && $val [ 'nb_diff' ] < 0 ? '' : '+' ) . round ( ! empty ( $val [ 'nb_diff' ]) ? $val [ 'nb_diff' ] : 0 ) . '%</td>' ;
2021-03-29 13:00:17 +02:00
print '<td class="right"><span class="amount">' . price ( price2num ( $val [ 'total' ], 'MT' ), 1 ) . '</span></td>' ;
2021-12-08 14:36:34 +01:00
print '<td class="right opacitylow" style="' . (( empty ( $val [ 'total_diff' ]) || $val [ 'total_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . ( ! empty ( $val [ 'total_diff' ]) && $val [ 'total_diff' ] < 0 ? '' : '+' ) . round ( ! empty ( $val [ 'total_diff' ]) ? $val [ 'total_diff' ] : 0 ) . '%</td>' ;
2021-03-29 13:00:17 +02:00
print '<td class="right"><span class="amount">' . price ( price2num ( $val [ 'avg' ], 'MT' ), 1 ) . '</span></td>' ;
2021-12-08 14:36:34 +01:00
print '<td class="right opacitylow" style="' . (( empty ( $val [ 'avg_diff' ]) || $val [ 'avg_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . ( ! empty ( $val [ 'avg_diff' ]) && $val [ 'avg_diff' ] < 0 ? '' : '+' ) . round ( ! empty ( $val [ 'avg_diff' ]) ? $val [ 'avg_diff' ] : 0 ) . '%</td>' ;
2008-09-08 09:32:03 +02:00
print '</tr>' ;
2020-04-10 10:59:32 +02:00
$oldyear = $year ;
2003-11-23 18:53:22 +01:00
}
2010-03-27 03:35:08 +01:00
2008-09-08 09:32:03 +02:00
print '</table>' ;
2018-10-26 15:46:17 +02:00
print '</div>' ;
2003-11-23 18:53:22 +01:00
2021-10-23 17:18:35 +02:00
print '</div><div class="fichetwothirdright">' ;
2013-04-04 19:42:21 +02:00
2008-09-08 09:32:03 +02:00
// Show graphs
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">' ;
2021-02-23 21:09:01 +01:00
if ( $mesg ) {
print $mesg ;
} else {
2011-12-17 15:55:49 +01:00
print $px1 -> show ();
2008-09-08 09:32:03 +02:00
print " <br> \n " ;
2011-12-17 15:55:49 +01:00
print $px2 -> show ();
2020-10-31 14:32:18 +01:00
print " <br> \n " ;
print $px3 -> show ();
2008-09-08 09:32:03 +02:00
}
print '</td></tr></table>' ;
2013-04-04 19:42:21 +02:00
2021-10-23 17:18:35 +02:00
print '</div></div>' ;
2013-04-04 19:42:21 +02:00
print '<div style="clear:both"></div>' ;
2008-09-08 09:32:03 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2012-02-11 00:11:49 +01:00
2018-07-30 17:28:44 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2011-12-17 15:55:49 +01:00
$db -> close ();