This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
phptsmadmin/htdocs/gantt.activity.php
2011-01-14 01:45:19 +11:00

117 lines
3.8 KiB
PHP

<?php
// $Header: /cvsroot/phptsmadmin/phpTSMadmin/htdocs/gantt.activity.php,v 1.6 2008/07/01 01:18:34 wurley Exp $
# Required Libraries
require './common.php';
initJPGraph(true);
# Defaults
$reportEnd = strftime('%y-%m-%d %H:%M',time());
$reportStart = strftime('%y-%m-%d %H:%M',time()-86400);
$startActivities['811'] = array('start'=>'Expire Inventory');
$startActivities['812'] = array('success'=>'Expire Inventory');
$startActivities['2562'] = array('start'=>'Event Records Delete');
$startActivities['2564'] = array('success'=>'Event Records Delete');
$startActivities['2102'] = array('start'=>'Activity Log Delete');
$startActivities['2102'] = array('success'=>'Activity Log Delete');
$startActivities['2280'] = array('start'=>'DB Backup');
$startActivities['4550'] = array('success'=>'DB Backup');
$startActivities['406'] = array('start'=>'Session');
$startActivities['403'] = array('success'=>'Session');
# Admin schedules
$tsmActivitys = TSMQuery($_REQUEST['server_id'],"select date(DATE_TIME) as DATE,time(DATE_TIME) as TIME,MSGNO from ACTLOG where ORIGINATOR='SERVER' and DATE_TIME \> '$reportStart' and MSGNO in (".implode(",",array_keys($startActivities)).")");
foreach ($tsmActivitys as $tsmActivity) {
$datetime = $tsmActivity['DATE']." ".(preg_replace('/(.*:.*):.*/',"$1",$tsmActivity['TIME']));
$msgNum = $tsmActivity['MSGNO'];
# Do we know this message number?
if (isset($startActivities[$msgNum])) {
# New Event.
if (isset($startActivities[$msgNum]['start'])) {
$activity[$startActivities[$msgNum]['start']][]['start'] = $datetime;
} else if (isset($startActivities[$msgNum]['success'])) {
$item = (isset($activity[$startActivities[$msgNum]['success']]) ?
count($activity[$startActivities[$msgNum]['success']])-1 : 0);
# Is there a start event.
if (! isset($activity[$startActivities[$msgNum]['success']][$item]['start'])) {
$activity[$startActivities[$msgNum]['success']][$item]['start'] = $datetime;
}
$activity[$startActivities[$msgNum]['success']][$item]['end'] = $datetime;
} else {
print "Che? Unknown index??";
}
} else {
}
}
// A new graph with automatic size
$graph = new GanttGraph(0,0,"auto");
$item = 0;
# Admin Schedules
foreach ($activity as $tsmSchedAdmin => $value) {
foreach ($value as $instance) {
printf ("Drawing [%s] [%s] [%s] [%s]<BR>",$item,$tsmSchedAdmin,$instance['start'],($instance['end'] ? $instance['end'] : $instance['start']));
$activity = new GanttBar($item,$tsmSchedAdmin,$instance['start'],($instance['end'] ? $instance['end'] : $instance['start']));
$item++;
$graph->Add($activity);
}
}
$graph->SetMarginColor('white');
$graph->SetFrame(false);
// We want to display day, hour and minute scales
$graph->ShowHeaders(GANTT_HDAY | GANTT_HHOUR | GANTT_HMIN);
$graph->hgrid->Show();
$graph->hgrid->SetRowFillColor('darkred@0.85');
$graph->hgrid->line->SetColor('red@0.85');
$graph->hgrid->line->Show(false);
// A new activity on row '0'
// Setup hour format
$graph->scale->hour->SetIntervall(1);
$graph->scale->hour->SetStyle(HOURSTYLE_H24);
$graph->scale->minute->SetIntervall(30);
// Display the Gantt chart
$graph->Stroke();
die();
# Block Title
$blockTitle = _('Server Status for').'&nbsp;'.TSMServerName($_REQUEST['server_id']);
$blockBody = '<table border="0" cellpadding="0" cellspacing="0" class="blockcitem">';
# Client Details
$blockBody .= '<tr><th colspan=2 class="title">&nbsp;Clients</th><th class="title">&nbsp;</th></tr>';
#$blockBody .= sprintf('<tr><td>&nbsp;</td><td>'.
# classValue(_('%s clients registered to this TSM server.'),'value').
# '</td><td>&nbsp;</td></tr>',
# count($tsmClientsTotal));
$blockBody .= '<tr><td colspan=3>&nbsp;</td></tr>';
# End
$blockBody .= '</table>';
$left = ''; # Use default left blocks.
$centre = buildBlock("centre",$blockTitle,$blockBody);
$right = ''; # Use default right blocks.
print buildPage($left,$centre,$right);
?>