backoffice/html/stats/index.php
2011-06-21 13:28:10 +00:00

137 lines
4.2 KiB
PHP

<?php
/**
* Inclusion du fichier de configuration des includes Métiers de S&D
*/
include '/var/www/includes/config.php';
/**
* Inclusion du Framework
*/
if( !defined('FWK_PATH') )
include '/var/www/framework/fwk.php';
$t1=microtime_float();
include_once(INCLUDE_PATH.'insee/classMInsee.php');
include_once(INCLUDE_PATH.'bodacc/classMBodacc.php');
include_once(FWK_PATH.'common/dates.php');
$iDb=new WDB('jo');
$iDb2=new WDB('sdv1');
session_start();
$authorized = false;
if(isset($_GET['logout']) && ($_SESSION['auth'])) {
$_SESSION['auth'] = null;
session_destroy();
echo "logging out...";
}
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
$user=addslashes(trim($_SERVER['PHP_AUTH_USER']));
$pwd =addslashes(trim($_SERVER['PHP_AUTH_PW']));
$tabTmp=$iDb2->select( 'utilisateurs',
'id, email',
"login='$user' AND password='$pwd' AND idClient=1 AND actif=1 AND deleted=0");
$_SESSION['userId']=$tabTmp[0][0];
$_SESSION['userMail']=$tabTmp[0][1];
if ( $_SESSION['userId'] ) {//&& $_SESSION['auth']) {
$authorized = true;
}
} else {
//if (isset($_GET["login"]) && (! $authorized)) {
header('WWW-Authenticate: Basic Realm="Login please"');
header('HTTP/1.0 401 Unauthorized');
$_SESSION['auth'] = true;
print('Login now or forever hold your clicks...');
exit;
}
if (!$authorized) {
?><h1>you have <? echo ($authorized) ? '' : 'not'; ?> logged!</h1><?
} else {
$Y=date('Y')-1;
$m=date('m');
?>
<h3 align="center">Requêtes Mensuelles Extranet/WS</h3>
<?
// WS Infogreffe
$tabConsos=$iDb->select('sdv1.`logs`',
"date(dateHeure) AS jour, page, COUNT(*) AS nb, YEAR(dateHeure) AS annee, MONTH(dateHeure) AS mois",
"dateHeure>='$Y-$m-01' AND siren<>552144503
GROUP BY annee, mois, page
ORDER BY annee, mois, page", false, MYSQL_ASSOC);
$tabAff=array();
foreach ($tabConsos as $tabConso) {
$mois=''.sprintf('%02s',$tabConso['mois']).'/'.$tabConso['annee'];
$page=trim(''.$tabConso['page']);
if ($page<>'') {
$tabPages[]=$page;
@$tabAff[$mois][$page]=$tabConso['nb'];
}
}
$tabPages=array_unique($tabPages);
?>
<table BgColor="#177AE9" cellspacing="1" cellpadding="2" border="0" align="center" BorderColor="#000020">
<tr>
<td align="center"><b><font color="Black">Mois/Ann&eacute;e</font></b></td>
<?
foreach (@$tabPages as $page) {
/*switch ($page) {
case 'competences': $page='Comp.'; break;
case 'dirigeants': $page='Diri.'; break;
case 'etablissements': $page='Etabs'; break;
case 'commandeAsso': $page='Asso'; break;
case 'redirection_gmap':$page='Gmap'; break;
case 'international_identi':$page='Graydon';break;
case 'enqueteDemNF': $page='Enquetes';break;
case 'greffe_':
case 'greffe_statuts':
case 'greffe_actes': $page='Actes'; break;
case 'greffe_bilans': $page='Bilans'; break;
case 'avis_situation': $page='Avis'; break;
case 'bilans': $page='Liasse'; break;
case 'rsynthese':
case 'rsynthesemin': $page=''; break;
}*/
//synthese commandeAsso enqueteDemNF greffe_statuts
//kbis privileges redirection_gmap scorecsf international_identi flux indiscore2
//indiscore3 greffe_ liassexls
if ($page<>'') {
?>
<td align="center"><b><font color="Black"><?=@trim($page)?></font></b></td>
<? }
} ?>
</tr>
<?
foreach (@$tabAff as $moisAnnee=>$tabConso) {
?><tr BgColor="#E2EEFC">
<td align="center"><?=$moisAnnee?></td>
<?
$total=0;
foreach (@$tabPages as $page) {
$ignore=false;
/*switch ($page) {
case 'rsynthese': $page='indiscore3'; @$tabConso[$page]+=@$tabConso['rsynthese']; $ignore=true; break;
case 'rsynthesemin': $page='indiscore2'; @$tabConso[$page]+=@$tabConso['rsynthesemin']; $ignore=true; break;
case 'greffe_': $page='greffe_actes'; @$tabConso[$page]+=@$tabConso['greffe_']; $ignore=true; break;
case 'greffe_statuts': $page='greffe_actes'; @$tabConso[$page]+=@$tabConso['greffe_statuts']; $ignore=true; break;
}*/
$total+=@$tabConso[$page]*1;
if (!$ignore) {
?>
<td align="right">&nbsp;<?=@number_format($tabConso[$page]*1,0,'.',chr(160))?></td>
<?
}
}
echo '<td align="right"><b>'.number_format($total,0,'.',chr(160)).'</b></td></tr>';
}
?>
</table><br/>
<?
}
?>