php?> // Define the page type define ("AUTHTYPE", "user"); // Include the Necessary Files for Correct Operation require_once("./config.php"); require_once("./includes/init.php"); //print html search boxes print " Reports
Search by Tech


Month Day Year


Daily Report
Month Day Year


Monthly Report
Month Year


Yearly Report
Year
"; ########SEARCH BY TECH if ($_GET['cmd'] == "search"){ $tech = $_POST['tech']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $date = "$month-$day-$year"; $query = "SELECT * FROM " . PREFIX . "actionlog WHERE action = 'Ticket replied by' && username = '$tech' && FROM_UNIXTIME( date, '%m' ) = $month && FROM_UNIXTIME( date, '%d' ) = $day && FROM_UNIXTIME( date, '%Y' ) = $year"; $result = mysql_query("$query") or die ("Query; $query :" . mysql_error()); $i = "0"; while ($row = mysql_fetch_array($result)) { $i++; print "Ticket ID: $row[ticket_id]
"; } print "
total: $i"; print "
posted date $date"; } ###### YEARLY REPORT if ($_GET['cmd'] == "yearly"){ $year = $_POST['year']; $query = "SELECT " . PREFIX . "staff.fullname, " . PREFIX . "staff.userid FROM " . PREFIX . "staff ORDER BY " . PREFIX . "staff.userid ASC"; $iduser = mysql_query("$query"); print " "; $i = "1"; while ($row = mysql_fetch_array($iduser)) { $tquery = "SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$i' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'"; $tickets = mysql_num_rows(mysql_query($tquery)); print " "; $aquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$i' ORDER BY " . PREFIX . "staff.userid ASC")); if ($aquery > 0){ print " "; } else { $a = $i; do { $a++; $bquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$a' ORDER BY " . PREFIX . "staff.userid ASC")); } while ($bquery == NULL); $ticketsb = mysql_num_rows(mysql_query("SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$a' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'")); print " "; $i = $a; } $i++; } print "
User Closed
$row[fullname]$tickets
$ticketsb
"; } ########### MONTHLY REPORT if ($_GET['cmd'] == "monthly"){ $month = $_POST['month']; $year = $_POST['year']; $query = "SELECT " . PREFIX . "staff.fullname, " . PREFIX . "staff.userid FROM " . PREFIX . "staff ORDER BY " . PREFIX . "staff.userid ASC"; $iduser = mysql_query("$query"); print " "; $i = "1"; while ($row = mysql_fetch_array($iduser)) { $tquery = "SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$i' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%m' ) = '$month' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'"; $tickets = mysql_num_rows(mysql_query($tquery)); print " "; $aquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$i' ORDER BY " . PREFIX . "staff.userid ASC")); if ($aquery > 0){ print " "; } else { $a = $i; do { $a++; $bquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$a' ORDER BY " . PREFIX . "staff.userid ASC")); } while ($bquery == NULL); $ticketsb = mysql_num_rows(mysql_query("SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$a' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%m' ) = '$month' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'")); print " "; $i = $a; } $i++; } print "
User Closed
$row[fullname]$tickets
$ticketsb
"; } ############# Daily Report if ($_GET['cmd'] == "daily"){ $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $query = "SELECT " . PREFIX . "staff.fullname, " . PREFIX . "staff.userid FROM " . PREFIX . "staff ORDER BY " . PREFIX . "staff.userid ASC"; $iduser = mysql_query("$query"); print " "; $i = "1"; while ($row = mysql_fetch_array($iduser)) { $tquery = "SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$i' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%d' ) = '$day' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%m' ) = '$month' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'"; $tickets = mysql_num_rows(mysql_query($tquery)); print " "; $aquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$i' ORDER BY " . PREFIX . "staff.userid ASC")); if ($aquery > 0){ print " "; } else { $a = $i; do { $a++; $bquery = mysql_num_rows(mysql_query("SELECT " . PREFIX . "staff.userid FROM " . PREFIX . "staff WHERE " . PREFIX . "staff.userid = '$a' ORDER BY " . PREFIX . "staff.userid ASC")); } while ($bquery == NULL); $ticketsb = mysql_num_rows(mysql_query("SELECT * FROM " . PREFIX . "actionlog, " . PREFIX . "staff WHERE " . PREFIX . "actionlog.action = 'Ticket replied by' && " . PREFIX . "actionlog.username = " . PREFIX . "staff.fullname && " . PREFIX . "staff.userid = '$a' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%d' ) = '$day' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%m' ) = '$month' && FROM_UNIXTIME( " . PREFIX . "actionlog.date, '%Y' ) = '$year'")); print " "; $i = $a; } $i++; } print "
User Closed
$row[fullname]$tickets
$ticketsb
"; } print "
"; ?>