2004-10-19 20:58:50 +02:00
< ? php
2003-11-09 18:32:09 +01:00
/* Copyright ( C ) 2001 - 2003 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2013-07-25 15:02:40 +02:00
* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ inodbox . com >
2012-08-14 21:23:14 +02:00
* Copyright ( C ) 2012 Marcos García < marcosgdf @ gmail . com >
2015-04-18 21:28:55 +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-09 18:32:09 +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-09 18:32:09 +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-09 18:32:09 +01:00
*/
2004-12-04 20:07:24 +01:00
/**
2009-05-18 13:39:51 +02:00
* \file htdocs / commande / stats / index . php
* \ingroup commande
2011-06-13 15:07:10 +02:00
* \brief Page with customers or suppliers orders statistics
*/
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 . '/commande/class/commande.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/commande/class/commandestats.class.php' ;
2020-04-29 09:15:27 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2016-11-03 19:39:54 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formorder.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' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/dolgraph.class.php' ;
2005-07-16 16:56:25 +02:00
2020-04-10 10:59:32 +02:00
$WIDTH = DolGraph :: getDefaultGraphSizeForStats ( 'width' );
$HEIGHT = DolGraph :: getDefaultGraphSizeForStats ( 'height' );
2005-07-16 16:56:25 +02:00
2020-11-29 20:27:40 +01:00
$mode = GETPOSTISSET ( " mode " ) ? GETPOST ( " mode " , 'aZ09' ) : 'customer' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' && ! $user -> rights -> commande -> lire ) {
accessforbidden ();
}
if ( $mode == 'supplier' && ! $user -> rights -> fournisseur -> commande -> lire ) {
accessforbidden ();
}
2006-08-13 15:30:53 +02: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' );
2009-05-18 13:39:51 +02:00
// Security check
2021-02-23 20:46:19 +01:00
if ( $user -> socid > 0 ) {
2020-10-31 14:32:18 +01:00
$action = '' ;
$socid = $user -> socid ;
2003-11-24 13:18:02 +01:00
}
2003-11-09 18:32:09 +01:00
2020-04-10 10:59:32 +02:00
$nowyear = strftime ( " %Y " , dol_now ());
$year = GETPOST ( 'year' ) > 0 ? GETPOST ( 'year' ) : $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 ;
2005-07-16 16:56:25 +02:00
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'orders' , 'companies' , 'other' , 'suppliers' ));
2009-05-18 13:39:51 +02:00
2008-09-08 21:04:19 +02:00
2008-09-08 15:32:37 +02:00
/*
* View
*/
2009-05-18 13:39:51 +02:00
2020-04-10 10:59:32 +02:00
$form = new Form ( $db );
$formorder = new FormOrder ( $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
2020-04-25 13:49:44 +02:00
$picto = 'order' ;
$title = $langs -> trans ( " OrdersStatistics " );
$dir = $conf -> commande -> dir_temp ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'supplier' ) {
2020-04-25 13:49:44 +02:00
$picto = 'supplier_order' ;
2020-10-31 14:32:18 +01:00
$title = $langs -> trans ( " OrdersStatisticsSuppliers " );
$dir = $conf -> fournisseur -> commande -> dir_temp ;
2008-09-08 21:04:19 +02:00
}
2003-11-09 18:32:09 +01:00
2016-01-25 12:33:38 +01:00
llxHeader ( '' , $title );
2020-04-25 13:49:44 +02:00
print load_fiche_titre ( $title , '' , $picto );
2008-09-08 15:32:37 +02:00
2012-02-19 18:34:22 +01:00
dol_mkdir ( $dir );
2008-09-08 15:32:37 +02:00
2020-04-29 09:15:27 +02:00
$stats = new CommandeStats ( $db , $socid , $mode , ( $userid > 0 ? $userid : 0 ), ( $typent_id > 0 ? $typent_id : 0 ), ( $categ_id > 0 ? $categ_id : 0 ));
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
if ( $object_status != '' && $object_status >= - 1 ) {
2021-03-22 12:00:41 +01:00
$stats -> where .= ' AND c.fk_statut IN (' . $db -> sanitize ( $object_status ) . ')' ;
2021-02-23 20:46:19 +01:00
}
2016-11-03 19:39:54 +01:00
}
2021-02-23 20:46:19 +01:00
if ( $mode == 'supplier' ) {
if ( $object_status != '' && $object_status >= 0 ) {
2021-03-22 12:00:41 +01:00
$stats -> where .= ' AND c.fk_statut IN (' . $db -> sanitize ( $object_status ) . ')' ;
2021-02-23 20:46:19 +01:00
}
2016-11-03 19:39:54 +01:00
}
2008-09-08 15:32:37 +02:00
// Build graphic number of object
2019-01-27 11:55:16 +01:00
$data = $stats -> getNbByMonthWithPrevYear ( $endyear , $startyear );
2016-11-03 19:39:54 +01:00
2008-09-08 15:32:37 +02:00
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
2004-12-04 20:07:24 +01:00
2021-02-23 20:46:19 +01:00
if ( ! $user -> rights -> societe -> client -> voir || $user -> socid ) {
2020-10-31 14:32:18 +01:00
$filenamenb = $dir . '/ordersnbinyear-' . $user -> id . '-' . $year . '.png' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersnbinyear-' . $user -> id . '-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-' . $user -> id . '-' . $year . '.png' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$filenamenb = $dir . '/ordersnbinyear-' . $year . '.png' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersnbinyear-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurlnb = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersnbinyear-' . $year . '.png' ;
}
2006-05-26 17:40:39 +02:00
}
2003-11-16 17:45:13 +01:00
2011-12-17 15:55:49 +01:00
$px1 = new DolGraph ();
$mesg = $px1 -> isGraphKo ();
2021-02-23 20:46:19 +01:00
if ( ! $mesg ) {
2020-10-31 14:32:18 +01:00
$px1 -> SetData ( $data );
$i = $startyear ; $legend = array ();
2021-02-23 20:46:19 +01:00
while ( $i <= $endyear ) {
2020-10-31 14:32:18 +01:00
$legend [] = $i ;
$i ++ ;
}
$px1 -> SetLegend ( $legend );
$px1 -> SetMaxValue ( $px1 -> GetCeilMaxValue ());
$px1 -> SetMinValue ( min ( 0 , $px1 -> GetFloorMinValue ()));
$px1 -> SetWidth ( $WIDTH );
$px1 -> SetHeight ( $HEIGHT );
$px1 -> SetYLabel ( $langs -> trans ( " NbOfOrder " ));
$px1 -> SetShading ( 3 );
$px1 -> SetHorizTickIncrement ( 1 );
$px1 -> mode = 'depth' ;
$px1 -> SetTitle ( $langs -> trans ( " NumberOfOrdersByMonth " ));
$px1 -> draw ( $filenamenb , $fileurlnb );
2009-05-18 13:39:51 +02:00
}
2008-09-08 15:32:37 +02:00
// Build graphic amount of object
2019-01-27 11:55:16 +01:00
$data = $stats -> getAmountByMonthWithPrevYear ( $endyear , $startyear );
2008-09-08 15:32:37 +02:00
//var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...)
2021-02-23 20:46:19 +01:00
if ( ! $user -> rights -> societe -> client -> voir || $user -> socid ) {
2020-10-31 14:32:18 +01:00
$filenameamount = $dir . '/ordersamountinyear-' . $user -> id . '-' . $year . '.png' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersamountinyear-' . $user -> id . '-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-' . $user -> id . '-' . $year . '.png' ;
}
2020-05-21 15:05:19 +02:00
} else {
2020-10-31 14:32:18 +01:00
$filenameamount = $dir . '/ordersamountinyear-' . $year . '.png' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstats&file=ordersamountinyear-' . $year . '.png' ;
}
if ( $mode == 'supplier' ) {
$fileurlamount = DOL_URL_ROOT . '/viewimage.php?modulepart=orderstatssupplier&file=ordersamountinyear-' . $year . '.png' ;
}
2008-09-08 15:32:37 +02:00
}
2011-12-17 15:55:49 +01:00
$px2 = new DolGraph ();
$mesg = $px2 -> isGraphKo ();
2021-02-23 20:46:19 +01:00
if ( ! $mesg ) {
2020-10-31 14:32:18 +01:00
$px2 -> SetData ( $data );
$i = $startyear ; $legend = array ();
2021-02-23 20:46:19 +01:00
while ( $i <= $endyear ) {
2020-10-31 14:32:18 +01:00
$legend [] = $i ;
$i ++ ;
}
$px2 -> SetLegend ( $legend );
$px2 -> SetMaxValue ( $px2 -> GetCeilMaxValue ());
$px2 -> SetMinValue ( min ( 0 , $px2 -> GetFloorMinValue ()));
$px2 -> SetWidth ( $WIDTH );
$px2 -> SetHeight ( $HEIGHT );
$px2 -> SetYLabel ( $langs -> trans ( " AmountOfOrders " ));
$px2 -> SetShading ( 3 );
$px2 -> SetHorizTickIncrement ( 1 );
$px2 -> mode = 'depth' ;
$px2 -> SetTitle ( $langs -> trans ( " AmountOfOrdersByMonthHT " ));
$px2 -> draw ( $filenameamount , $fileurlamount );
2008-09-08 15:32:37 +02:00
}
2012-02-11 00:11:49 +01:00
2012-08-14 21:23:14 +02:00
$data = $stats -> getAverageByMonthWithPrevYear ( $endyear , $startyear );
2012-02-11 00:11:49 +01:00
2021-02-23 20:46:19 +01:00
if ( ! $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 20:46:19 +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 20:46:19 +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 20:46:19 +01:00
if ( ! $mesg ) {
2020-10-31 14:32:18 +01:00
$px3 -> SetData ( $data );
$i = $startyear ; $legend = array ();
2021-02-23 20:46:19 +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 ) {
if ( ! empty ( $val [ 'year' ])) {
$arrayyears [ $val [ 'year' ]] = $val [ 'year' ];
2012-07-13 10:15:47 +02:00
}
2012-02-11 00:11:49 +01:00
}
2021-02-23 20:46:19 +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 ();
2020-04-10 10:59:32 +02:00
$head [ $h ][ 0 ] = DOL_URL_ROOT . '/commande/stats/index.php?mode=' . $mode ;
2012-02-11 00:11:49 +01:00
$head [ $h ][ 1 ] = $langs -> trans ( " ByMonthYear " );
$head [ $h ][ 2 ] = 'byyear' ;
$h ++ ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$type = 'order_stats' ;
}
if ( $mode == 'supplier' ) {
$type = 'supplier_order_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 );
2012-02-11 00:11:49 +01:00
2013-04-04 19:42:21 +02:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2012-07-26 17:45:08 +02:00
2017-01-22 16:03:08 +01: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 () . '">' ;
2017-01-22 16:03:08 +01: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">' ;
2017-01-22 16:03:08 +01:00
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">' . $langs -> trans ( " Filter " ) . '</td></tr>' ;
// Company
2019-01-19 12:28:18 +01:00
print '<tr><td class="left">' . $langs -> trans ( " ThirdParty " ) . '</td><td class="left">' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
$filter = 's.client IN (1,2,3)' ;
}
if ( $mode == 'supplier' ) {
$filter = 's.fournisseur = 1' ;
}
2021-06-14 01:11:39 +02:00
print img_picto ( '' , 'company' , 'class="pictofixedwidth"' );
print $form -> select_company ( $socid , 'socid' , $filter , 1 , 0 , 0 , array (), 0 , 'widthcentpercentminusx maxwidth300' );
2017-01-22 16:03:08 +01:00
print '</td></tr>' ;
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:48:17 +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 20:46:19 +01:00
if ( $user -> admin ) {
print ' ' . info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
}
2020-04-29 09:15:27 +02:00
print '</td></tr>' ;
// Category
2021-02-23 20:46:19 +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-04-29 09:15:27 +02:00
}
2021-02-23 20:46:19 +01:00
if ( $mode == 'supplier' ) {
2020-10-31 14:32:18 +01:00
$cat_type = Categorie :: TYPE_SUPPLIER ;
2021-02-23 20:46:19 +01:00
$cat_label = $langs -> trans ( " Category " ) . ' ' . lcfirst ( $langs -> trans ( " Supplier " ));
2020-04-29 09:15:27 +02:00
}
print '<tr><td>' . $cat_label . '</td><td>' ;
2021-06-14 01:11:39 +02:00
print img_picto ( '' , 'category' , 'class="pictofixedwidth"' );
2021-06-14 01:33:01 +02:00
print $formother -> select_categories ( $cat_type , $categ_id , 'categ_id' , 0 , 1 , 'widthcentpercentminusx maxwidth300' );
2020-04-29 09:15:27 +02:00
print '</td></tr>' ;
2017-01-22 16:03:08 +01:00
// User
2021-06-14 01:33:01 +02:00
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' );
2017-01-22 16:03:08 +01:00
// Status
2021-06-14 01:33:01 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td><td>' ;
2021-02-23 20:46:19 +01:00
if ( $mode == 'customer' ) {
2020-10-31 14:32:18 +01:00
$liststatus = array (
Commande :: STATUS_DRAFT => $langs -> trans ( " StatusOrderDraft " ),
Commande :: STATUS_VALIDATED => $langs -> trans ( " StatusOrderValidated " ),
Commande :: STATUS_SHIPMENTONPROCESS => $langs -> trans ( " StatusOrderSent " ),
Commande :: STATUS_CLOSED => $langs -> trans ( " StatusOrderDelivered " ),
Commande :: STATUS_CANCELED => $langs -> trans ( " StatusOrderCanceled " )
);
2020-11-29 21:35:03 +01:00
print $form -> selectarray ( 'object_status' , $liststatus , GETPOST ( 'object_status' , 'intcomma' ), - 4 );
2017-01-22 16:03:08 +01:00
}
2021-02-23 20:46:19 +01:00
if ( $mode == 'supplier' ) {
2020-12-01 02:41:19 +01:00
$formorder -> selectSupplierOrderStatus (( strstr ( $object_status , ',' ) ? - 1 : $object_status ), 0 , 'object_status' );
2017-01-22 16:03:08 +01:00
}
print '</td></tr>' ;
// Year
2019-01-17 14:27:07 +01:00
print '<tr><td class="left">' . $langs -> trans ( " Year " ) . '</td><td class="left">' ;
2021-02-23 20:46:19 +01:00
if ( ! in_array ( $year , $arrayyears )) {
$arrayyears [ $year ] = $year ;
}
if ( ! in_array ( $nowyear , $arrayyears )) {
$arrayyears [ $nowyear ] = $nowyear ;
}
2017-01-22 16:03:08 +01:00
arsort ( $arrayyears );
2019-01-27 11:55:16 +01:00
print $form -> selectarray ( 'year' , $arrayyears , $year , 0 );
2017-01-22 16:03:08 +01:00
print '</td></tr>' ;
2021-06-14 01:11:39 +02:00
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="' . $langs -> trans ( " Refresh " ) . '"></td></tr>' ;
2017-01-22 16:03:08 +01: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-01-23 17:34:30 +01:00
print '<td class="right">' . $langs -> trans ( " NbOfOrders " ) . '</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 15:32:37 +02:00
print '</tr>' ;
2009-05-18 13:39:51 +02:00
2020-04-10 10:59:32 +02:00
$oldyear = 0 ;
2021-02-23 20:46:19 +01:00
foreach ( $data as $val ) {
2012-07-13 10:15:47 +02:00
$year = $val [ 'year' ];
2021-02-23 20:46:19 +01:00
while ( ! empty ( $year ) && $oldyear > $year + 1 ) { // If we have empty year
2015-08-12 22:28:30 +02:00
$oldyear -- ;
2017-06-20 12:17:13 +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-01-23 17:34:30 +01:00
print '<td class="right">0</td>' ;
print '<td class="right"></td>' ;
print '<td class="right">0</td>' ;
print '<td class="right"></td>' ;
print '<td class="right">0</td>' ;
print '<td class="right"></td>' ;
2015-08-12 22:28:30 +02:00
print '</tr>' ;
2012-07-13 10:15:47 +02:00
}
2017-06-20 12:17:13 +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-01-23 17:34:30 +01:00
print '<td class="right">' . $val [ 'nb' ] . '</td>' ;
2021-06-14 01:33:01 +02:00
print '<td class="right opacitylow" style="' . (( $val [ 'nb_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . round ( $val [ 'nb_diff' ]) . '%</td>' ;
2019-01-27 11:55:16 +01:00
print '<td class="right">' . price ( price2num ( $val [ 'total' ], 'MT' ), 1 ) . '</td>' ;
2021-06-14 01:33:01 +02:00
print '<td class="right opacitylow" style="' . (( $val [ 'total_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . round ( $val [ 'total_diff' ]) . '%</td>' ;
2019-01-27 11:55:16 +01:00
print '<td class="right">' . price ( price2num ( $val [ 'avg' ], 'MT' ), 1 ) . '</td>' ;
2021-06-14 01:33:01 +02:00
print '<td class="right opacitylow" style="' . (( $val [ 'avg_diff' ] >= 0 ) ? 'color: green;' : 'color: red;' ) . '">' . round ( $val [ 'avg_diff' ]) . '%</td>' ;
2012-07-13 10:15:47 +02:00
print '</tr>' ;
2020-04-10 10:59:32 +02:00
$oldyear = $year ;
2003-11-09 18:32:09 +01:00
}
2003-11-24 13:18:02 +01:00
print '</table>' ;
2018-10-26 15:46:17 +02:00
print '</div>' ;
2003-11-24 13:18:02 +01:00
2003-11-09 18:32:09 +01:00
2013-04-04 19:42:21 +02:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">' ;
2008-09-08 15:32:37 +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 20:46:19 +01:00
if ( $mesg ) {
print $mesg ;
} else {
2020-10-31 14:32:18 +01:00
print $px1 -> show ();
print " <br> \n " ;
print $px2 -> show ();
print " <br> \n " ;
print $px3 -> show ();
2008-09-08 15:32:37 +02:00
}
print '</td></tr></table>' ;
2013-04-04 19:42:21 +02:00
print '</div></div></div>' ;
print '<div style="clear:both"></div>' ;
2008-09-08 15:32:37 +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-29 19:16:28 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2011-12-17 15:55:49 +01:00
$db -> close ();