<?php
session_start();
include 'session_check.php';
include 'include/db.php';
require_once('include/functions.php');
$_SESSION['requirity_check'] = md5(get_unique_id(''));

//   fetch tax amount
$slt_tax="select * from tax";
$con_tax=mysqli_query($conn,$slt_tax);
if(mysqli_num_rows($con_tax)>0)
{
    $aa=mysqli_fetch_assoc($con_tax);
    $tax_amount=$aa['tax_amount'];
}

// mail
/*$to = "apurbakarar7063@gmail.com";
$subject = "My subject";
$txt = "Hello world!";
$headers = "From: apurbakarar7063@gmail.com" . "\r\n" .
"CC: apurbakarar7063@gmail.com";

if(mail($to,$subject,$txt,$headers))
{
	echo 'send'; die;
}
else
{
	'not send'; die;
}

*/

/*$registration = [
	'[USER_NAME]'      => 'Apurba Karar',
	'[WEBSITE_NAME]'   => WEBSITE_DOMAIN,
	'[UNIQUE_ID]'      => 'B00001',
	'[PASSWORD]'       => 'password12345',
];

$sms_body = str_replace(array_keys($registration), $registration, get_sms_template('REGISTRATION'));
$return =  json_decode(SendSMS(8918781267, $sms_body), true);
echo $return['status'];*/

?>
	<head>
    <meta charset="UTF-8">
    <title>Fairy Herbal Portal | Buy Product</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap 3.3.2 -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />    
    <!-- FontAwesome 4.3.0 -->
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <!-- Ionicons 2.0.0 -->
    <link href="https://code.ionicframework.com/ionicons/2.0.0/css/ionicons.min.css" rel="stylesheet" type="text/css" />    
    <!-- Theme style -->
    <link href="dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
    <!-- AdminLTE Skins. Choose a skin from the css/skins 
         folder instead of downloading all of them to reduce the load. -->
    <link href="dist/css/skins/_all-skins.min.css" rel="stylesheet" type="text/css" />
    <!-- iCheck -->
    <link href="plugins/iCheck/flat/blue.css" rel="stylesheet" type="text/css" />
    <!-- Morris chart -->
    <link href="plugins/morris/morris.css" rel="stylesheet" type="text/css" />
    <!-- jvectormap -->
    <link href="plugins/jvectormap/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
    <!-- Date Picker -->
    <link href="plugins/datepicker/datepicker3.css" rel="stylesheet" type="text/css" />
    <!-- Daterange picker -->
    <link href="plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
    <!-- bootstrap wysihtml5 - text editor -->
    <link href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css" rel="stylesheet" type="text/css" />
	
	<!-----		sweet alert css and js link	---->
	<link rel="stylesheet" href="dist/sweetalert.css">
	<script src="dist/sweetalert.min.js"> </script>
   
   
	<link rel="stylesheet" type="text/css" href="custom/custom.css">
	<!---- Ck editor-->
	 <script src="ckeditor/ckeditor.js"></script>
	 
  </head>

<?php
include 'include/header.php';
include 'include/left-nav.php';
?>

      <?php


	  ?>
      <!-- Right side column. Contains the navbar and content of the page -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container">
            <form method="POST" action="purchase_code.php">
				<input type="hidden" name="security_check" value="<?php echo isset($_SESSION['requirity_check']) ? $_SESSION['requirity_check'] : '';?>">
                <!-----   tax amount hidden fields     --->
                <input type="hidden" id="take_tax_amount" value="<?php if(isset($aa['tax_amount'])) echo $tax_amount;?>">
                <input type="hidden" id="print_tax_amount" name="get_tax_amount">
                <!---   end  tax blog --->
                <input type="hidden" id="take_user_id" name="take_user_id" value="<?php echo $got_unique_id?>">
                <div class="well col-sm-6 col-sm-offset-3" style="margin-top: 20px">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2 text-center">
                            <?php
                            $qqr="select * from wallet_balance where balance_user_id='$got_unique_id' ";
                            $conn2=mysqli_query($conn,$qqr);
                            if(mysqli_num_rows($conn2)>0)
                            {
                                $xyz=mysqli_fetch_array($conn2);
                                $total_balance2=$xyz['total_balance'];
                            }
                            
                            ?>
                            <h3> Buy products  </h3>
                            <h5> Wallet balance : <span style="font-weight: bold"> Rs. <?php echo isset($total_balance2) && $total_balance2 !='' ? number_format((float)$total_balance2, 2, '.', '') : 0.00;?> </span> </h5>
                            
                            
                        </div>
                    </div>
                    <br>
                    <div class="row d-none">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="radio" name="user" value="self" id="self" checked>  Self  &nbsp 
                            <!--<input type="radio" name="user" value="others" id="others"> Others-->
                        </div>
                    </div>
                    <br>
                    <div id="hide_rw" class="d-none">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="fetch_id" name="fetch_id" value="<?php echo $got_unique_id;?>" readonly>
                        </div>
                    </div>
                    <br>
                    </div>
                    <div id="hide_rw2" class="d-none">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="buy_user_idd" name="buy_user_idd" placeholder="Enter user id">
                            <span id="err_buy_user_id" class="text-dengar"></span>
                            <span id="msg_check_buy" style="display: none"></span>
                        </div>
                       
                    </div>
                    <br>
                    </div>
                    <div id="hide_rw3">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="fetch_name_buy" readonly required>
                        </div>
                    </div>
                    <br>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <select class="form-control" name="product" id="product" required>
                                <option value=""> ** Please select product </option>
                                <?php
                                $qrr1="select * from product";
                                $con1=mysqli_query($conn,$qrr1);
                                if(mysqli_num_rows($con1)>0)
                                {
                                    while($rw=mysqli_fetch_array($con1))
                                    {
                                ?>
                                    <option value="<?php echo $rw['product_id']. '+' .$rw['product_price']. '+' .$rw['product_bv'] ; ?>" > <?php echo $rw['product_name']; ?> </option>
                                <?php
                                    }
                                }
                                ?>
                            </select>
                            <span id="err_product"></span>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="fetch_amount" name="fetch_amount" readonly>
                            <span id="err_amount_not"></span>
                            <span id="print_tax_msg"></span>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
					<div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <select class="form-control" name="purchase_by" required>
                                <option value=""> ** Please select purchase by </option>
								<option value="post"> By Post </option>
								<option value="courier"> By Courier </option>
								<option value="hand"> By Hand </option>
                            </select>
                        </div>
                    </div>
					</div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="password" class="form-control" id="treansaction_pwd_buy" name="treansaction_pwd_buy" placeholder="Enter the transaction password" required>
                            <span id="err_trns_pwd_buy"></span>
                            <span id="err_pwd_check_buy" style="display: none"></span>
                        </div>
                    </div>
                    </div>
					
					<!--------- mailing address  ------->
					<div class="form-group">
					<div class="row">
						 <div class="col-sm-8 col-sm-offset-2 text-center" style="font-size: 15px">
						  Mailing Address
						 </div>
					</div>
					<br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" name="m_name" placeholder="Name" maxlength="30" value="" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" name="m_co" placeholder="C/O" maxlength="30" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" name="m_address" placeholder="Address" maxlength="60" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" name="m_landmark" placeholder="Landmark" maxlength="30" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="number" class="form-control" name="m_pin" placeholder="Pincode" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="number" class="form-control" name="m_mobile" placeholder="Phone Number" required>
                        </div>
                    </div>
                    </div>
					<div class="form-group">
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <textarea class="form-control" name="m_remarks" placeholder="Remarks" maxlength="50"></textarea>
                        </div>
                    </div>
                    </div>
					
					<div class="form-group">
                     <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="submit" class="form-control" id="buy_product_btn" name="purchase_btn" value="Buy now">
                        </div>
                    </div>
					</div>
                </div>
            </form>
            </div>
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->

	
		 <!-- jQuery 2.1.3 -->
    <script src="plugins/jQuery/jQuery-2.1.3.min.js"></script>
    <!------    custom js    -------->
     <script src="js/custom.js"></script>
    <!-- jQuery UI 1.11.2 -->
    <script src="https://code.jquery.com/ui/1.11.2/jquery-ui.min.js" type="text/javascript"></script>
    <?php
    if($status=='Deactive')
    {
        include 'modal_show.php';
    }
    ?>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script>
      $.widget.bridge('uibutton', $.ui.button);
    </script>
    <!-- Bootstrap 3.3.2 JS -->
    <script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>    
    <!-- Morris.js charts -->
   <!-- <script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>-->
    <!---<script src="plugins/morris/morris.min.js" type="text/javascript"></script>-->
    <!-- Sparkline -->
    <script src="plugins/sparkline/jquery.sparkline.min.js" type="text/javascript"></script>
    <!-- jvectormap -->
    <script src="plugins/jvectormap/jquery-jvectormap-1.2.2.min.js" type="text/javascript"></script>
    <script src="plugins/jvectormap/jquery-jvectormap-world-mill-en.js" type="text/javascript"></script>
    <!-- jQuery Knob Chart -->
    <script src="plugins/knob/jquery.knob.js" type="text/javascript"></script>
    <!-- daterangepicker -->
    <script src="plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
    <!-- datepicker -->
    <script src="plugins/datepicker/bootstrap-datepicker.js" type="text/javascript"></script>
    <!-- Bootstrap WYSIHTML5 -->
    <script src="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
    <!-- iCheck -->
    <script src="plugins/iCheck/icheck.min.js" type="text/javascript"></script>
    <!-- Slimscroll -->
    <script src="plugins/slimScroll/jquery.slimscroll.min.js" type="text/javascript"></script>
    <!-- FastClick -->
    <script src='plugins/fastclick/fastclick.min.js'></script>
    <!-- AdminLTE App -->
    <script src="dist/js/app.min.js" type="text/javascript"></script>
    
    
    
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
   <!-- <script src="dist/js/pages/dashboard.js" type="text/javascript"></script>-->
	  
	  
<?php
include 'include/footer.php';
?>