<? include("header.php");
//session_start();
//error_reporting(0);
include "checksession.php";
include ("include/db-connect.php");

 if(isset($_REQUEST['submit']))
	{ 
 		 $order_id= $_REQUEST['order_id'];
		 $awb_num= $_REQUEST['awb_num'];
		 $set=mysql_query("select awb_num from ".$ORDER." WHERE `order_id`='$order_id'");
		$fet=mysql_fetch_array($set);
		$awb=$fet['awb_num'];  
		if($awb==NULL)
		 { 
		$sql="UPDATE ".$ORDER." SET  `awb_num`='$awb_num' WHERE `order_id`='$order_id'";
		$result=mysql_query($sql);
		
		//Fetch Details
		$set=mysql_query("select * from ".$ORDER." WHERE `order_id`='$order_id'");
		$fet=mysql_fetch_array($set);
		$name=$fet['name'];
		$order_id=$fet['order_id'];
		$product_id=$fet['product_id'];
		$product_name=$fet['product_name'];
		$quantity=$fet['quantity'];
		$date=$fet['date'];
		$tot_amount=$fet['tot_amount'];
		$phone=$fet['phone'];
		
		//Mail Start
		$to .=$email;
// subject
$subject = "AWB Number";
$message .= "<div style=width:700px; height:730px; border:solid; color:#00F;>
<div style='width:700px; height:140px;'>
<div style='float:left; width:300px; height:140px;'><img src='".$activatieon_url."/images/1413logo.png' width='300' height='120' /></div>
</div>

<div style='width:750px; height:140px;'>
<div style='float:left; width:px; height:140px;'>
<div style='margin-left:20px;font-size:20px; color:#03C; margin-top:60px;'>
Dear <font size='8'>".$name."</font></div>
</div>
<div style=' float:left;width:100px; height:140px;'>
<div style='margin-left:-10px;font-size:20px; color:#03C'><p><img src='".$activatieon_url."/images/order.jpg' width='131' height='124'></p>
</div>
</div>
</div>

<div style='width:750px;; height:140px;'>
<div style='height:110px; width:700px; margin-top:30px; margin-left:150px;'>
  <p>Your order has been delivered.</p>
  <p>AWB number is $awb_num</p>
  <p>Thank You..!..</p>
  <p>Order ID:&nbsp;&nbsp;<font color='black'><b>".$order_id."</b></font> </p>
</div>
</div>
<div style='width:750px; height:110px;'>
<table width='726' height='99' border='1' bordercolor='#999999'>
<tr>
	<th width='111' height='52'>Product ID</th><th width='151' height='52'>Product Name</th><th width='100'>Quantity</th><th width='97'>date</th><th width='126'>Toatal Order Amount</th><th width='101'>Status</th>
</tr>

<tr>
	<td align='center'>".$product_id."</td>
	<td align='center'>".$product_name."</td>
	<td align='center'>".$quantity."</td>
	<td align='center'>".$date."</td>
	<td align='center'>&#x20B9;".$tot_amount."</td>
	<td align='center'>AWB No. Received</td>
</tr>
</table>
</div>
<div style='width:730; height:30; margin-left:5px;'>
<b>Note:</b> Keep your order number handy for any future communication with us regarding this number.
</div>
<div style='width:750px; height:50px;'>
<div style='width:200px; height:70px; margin-left:250px; color:#900;'>
  <h2>Happy Shopping!!!</h2>
  <h4>&nbsp;&nbsp;&nbsp;&nbsp;Our Team</h4>
</div>
</div>
</div>";


// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From:<'.$adminemail_id.'>'."\r\n";
$headers .= 'Cc: ' . "\r\n";
$headers .= 'Bcc: ' . "\r\n";

mail($to, $subject, $message, $headers);

		/*$url='http://bhashsms.com/api/sendmsg.php?user=veludvb&pass=190290&sender=cccmdu&phone='.$phone.'&text=AWB%20number%20Received.Your%20Order%20ID:'.$order_id.'%20your%20amount%20Rs:'.$tot_amount.'%20your%20AWB%20Number%20Rs:'.$awb_num.'&priority=ndnd&stype=normal';
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$curl_scraped_page = curl_exec($ch);
		curl_close($ch);
		$curl_scraped_page;*/
        //SMS END

		?><script>window.location="tot_purchase.php";</script><? 	}
		 else
		 {
		 ?><script>window.location="add_awb.php?no=suc";</script><?
		 }}
?>		 
		



<div id="content">
  <div class="breadcrumb">
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" />Add AWB Number</h1>
    </div>
    <div class="content">
        
 
 <?php if($_REQUEST['no']=='suc'){ echo "<div class='alert_succes'>Enter Again</div>"; } else { echo "";}?>

 <form method="post" id="client" enctype="multipart/form-data" autocomplete="off">
 <table cellpadding="8" align="center">
 <tr>
 <td>Order ID</td>
 <td><input list="browsers" name="order_id" style="width:250px;height:30px;" autofocus="autofocus"  required="required">
  <datalist id="browsers">
  <?php
  $query = mysql_query("SELECT * FROM orders");
  while($rows = mysql_fetch_array($query))
  {
  ?>
  <option value="<?php echo $rows['order_id']; ?>">
  <?php } ?>  
  </datalist></td>
 </tr>
  <tr>
 <td>Enter AWB Number</td>
 <td><input type="text" name="awb_num" size="55" required="required"  style="width:250px;"></td>
 </tr>
  <tr>
 <td>&nbsp;</td>
 <td><input type="submit" name="submit" value="Submit" style="background:#090;color:#FFF;width:80px;height:30px;border:0px;border-radius:10px 6px;cursor:pointer;"></td>
 </tr>
 </table>
   </form>
      
      
    </div>
  </div>
</div>
</div>
<?  include("footer.php"); ?>



