Location: PHPKode > projects > Work Tracker > work-tracker-0.1/modules/reports/reports.php
<?php
/* $Id: reports.php,v 1.2 2006/01/27 22:52:02 rschilling Exp $ */

if (eregi(basename(__FILE__),$_SERVER['PHP_SELF'])) {
  print "Direct module access forbidden.";
  exit;
}

$fields = array(
  "assigned_to" => "Technician Assigned",
  "opened_by"   => "Work Item Owner (Opened By)",
  "opened"      => "Time Opened",
  "closed"      => "Time Closed",
  "modified"    => "Last Modified",
  "status"      => "Work Item Status",
  "category"    => "Work Item Category",
  "product"     => "Work Item Product",
  "severity"    => "Work Item Severity",
  "problem"     => "Work Item Problem"
);

$options = array(
  "avgclose"    => "Average Resolution Time",
  "maxclose"    => "Maximum Resolution Time",
  "avgfirst"    => "Average Time for First Response",
  "maxfirst"    => "Maximum Time for First Response",
  "percat"      => "Work Items Per Category",
  "perstat"     => "Work Items Per Status",
  "perprod"     => "Work Items Per Product",
  "persev"      => "Work Items Per Severity",
  "pertech"     => "Work Items Per Technician",
  "opened"      => "Number of Work Items Opened",
  "resolved"    => "Number of Work Items Resolved",
  "numevents"   => "Number of Events Entered"
);
  
if (is_employee()) {
  $options['escto'] = "Work Items Escalated To Group";
  $options['escfrom'] = "Work Items Escalated From Group";
  $options['numhours'] = "Number of Hours Logged";
  
  if (is_manager()) {
    $sql  = "SELECT gid ";
    $sql .= "FROM groups ";
    $sql .= "ORDER BY name";
    $groups = $dbi->fetch_all($sql);
    $smarty->assign('groups',$groups);
  } else {
    $smarty->assign('groups',$_SESSION['groups']);
  }

  $template = "reports/employee.tpl";
} else {
  if (empty($_POST['gid']) and $_SESSION['group_count'] == 1) {
    $_POST['gid'] = $_SESSION['groups'][0];
  }

  $template = "reports/client.tpl";
}

$saved = array();
$sql  = "SELECT rid,name ";
$sql .= "FROM reports ";
$sql .= "WHERE userid='".$_SESSION['userid']."' ";
$sql .= "ORDER BY name";
$reports = $dbi->fetch_all($sql,"array");
if (is_array($reports)) {
  foreach ($reports as $report) {
    $saved[$report['rid']] = $report['name'];
  }
}
$smarty->assign('saved',$saved);
$smarty->assign('options',$options);
$smarty->assign('fields',$fields);
$smarty->display($template);
?>
Return current item: Work Tracker