<?php include("connectdb.php"); ?>
<?php include("side_nav.php"); ?>
<?php include("top_nav.php"); ?>

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
                <h3></h3>
              </div>

            </div>
            <div class="clearfix"></div>

            <div class="row">

              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Sell from Rx Wallet <small></small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <p class="text-muted font-13 m-b-30">
                      User can pay with their rx wallet from here.
                    </p>

                    <!-- Smart Wizard -->
                    <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off" class="form-horizontal form-label-left">
					
					  <?php
			             if ( isset($output) ) {
				      ?>
				         <div class="form-group">
            	            <div class="alert alert-danger">
				               <span class="glyphicon glyphicon-info-sign"></span> <?php echo $output; ?>
                            </div>
            	         </div>
                     <?php
			           }
			         ?>
					

                      <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Email"> Scan bar code<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input name="loyalty_id" type="text" id="loyalty_id" onkeyup="process_key(event)" placeholder="Scan the barcode" required="required" class="form-control col-md-7 col-xs-12">
                        </div>
                      </div>
					  
					  <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Email"> Email<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                          <input type="email" id="email" name="email" required="required" class="form-control col-md-7 col-xs-12" placeholder="Enter user email">
                        </div>
                      </div>
					  
					  <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="amount"> Amount<span class="required">*</span>
                        </label>
                        <div class="col-md-4 col-sm-4 col-xs-12">
                          <input type="number" id="amount" name="amount" required="required" class="form-control col-md-7 col-xs-12" placeholder="Cost of items">
                        </div>
                      </div>
                      
                      <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                          <button name="submit" onclick="sellNow()" type="submit" class="btn btn-primary">Submit</button>
                        </div>
                      </div>

                    </form>
                    <!-- End SmartWizard Content -->
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
<?php include("footer.php"); ?>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
function sellNow(){
	var barcode_value = $('#loyalty_id').val();
	var email = $('#email').val();
	var amount = $('#amount').val();
	
	var d = new Date();
	var sell_id = Math.floor((Math.random() * 100) + 1) + 'sale' + d.getTime();
	
	 $.ajax({
			url	:	"process.php",
			type:	"POST",
			data	:	{sellNow:1, barcode_value:barcode_value, email:email, amount:amount, tranx_id:sell_id },
			success	:	function(data){ 
				alert(data);
			}
        });      
	
}
</script>
