.
*/
include("./include/include.php");
admin_header(true, true);
if( !in_array("statistics_view", $_SESSION['sess_functions']) ) {
echoln("You are not authorized to see this page.");
}else {
header ("Content-type: image/png"); //use PNG, smaller in size, and better quality for text
switch( $_GET['show'] ) {
case "perday":
$query="SELECT LEFT(`Created`,10) AS `ApplicationDay`, COUNT(`id`) AS `Number`
FROM `applications`
WHERE ".$_SESSION['sess_sel']."
GROUP BY LEFT(`Created`,10)";
if( @mysql_num_rows($res=doquery($query))>0 ) {
// Read data
$count=0;
$total=0;
$startday=mktime(0, 0, 0, substr($setup['EventDateAppStart'], 3, 2), substr($setup['EventDateAppStart'], 0, 2), substr($setup['EventDateAppStart'], 6, 4))/(24*3600);
$deadlineday=mktime(0, 0, 0, substr($setup['EventDateAppEnd'], 3, 2), substr($setup['EventDateAppEnd'], 0, 2), substr($setup['EventDateAppEnd'], 6, 4))/(24*3600);
$endday=mktime(1, 0, 0, substr($setup['EventDateAppEndReal'], 3, 2), substr($setup['EventDateAppEndReal'], 0, 2), substr($setup['EventDateAppEndReal'], 6, 4))/(24*3600);
$data=array();
while( $row=mysql_fetch_array($res) ) {
$count++;
$total+=$row['Number'];
$day=(mktime(1, 0, 0, substr($row['ApplicationDay'], 5, 2), substr($row['ApplicationDay'], 8, 2), substr($row['ApplicationDay'], 0, 4))/(24*3600)-$startday);
$data[ $day ]=$total;
}
//Initialize image
$sw=500/($endday-$startday); // Scale width
$sh=min(1, 500/$total); // Scale height
$wl=35; // White space left
$wr=10; // White space right
$wt=10; // White space top
$wb=40; // White space bottom
$gw = ($endday-$startday)*$sw; // graphic width
$gh = $total*$sh; // graphic height
$im = imagecreate($gw+$wl+$wr, $gh+$wt+$wb);
$background_color = imagecolorallocate($im, 245, 245, 245);
$grid_color = imagecolorallocate($im, 204, 204, 204);
$text_color = imagecolorallocate($im, 0, 0, 0);
$weekend_color = imagecolorallocate($im, 100, 100, 100);
$line_color = imagecolorallocate($im, 0, 0, 255);
$deadline_color = imagecolorallocate($im, 255, 0, 0);
//Draw axis
imageline($im, $wl, $gh+$wt, $gw+$wl, $gh+$wt, $text_color);
imageline($im, $wl, $gh+$wt, $wl, $wt, $text_color);
//Draw vertical grid+labels
if( date("w", $startday*(24*3600))==0 OR date("w", $startday*(24*3600))==6 )
imagestringup($im, 2, $wl-6, $gh+$wt+32, date("d.m", $startday*(24*3600)), $weekend_color);
else
imagestringup($im, 2, $wl-6, $gh+$wt+32, date("d.m", $startday*(24*3600)), $text_color);
for( $i=1; $i<($endday-$startday+1); $i++ ) { // vertical grid
imageline($im, ($i)*$sw+$wl, $gh+$wt-1, ($i)*$sw+$wl, $wt, $grid_color);
if( date("w", ($startday+$i)*(24*3600))==0 OR date("w", ($startday+$i)*(24*3600))==6 )
imagestringup($im, 2, ($i)*$sw+$wl-6, $gh+$wt+32, date("d.m", ($startday+$i)*(24*3600)), $weekend_color);
else
imagestringup($im, 2, ($i)*$sw+$wl-6, $gh+$wt+32, date("d.m", ($startday+$i)*(24*3600)), $text_color);
}
//Draw horizontal grid+labels
for( $i=50*$sh; $i<$gh; $i+=50*$sh ) { // horizontal grid
imageline($im, $wl+1, -$i+$gh+$wt, $gw+$wl, -$i+$gh+$wt, $grid_color);
imagestring($im, 2, $wl-2-imagefontwidth(2)*strlen($i/$sh), -$i+$gh+$wt-6, ($i/$sh), $text_color);
}
//Draw deadline
imageline($im, ($deadlineday-$startday)*$sw+$wl, $gh+$wt, ($deadlineday-$startday)*$sw+$wl, $wt, $deadline_color);
//Draw grafic
$ak=array_keys($data);
for( $i=1; $i