<?php
/*
* Created on Jul 23, 2009
*
* Author:: Muhammed Nilufer Nilar
*
*/
require_once('../classes/SupportRequest.php');
require_once('../classes/Customer.php');
if( isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == false ) {
//echo "dfsd";exit;
//echo "<pre>";print_r($_GET);print_r($_POST);print_r($_SESSION);exit;
header("Location: ./login.php");
exit();
}
function flushRequestTemplate($obj=null, $msg=null){
?>
<html>
<head>
<title>Support Request Form</title>
<link href="../templates/css/css.css" rel="stylesheet" type="text/css">
<!-- Author: Bazillyo - hide@address.com - http://www.geocities.com/bazillyo/spiffy/calendar/ -->
<!-- Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/ -->
<link rel="stylesheet" type="text/css" href="../js/spiffyCal.css">
<script language="JavaScript" src="../js/spiffyCal.js"></script>
<script language="javascript">
var cal1=new ctlSpiffyCalendarBox("cal1", "suportForm", "date","btnDate1", "<?php if($obj != null) echo $obj->date; ?>", 2);
</script>
</head>
<body>
<div id="spiffycalendar" class="text"></div>
<h2>Support Request Form</h2>
<?php if($msg != null){
echo $msg;
}
?>
<?php //echo "<pre>"; print_r($obj);exit; ?>
<form name='suportForm' id='supportForm' onsubmit='validate' method='POST' action='./SupportController.php?code=add'>
<input type='hidden' name='id' id='id' <?php if($obj != null) echo "value=" . $obj->id; ?> />
<table>
<tr class="even">
<td><label><?php echo "Summary";?></label></td>
<td><input type='text' name='summary' size="75" id='summary'<?php if($obj != null) echo "value='" . $obj->summary . "'"; ?>/></td>
</tr>
<tr class="odd">
<td><label><?php echo "Customer";?></label></td>
<td>
<select name='cmbcustomer' id='cmbcustomer' size="1">
<?php
$customers = Customer::fetchAllCustomers();
//print_r($customers);exit;
foreach($customers as $cstmr){
?>
<option value=<?php echo "'" . $cstmr->id . "'"; if($obj != null) echo ($obj->customer == $cstmr->id)? " selected":""; ?>>
<?php echo $cstmr->companyName; ?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr class="even">
<td><label><?php echo "Date";?></label></td>
<td><SCRIPT language="JavaScript">cal1.writeControl();</SCRIPT></td>
</tr>
<tr class="odd">
<td><label><?php echo "Status";?></label></td>
<td>
<select name="status" size="1">
<option value='Open'<?php if($obj != null) echo ($obj->status == 'Open')? "selected":""; ?>>Open</option>
<option value='Pending'<?php if($obj != null) echo ($obj->status == 'Pending')? "selected":""; ?>>Pending</option>
<option value='Resolved'<?php if($obj != null) echo ($obj->status == 'Resolved')? "selected":""; ?>>Resolved</option>
<option value='Removed'<?php if($obj != null) echo ($obj->status == 'Removed')? "selected":""; ?>>Removed</option>
</select>
</td>
</tr>
<tr class="even">
<td><label><?php echo "Description";?></label></td>
<?php
if($obj != null){
echo "<td>" . nl2br($obj->description) . "</td>";
}else{
?>
<td><textarea name='description' id='description' cols="75" rows="7"></textarea></td>
<?php
}
?>
<!-- <td><textarea name='description' id='description' cols="75" rows="7"><?php //if($obj != null) echo nl2br($obj->description); ?></textarea></td> -->
</tr>
<tr class="odd">
<td><input type='submit' name='submit' id='submit' value='Save'/></td>
<td><?php if($obj != null) echo "Last modified on $obj->lastUpdatedOn by $obj->lastUpdatedBy"; ?></td>
</tr>
</table>
</form>
<?php
if($obj != null) {
?>
<br><br><label>Add a Comment</label><br>
<form name='commentForm' id='commentForm' onsubmit='validateComment' method='POST' action='./SupportController.php?code=comment'>
<input type='hidden' name='requestID' id='requestID' <?php if($obj != null) echo "value=" . $obj->id; ?> />
<textarea name='txtcomment' id='txtcomment' cols="75" rows="7"></textarea><br>
<input type='submit' name='submit' id='submit' value='Add'/><br>
</form>
<?php
//the comments go here.
if(is_array($obj->comments)){
echo "<br><br><table width='900px'>";
foreach( $obj->comments as $comment){
// print_r($comment);
echo "<tr class='odd'>";
echo "<td><label>Comment added by $comment->addedBy</lable><td><label>Added on $comment->dateAdded.</label></td>";
echo "</tr>";
echo "<tr class='even'>";
echo "<td colspan='2'>" . nl2br($comment->comment) . "</td>";
echo "</tr><tr></tr>";
}
echo "</table>";
}
}
?>
</body>
</html>
<?php
}
/*
* here $code can be only one of 'all', 'plan' or 'status'.
*/
function flushListTemplate($requestsArr, $numOfpages, $pgNo, $filterBy='all', $filterValue=null){
?>
<html>
<head>
<title>Support Requests complete list</title>
<link rel="stylesheet" type="text/css" href="../templates/css/css.css">
</head>
<body>
<?php
$i = 1;
echo "Go to page ";
while($numOfpages != 0){
if( $i != $pgNo){
if($filterBy == 'all'){
echo "<a href='SupportController.php?code=all&pgno=$i'>$i</a>   ";
}
else{
echo "<a href='SupportController.php?code=filter&by=$filterBy&value=$filterValue&pgno=$i'>$i</a>   ";
}
}
else{
echo "$i   ";
}
$numOfpages--;
$i++;
}
?>
<h2>Support Requests complete list</h2>
<!-- todo tableborder to be shown -->
<div class='tableDiv'>
<table id='RequestList' width="900px">
<tr>
<th>ID</th>
<th>Summary</th>
<th>Customer</th>
<th>Plan</th>
<th>Date</th>
<th>Status</th>
<th>Delete</th>
<th>Updated On</th>
<th>Updated By</th>
</tr>
<?php
$rowCount = 1;
foreach($requestsArr as $rqst){
?>
<tr class='<?php echo ($rowCount%2==0)?"even":"odd" ; $rowCount++; ?>'>
<td><?php echo $rqst->id; ?></td>
<td><a href="SupportController.php?code=single&id=<?php echo $rqst->id; ?>"><?php echo $rqst->summary; ?></a></td>
<td><?php echo $rqst->customer; ?></td>
<td><?php echo $rqst->customerPlan; ?></td>
<td><?php echo $rqst->date; ?></td>
<td><?php echo $rqst->status; ?></td>
<td class="redhighlight"><a href="SupportController.php?code=delete&id=<?php echo $rqst->id; ?>"> <img src="../templates/images/delete4.png" width="35px" height="20px" alt="Delete"/><?php //echo "X"; ?></a></td>
<td><?php echo $rqst->lastUpdatedOn; ?></td>
<td><?php echo $rqst->lastUpdatedBy; ?></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
<?php
}
function showSearchForm($requestsArr=null, $numOfpages=null, $pgNo=null, $paramString=null, $count=null){
?>
<html>
<head>
<title>Support Reuest Search Form</title>
<link rel="stylesheet" type="text/css" href="../templates/css/css.css">
<!-- Author: Bazillyo - hide@address.com - http://www.geocities.com/bazillyo/spiffy/calendar/ -->
<!-- Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/ -->
<link rel="stylesheet" type="text/css" href="../js/spiffyCal.css">
<script language="JavaScript" src="../js/spiffyCal.js"></script>
<script language="javascript">
var cal1=new ctlSpiffyCalendarBox("cal1", "searchForm", "date","btnDate", "<?php //if($_GET['date'] != null) echo $_GET['date']; ?>", 2);
</script>
</head>
<body>
<h2>Support Reuest Search Form</h2>
<form name='searchForm' id='searchForm' onsubmit='validate' method='GET' action='./SupportController.php'>
<input type="hidden" name="code" id="code" value="search"/>
<input type="hidden" name="by" id="by" value="plan"/>
<table>
<tr class="odd">
<td><label><?php echo "Plan";?></label></td>
<td>
<select name='plan' id='plan' size="1">
<option value="0"<?php if( ($_GET['plan'] == null) || ($_GET['plan'] == 0) ) echo "selected"; ?>>All</option>
<?php
$plans = Plan::fetchAllPlans();
//print_r($customers);exit;
foreach($plans as $plan){
?>
<option value=<?php echo "'" . $plan->id . "'"; if($_GET['plan'] != null) echo ($_GET['plan'] == $plan->id)? " selected":""; ?>>
<?php echo $plan->name; ?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr class="even">
<td><label><?php echo "Status";?></label></td>
<td>
<select name='status' id='status' size="1">
<option value="All"<?php if( ($_GET['status'] == null) or ($_GET['status'] == 0) ) echo "selected"; ?>>All</option>
<?php
$statuses = SupportRequest::getAllStatuses();
//print_r($customers);exit;
foreach($statuses as $status){
?>
<option value=<?php echo "'" . $status . "'"; if($_GET['status'] != null) echo ($_GET['status'] == $status)? " selected":""; ?>>
<?php echo $status; ?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr class="odd">
<td><label><?php echo "Reported ";?></label></td>
<td>
before<input name="when" id="when" type="radio" value="before" <?php if($_GET['status'] != null) echo ($_GET['when'] == "before")? " checked":""; ?>/>after<input name="when" id="when" type="radio" value="after" <?php if($_GET['status'] != null) echo ($_GET['when'] == "after")? " checked":"" ?>/>
<SCRIPT language="JavaScript">cal1.writeControl();</SCRIPT>
<!-- <input type="text" name="date" id="date" value="<?php if($_GET['date'] != null) echo $_GET['date']; ?>"/> -->
</td>
</tr>
<tr class="even">
<td><input type='submit' name='submit' id='submit' value='Search'/></td>
<td/>
</tr>
</table>
</form>
<?php
if ( is_null($requestsArr) ){
echo "</html>"; //Show the search form only. No need to show the result section.
exit;
}
$i = 1;
echo "Go to page ";
while($numOfpages != 0){
if( $i != $pgNo){
// if($filterBy == 'all'){
echo "<a href='SupportController.php?$paramString&pgno=$i'>$i</a>   ";
// }
// else{
// echo "<a href='SupportController.php?code=$paramString&pgno=$i'>$i</a>   ";
// }
}
else{
echo "$i   ";
}
$numOfpages--;
$i++;
}
?>
<h2>Support Requests</h2>
<h4>Total Records Found = <?php echo $count ?></h4>
<!-- todo tableborder to be shown -->
<div class='tableDiv'>
<table id='RequestList' width="900px">
<tr>
<th>ID</th>
<th>Summary</th>
<th>Customer</th>
<th>Plan</th>
<th>Date</th>
<th>Status</th>
<th>Delete</th>
<th>Updated On</th>
<th>Updated By</th>
</tr>
<?php
$rowCount = 1;
foreach($requestsArr as $rqst){
?>
<tr class='<?php echo ($rowCount%2==0)?"even":"odd" ; $rowCount++; ?>'>
<td><?php echo $rqst->id; ?></td>
<td><a href="SupportController.php?code=single&id=<?php echo $rqst->id; ?>"><?php echo $rqst->summary; ?></a></td>
<td><?php echo $rqst->customer; ?></td>
<td><?php echo $rqst->customerPlan; ?></td>
<td><?php echo $rqst->date; ?></td>
<td><?php echo $rqst->status; ?></td>
<td class="redhighlight"><a href="SupportController.php?code=delete&id=<?php echo $rqst->id; ?>"> <img src="../templates/images/delete4.png" width="35px" height="20px" alt="Delete"/><?php //echo "X"; ?></a></td>
<td><?php echo $rqst->lastUpdatedOn; ?></td>
<td><?php echo $rqst->lastUpdatedBy; ?></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
<?php
}
?>