Hi All,
The current script below works fine. Items are returned to store when the return to store button by each item is clicked. I however want to change the idea so that when the Reject Requisition button is clicked, the item is return to store instead of the individual return to store button. In this case three tables will be involved that is issueditems, issueditems_details and store.
You can study the script and your recommendation is welcome.
This is the VIEW PAGE SCRIPT
<form name="actionta" id="actionta" action="process_storeq.php" method="post">
<table width="752" border="1" align="center">
<tr>
<td colspan="25"><img src="../images/tesog.jpg" width="82" height="83" border="0" /></td>
</tr>
<tr>
<td colspan="25"> </td>
</tr>
<tr>
<td><strong>Entry ID:</strong></td>
<td colspan="2"><b><input name="entryid" id="entryid" value="<?php echo $row_rsViewTA[entryid]; ?>" READONLY/></b></td>
<td><b>Status:</b></td>
<td><b><input name="status" id="status" value="<?php echo $row_rsViewTA[status]; ?>" READONLY/></b></td>
</tr>
<tr>
<td colspan="25"> </td>
</tr>
<tr>
<td width="89">Requester:</td>
<td colspan="2"><b><?php echo $row_rsViewTA[receipient]; ?></b></td>
<td>Request Date:</td>
<td><b><?php echo $row_rsViewTA[issuedate]; ?></b></td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
<tr>
<td width=\"89\">Unit:</td>
<td colspan="2"> <b><?php echo $row_rsViewTA[division]; ?></b></td>
<td>Extension:</td>
<td> <b><?php echo $row_rsViewTA[extension]; ?></b></td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
<tr>
<td colspan=\"25\"><strong>Store Request Details</strong></td>
</tr>
<tr>
<td colspan=\"25\" ><?php
$sqlItems = "SELECT * FROM issueditems_details WHERE issueno='$row_rsViewTA[entryid]'";
$resultItems=mysql_query($sqlItems);
//determing the actions which have been taken on the issue
if(mysql_affected_rows()>0)
{
if(mysql_affected_rows()==1)
{
//at least one action has been taken
// echo"<b>" . mysql_affected_rows() . " action has been taken on the above issue.</b>";
}
else//more than one action has been taken
{
// echo"<b>" . mysql_affected_rows() . " actions have been taken on the above issue.</b>";
}
}
else
{
echo"<b>No action has been taken on the above issue.</b>";
}
//Adding 'ADD ACTION' Button
echo"<table class=\"data-table\"><thead><tr>";
echo"<td scope=\"col\">Request ID</td><td>Item Description</td><td>Quantity</td><td>Remarks</td></tr></thead>";
$rowcount=1;
while ($rowitems = mysql_fetch_array($resultItems)) {
if (($rowcount%2)==0){
echo('<tr>' );
echo"<tr><td>$rowitems[issueno]</td><td>$rowitems[product]</td><td>$rowitems[qtyfigs]</td><td>$rowitems[remarks]</td><td valign=top><a href=\"" . $_SERVER['PHP_SELF'] . "?deductfromstores=" .$rowitems['entryid'] . "&Submit=Edit\"><img title=\"Return to Stores\" alt=\"Return to Stores\" src=\"../images/deduct.png\" border=\"0\"></a></td></tr>";
}
else
{
echo('<tr>' );
echo"<tr><td>$rowitems[issueno]</td><td>$rowitems[product]</td><td>$rowitems[qtyfigs]</td><td>$rowitems[remarks]</td><td valign=top><a href=\"" . $_SERVER['PHP_SELF'] . "?deductfromstores=" .$rowitems['entryid'] . "&Submit=Edit\"><img title=\"Return to Stores\" alt=\"Return to Stores\" src=\"../images/deduct.png\" border=\"0\"></a></td></tr>";
}
}
echo"</tr></form></table>";
if (isset($_GET['deductfromstores'])) {
$entryid = $_GET['deductfromstores'];
$sql = "SELECT * FROM issueditems_details WHERE entryid=$entryid";
$resulti = mysql_query($sql);
$rowproduct = mysql_fetch_array($resulti);
$qtyfigs = $rowproduct['qtyfigs'];
$product = $rowproduct['product'];
$productid = $rowproduct['productid'];
//updating stores
$sql_stores = "UPDATE stores SET qtyinstock = qtyinstock + '$qtyfigs' WHERE productid= '$productid'";
$result = mysql_query($sql_stores);
//deleting record
$sql = "DELETE FROM issueditems_details WHERE entryid=$entryid";
$resulti = mysql_query($sql);
echo"<p><b>Item returned successfully to stores.</p><p><a href=storeq.php>Please click here to return to the pending list page.</a></b></p>";
}
?>
</td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
<tr>
<td >Rejected Reason:<textarea name="rejectreason" cols="30" rows="5" id="rejectreason"></textarea></td>
<td colspan="25"> </td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
<tr>
<td colspan=\"25\"><center><input type="Submit" name="Submit" id="Submit" value="Submit to PROCUREMENT" /> <input type="Submit" name="Submit2" id="Submit2" value="Reject Requisition" onClick="return validater(this)" /></center></td>
</tr>
<tr>
<td colspan=\"25\"> </td>
</tr>
</table>
</form>
AND THIS IS THE PROCESS SCRIPT
// When Approve is click
if (@$_REQUEST['Submit'] == "Submit to PROCUREMENT") {
$entryid = $_REQUEST['entryid'];
$status = $_REQUEST['status'];
$firstapprover = $_REQUEST['firstapprover'];
$firstapprovername = $_REQUEST['firstapprovername'];
$systemapprovallist = $_REQUEST['systemapprovallist'];
$signalprocurement = $_REQUEST['signalprocurement'];
require_once("../admin/db.php");
$sql_update="UPDATE issueditems SET
status='APPROVED',
firstapprover='APPROVED',
firstapprovername='$fullname',
signalprocurement='PR',
systemapprovallist='PROCUREMENT'
WHERE entryid='$entryid'";
/* Passes query to database */
$result = mysql_query($sql_update);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p><p><a href=\"" . $_SERVER['PHP_SELF'] . "?updaterecord=" .$entryid. "&Submit=Edit\">Click here</a> to return to Problem Log page");
exit();
}
else{
echo"<b>Store Requisition hass been successfully submitted to PROCUREMENT UNIT.</b>";
}
}
// When Reject is clicked
if (@$_REQUEST['Submit2'] == "Reject Requisition") {
$entryid = $_REQUEST['entryid'];
$status = $_REQUEST['status'];
$firstapprover = $_REQUEST['firstapprover'];
$firstapprovername = $_REQUEST['firstapprovername'];
$systemapprovallist = $_REQUEST['systemapprovallist'];
$rejectreason = addslashes($_REQUEST['rejectreason']);
//$approvallevel = $_REQUEST['approvallevel'];
require_once("../admin/db.php");
$sql_update="UPDATE `issueditems` SET
status='REJECTED',
firstapprover='REJECTED',
firstapprovername='$fullname',
systemapprovallist='REJECTED',
rejectreason='$rejectreason'
WHERE entryid='$entryid'";
/* Passes query to database */
$result = mysql_query($sql_update);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p><p><a href=\"" . $_SERVER['PHP_SELF'] . "?updaterecord=" .$entryid. "&Submit=Edit\">Click here</a> to return to Problem Log page");
exit();
}
else{
echo"<b>Store Requisition Rejected.</b>";
}
}
Thanks.