1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
//if we have the two parameters we create the graph
if (isset($_POST['appname']) && $_POST['appname'] != null && isset($_POST['projname']) && $_POST['projname'] != null && isset($_POST['period']) && $_POST['period'] != null)
{
$appname = htmlentities($_POST['appname']);
$projname = htmlentities($_POST['projname']);
$period = htmlentities($_POST['period']);
//connection to the database
$connect = connexion();
//we create the request functions of the period and we print a title
if ($period == 'week')
{
$requeteSQL = 'SELECT nb_statsappli, statsappli FROM statsappliDay WHERE AppName=\''.escapeRequest($appname).'\' AND ProjName=\''.escapeRequest($projname).'\' AND to_char(day, \'IW\')=to_char(sysdate, \'IW\')';
echo '<h2>Graphics for week '.date('W').'</h2>';
}
else if ($period == 'month')
{
$requeteSQL = 'SELECT nb_statsappli, statsappli FROM statsappliDay WHERE AppName=\''.escapeRequest($appname).'\' AND ProjName=\''.escapeRequest($projname).'\' AND to_char(day, \'MM\')=to_char(sysdate, \'MM\')';
echo '<h2>Graphics for '.date('F').'</h2>';
}
else if ($period == 'quarter')
{
$requeteSQL = 'SELECT nb_statsappli, statsappli FROM statsappliDay WHERE AppName=\''.escapeRequest($appname).'\' AND ProjName=\''.escapeRequest($projname).'\' AND to_char(day, \'q\')=to_char(sysdate, \'q\')';
if (1 <= date('m') && date('m') <= 3)
{
echo '<h2>Graphics for first quarter</h2>';
}
else if (4 <= date('m') && date('m') <= 6)
{
echo '<h2>Graphics for second quarter</h2>';
}
else if (7 <= date('m') && date('m') <= 9)
{
echo '<h2>Graphics for third quarter</h2>';
}
else if (10 <= date('m') && date('m') <= 12)
{
echo '<h2>Graphics for fourth quarter</h2>';
}
}
else if ($period == 'year')
{
$requeteSQL = 'SELECT nb_statsappli, statsappli FROM statsappliDay WHERE AppName=\''.escapeRequest($appname).'\' AND ProjName=\''.escapeRequest($projname).'\' AND to_char(day, \'YYYY\')=to_char(sysdate, \'YYYY\')';
echo '<h2>Graphics for year '.date('Y').'</h2>';
}
//execution of the request
$res = requete($connect, $requeteSQL);
//if the request doesn't return anything we print the error
if (!$res['exec_req'])
{
$exec_err = oci_error($res['stmt']);
$ERR_TXT = "Erreur Oracle ".$exec_err['code']." - ".$exec_err['message'];
echo '<p>'.$ERR_TXT.'</p>';
mail('@mail', 'Erreur lors d\'une requête SQL ...', $ERR_TXT);
}
//else we get the stats
{
$stats['ko'] = 0;
$stats['ok'] = 0;
while ($appstatus = oci_fetch_assoc($res['stmt']))
{
foreach ($appstatus as $champ => $val)
{
$status[$champ] = $val;
}
if ($status['STATSAPPLI'] == 0)
{
$stats['ko'] += $status['NB_STATSAPPLI'];
}
else if ($status['STATSAPPLI'] == 1)
{
$stats['ok'] += $status['NB_STATSAPPLI'];
}
}
//if we have no state, we print a message
if ($stats['ok'] == 0 && $stats['ko'] == 0)
{
echo '<p>No stats availables.</p>';
}
//else we print the graph
else
{
//création et affichage du graphique
}
}
deconnexion($connect, $res['stmt']);
}
?> |
Partager