MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.12.123.41
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0750) :  /home2/ppcad7no/lizatilessolution.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/lizatilessolution.com/create_order.php
<?php 
ob_start();
require_once("includes/dbsmain.inc.php");
include("site-main-query.php");
$site_url=$compDATA['admin_website_url'];


?>


<?php
/*$check_cart_empty=db_query("select * from tbl_basket where 1 and bskt_session_id='$_SESSION[cart_session_id]' ");
if(mysqli_num_rows($check_cart_empty)<=0)
{?>
  <script>
      alert("Your cart is empty !");
      window.location.href="cart.html";
  </script>
<?}*/

$Curr_Date = date("Y-m-d");
if($_SESSION['cart_session_id']!="" && !empty($_SESSION['cart_session_id']) && $_SESSION['login_id']!="" && !empty($_SESSION['login_id']))
{
    $check_cart_empty=db_query("select * from tbl_basket where 1 and bskt_session_id='$_SESSION[cart_session_id]' ");
if(mysqli_num_rows($check_cart_empty)<=0)
{?>
  <script>
      alert("Your cart is empty !");
      window.location.href="cart.html";
  </script>
<?}else{
    
db_query("insert into tbl_order set 
ord_reg_id='$_SESSION[login_id]',
ord_net_amount='$_SESSION[payable_amount]',
ord_tax='$_SESSION[tax]',
ord_amount='$_SESSION[sub_total]',
order_payment_method='$_SESSION[payment_method]',
ord_comment='$_SESSION[comment]',
ord_date='$Curr_Date'");

$order_id=db_scalar("select max(ord_id) from tbl_order");

 $cart_sql=db_query("select * from tbl_basket where 1 and bskt_session_id='$_SESSION[cart_session_id]' ");
  while($cart_data=mysqli_fetch_array($cart_sql))
  {
db_query("insert into tbl_order_detail set 
order_id='$order_id',
order_reg_id='$_SESSION[login_id]',
product_id='$cart_data[bskt_prd_id]',
product_qty='$cart_data[bskt_prd_qnty]',
product_unit_price='$cart_data[bskt_prd_unit_price]',
product_price='$cart_data[bskt_prd_subtotal]',
product_color='$cart_data[color]',
product_size='$cart_data[size]',
product_area='$cart_data[area]',
order_payment_method='$_SESSION[payment_method]',
order_date='$Curr_Date'");

$db_qnty=db_scalar("select category_qnty from tbl_category where category_id='$cart_data[bskt_prd_id]' ");
$qnty=$db_qnty-$cart_data['bskt_prd_qnty'];
db_query("update tbl_category set category_qnty='$qnty' where category_id='$cart_data[bskt_prd_id]'");

    }
    
    
/////////////////////// Data Entry For Invoice /////////////////////////////////////

$fullAdrsComp=$compDATA['admin_address']." ".$compDATA['admin_city'].", ".$compDATA['admin_state'].", ".$compDATA['admin_zip_code'];

//$fullAdrsBill=$userDATA['reg_address']." ".$userDATA['reg_city'].", ".$userDATA['reg_state'].", ".$userDATA['reg_zip_code'];


/*$sql="SELECT * FROM tbl_address WHERE 1 AND id='$adrsID'";
$data=db_query($sql);
$recAdrs=mysqli_fetch_array($data);	

$fullAdrsShip=$recAdrs['shipping_address']." ".$recAdrs['shipping_city'].", ".$recAdrs['shipping_state'].", ".$recAdrs['shipping_zip_code'];
*/

$ship_ad_sql=db_query("select * from tbl_registration where reg_id='$_SESSION[login_id]' and reg_status='Active' ");
$recAdrs=mysqli_fetch_array($ship_ad_sql);	
$fullAdrsShip=$recAdrs['reg_shipping_address']." ".$recAdrs['reg_shipping_city'].", ".$recAdrs['reg_shipping_state'].", ".$recAdrs['reg_shipping_zip_code'];

if($recAdrs['reg_billing_address_same']=="No")
{
$fullAdrsBill=$recAdrs['reg_billing_address']." ".$recAdrs['reg_billing_city'].", ".$recAdrs['reg_billing_state'].", ".$recAdrs['reg_billing_zip_code'];
}else{
    $fullAdrsBill='Yes';
}

$sql_invoice="INSERT INTO tbl_invoice SET inv_comp_name='$compDATA[admin_company_name]',
                                  inv_comp_adrs='$fullAdrsComp',
								  inv_comp_gst_num='$compDATA[admin_gst_no]',
								  inv_order_num='$order_id',
								  inv_order_date='$Curr_Date',
								  inv_billing_name='$recAdrs[reg_billing_name]',
								  inv_billing_adrs='$fullAdrsBill',
								  inv_shipping_name='$recAdrs[reg_shipping_name]',
								  inv_shipping_adrs='$fullAdrsShip',
								  inv_sub_total='$_SESSION[sub_total]',
								  inv_gst_amount='$_SESSION[tax]',
								  inv_grand_total='$_SESSION[payable_amount]'
								  ";
db_query($sql_invoice);


///////////////////////////// Invoive End //////////////////////////////////////////


$sql_logo_welcome=db_query("select * from tbl_header where 1 and header_status='Active' limit 1");
if(mysqli_num_rows($sql_logo_welcome)>0){
$DATALOGO=mysqli_fetch_array($sql_logo_welcome);
@extract($DATALOGO);
}
$im=$site_url."/header_files/".$DATALOGO['header_logo'];

$order_date=db_scalar("select ord_date from  tbl_order where 1 and ord_id='".$order_id."'");

$reg_email=db_scalar("select reg_email from tbl_registration where 1 and reg_status='Active' and reg_id='$_SESSION[login_id]'");
$reg_name=db_scalar("select reg_name from tbl_registration where 1 and reg_status='Active' and reg_id='$_SESSION[login_id]'");

$mailtext = "
<html>
<head>
  <title>Order Details</title>
</head>
<body>
<div style='background-color:white; padding:20px;'>

<h1 style='text-align:center; color:green; font-weight:bold;'>
<img src='$im'  border='0' alt'=$compDATA[admin_company_name]'>
<br>
<br>

Your order has been placed successfully !
</h1>
<h2 style='text-align:center; color:green;'>You will receive order your on time.</h2>
</div>
";

  $sql=db_query("select * from tbl_order_detail where 1 and order_id='".$order_id."' order by od_id desc");
   if(mysqli_num_rows($sql)>0){

$mailtext.="
  <table width='100%'  border='0' align='center' cellpadding='5' cellspacing='5' class='tableForm' style='background-color:#F0F0E1; border:2px solid #DCDCB8; margin-top:10px;'>
   <tr style='height:30px; background-color:#E4E4C9'>
   <td colspan='6'>";
   

   
    $mailtext.=" (Order Id : $order_id) Order Date: $order_date</td> </tr>
    <tr style='height:30px; background-color:#E4E4C9'>
      <td width='25%' align='center' class='tdLabel' style='font-size:12px; color:#0000D7;'><strong>Product Name</strong></td>
      <td width='10%' align='center' class='tdLabel' style='font-size:12px; color:#0000D7;'><strong>Image</strong></td>
            
      <td width='10%' align='center' class='tdLabel' style='font-size:12px; color:#0000D7;'><strong>Unit Price (Rs.)</strong></td>
      <td width='10%' align='center' class='tdData' style='font-size:12px; color:#0000D7;'><strong>Quantity</strong></td>
	  	  <td width='11%' align='center' class='tdData' style='font-size:12px; color:#0000D7;'><strong>Total</strong></td>
		  
		  ";
		  

    $mailtext.="  
    </tr>
    <tr>
      <td colspan='8'>&nbsp;</td>
    </tr>";
   
  $i=0;
   $net_amount=0;
   $shipping_cost=0;
   $final_shipping_cost=0;
   
   while($recd=mysqli_fetch_array($sql)){
   $i++;
   @extract($recd);
   $net_amount=$net_amount+$product_price;	
   $subcat = db_scalar("select category_parent_id from tbl_category where 1 and category_id='$recd[product_id]' ");
 //  $catID = db_scalar("select category_parent_id from tbl_category where 1 and category_id='$subcat' ");
   
   $pro_name=db_scalar("select category_name from tbl_category where 1 and category_id='$recd[product_id]'");
   $cate_name=db_scalar("select category_name from tbl_category where 1 and category_id='$subcat'");
   
$mailtext.="
    <tr>
      <td class='tdLabel' align='center' style='font-size:11px;'>
	  <b>$pro_name</b>
	<p>($cate_name)</p>	";


$mailtext.="
<table id='tbl-attrib' >
<tr><td class='tbl-attrib-col-2'>Size:</td><td class='tbl-attrib-col-3'>$recd[product_size]</td></tr>
</table>
";

$mailtext.="
<table id='tbl-attrib' >
<tr><td class='tbl-attrib-col-2'>Colour:</td><td class='tbl-attrib-col-3'>$recd[product_color]</td></tr>
</table>
";


$mailtext.="
<table id='tbl-attrib' >
<tr><td class='tbl-attrib-col-2'>Area:</td><td class='tbl-attrib-col-3'>$recd[product_area]</td></tr>
</table>
";



$pro_image=db_scalar("select category_image_name from tbl_category where 1 and category_id='$recd[product_id]'");
$final_shipping_cost=$shipping_cost+$final_shipping_cost;

$pat=$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
//echo $pat."/uploaded_files/".$pro_image;
    
     $mailtext.=" 	  
	  </td>
	  
     <td class='tdLabel' align='center' style='font-size:11px;'>
	 <img src='$pat/uploaded_files/$pro_image' width='70' height='70' />	
	  </td>
	  
        
      <td width='10%' align='center' class='tdData' style='font-size:11px;'><strong>
       $product_unit_price
        </strong></td>
      <td width='10%' align='center' class='tdData' style='font-size:11px;'><strong>
        $product_qty
        </strong></td>
		<td width='10%' align='center' class='tdData' style='font-size:11px;'><strong>
		";
        $totl=$product_qty * $product_unit_price;
        
        $mailtext.="$totl
        </strong></td>";
		

		 $mailtext.="</tr>";
		 } 
		 
		      $mailtext.="<tr>";
        $mailtext.="<td "; 
        $mailtext.="colspan='4'";
        $mailtext.=" align='right' style='text-align:right;'><strong style='color:#0033CC; font-size:13px;'>Tax Amount : </strong></td>
        <td  align='center'><span class='style1' style='font-size:13px;'> 
        ";
         $net_amount+=$ship_charges;
         $tax=db_scalar("select ord_tax from tbl_order where ord_id='$order_id'");
        $number_frmt=number_format($tax,2,'.',',');
        
        $mailtext.="$number_frmt </span></td>
        </tr>";	 
        
		 $mailtext.="<tr>";
      $mailtext.="<td "; 
      $mailtext.="colspan='4'";
      $mailtext.=" align='right' style='text-align:right;'><strong style='color:#0033CC; font-size:13px;'>Total Amount : </strong></td>
      <td  align='center'><span class='style1' style='font-size:13px;'> 
        ";
        $net_amount=$net_amount+$final_shipping_cost;
		$number_frmt=number_format($net_amount,2,'.',',');
		
        $mailtext.="$number_frmt </span></td>
    </tr>
  
  </table>";
  } 
  $mailtext.= '</body>
</html>';



//echo $mailtext;
$hostName = $_SERVER['HTTP_HOST'];	 
//Send to admin
$toEmail = $compDATA['admin_email'];
//$toEmail="rehantki@gmail.com";
$subject = "Order Received From $hostName";
		        $from="$reg_email";
				$Headers1 = "From: $reg_name<$from>\n";
				$Headers1 .= "X-Mailer: PHP/". phpversion();
				$Headers1 .= "X-Priority: 3 \n";
				$Headers1 .= "MIME-version: 1.0\n";
				$Headers1 .= "Content-Type: text/html; charset=iso-8859-1\n"; 
				@mail("$toEmail", "$subject", "$mailtext","$Headers1","-fenquiry@tradekeyindia.com");
				//@mail("amitabh.tradekeyindia@gmail.com", "Subject", "Msg1","$Headers1","-fenquiry@tradekeyindia.com");
				 $toEmail."<br>";
				 
	// Send to client OR user			 
$toEmail="$reg_email";
$subject = "Order Confirmation From $hostName";
		       $from="$compDATA[admin_email]";
		       //$from="rehantki@gmail.com";
				$Headers1 = "From: $compDATA[admin_company_name]<$from>\n";
				$Headers1 .= "X-Mailer: PHP/". phpversion();
				$Headers1 .= "X-Priority: 3 \n";
				$Headers1 .= "MIME-version: 1.0\n";
				$Headers1 .= "Content-Type: text/html; charset=iso-8859-1\n"; 
				@mail("$toEmail", "$subject", "$mailtext","$Headers1","-fenquiry@tradekeyindia.com");
				//@mail("amitabh.tradekeyindia@gmail.com", "Subject", "Msg1","$Headers1","-fenquiry@tradekeyindia.com");
				 $toEmail."<br>";
				 
///////////////****** Mailer to client end here **********************//////////////
///////////////// Mail To Admin //////////////////////////////////

$mail_to_admin="client_enquiry@tradekeyindia.com";
$sub_admin="Business Enquiry From $hostName";
$mail_admin_body = "$mailtext";	
$sender_admin =$reg_email;		
$headers_admin  = "MIME-Version: 1.0" . "\r\n";
$headers_admin .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers_admin .= "from: ".$sender_admin."\n";
if($reg_email){
@mail($mail_to_admin,$sub_admin,$mail_admin_body,$headers_admin);

}



db_query("DELETE FROM tbl_basket WHERE bskt_session_id='$_SESSION[cart_session_id]' ");

unset($_SESSION["cart_session_id"]);
unset($_SESSION["payable_amount"]);
unset($_SESSION["payment_method"]);
unset($_SESSION["comment"]);
unset($_SESSION["tax"]);
unset($_SESSION["sub_total"]);

header("location:thanks.html");
}
}
?>

MMCT - 2023