*/
include("session.php");
require_once("class_functions.php");
require_once("class_db.php");
require_once("class_graphics.php");
if(file_exists($_SESSION['config']['lang'].'.php'))
{
include($_SESSION['config']['lang'].'.php');
}
else
{
$_SESSION['error'] = "Language file missing...
";
}
$func = new functions();
$db = new dbquery();
$db->connect();
$db2 = new dbquery();
$db2->connect();
$graphi = new graphics();
$table = 'res_x';
$_SESSION['labels1'] = array();
$_SESSION['labels2'] = array();
$year = date('Y');
$label_month = '';
?>
"")
{
$my_year = $_SESSION['year'];
$the_date = " year(CREATION_DATE) = '".$my_year."'";
$title = _TITLE_STATS_ONE." (".$my_year.")";
}
elseif ($_SESSION['month'] <> "")
{
$my_month = $_SESSION['month'];
$the_date = " year(CREATION_DATE) = '".date("Y")."' and month(CREATION_DATE) = '".$my_month."'";
$title = _TITLE_STATS_ONE." (".$db->get_month_name($my_month)." ".date("Y").")";
}
if($_SESSION['form_stats'] == "graph")
{
$val_an = array();
}
elseif($_SESSION['form_stats'] == "tab")
{
$data = array();
}
$has_data = false;
if ($_SESSION['year'] <> "")
{
$_SESSION['labels1'] = array(ucfirst(_JANUARY_SHORT), ucfirst(_FEBRUARY_SHORT), ucfirst(_MARCH_SHORT), ucfirst(_APRIL_SHORT), ucfirst(_MAY_SHORT), ucfirst(_JUNE_SHORT), ucfirst(_JULY_SHORT), ucfirst(_AUGUST_SHORT), ucfirst(_SEPTEMBER_SHORT), ucfirst(_OCTOBER_SHORT), ucfirst(_NOVEMBER_SHORT), ucfirst(_DECEMBER_SHORT));
for($i=1; $i<= 12; $i++)
{
$db->query("SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE month( creation_date ) = ".$i." and YEAR(creation_date) = ".$my_year." AND STATUS = 'END' AND IS_FOLDER = 'Y'");
if( $db->nb_result() > 0)
{
$tmp = 0;
while($res = $db->fetch_object())
{
$tmp = $tmp + $res->DELAI;
}
if($_SESSION['form_stats'] == "graph")
{
array_push($val_an, (string)$tmp / $db->nb_result());
}
elseif($_SESSION['form_stats'] == "tab")
{
array_push($data, array('LABEL' => $func->get_month_name($i), 'VALUE' => (string)$tmp / $db->nb_result()));
}
if($tmp / $db->nb_result() > 0)
{
$has_data = true;
}
}
else
{
if($_SESSION['form_stats'] == "graph")
{
array_push($val_an, 0);
}
elseif($_SESSION['form_stats'] == "tab")
{
array_push($data, array('LABEL' => $func->get_month_name($i), 'VALUE' => _UNDEFINED));
}
}
}
$title1 = _TITLE_STATS_ONE." (".$my_year.")";
if($_SESSION['form_stats'] == 'graph')
{
$src1 = "graphs.php?type=courbe&largeur=650&hauteur=400&titre=".$title1."&labelX=MOIS&labelY="._N_DAYS;
$_SESSION['tmp_graph']['labels'] = $_SESSION['labels1'];
$_SESSION['tmp_graph']['values'] = $val_an;
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _MONTH_CREATION_FOLDER, 'VALUE' => _PROCESS_DELAI_AVG));
}
}
if ($_SESSION['month'] <> "")
{
if($_SESSION['form_stats'] == 'graph')
{
$val_mois = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
$max = $func->get_nb_days_in_month($_SESSION['month'], date("Y"));
for($i=1; $i<= $max; $i++)
{
if($_SESSION['form_stats'] == 'graph')
{
array_push( $_SESSION['labels2'],(string) $i);
}
$db->query("SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE month( creation_date ) = ".$my_month." and YEAR(creation_date) = ".date("Y")." and day(CREATION_DATE) = ".$i." AND STATUS = 'END' AND IS_FOLDER = 'Y'");
if( $db->nb_result() > 0)
{
$tmp = 0;
while($res = $db->fetch_object())
{
$tmp = $tmp + $res->DELAI;
}
if($_SESSION['form_stats'] == 'graph')
{
array_push($val_mois, (string) $tmp / $db->nb_result());
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' => $i, 'VALUE' => (string) $tmp / $db->nb_result()));
}
$has_data = true;
}
else
{
if($_SESSION['form_stats'] == 'graph')
{
array_push($val_mois, 0);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' => $i, 'VALUE' => _UNDEFINED));
}
}
}
$title2 = _TITLE_STATS_ONE;": ".date("M");
if($_SESSION['form_stats'] == 'graph')
{
$src2 = "graphs.php?type=courbe&id=an&largeur=670&hauteur=400&titre=".$title."&labelX="._DAYS."&labelY="._N_DAYS;
$_SESSION['tmp_graph']['labels'] = $_SESSION['labels2'];
$_SESSION['tmp_graph']['values'] = $val_mois;
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _DAY_CREATION_FOLDER, 'VALUE' => _PROCESS_DELAI_AVG));
}
}
if ($_SESSION['year'] <> "" && $has_data)
{
if($_SESSION['form_stats'] == 'graph')
{
?>
show_stats_array($title1, $data);
}
}
elseif ($_SESSION['month'] <> "" && $has_data)
{
if($_SESSION['form_stats'] == 'graph')
{?>
show_stats_array($title2, $data);
}
}
else
{
echo '
'._NO_DATA_MESSAGE.'
';
}
}
elseif($_GET['type'] == "barre")
{
/*if($_GET['id'] == "delai_type")
{
$db->query("select distinct TYPE_ID from ".$_SESSION['tablename']['doctypes']." where RES_TABLE = 'res_x' ");
if($_SESSION['form_stats'] == 'graph')
{
$types = array();
$etiq = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
$has_data = false;
while( $line = $db->fetch_object() )
{
array_push($etiq, $line->TYPE_ID);
if(isset($_SESSION['year']) && !empty($_SESSION['year']))
{
$query = "SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE TYPE_ID = '".$line->TYPE_ID."' AND STATUS = 'END' AND IS_FOLDER = 'Y' and YEAR(creation_date) = ".$_SESSION['year'];
$year = $_SESSION['year'];
}
elseif(isset($_SESSION['month']) && !empty($_SESSION['month']))
{
$query = "SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE TYPE_ID = '".$line->TYPE_ID."' AND STATUS = 'END' AND IS_FOLDER = 'Y' and YEAR(creation_date) = ".$year." and MONTH(creation_date) = ".$_SESSION['month'];
$label_month = $db->get_month_name($_SESSION['month']);
}
else
{
$query = "SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE TYPE_ID = '".$line->TYPE_ID."' AND STATUS = 'END' AND IS_FOLDER = 'Y' and YEAR(creation_date) = ".$year;
}
$db2->query($query);
//$db2->show();
if( $db2->nb_result() > 0)
{
$tmp = 0;
while($res = $db2->fetch_object())
{
$tmp = $tmp + $res->DELAI;
}
array_push($types,(string) $tmp / $db2->nb_result());
if( $tmp / $db2->nb_result() > 0)
{
$has_data = true;
}
}
else
{
array_push($types, 0);
}
}
$title = _TITLE_STATS_TWO." (".$label_month." ".$year." )";
$src = "graphs.php?type=histo&largeur=790&hauteur=550&titre=".$title."&marge_bas=150&labelY="._STATS_LABEL01;
for($i=0;$i
'._NO_DATA_MESSAGE.'
';
}
}
elseif($_GET['id'] == "vol_quartier")
{
$vol_quart = array();
for($i=0; $i < count($_SESSION['quartiers']); $i++)
{
$db->query("select count(*) as TOTAL from ".$table." where CUSTOM_T14 = '".$_SESSION['quartiers'][$i]."' and STATUS <> 'REP' and YEAR(creation_date) =".year." ");
//$db->show();
$res = $db->fetch_object();
array_push($vol_quart, $res->TOTAL);
}
$title = _TITLE_STATS_THREE." ".date('Y')." : ";
$src = "graphs.php?type=histo&largeur=400&hauteur=500&titre=".$title."&marge_bas=140&labelY="._STATS_LABEL02."&labelX="._STATS_LABEL03;
for($i=0;$i
"")
{
$my_year = $_SESSION['year'];
$the_date = " year(CREATION_DATE) = '".$my_year."'";
$title = stripslashes(_TITLE_STATS_FOUR)." (".$my_year.") ";
}
elseif ($_SESSION['statspol_datestart'] <> "" && $_SESSION['statspol_datefin'] <> "")
{
$my_datestart= $_SESSION['statspol_datestart'];
$my_datefin = $_SESSION['statspol_datefin'];
$title = stripslashes(_TITLE_STATS_FOUR)." (".$my_datestart." "._UNTIL." ".$my_datefin.")";
$my_datestart = $func->inverse_date($_SESSION['statspol_datestart'], "no", _RECIPIENT , "no");
$my_datefin = $func->inverse_date($_SESSION['statspol_datefin'], "no", _RECIPIENT , "no");
$the_date = " date(CREATION_DATE) >= '".$my_datestart."' and date(CREATION_DATE) <='".$my_datefin."' ";
}
elseif ($_SESSION['month'] <> "")
{
$my_month = $_SESSION['month'];
$the_date = " year(CREATION_DATE) = '".date("Y")."' and month(CREATION_DATE) = '".$my_month."'";
$title = stripslashes(_TITLE_STATS_FOUR)." (".$db->get_month_name($my_month)." ".date("Y")." : ";
}
$db->query("select ID, SERVICE from ".$_SESSION['tablename']['services']." where ENABLED = 'Y' order by ID");
if($_SESSION['form_stats'] == 'graph')
{
$services = array();
$vol_serv = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
while($line = $db->fetch_object())
{
$db2->query("select count(*) as TOTAL from ".$table." where DESTINATION = '".$line->ID."' and STATUS <> 'DEL' and STATUS <> 'REP' and STATUS <> 'WAI' and IS_FOLDER = 'Y' and ".$the_date);
$res = $db2->fetch_object();
if($_SESSION['form_stats'] == 'graph')
{
array_push($services, $line->ID);
array_push($vol_serv, $res->TOTAL);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array( 'LABEL' => stripslashes($line->SERVICE), 'VALUE' => $res->TOTAL));
}
if($res->TOTAL > 0)
{
$has_data = true;
}
}
if($_SESSION['form_stats'] == 'graph')
{
$src = "graphs.php?type=histo&largeur=780&hauteur=500&titre=".stripslashes($title)."&marge_bas=100&labelY="._STATS_LABEL04."&labelX="._STATS_LABEL05;
$_SESSION['tmp_graph']['values'] = $vol_serv;
$_SESSION['labels1'] = str_replace('\\', '',$services);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _DEPARTMENT, 'VALUE' => _NB_MAILS1));
}
if($has_data)
{
if($_SESSION['form_stats'] == 'graph')
{
?>
show_stats_array($title, $data);
}
}
else
{
echo '
'._NO_DATA_MESSAGE.'
';
}
}
elseif($_GET['id'] == "vol_retard_service")
{
$has_data = false;
$db->query("select ID, SERVICE from ".$_SESSION['tablename']['services']." where ENABLED = 'Y' order by ID");
if($_SESSION['form_stats'] == 'graph')
{
$services = array();
$vol = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
while($line = $db->fetch_object())
{
$db2->query("select count(*) as TOTAL from ".$table." where DESTINATION = '".$line->ID."' and (STATUS = 'NEW' or STATUS = 'COU') AND IS_FOLDER = 'Y' and datediff(curdate(), CUSTOM_D5) >= 0 ");
//$db2->show();
$res = $db2->fetch_object();
if($_SESSION['form_stats'] == 'graph')
{
array_push($vol, $res->TOTAL);
array_push($services, $line->ID);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' => $line->SERVICE, 'VALUE' => $res->TOTAL));
}
if($res->TOTAL > 0)
{
$has_data = true;
}
}
$title = _TITLE_STATS_FIVE." ";
if($_SESSION['form_stats'] == 'graph')
{
$src = "graphs.php?type=histo&largeur=780&hauteur=500&titre=".$title."&marge_bas=100&labelY="._STATS_LABEL06."&labelX="._STATS_LABEL07;
$_SESSION['tmp_graph']['values'] = $vol;
$_SESSION['labels1'] = str_replace('\\', '',$services);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _DEPARTMENT, 'VALUE' => _NB_FOLDERS1));
}
if($has_data)
{
if($_SESSION['form_stats'] == 'graph')
{
?>
show_stats_array($title, $data);
}
}
else
{
echo '
'._NO_DATA_MESSAGE.'
';
}
}
elseif($_GET['id'] == 'vol_delai_service')
{
if ($_SESSION['year'] <> "")
{
$my_year = $_SESSION['year'];
$the_date = " year(CREATION_DATE) = '".$my_year."'";
$title = _TITLE_STATS_ONE." (".$my_year.")";
}
elseif ($_SESSION['month'] <> "")
{
$my_month = $_SESSION['month'];
$the_date = " year(CREATION_DATE) = '".date("Y")."' and month(CREATION_DATE) = '".$my_month."'";
$title = _TITLE_STATS_ONE." (".$db->get_month_name($my_month)." ".date("Y").")";
}
$db2->query("SELECT ID, SERVICE from ".$_SESSION['tablename']['services']." where ENABLED = 'Y'");
if($_SESSION['form_stats'] == 'graph')
{
$val_an = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
$has_data = false;
while($line = $db2->fetch_object())
{
$tmp_id = addslashes($line->ID);
$db->query("SELECT datediff( custom_d3, creation_date ) AS DELAI FROM ".$table." WHERE ".$the_date." AND STATUS = 'END' AND IS_FOLDER = 'Y' and DESTINATION = '".$tmp_id."'");
if( $db->nb_result() > 0)
{
$tmp = 0;
while($res = $db->fetch_object())
{
$tmp = $tmp + $res->DELAI;
}
if($_SESSION['form_stats'] == 'graph')
{
array_push($val_an, (string)$tmp / $db->nb_result());
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' => stripslashes($line->SERVICE), 'VALUE' => (string)$tmp / $db->nb_result()));
}
if($tmp / $db->nb_result() > 0)
{
$has_data = true;
}
}
else
{
if($_SESSION['form_stats'] == 'graph')
{
array_push($val_an, 0);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' => stripslashes($line->SERVICE), 'VALUE' => _UNDEFINED));
}
}
if($_SESSION['form_stats'] == 'graph')
{
array_push($_SESSION['labels1'], $line->ID);
}
}
if($_SESSION['form_stats'] == 'graph')
{
$src1 = "graphs.php?type=histo&largeur=650&hauteur=400&titre=".$title."&labelX=MOIS&labelY="._N_DAYS;
$_SESSION['tmp_graph']['labels'] = $_SESSION['labels1'];
$_SESSION['tmp_graph']['values'] = $val_an;
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _DEPARTMENT, 'VALUE' => _PROCESS_DELAI));
}
if ( $has_data)
{
if($_SESSION['form_stats'] == 'graph')
{
?>
show_stats_array($title, $data);
}
}
else
{
echo '
'._NO_DATA_MESSAGE.'
';
}
}
}
elseif($_GET['type'] == "camembert")
{
/*if($_GET['id'] == "typo_service")
{
if ($_SESSION['year'] <> "")
{
$my_year = $_SESSION['year'];
$the_date = " year(CREATION_DATE) = '".$my_year."'";
}
elseif ($_SESSION['statspol_datestart'] <> "" && $_SESSION['statspol_datefin'] <> "")
{
$my_datestart= $_SESSION['statspol_datestart'];
$my_datefin = $_SESSION['statspol_datefin'];
$my_datestart = $func->inverse_date($_SESSION['statspol_datestart'], "no", _RECIPIENT , "no");
$my_datefin = $func->inverse_date($_SESSION['statspol_datefin'], "no", _RECIPIENT , "no");
$the_date = " date(CREATION_DATE) >= '".$my_datestart."' and date(CREATION_DATE) <='".$my_datefin."' ";
}
elseif ($_SESSION['month'] <> "")
{
$my_month = $_SESSION['month'];
$the_date = " year(CREATION_DATE) = '".date("Y")."' and month(CREATION_DATE) = '".$my_month."'";
}
$services = array();
$db->query("select distinct DESTINATION from ".$table." where ".$the_date." and STATUS <> 'REP' and IS_FOLDER = 'Y'");
//$db->show();
while($line = $db->fetch_object())
{
$db2->query("select ID, SERVICE from ".$_SESSION['tablename']['services']." where ID = '".$line->DESTINATION."'");
$res = $db2->fetch_object();
array_push($services, array('ID' => $res->ID, "SERVICE" => $res->SERVICE));
}
?>
"")
{
$my_year = $_SESSION['year'];
$the_date = " year(CREATION_DATE) = '".$my_year."'";
$title = _TITLE_STATS_SEVEN." (".$my_year.")";
}
elseif ($_SESSION['statspol_datestart'] <> "" && $_SESSION['statspol_datefin'] <> "")
{
$my_datestart= $_SESSION['statspol_datestart'];
$my_datefin = $_SESSION['statspol_datefin'];
$title = _TITLE_STATS_SEVEN." (".$my_datestart." "._UNTIL." ".$my_datefin.")";
$my_datestart = $func->inverse_date($_SESSION['statspol_datestart'], "no", _RECIPIENT , "no");
$my_datefin = $func->inverse_date($_SESSION['statspol_datefin'], "no", _RECIPIENT , "no");
$the_date = " date(CREATION_DATE) >= '".$my_datestart."' and date(CREATION_DATE) <='".$my_datefin."' ";
}
elseif ($_SESSION['month'] <> "")
{
$my_month = $_SESSION['month'];
$the_date = " year(CREATION_DATE) = '".date("Y")."' and month(CREATION_DATE) = '".$my_month."'";
$label_month = $db->get_month_name($my_month);
$title = _TITLE_STATS_SEVEN." (".$label_month." ".date("Y").")";
}
$db->query("select distinct TYPE_ID from ".$table." where STATUS <> 'REP' and STATUS <> 'DEL' and STATUS <> 'MEL' and ".$the_date);
if($_SESSION['form_stats'] == 'graph')
{
$vol_an = array();
$vol_mois = array();
}
elseif($_SESSION['form_stats'] == 'tab')
{
$data = array();
}
while($line = $db->fetch_object())
{
$tmp = addslashes($line->TYPE_ID);
$db2->query("select count(*) as TOTAL from ".$table." where STATUS <> 'REP' and STATUS <> 'DEL' and STATUS <> 'MEL' and ".$the_date." and TYPE_ID = '".$tmp."'");
//$db2->show();
$res = $db2->fetch_object();
if($_SESSION['form_stats'] == 'graph')
{
array_push($_SESSION['labels1'], (string) $line->TYPE_ID);
array_push($vol_an, $res->TOTAL);
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_push($data, array('LABEL' =>$line->TYPE_ID, 'VALUE' => $res->TOTAL ));
}
if($res->TOTAL > 0)
{
$has_data = true;
}
}
if($_SESSION['form_stats'] == 'graph')
{
$src1 = "graphs.php?type=pie&largeur=750&hauteur=280&titre=".$title;
$_SESSION['tmp_graph']['values'] = $vol_an;
}
elseif($_SESSION['form_stats'] == 'tab')
{
array_unshift($data, array('LABEL' => _DOCTYPE, 'VALUE' => _NB_MAILS1));
}
//echo $src1;
if($has_data)
{
if($_SESSION['form_stats'] == 'graph')
{
?>

show_stats_array($title, $data);
}
}
else
{
echo '
'._NO_DATA_MESSAGE.'
';
}
}
}
?>