Jump to content

Textbox to appear...


phpanon

Recommended Posts

Hello everyone,

 

I have a simple internal ordering system. Every order needs to be approved by the manager before it can be submitted. What idealy I want to happen is that, if for some reason the manager rejects an order then when he changes the dropdown menu to 'Reject' a text box appears where he can write the reasons for rejection which can then be writen to the database with the rest of the information into the 'comments' field.

 

Thanking you kindly in advance

 

Here is my code

<?php
session_start();
if (isset($_SESSION['username']) == false){
	header("Location: login.php");
	exit();
}
require "connect.php";

$orderID = $_GET['orderID'];
$query = "SELECT * FROM orders o, productorder p WHERE o.orderID = p.orderID AND p.status = 'Awaiting Approval' AND o.orderID = ".$orderID;

$result = mysql_query($query, $connection) or die ("Unable to perform query $query");

$row= mysql_fetch_array($result);

$query3 = "SELECT * FROM orders WHERE orderID = ".$orderID;
$result3 = mysql_query($query3, $connection) or die ("Unable to perform query $query3");

$row3= mysql_fetch_array($result3);

?>
<body>
<div id="OrdersBasketTable">
<table border="0" width="100%">
<hr />
<tr>
	<th width="100">Order Number</th>
</tr>
		<tr><td align="center"><h2><strong><?php echo $row['orderID']?></strong></h2></td>
		<td>
		<table border="0"width="100%">
		<tr>
			<th width="30%" align="left">Product</th>
			<th width="10%" align="left">Price</th>
			<th width="10%" align="left">Quantity</th>
			<th width="14%" align="left">Date</th>
			<th width="25%" align="left">User</th>
			<th width="13%" align="left">Total</th>
		</tr>
		<tr>

<?php
$query2 = "SELECT * FROM orders o, productorder e, product p WHERE o.orderID = e.orderID AND p.URN = e.URN AND e.status = 'Awaiting Approval' AND o.orderID = '".$row['orderID']."'";
$result2 = mysql_query ($query2, $connection) or die ("Unable to perform query<br>$query2");

			while($row2=mysql_fetch_array($result2))
			{ ?>
  		  <tr>
					<td><?php echo $row2['productName']?></td>
					<td>£<?php echo $row2['price']?></td>
					<td align="center"><?php echo $row2['quantity']?></td>
					<td><?php echo $row2['date']?></td>
					<td><?php echo $_SESSION['fName']?> <?php echo $_SESSION['sName']?></td>

					<?php $total = $row2['quantity'] * $row2['price']; ?>
					<td>£<?php echo $total ?></td>
					<?php $total2 = $total2 + $total ?>
  		  </tr>
				<?php
			} ?>
			</td>
			</tr>
			<td></td>
			<td></td>
			<td></td>
			<td></td>
			<td><strong>Total</strong></td>
			<td>£<?php echo $total2 ?></td>
			<td></td>
  </table>
</table>
</td>
</table>

<form action="OrderApprovalQuery.php" method="get">
<table width ="100%" border="0">
	<tr>
	  <td>Status:</td>
	  <td><select name="status">
            <option>Awaiting Approval</option>
            <option>Complete</option>
            <option>Reject</option>
          </select></td>
	  <td> </td>
  </tr>
	<tr>
	  <td><input name="orderID" type="hidden" value="<?php echo $row3['orderID']?>"  /></td>
	  <td> </td>
	  <td> </td>
  </tr>
	<tr>
		<td width="20%"> </td>
        	<td width="22%"><input name="Save" type="submit" value="Update" /></td>
        	<td width="58%"> </td>
	</tr>
</table>
</form>
</div>
</body>

 

<?php
require "connect.php";
$orderID = $_GET['orderID'];
$status = $_GET['status'];

$query =  "UPDATE productorder SET status = '".$status."', apprDate = '".date("d-M-Y")."' WHERE orderID = ".$orderID;
$result = @mysql_query($query, $connection) 
or die ("Unable to perform query<br>$query");
header("Location: pendingOrders.php");
exit();
?>

Link to comment
Share on other sites

Hi,

 

Near

 

</select></td>

  <td> </td>---- create a div with style hidden

 

and on dropdown of status and its event onchange create a js function which checks wether it is status=='Rejected' then show you div and do something like

div.innerHTML='<input type="comment" value="your message">';

 

so when you will submi tyour form you will be able to read this comment text box.

 

hope it help you !!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.