<?php
error_reporting(0);
ob_start();
include '../dbconnect.php';
?>

<?php 
if($_POST['orderstatus']!="")
 {
	
if(!mysql_query("update tblcart set orderstatus=".$_POST['orderstatus']." where cartid=".$_POST['hideencartid']." "))
  die("error:".mysql_error());
  header("Location: orderdetails.php?cartid=".$_POST['hideencartid']."");
  }



if($_POST['statuschange']!="")
 {
//echo $_POST['statuschange']; exit;

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

if($_POST['statuschange']!="")
 {
  if($_POST['statuschange']==4) 
    {
$Queryreg1=mysql_query("select * from tblcart where cartid=".$_POST['hidcartid']); 

$cart=mysql_fetch_array($Queryreg1);


$Queryreg=mysql_query("select * from register where user_id=".$cart['userid'].""); 

$res12=mysql_fetch_array($Queryreg);

include('class.Email.php');

  $Sender = 'infos@nricollection.com'; 
    $res=$res12['Email'];
   
    $Recipiant =$res;
  
  
  $Subject = 'SHIPPING CONFIRMATION';
   $msg=


  $CustomHeaders= '';
   $to='infos@dallafashion.com';


  $message = new Email($to,$Sender, $Subject, $CustomHeaders);
  $message->Cc = $Cc; 
  $message->Bcc = $Recipiant; 
  
 
  $zing = '30';	
  
   $html ='<table width="100%">
            <tr>
			<td align="left" colspan="2"><font size="+0">Thank you for your recent order. Below is your confirmation that we have shipped your order. To track your package, please visit the customer service section of our store (place link to customer service page here) .</font><br />
            <br />
           Please review the information below and notify us immediately if you have any questions.
              </td>
			</tr>
			<tr>
			<td width="25%" height="8" align="left" valign="top"   >SHIPPING CONFIRMATION</td>
            <td width="74%" height="8" align="left" valign="top"   > </td>
			</tr>
            <tr>
			<td height="30" valign="middle">Bill To:</td>
			<td valign="top">'. $res12['Fname'] .'</td>
			</tr>
			<tr><td height="30" valign="middle"><p>Ship  To:</p></td><td>'.  $res12['Fname'] .'<br />
			'. $res12['shippingaddress1'] .' '. $res12['shippingaddress2']  .'<br />
       '. $res12['shippingcity']  .' '. $res12['shippingstate'] .' '. $res12['shippingzip']  .' <br />
            '. $res12['shippingcountry']  .'
            </td></tr>
			<tr><td height="30">Order Date:    </td><td>'. $cart['time'] .'</td></tr>
          
		  

		  ';
          
          
        

if($_SESSION['dallacount']>=1)
{
	
	for($i=1;$i<=$_SESSION["dallacount"];$i++)

 								 			{ 
											

                 
            
          
          
		  
		  $totqty=$totqty+$_SESSION['dallacart'][$i]["qty"];
    	
		$totres=$totres+$_SESSION['dallacart'][$i]["totprice"];

		$totwieght=$totwieght+$_SESSION['dallacart'][$i]["totwieght"];

		  } 
		  	$_SESSION['totalquentity']=$totqty;

											$_SESSION['totalamount']=$totres;

											$_SESSION['totwieght']=$totwieght;	

		  
		  
		  }
          $html.=' <tr>
          <td height="30" align="center" >Sub-Total:  </td>
          <td>
            $
             '.	$totres=$_SESSION['totalamount'];

				 number_format($totres,2)

									.'
                                    </td>
            </tr>';
             if($_SESSION['ship']){ 
         $html.='  <tr>
          <td height="30" align="center" >Shipping:   </td>
          <td>
           $'. number_format($_SESSION['ship'],2) .'

								 </td>
            </tr>';
             } 
              $al=mysql_query("select * from tax");
        $re=mysql_fetch_array($al);  
		$narayana=$re['tax'];
		$_SESSION['tax'] = ($totres*$narayana) / 100;
		$tax = number_format($_SESSION['tax'],2);
		 
              $html.=' 
			  <tr>
          <td align="center" >Tax:    </td>
          <td>
            $
          '.$tax.'
					 
                              
                               </td>
            </tr>
            
             <tr>
          <td align="center" >Invoice Total:    </td>
          <td>
            $
          '.$_SESSION['totalamounttax']=$_SESSION['totalamount'] + $tax + $_SESSION['ship']; 
                      number_format($_SESSION['totalamounttax'],2) .'
					 
                              
                               </td>
            </tr>
          
         
           </table>"';
		 				 
						
  $message->SetHtmlContent($html);


  $pathToServerFile = __FILE__;        //** attach this very PHP script.
  $serverFileMimeType = 'text/plain';  //** this PHP file is plain text.


  //$pathToServerFile = 'HelloWorld.doc';      //** use Word doc as version.
  //$serverFileMimeType = 'application/word';  //** standard word MIME type.

  //$message->SetFileContent($pathToServerFile, $serverFileMimeType);

  

  $message->Send();
	
	//$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']."");
  }
 ?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
     <style type="text/css">

      /* Sticky footer styles
      -------------------------------------------------- */

    </style>
    <?php include_once("title.php"); ?>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/logo-nav.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>

<body>
     <div id="wrap">
    <!-- Navigation -->
      <?php include_once("header.php"); ?>

    <!-- Page Content -->
    <div class="container">
        <div class="row">
            <div class="col-lg-12">

                 
                <br><br><br><br>
                <h2 style="display: inline"> Order Detils</h2> <a href="#" class="btn btn-info"><span class="glyphicon glyphicon-print"></span> Print This Page</a>
                
<?php
							   $userd="select * from tblcart where cartid=".$_GET['cartid']."";
								$quw=mysql_query($userd);
								$userdet=mysql_fetch_array($quw); 
										  ?>
                               <?php 
								//echo "select * from addressdetails where Id_user=".$userdet['userid'];
			$result=mysql_query("select * from register where user_id=".$userdet['userid']);
										     $userres=mysql_fetch_array($result);
                                                                                   
											   ?>
                  <div class="row">
            <div class="col-lg-12 col-mg-12">
                <br>
                 <div class="col-lg-6 col-mg-6 col-xs-12 col-sm-12">
                <h2>Customer Details :</h2>

                     <table class="table table-responsive">
	<thead>
		<tr class="info">
			<th>
				<strong>Billing Address :</strong>
			</th>
			<th>&nbsp;
				
			</th>		
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>
				<strong>First Name :</strong>
			</td>
			<td>
				<?php echo ucfirst($userres['billfname'])." ".$userres['billlname']; ?>
			</td>			
		</tr>
	
		<tr>
			<td>
				<strong>Email :</strong>
			</td>
			<td>
				<a href="mailto:<?php echo $userres['email']; ?>"><?php echo $userres['email']; ?></a>
			</td>			
		</tr>
        <tr>
			<td>
				<strong>Telephone Number :</strong>
			</td>
			<td>
				<?php echo $userres['billphone']; ?>
			</td>
			
		</tr>
		<tr>
			<td>
				<strong>Street Address :</strong>
			</td>
			<td>
				<?php echo $userres['billaddress']; ?>
			</td>
			
		</tr>
		<tr>
		<td>
				<strong>City/Town :</strong>
			</td>
			<td>
				<?php echo $userres['billcity']; ?>
			</td>
			</tr>
		<tr>
			<td>
				<strong>State :</strong>
			</td>
			<td>
				<?php echo $userres['billstate']; ?>
			</td>
			
		</tr>

		<tr>
			<td>
				<strong>Zip Code :</strong>
			</td>
			<td>
				<?php echo $userres['billzip']; ?>
			</td>
			
		</tr><?php
							   $userd="select * from tblcart where cartid=".$_GET['cartid']."";
								$quw=mysql_query($userd);
								$userdet=mysql_fetch_array($quw); 
										  
							
										  
										  
										  ?>
		<tr>
			<td>
				<strong>Special Instructions :</strong>
			</td>
			<td>
				<?php echo htmlspecialchars($userdet['specialins']); ?>
			</td>
			
		</tr>
	</tbody>
</table>

         

                </div>

                <div class="col-lg-6 col-mg-6 col-xs-12 col-sm-12">
               <h2>&nbsp;</h2>
<table class="table table-responsive">
	<thead>
		<tr class="info">
			<th>
				<strong>Send the Order Confirmation mail to customer</strong>
			</th>
			<th>&nbsp;
				
			</th>		
		</tr>
	</thead>
	<tbody>
    <form action="cmail.php" method="post">
		<tr>
			<td colspan="2">
				<strong>The order will be ready/delivered in:</strong>
			</td>
						
		</tr>
        <tr>
			<td colspan="2">
				<input type="radio" required name="delivered" value="45 Min">45  Min<input required type="radio" name="delivered" value="60 Min">60  Min<input type="radio" required name="delivered" value="90 Min">90  Min
			</td>			
		</tr>
	
		<tr>
			<td colspan="2">
				<button class="btn btn-info" type="submit">Submit</button>
			</td>
					
		</tr>	
        <?php 
		if($_GET['suc']=="suc"){
		?>
        <tr>
			<td colspan="2">
				<strong style="color:#03F; font-weight:bold">Order Confirmation Mail Has Been Send Successfully..</strong>
			</td>
						
		</tr>
        <?php } ?>
        <input type="hidden" name="cartid" value="<?php echo $_GET['cartid']; ?>">
        <input type="hidden" name="userid" value="<?php echo $_GET['userid']; ?>">
        <input type="hidden" name="email" value="<?php echo $userres['email']; ?>">
        </form>
	</tbody>
</table>

                </div>
                              
    </div>

<div class="col-sm-12 col-md-12">
	<?php 
	
	
	$pro="select * from tblcartdetails where cartid=".$_GET['cartid'];
	
	$proddetails=mysql_query($pro);
	
	
									 ?>
            <table class="table table-hover">
                <thead>
                    <tr class="warning">
                        <th>Product Name</th>
                        <th class="text-center">How Spicy?</th>
                        <th class="text-center">Qty</th>
                          <th class="text-center">Unit Price</th>
                        <th class="text-center">Total</th>
                      
                    </tr>
                </thead>
                <tbody>
<?php 
	 while($prodres=mysql_fetch_array($proddetails)) {
						         
	
	
	
	
									 ?>
                    <tr>
                        <!--<td class="col-sm-2 col-md-2">
                        <div class="media">
                            <a class="thumbnail pull-left" href="#"> <img class="media-object" src="http://icons.iconarchive.com/icons/custom-icon-design/flatastic-2/72/product-icon.png" style="width: 72px; height: 72px;"> </a>
                            <div class="media-body" style="padding-left:2%;">                                
                            </div>
                        </div></td>-->

                      <td class="col-md-2">
                      <h4 class="media-heading"><a href="#"><?php   echo $prodres['pname'];  ?> </a></h4>
                      <?php if($prodres['addonsre']!=""){ ?><br>
                      <?php   echo $prodres['addonsre'];  ?>
                      <?php } ?>
                      <?php if($prodres['mildver']!=""){ ?><br>
                      <?php   echo $prodres['mildver'];  ?>
                      <?php } ?>
                      <?php if($prodres['spicy']!=""){ ?><br>
                      <?php   echo $prodres['spicy'];  ?>
                      <?php } ?>
                      <?php if($prodres['nhp']!=""){ ?><br>
                      <?php   echo $prodres['nhp'];  ?>
                      <?php } ?>
                      <?php if($prodres['notes']!=""){ ?><br>
                      <?php   echo $prodres['notes'];  ?>
                      <?php } ?>
                      <?php if($prodres['forveg']!=""){ ?><br>
                      <?php   echo $prodres['forveg'];  ?>
                      <?php } ?>
                      <?php if($prodres['fornonveg']!=""){ ?><br>
                      <?php   echo $prodres['fornonveg'];  ?>
                      <?php } ?>
                      <?php if($prodres['fornonveg2']!=""){ ?><br>
                      <?php   echo $prodres['fornonveg2'];  ?>
                      <?php } ?>
                        <?php if($prodres['vegbox']!=""){ ?><br>
                      <?php   echo $prodres['vegbox'];  ?>
                      <?php } ?>
                        <?php if($prodres['mtnveg']!=""){ ?><br>
                      <?php   echo $prodres['mtnveg'];  ?>
                      <?php } ?>
                        <?php if($prodres['mtnveg1']!=""){ ?><br>
                      <?php   echo $prodres['mtnveg1'];  ?>
                      <?php } ?>
                        <?php if($prodres['ftm']!=""){ ?><br>
                      <?php   echo $prodres['ftm'];  ?>
                      <?php } ?>
                        <?php if($prodres['lassi']!=""){ ?><br>
                      <?php   echo $prodres['lassi'];  ?>
                      <?php } ?>
                      <?php if($prodres['soda']!=""){ ?><br>
                      <?php   echo $prodres['soda'];  ?>
                      <?php } ?>
                      </td>

                        <td class="col-sm-2 col-md-2 text-center"><strong><?php   echo $prodres['pickuptime'];  ?></strong></td>
                        <td class="col-sm-2 col-md-2 text-center"><strong><?php  echo $prodres['qty'];?></strong></td>
                        <td class="col-sm-2 col-md-2 text-center"><strong><?php  echo $prodres['UNITPRICE'];?></strong></td>
                        <td class="col-sm-2 col-md-2 text-center"><strong>Total : $ <?php echo $prodres['UNITPRICE']*$prodres['qty'];?></strong></td>
                    </tr>
                     <?php } ?>
                     <?php $sam143=$userdet['grandtotal']-$userdet['orderstatus']+$userdet['tip']+$userdet['tax']; ?>
                     
                    <!-- <tr class="info">
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td><h5><strong>Discount :</strong></h5></td>
                        <td class="text-right"><h5><strong>$ - <?php echo number_format($userdet['orderstatus'],2)?></strong></h5></td>
                    </tr>-->
                    <!--   <tr class="info">
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td><h5><strong>Tip :</strong></h5></td>
                        <td class="text-right"><h5><strong>$ <?php echo number_format($userdet['tip'],2)?></strong></h5></td>
                    </tr>-->
                    <?php
					if($userdet['delivery_area']!=""){
					?>
                     <tr class="info">
                        <td>&nbsp;  </td>
                       
                        <td colspan="3"><h5><strong><?php echo $userdet['cooldrinks']; ?></strong></h5></td>
                        <td class="text-right"><h5><strong>$ <?php echo number_format($userdet['cooldrinksprice'],2)?></strong></h5></td>
                    </tr><?php } ?>
                      <tr class="info">
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td><h5><strong>Delivery Charges :</strong></h5></td>
                        <td class="text-right"><h5><strong>$ <?php echo number_format($userdet['delivery_area'],2)?></strong></h5></td>
                    </tr>
                    <tr class="info">
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td><h5><strong>Tax :</strong></h5></td>
                        <td class="text-right"><h5><strong>$ <?php echo number_format($userdet['tax'],2)?></strong></h5></td>
                    </tr>
                  
                    <tr class="danger">
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td>&nbsp;  </td>
                        <td><h3><strong>Total Amount :</strong></h3></td>
                        <td class="text-right"><h3><strong>$<?php echo number_format($userdet['grandtotal'],2)?></strong></h3></td>
                    </tr>
            
                </tbody>
            </table>
        </div>


        </div>

                
               
    </div>

        </div>

  

            </div>
            
         <div id="push"></div>
    </div>

    <?php include_once("footer.php"); ?>
   

    
    <!-- /.container -->

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>


</body>

</html>
