<? ob_start();
session_start();
require_once("../dbconnect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php include_once("title.php");?>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="ajaxvalid.js"></script>
<? 
if($_POST['statuschange']!="")
 {
if(!mysql_query("update tblcart set status=".$_POST['statuschange']." where CARTID=".$_POST['hidcartid']." "))
  die("error:".mysql_error());
  }

if($_POST['statuschange']!="")
 {
  if($_POST['statuschange']==3) 
    {
	$prodlist=mysql_query("select * from tblcartdetails where CARTID=".$_POST['hidcartid']."");
	   while($prodrows=mysql_fetch_array($prodlist))
	     { 
		   //echo $prodrows['PRODUCTID'];
		  $selprod=mysql_query("select * from addproduct where p_id=".$prodrows['PRODUCTID']." ");
		     $selproducts=mysql_fetch_array($selprod);
			 $final=$selproducts['pqty']-$prodrows['QUANTITY'];
		  mysql_query("update addproduct set pqty=".$final." where p_id=".$selproducts['p_id']."");
		 }

	 }
if(!mysql_query("update tblcart set status=".$_POST['statuschange']." where CARTID=".$_POST['hidcartid']." "))
  die("error:".mysql_error());
  header("Location: orderdetails.php?cartid=".$_POST['hidcartid']."");
  }

 ?></head>
<body>
<table width="1003" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><? require_once("header.php"); ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
            
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td align="left" valign="middle"class="cate_pro" style="padding-right:15px;">ORDERS</td>
                <td align="right" style="padding-right:15px;">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="65%" valign="top" style="padding-right:1px;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="35" colspan="5">
						
						
						<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:#FFFFFF solid 1px;">
                            <tr>
                              <td height="250" align="center" valign="top"><?php
							
							  //echo "select * from tblcart where cartid=".$_GET['cartid'];
							    $userd=mysql_query("select * from tblcart where cartid=".$_GET['cartid']." ");
									      $userdet=mysql_fetch_array($userd); 
										  
										  ?>
                                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                      <td align="right" valign="top" width="33%"><?php 
									 
									 //echo "select * from register where user_id=".$userdet['userid'];
									  $result=mysql_query("select * from register where user_id=".$userdet['userid']."");
										     $userres=mysql_fetch_array($result);
											   ?>
                                          <table width="100%">
                                            <tr>
                                              <td colspan="2" align="left" bgcolor="#D7D6CC"><strong>User Details </strong></td>
                                            </tr>
                                            <tr>
                                              <td width="27%" align="left"><strong>Name:</strong></td>
                                              <td width="73%" align="left"><?php echo ucfirst($userres['Fname'])." ".$userres['Lname']; ?></td>
                                            </tr>
                                            <tr>
                                              <td align="left"><strong>Email:</strong></td>
                                              <td align="left"><?php echo $userres['Email']; ?></td>
                                            </tr>
                                            <tr>
                                              <td align="left"><strong>Phone:</strong></td>
                                              <td align="left"><?php echo $userres['Phone']; ?></td>
                                            </tr>
                                            <tr>
                                              <td align="left"><strong>Fax:</strong></td>
                                              <td align="left"><?php echo $userres['Fax']; ?></td>
                                            </tr>
                                            <tr>
                                              <td align="left"><strong>order on : </strong></td>
                                              <td align="left"><?php echo $userdet['time']; ?></td>
                                            </tr>
                                          </table>
                 
					
                                      </td>
                                      <td align="right" valign="top" width="33%"><table width="100%">
                                          <tr>
                                            <td colspan="2" align="left" bgcolor="#D7D6CC"><strong>Shipping Address </strong></td>
                                          </tr>
                                          <tr>
                                            <td align="left" ><strong>Address:</strong></td>
                                            <td align="left" ><?php echo $userres['billingaddress1']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left" ><label for="form_myaccount_address2"><strong>Address Line 2:</strong></label></td>
                                            <td align="left" ><?php echo $userres['billingaddress2']; ?></td>
                                          </tr>
                                          <tr>
                                            <td width="37%" align="left"><strong>City:</strong></td>
                                            <td width="63%" align="left"><?php echo $userres['billingcity']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>State:</strong></td>
                                            <td align="left"><?php echo $userres['billingstate']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>
                                              <label for="form_myaccount_zip">ZIP Code:</label>
                                            </strong></td>
                                            <td align="left"><?php echo $userres['billingzip']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>Country:</strong></td>
                                            <td align="left"><?php echo $userres['billingcountry']; ?></td>
                                          </tr>
                                      
										  
										    <tr>
                                            <td align="left"><strong>Phone:</strong></td>
                                            <td align="left"><?php echo $userres['billingphone']; ?></td>
                                          </tr>
                                      </table></td>
                                      <td align="right" valign="top" width="33%"><table width="100%">
                                          <tr>
                                            <td colspan="2" align="left" bgcolor="#D7D6CC"><strong>Payment Address </strong></td>
                                          </tr>
                                          <tr>
                                            <td align="left" ><strong>Address</strong><strong>:</strong></td>
                                            <td align="left" ><?php echo $userres['shippingaddress1']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left" ><label for="form_myaccount_address2"><strong>Address Line 2:</strong></label></td>
                                            <td align="left" ><?php echo $userres['shippingaddress2']; ?></td>
                                          </tr>
                                          <tr>
                                            <td width="39%" align="left"><strong>City:</strong></td>
                                            <td width="61%" align="left"><?php echo $userres['shippingcity']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>State:</strong></td>
                                            <td align="left"><?php echo $userres['shippingstate']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>
                                            <label for="form_myaccount_zip">ZIP Code:</label>
                                            </strong></td>
                                            <td align="left"><?php echo $userres['shippingzip']; ?></td>
                                          </tr>
                                          <tr>
                                            <td align="left"><strong>Country:</strong></td>
                                            <td align="left"><?php echo $userres['shippingcountry']; ?></td>
                                          </tr>
										    <tr>
                                            <td align="left"><strong>Phone:</strong></td>
                                            <td align="left"><?php echo $userres['shippingphone']; ?></td>
                                          </tr>
                                      </table></td>
                                    </tr>
                                    <tr>
                                      <td colspan="2" align="right" valign="top"></td>
                                      <td align="right" valign="top">&nbsp;</td>
                                    </tr>
								
								
									  	<tr>
                                      <td align="center" colspan="3">&nbsp;</td>
                                     
                                    </tr>
                                    <tr>
                                      <td colspan="3" align="center" valign="top">
	<?php 
	//echo "select * from tblcartdetails where cartid=".$_GET['cartid'];
	
	 $pro="select * from tblcartdetails where cartid=".$_GET['cartid'];
	
	$proddetails=mysql_query($pro);
	
	
						         
									 ?>
                                          <table width="78%" border="0" cellspacing="0" cellpadding="3">
                                            <tr>
                                              <td align="center" bgcolor="#D7D6CC" style=" font-size:10px"><strong>Product Image </strong></td>
                                              <td align="center" bgcolor="#D7D6CC" style=" font-size:10px"><strong>Product Name</strong></td> 
                                              <td align="center" bgcolor="#D7D6CC" style=" font-size:10px"><strong class="text1">Quantity</strong></td>
                                              <td align="center" bgcolor="#D7D6CC" style=" font-size:10px"><strong class="text1">Total</strong></td>
                                            </tr>
                                            
                                               
											  <?php $prod=mysql_query("Select * from tblcartdetails where cartid=".$_GET['cartid']); ?>
                                              <?php while($prodres=mysql_fetch_array($prod))
											  {
												  ?>
                                            <tr>
                                              <td width="18%" align="center"><img src="../products/thumb/<?php echo $prodres['productid'];?>-1.jpg" width="50" height="100" /></td>
                                             
                                              <td width="22%" align="center"><? echo $prodres['pname']; ?>
                                              </td>  
                                              <td width="21%" align="center"><?php echo $prodres['qty'];?> </td>                     <td width="20%" align="center">$<?php echo number_format($prodres['total'],2);?> </td>
                                            </tr>
                                            <?php }?>
											 <tr>
                                              <td>&nbsp;</td>
                                              <td>&nbsp;</td>
                                              <td colspan="2" align="center"> Shipping Method :<?php echo $userdet['method'];?></td>
                                              </tr>
											  <tr>
                                              <td>&nbsp;</td>
                                              <td>&nbsp;</td>
                                              <td colspan="2" align="center">Shipping  Amount :$<?php echo number_format($userdet['ship'],2);?></td>
                                              </tr>
                                            <tr>
                                              <td>&nbsp;</td>
                                              <td>&nbsp;</td>
                                              <td colspan="2" align="center">Total Amount :$<?php echo number_format($userdet['grandtotal'],2);?></td>
                                              </tr>
                                          </table>
                                   
                                      </td>
                                    </tr>
                                    <tr>
                                      <td colspan="2" align="right" valign="top"><table width="66%" border="0" cellspacing="0" cellpadding="4">
                                          <tr>
                                            <td width="41%" style=" font-size:14px"><strong>Order Status : </strong></td>
                                            <form action="orderdetails.php" method="post" name="cartform<?php echo $userdet['cartid']; ?>" id="cartform<?php echo $userdet['cartid']; ?>">
                                              <td width="59%" align="left" style="padding-left:10px;" ><input type="hidden" value="<?php echo $userdet['cartid']; ?>" name="hidcartid" />
                                                  <select onchange="cartform<?php echo $userdet['cartid']; ?>.submit();" style="height:18px; font-size:10px;" name="statuschange" >
                                                    <option value="1" <?php if($userdet['status']==1) {?>selected="selected" <?php }?> >Not Verified</option>
                                                    <option value="2" <?php if($userdet['status']==2) {?>selected="selected" <?php }?> >Paid</option>
                                                    <option value="3" <?php if($userdet['status']==3) {?>selected="selected" <?php }?> >Shipped</option>
                                                    <option value="4" <?php if($userdet['status']==4) {?>selected="selected" <?php }?> >Delivered</option>
                                                    <option value="5" <?php if($userdet['status']==5) {?>selected="selected" <?php }?> >Cancelled</option>
                                                  </select>
                                              </td>
                                            </form>
                                          </tr>
                                      </table></td>
                                      <td align="right" valign="top">&nbsp;</td>
                                    </tr>
                                  </table>
                               
                              </td>
                            </tr>
                        </table>						</td>
                      </tr>
                      <tr>
                        <td width="22%" height="35">&nbsp;</td>
                        <td width="16%" align="center">
						<a href="addcategory.php?addcat=addcat"></a></td>
                        <td width="16%" align="center"></td>
                        <td width="23%">&nbsp;</td>
                        <td width="23%">&nbsp;</td>
                      </tr>
                    </table></td>
                    </tr>
                </table></td>
              </tr>
              <tr>
                <td colspan="2">&nbsp;</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>

          <tr>
            <td><? require_once("footer.php"); ?></td>
          </tr>
          <tr>
            <td>&nbsp; </td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
