89 lines
2.6 KiB
PHP
89 lines
2.6 KiB
PHP
|
<?php
|
||
|
// $Header: /cvsroot/phptsmadmin/phpTSMadmin/htdocs/image.schedule.gantt.php,v 1.2 2009/04/19 03:54:40 wurley Exp $
|
||
|
|
||
|
# TODO:
|
||
|
# Need better date handling - currently this script misses out events that start before midnight, but flow into today.
|
||
|
# Want to make a week/month view, or select the day to view.
|
||
|
# Currently only DURUNITS of HOUR schedules are shown.
|
||
|
# Currently ASSUMES PERUNITS of DAY.
|
||
|
|
||
|
# Required Libraries
|
||
|
require './common.php';
|
||
|
initJPGraph(true);
|
||
|
|
||
|
# Defaults
|
||
|
# Get Schedules
|
||
|
$dayOfWeek = strtoupper(strftime('%A',time()));
|
||
|
$todayDate = strftime('%y-%m-%d',time());
|
||
|
|
||
|
$tsmSchedAdmins = $app['server']->query("select * from ADMIN_SCHEDULES where DAYOFWEEK in ('ANY','".$dayOfWeek."')",null,'SCHEDULE_NAME');
|
||
|
$tsmSchedClients = $app['server']->query("select * from CLIENT_SCHEDULES where DAYOFWEEK in ('ANY','".$dayOfWeek."')",null,'SCHEDULE_NAME');
|
||
|
|
||
|
# A new graph with automatic size
|
||
|
$graph = new GanttGraph(0,0,"auto");
|
||
|
|
||
|
# Only show the current date.
|
||
|
$graph->SetDateRange($todayDate,$todayDate);
|
||
|
|
||
|
$graph->SetMarginColor('#eeeeff');
|
||
|
$graph->SetFrame(true,'#eeeeff',0);
|
||
|
|
||
|
# We want to display day, hour and minute scales
|
||
|
$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR | GANTT_HMIN);
|
||
|
|
||
|
# Setup hour format
|
||
|
$graph->scale->hour->SetIntervall(1);
|
||
|
$graph->scale->hour->SetStyle(HOURSTYLE_H24);
|
||
|
$graph->scale->minute->SetIntervall(30);
|
||
|
$graph->hgrid->Show();
|
||
|
$graph->hgrid->SetRowFillColor('darkred@0.85');
|
||
|
|
||
|
$item = 0;
|
||
|
|
||
|
# Admin Schedules
|
||
|
if ($tsmSchedAdmins) {
|
||
|
foreach ($tsmSchedAdmins as $tsmSchedAdmin) {
|
||
|
|
||
|
if ($tsmSchedAdmin['DURUNITS'] == 'HOURS') {
|
||
|
$activity = new GanttBar($item,$tsmSchedAdmin['SCHEDULE_NAME'].
|
||
|
($tsmSchedAdmin['DESCRIPTION'] ? ' ('.$tsmSchedAdmin['DESCRIPTION'].')' : null),
|
||
|
strftime('%Y-%m-%d',time()).' '.$tsmSchedAdmin['STARTTIME'],
|
||
|
$tsmSchedAdmin['DURATION']/24);
|
||
|
|
||
|
if ($tsmSchedAdmin['ACTIVE'] == "NO") {
|
||
|
$activity->SetColor('gray');
|
||
|
$activity->SetPattern(GANTT_SOLID,'gray',50);
|
||
|
}
|
||
|
|
||
|
$item++;
|
||
|
$graph->Add($activity);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$item++;
|
||
|
|
||
|
# ClientSchedules
|
||
|
if ($tsmSchedClients) {
|
||
|
foreach ($tsmSchedClients as $tsmSchedAdmin) {
|
||
|
|
||
|
if ($tsmSchedAdmin['DURUNITS'] == 'HOURS') {
|
||
|
$activity = new GanttBar($item,$tsmSchedAdmin['SCHEDULE_NAME'].
|
||
|
($tsmSchedAdmin['DESCRIPTION'] ? ' ('.$tsmSchedAdmin['DESCRIPTION'].')' : null),
|
||
|
strftime('%Y-%m-%d',time()).' '.$tsmSchedAdmin['STARTTIME'],
|
||
|
$tsmSchedAdmin['DURATION']/24);
|
||
|
|
||
|
$item++;
|
||
|
$graph->Add($activity);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
# Show the current time.
|
||
|
$vline = new GanttVLine (strftime('%Y-%m-%d %H:%M',time()),"", "darkred",5);
|
||
|
$graph->Add($vline);
|
||
|
|
||
|
# Display the Gantt chart
|
||
|
$graph->Stroke();
|
||
|
?>
|