<?php
session_start();
include 'session_check.php';
require_once('include/constant.php');
include 'get_user_info.php';
require_once('include/functions.php');

$_SESSION['send_money_security'] = substr(str_shuffle(str_repeat("0123456789", 15)), 0, 10);
if($got_unique_id != ADMIN_ID)
{
	echo '<script> alert("Sorry, you do not have permission to access this page"); window.location="dashboard.php"; </script>';
	die;
}
?>
	<head>
    <meta charset="UTF-8">
    <title>AdminLTE 2 | Dashboard</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="send_money_code.php">
				<input type="hidden" name="send_money_security" value="<?php echo isset($_SESSION['send_money_security']) ? $_SESSION['send_money_security'] : ''?>">
                <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_balance=$xyz['total_balance'];
                            }
                            ?>
                            <h3> Send money  </h3>
                            <h5> Wallet balance : <span style="font-weight: bold"> Rs. <?php if(!EMPTY($total_balance)){echo number_format((float)$total_balance, 2, '.', '');}else{echo '0';}?> </span> </h5>
                            
                            
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="user_idd_send_money" name="user_idd" placeholder="Enter user id" maxlength="10" value="<?php echo isset($_REQUEST['id']) && $_REQUEST['id'] !='' ? $_REQUEST['id'] : ''?>" required>
                            <span id="err_user_id" class="text-dengar"></span>
                            <span id="msg_check" style="display: none"></span>
                        </div>
                       
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" id="fetch_name" name="fetch_name" readonly disabled>
                        </div>
                    </div>
					 <br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="radio" class="wallet-amount-btn" name="transffer_type" value="1" checked onclick="$('.affiliate-list').hide()"> Wallet Amount
							<input type="radio" class="amazon-amount-btn" name="transffer_type" value="5" onclick="$('.affiliate-list').show()" > Amazon Amount
                        </div>
                    </div>
					<br>
                    <div class="row affiliate-list">
                        <div class="col-sm-8 col-sm-offset-2">
                           <select class="form-control affiliate_id" name="affiliate_id">
							  <option value=""> Select affiliate product to pay </option>
							  <?php
							   if(isset($_REQUEST['id']) && $_REQUEST['id'] !='' && strtoupper($_REQUEST['id']) != ADMIN_ID)
							   {
							    $qry="select * from affiliate WHERE LOWER(user_id) = '".strtolower($_REQUEST['id'])."' ORDER BY last_update DESC " ;
								$con = mysqli_query($conn, $qry);
								if(mysqli_num_rows($con)>0)
								{
									while($rows=mysqli_fetch_assoc($con))
									{
										$is_selected = isset($_REQUEST['affiliate']) && $_REQUEST['affiliate'] !='' && trim($_REQUEST['affiliate']) == $rows['id'] ? 'selected' : '';
										echo '<option value="'.$rows['id'].'" '.$is_selected.'> '.$rows['product_name'].' </option>';
									}
								}
								
							   }
							   ?>
						   </select>
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="text" class="form-control" step="10" id="amount_send_money" name="amount" maxlength="10" placeholder="Enter the amount" maxlength="10" required>
                            <span id="err_amount"></span>
                            <span id="msg_check2" style="display: none"></span>
                        </div>
                    </div>
                    <br>
                    <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="password" class="form-control" id="treansaction_pwd2" name="treansaction_pwd" placeholder="Enter the transaction password" maxlength="10" required>
                            <span id="err_trns_pwd"></span>
                            <span id="err_pwd_check" style="display: none"></span>
                        </div>
                    </div>
                    <br>
                     <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <textarea class="form-control" id="remarks" name="remarks" placeholder="Enter the remark" rows="4"></textarea>
                        </div>
                    </div>
                    <br>
                     <div class="row">
                        <div class="col-sm-8 col-sm-offset-2">
                            <input type="submit" class="form-control" id="send_balance" name="btn_send_money" value="Send">
                        </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>
    <script>
		$(document).ready(function(){
			var affiliate_id = '<?php echo isset($_REQUEST["affiliate"]) ? $_REQUEST["affiliate"] : ''?>';
			if(typeof(affiliate_id) !='undefined' && affiliate_id!='')
			{
				$('.affiliate_id').attr('required','');
				$('.amazon-amount-btn').click();
			}
			else
			{
				$('.wallet-amount-btn').click();
				$('.amazon-amount-btn').attr('disabled', true);
				$('.amazon-amount-btn').attr('readonly', true);
				$('.affiliate_id').removeAttr('required');
			}
		});
	</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';
?>