Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/ilight/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/ilight/stcomplaints.inc

<h2 align='left'>User Complaint</h2>
<center>
<?php

$tbl = 'st_complaints';
$filter = $_REQUEST['filter']; 

$id = $_REQUEST["id"];
$complaintno = $_REQUEST["complaint_no"];
$complaintdate = $_POST['complaint_date'];
if (!$complaintdate) $complaintdate = date("Y-m-d");
$problem = $_POST['problem'];
$employee = $_POST['employee'];
$location = $_POST['location'];
$technician = $_POST['technician'];
$status = $_POST['status'];
if (!$status) $status = 'Pending';
$closingdate = $_POST['closing_date'];
if (!$closing_date || $status != 'Closed') $closingdate = '0000-00-00';
$remark = $_POST['remark'];

if ($_POST["submit"] == 'SAVE') {
	if (mysql_num_rows(mysql_query("select * from $tbl where complaint_no=$complaintno"))) {
		//update existing indent
		mysql_query("update $tbl set complaint_date='$complaintdate',problem='$problem',employee='$employee',
		location='$location',technician='$technician',status='$status',closing_date='$closingdate',remark='$remark',dated=now()
		where complaint_no=$complaintno");
	} else {
		//insert new indent
		mysql_query("insert into $tbl(complaint_date,problem,employee,location,technician,status,closing_date,remark,dated)
		values('$complaintdate','$problem','$employee','$location','$technician','$status','$closingdate','$remark',now())");
		$complaintno = mysql_insert_id();
	}

} else if ($_POST["submit"] == 'DELETE') {
	mysql_query("delete from $tbl where complaint_no=$complaintno");
	$complaintno = 0;

} else if ($_REQUEST["revive"] == 'Yes') {
	mysql_query("update $tbl set status='Pending' where complaint_no=$complaintno");
}

echo "<table width='50%'><tr><th>";

if ($complaintno) {
	echo "<input type='hidden' name='complaint_no' value='$complaintno'>
	[ <a href='?pg=$pg'>Post New Complaint</a> ] 
	<font size=+1>Complaint No. $complaintno</font> 
	[ <a href='?pg=$pg&filter=1'>Find Old Complaint</a> ] ";
	if ($status == 'Cancelled') { 
		echo "[ <a href='?pg=$pg&revive=Yes&complaint_no=$complaintno'>Revive</a> ]";
	}

	$rs = mysql_query("select * from $tbl where complaint_no=$complaintno");
	if (mysql_num_rows($rs)) {
		$o = mysql_fetch_object($rs);
	        $complaintdate = $o->complaint_date;
        	$problem = $o->problem;
	        $employee = $o->employee;
        	$location = $o->location;
	        $technician = $o->technician;
        	$status = $o->status;
	        $closingdate = $o->closing_date;
        	$remark = $o->remark;
	} else {
		$err = "<font color='red'>Complaint does not exist.</font>";
	}
} else {
	if ($filter) {
		echo "[ <a href='?pg=$pg'>Post New Complaint</a> ] or Find Old Complaint <input type='text' name='complaint_no' size='10' value='$complaintno'>
		<input type='submit' name='submit' value='OK'> ";
	} else {
		echo "Post New Complaint or [ <a href='?pg=$pg&filter=1'>Find Old Complaint</a> ] ";
	}
}
echo "</th></tr></table>";

if ($err) {
	echo $err;
} else {
	echo "<table width='80%' border='1' style='border-collapse: collapse'>
	<tr valign='top'><td>Complaint Date<br><input type='text' name='complaint_date' size='15' value='$complaintdate'><br>
	Problem Description<br><textarea name='problem' rows='2' cols='50'>$problem</textarea><br>
	Complainant/User<br>".employee_list($employee)."<br>
	Site Location<br><input type='text' name='location' size='40' value='$location'></td>
	<td width='50%'>Technician<br>".technician_list($technician)."<br>
	<h3 style='color:red'>STATUS ";
	foreach ($statuss as $st) {
		echo "<input type='radio' name='status' value='$st'";
		if ($st == $status) echo 'checked';
		echo ">&nbsp;$st ";
	} 
	echo "</h3>
	Closing Date<br><input type='text' name='closing_date' size='15' value='$closingdate'><br>
	Remark<br><textarea name='remark' rows='2' cols='50'>$remark</textarea></td></tr>";

	if ($complaintno) {
		if ($status == 'Closed') {
		} else if ($status == 'Pending') {
			echo "<tr><th><input type='submit' name='submit' value='SAVE'></th>
			<th><input type='submit' name='submit' value='DELETE'></th></tr>";
		} else { 
			echo "<tr><th colspan='2'><input type='submit' name='submit' value='SAVE'></th></tr>";
		}
	}
	echo "</table><br>";


	//items utilized for user
	echo "<h3>Items utilized at user location to resolve the above complaint</h3>
	<table width='90%' border='1' style='border-collapse: collapse'>
	<tr><th>No</th><th nowrap>Item Description</th><th>Qty</th></tr>";

	$sr = mysql_query("select * from st_utilization where complaint_no=$complaintno order by item");
	while ($q = mysql_fetch_object($sr)) {
		$j++;
		echo "<tr><th><a href='?pg=stutilization&complaint_no=$complaintno&id=$q->id'>$j</a></th><td>".item_detail($q->item)."</td><td>$q->qty_out</td></tr>";
	}
	echo "</table><br>";

	//items received from user
	echo "<h3>Items received from user location against the above complaint</h3>
	<table width='90%' border='1' style='border-collapse: collapse'>
	<tr><th>No</th><th nowrap>Item Description</th><th>Qty</th><th>Status</th></tr>";

	$sr = mysql_query("select * from st_useritems where complaint_no=$complaintno order by item");
	while ($q = mysql_fetch_object($sr)) {
		$k++;
		echo "<tr><th><a href='?pg=stuseritems&complaint_no=$complaintno&id=$q->id'>$k</a></th><td>".item_detail($q->item)."</td><td>$q->qty_in</td><td>$q->status</td></tr>";
	}
	echo "</table><br>";
}

?>
</center>