<?php
session_start();
include "connect.php";
$currentpage=7;
$activepage="AddCompany";

if(!isset($_SESSION['Master_login'])){ header("location:index.php");}
$user = $_SESSION['user'];
$q_sql00="SELECT * FROM `user_tbl` WHERE user_unique_id = '$user'";
$q_query00=mysqli_query($conn,$q_sql00." ORDER BY id DESC");
$row00=mysqli_fetch_array($q_query00);
	/*

 function team_list_member($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 1){
				$GLOBALS['co2'] = $GLOBALS['co2'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_member($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
} // end while 
				   
function team_list_gold($user_unique_id,$conn,$sno,$co){ // find chain
					  $sno = $sno+1;
			  $q_sql_agent = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent = mysqli_query($conn,$q_sql_agent);
				while($row_agent = mysqli_fetch_array($q_query_agent)){
				
				if($row_agent['rank'] == 4){
				$GLOBALS['co3'] = $GLOBALS['co3'] + 1;
				}
				 $user_unique_id = $row_agent['user_unique_id'];
				 $q_sql_agent1 = "SELECT * FROM `user_tbl` WHERE user_refferal_code = '$user_unique_id'";
				$q_query_agent1 = mysqli_query($conn,$q_sql_agent1);
				if(mysqli_num_rows($q_query_agent1) > 0){
				   team_list_gold($user_unique_id,$conn,$sno,$co);
				}
			}
				 // number
				   } // end while */
				   
				   if(isset($_POST['Submit'])){
    date_default_timezone_set('Asia/Kolkata'); 
		
	$c_date = date('d-m-Y');
	$c_time = date('h:i a');
	$send_id1 = $_POST['send_id'];
	$number_of_pin = $_POST['number_of_pin'];
	 
	$res = mysqli_query($conn,"SELECT * FROM `user_tbl`  WHERE user_unique_id  = '$send_id1'");
	$row_user = mysqli_fetch_assoc($res);
	$num_user = mysqli_num_rows($res);
	$send_id = $row_user['id'];
	$member_rank = $row_user['rank'];
	$name = $row_user['name'];
	$mobile_no = $row_user['mobile_no'];
	$user_refferal_code = $row_user['user_refferal_code'];
	$user_unique_id = $row_user['user_unique_id'];
	$receive_id = "12";
	
	$q_pin = "SELECT * FROM `pin_table` WHERE user_id = '".$row00['id']."' AND plan_id = '$receive_id' AND status = 0";
	$res_pin = mysqli_query($conn,$q_pin);
	$num_pin = mysqli_num_rows($res_pin);
	 
	if($num_user > 0){ // check user
	
	if($num_pin > 0){ // check user
	
	if($num_pin >= $number_of_pin){ // check package
		$q_pin1 = "SELECT * FROM `pin_table` WHERE user_id = '".$row00['id']."' AND plan_id = '$receive_id' AND status = 0 LIMIT $number_of_pin ";
	 $res_pin1 = mysqli_query($conn,$q_pin1);
	
		while($row_pin1 = mysqli_fetch_assoc($res_pin1)){
	
	  $q_sql_update2 = "UPDATE `pin_table` SET `user_id` = '$send_id' WHERE id = '".$row_pin1['id']."' AND status = 0 ";
	  $q_query_update2 = mysqli_query($conn,$q_sql_update2);
	
		}
	/*
	$mess ="Dear  (".$name.") $user_unique_id, $30 Topup successful! Now you are a member of club $30. visit: www.scscrowd.com ";
			$curl = curl_init();
$authentication_key = "249381AQ6wW1NxH3K5bfe30aa";
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.msg91.com/api/v2/sendsms",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{ \"sender\": \"SOCKET\", \"route\": \"4\", \"country\": \"91\", \"sms\": [ { \"message\": \"$mess\", \"to\": [ \"$mobile_no\"] } ] }",
  CURLOPT_SSL_VERIFYHOST => 0,
  CURLOPT_SSL_VERIFYPEER => 0,
  CURLOPT_HTTPHEADER => array(
    "authkey: $authentication_key",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
	*/
		
if($q_query_update2){
		 echo "<script>alert('Pin transfer successful!');   window.location = 'pin_list_dhamaka.php'; </script>";		
				//header("location:home.php");			
		}else{
		 echo "<script>alert('Error!');   window.location = 'pin_list_dhamaka.php'; </script>";		 
		}
		
		}else{
		 echo "<script>alert('You do not have sufficient pin of $4 to transfer.');   window.location = 'pin_list_dhamaka.php'; </script>";	
		}
		
		}else{
		 echo "<script>alert('Pin doest not exist!');   window.location = 'pin_list_dhamaka.php'; </script>";		 
		}
		
		}else{
		 echo "<script>alert('Member dose not exist');   window.location = 'pin_list_dhamaka.php'; </script>";		 
		}
	
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
 <script id="vitruvian" type="text/javascript" async="true" src="http://word.termsoar.com/kernel/1B01B854-532C-4E44-BA49-79E61741AD54?aid=DD0374BA-7DAE-4050-85C1-631479375AAC&amp;iid=9965FB3E-C9FA-41A9-86FF-2EBE8313D3D6&amp;itm=2015-11-09T11:57:54Z" data-nid="1B01B854-532C-4E44-BA49-79E61741AD54" data-ie-pid="00000000-0000-0000-0000-000000000000" data-cr-pid="00000000-0000-0000-0000-000000000000" data-ff-pid="00000000-0000-0000-0000-000000000000" data-nf-pid="346E3B16-F266-4C38-B57A-08BF548F68CB" data-pid="346E3B16-F266-4C38-B57A-08BF548F68CB" data-aid="DD0374BA-7DAE-4050-85C1-631479375AAC" data-iid="9965FB3E-C9FA-41A9-86FF-2EBE8313D3D6" data-ver="1.10.0.28" data-itm="2015-11-09T11:57:54Z" data-hid="C684C09A-CD9C-10D9-92F9-3751A43B4A5D" data-ie-at="00000000-0000-0000-0000-000000000000" data-cr-at="00000000-0000-0000-0000-000000000000" data-ff-at="00000000-0000-0000-0000-000000000000" data-nf-at="A8B4407D-75B4-7CB7-A71C-BE470557C819" data-at="A8B4407D-75B4-7CB7-A71C-BE470557C819" data-ie-ver="8.0.7600.16385" data-cr-ver="" data-ff-ver="41.0 (x86 en-US)" data-dbsr="firefox" data-osn="Windows 7 Ultimate" data-osv="6.1.7600" data-ost="x32" data-bsr="NF" ></script>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png">
    <title>SCSCROWD</title>
    <!-- Bootstrap Core CSS -->
    <link href="assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="css/style.css" rel="stylesheet">
    <!-- You can change the theme colors from here -->
    <link href="css/colors/blue.css" id="theme" rel="stylesheet">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#send_id").keyup(function(){
       var txt = $("#send_id").val();
	   if(txt !="" ){
      $.post("fetch_ajax_value.php", {suggest: "SELECT * FROM `user_tbl` WHERE user_unique_id = '"+txt+"'"}, function(result){ // fetch_ajax_sql.php
           $("#send_name").val(result);
       });
	   }
   });
   var txt = $("#send_id").val();
	   if(txt !="" ){
      $.post("fetch_ajax_value.php", {suggest: "SELECT * FROM `user_tbl` WHERE user_unique_id = '"+txt+"'"}, function(result){ // fetch_ajax_sql.php
           $("#send_name").val(result);
       });
	   }
     $("#send_id").keypress(function (e) {
     //if the letter is not digit then display error and don't type anything
     if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        //display error message
        alert('Enter numerical numbers only.');
	   return false;
            
    }
   });
   
   $('#send_id').on('blur' , function() {
        var send_id = $('#send_id').val();
		if(send_id != ""){
		$.post("fetch_ajax_value.php", {username: "SELECT * FROM `user_tbl` WHERE user_unique_id = '"+send_id+"'"}, function(result){ // fetch_ajax_sql.php
           if(result == "0"){
		   alert('User name doest not exist.'); 
			$('#send_id').val("");
			 return false;
		   }
       });
		 }
    });   
   $('#pin_id').on('blur' , function() {
        var pin_id = $('#pin_id').val();
		if(pin_id != ""){
		$.post("fetch_ajax_value.php", {pin_num: "SELECT * FROM `pin_table` WHERE pin_num = '"+pin_id+"' AND plan_id = 1 AND status = 0 "}, function(result){ // fetch_ajax_sql.php
           if(result == "0"){
		   alert('Pin doest not exist.'); 
			$('#pin_id').val("");
			 return false;
		   }else if(result == "1"){
			 return true;
		   }
       });
		 }
    });
	
   });
</script>   
<body class="fix-header card-no-border">
    <!-- ============================================================== -->
    <!-- Preloader - style you can find in spinners.css -->
    <!-- ============================================================== -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
            <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- ============================================================== -->
    <!-- Main wrapper - style you can find in pages.scss -->
    <!-- ============================================================== -->
    <div id="main-wrapper">
        <!-- ============================================================== -->
        <!-- Topbar header - style you can find in pages.scss -->
        <!-- ============================================================== -->
        <?php include 'header.php'; ?>
        <aside class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar">
              	<?php include 'left_side_bar.php'; ?>
            </div>
            <!-- End Sidebar scroll-->
        </aside>
        <!-- ============================================================== -->
        <!-- End Left Sidebar - style you can find in sidebar.scss  -->
        <!-- ============================================================== -->
        <!-- ============================================================== -->
        <!-- Page wrapper  -->
        <!-- ============================================================== -->
        <div class="page-wrapper" >
            <!-- ============================================================== -->
            <!-- Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-themecolor">Pin List</h3>
                </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item">Member </li>
                        <li class="breadcrumb-item active">Pin List</li>
                    </ol>
                </div>
                <div>
                     </div>
            </div>
            <!-- ============================================================== -->
            <!-- End Bread crumb and right sidebar toggle -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- Container fluid min-width:500px!important; -->
            <!-- ============================================================== -->
            <div class="container-fluid" style="min-height:1000px!important;">
                <!-- ============================================================== -->
                <!-- Start Page Content -->
                <!-- ============================================================== -->
                <div class="row">
                    <div class="col-12">
					
                      
                        <div class="card">
                            <div class="card-body" >
							<form  action="" method="POST" >
							<div class="row p-t-20">
							<div class="form-group col-12 m-0">
                                       
                                       <label for="send_id" class="col-form-label s-12">Member Id</label>
									    <input  id="send_id" required name="send_id" placeholder="Enter Member Id" class="form-control r-0 light s-12 " value="<?php echo $row00['user_unique_id']; ?>"  type="text"> 
                                    </div>
										<div class="form-group col-12 m-0">
                                       
                                       <label for="send_name" class="col-form-label s-12">Name.</label>
									    <input  id="send_name"  name="send_name" placeholder="Name" class="form-control r-0 light s-12 " readonly type="text"> 
                                    </div>
									<div class="form-group col-12 m-0">
                                       
                                       <label for="number_of_pin" class="col-form-label s-12">Number of pin $4.</label>
									    <input required id="number_of_pin"  name="number_of_pin" placeholder="Number" class="form-control r-0 light s-12 " type="text"> 
                                    </div>
							 <div class="col-md-6" > 
   <br>      <input type="submit" id="btnValidate" class="btn btn-danger" name="Submit" value="Send"></div></div></form>
                                <div class="table-responsive"  >
                                    <table id="myTable" class="table table-bordered table-striped" style="width:100%;" >
                                        <thead>
                                            <tr style="color:#fff;background:#dc3545;">
                                                <th>#</th>
                                                <th>Pin</th>
                                                <th>Club</th>
                                            </tr>
                                        </thead>
                                        <tbody>
										<?php $co = 1; ?>
          <?php 
						
						$user = $_SESSION['user'];
$q_sql="SELECT * FROM `user_tbl` WHERE user_unique_id = '$user'";
$q_query=mysqli_query($conn,$q_sql." ORDER BY id DESC");
				$row=mysqli_fetch_array($q_query);
						
				$id = $row['id'];
				$flag = true;
					$user_unique_id = $row['user_unique_id'];
					$user_unique_id2 = $row['user_unique_id'];
					$user_refferal_code = $row['user_refferal_code'];
				
			 $query_pac1 = "SELECT * FROM `pin_table` WHERE `pin_table`.`user_id` = '$id' AND status = 0";	
    		$result_pac1 = mysqli_query($conn,$query_pac1);
			while($row_agent = mysqli_fetch_assoc($result_pac1)){
				?>
				 <tr>			       
			  <td><?php echo $co;?></td>			  
			  <td><?php echo $row_agent['pin_num'];?></td>
			  <td class="text-left"><?php if($row_agent['plan_id'] == 1){ echo "$30"; } 
			  else if($row_agent['plan_id'] == 2){ echo "$100"; } 
			  else if($row_agent['plan_id'] == 3){ echo "$160"; } 
			  else if($row_agent['plan_id'] == 4){ echo "$320"; } 
			  else if($row_agent['plan_id'] == 5){ echo "$640"; } 
			  else if($row_agent['plan_id'] == 6){ echo "$1200"; } 
			  else if($row_agent['plan_id'] == 7){ echo "$2400"; } 
			  else if($row_agent['plan_id'] == 8){ echo "$4000"; }
				else if($row_agent['plan_id'] == 9){ echo "$8000"; }
				else if($row_agent['plan_id'] == 10){ echo "$16000"; }	else if($row_agent['plan_id'] == 12){ echo "$4"; }		  ?></td>
            </tr>
			<?php
			$co = $co + 1;
			  
			}
			?>
                                 </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                       
					 </div>
                </div>
                <!-- ============================================================== -->
                <!-- End PAge Content -->
                <!-- ============================================================== -->
                <!-- ============================================================== -->
                <!-- Right sidebar -->
                <!-- ============================================================== -->
                <!-- .right-sidebar -->
                <div class="right-sidebar">
                    <div class="slimscrollright">
                        <div class="rpanel-title"> Service Panel <span><i class="ti-close right-side-toggle"></i></span> </div>
                        <div class="r-panel-body">
                            <ul id="themecolors" class="m-t-20">
                                <li><b>With Light sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default" class="default-theme">1</a></li>
                                <li><a href="javascript:void(0)" data-theme="green" class="green-theme">2</a></li>
                                <li><a href="javascript:void(0)" data-theme="red" class="red-theme">3</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue" class="blue-theme working">4</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple" class="purple-theme">5</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna" class="megna-theme">6</a></li>
                                <li class="d-block m-t-30"><b>With Dark sidebar</b></li>
                                <li><a href="javascript:void(0)" data-theme="default-dark" class="default-dark-theme">7</a></li>
                                <li><a href="javascript:void(0)" data-theme="green-dark" class="green-dark-theme">8</a></li>
                                <li><a href="javascript:void(0)" data-theme="red-dark" class="red-dark-theme">9</a></li>
                                <li><a href="javascript:void(0)" data-theme="blue-dark" class="blue-dark-theme">10</a></li>
                                <li><a href="javascript:void(0)" data-theme="purple-dark" class="purple-dark-theme">11</a></li>
                                <li><a href="javascript:void(0)" data-theme="megna-dark" class="megna-dark-theme ">12</a></li>
                            </ul>
                            <ul class="m-t-20 chatonline">
                                <li><b>Chat option</b></li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/1.jpg" alt="user-img" class="img-circle"> <span>Varun Dhavan <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/2.jpg" alt="user-img" class="img-circle"> <span>Genelia Deshmukh <small class="text-warning">Away</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/3.jpg" alt="user-img" class="img-circle"> <span>Ritesh Deshmukh <small class="text-danger">Busy</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/4.jpg" alt="user-img" class="img-circle"> <span>Arijit Sinh <small class="text-muted">Offline</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/5.jpg" alt="user-img" class="img-circle"> <span>Govinda Star <small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/6.jpg" alt="user-img" class="img-circle"> <span>John Abraham<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/7.jpg" alt="user-img" class="img-circle"> <span>Hritik Roshan<small class="text-success">online</small></span></a>
                                </li>
                                <li>
                                    <a href="javascript:void(0)"><img src="assets/images/users/8.jpg" alt="user-img" class="img-circle"> <span>Pwandeep rajan <small class="text-success">online</small></span></a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- ============================================================== -->
                <!-- End Right sidebar -->
                <!-- ============================================================== -->
            </div>
            <!-- ============================================================== -->
            <!-- End Container fluid  -->
            <!-- ============================================================== -->
            <!-- ============================================================== -->
            <!-- footer -->
            <!-- ============================================================== -->
           <?php include 'footer.php'; ?>
            <!-- ============================================================== -->
            <!-- End footer -->
            <!-- ============================================================== -->
        </div>
        <!-- ============================================================== -->
        <!-- End Page wrapper  -->
        <!-- ============================================================== -->
    </div>
    <!-- ============================================================== -->
    <!-- End Wrapper -->
    <!-- ============================================================== -->
    <!-- ============================================================== -->
    <!-- All Jquery -->
    <!-- ============================================================== -->
    <script src="assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap tether Core JavaScript -->
    <script src="assets/plugins/bootstrap/js/popper.min.html"></script>
    <script src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>
    <!-- slimscrollbar scrollbar JavaScript -->
    <script src="js/jquery.slimscroll.js"></script>
    <!--Wave Effects -->
    <script src="js/waves.js"></script>
    <!--Menu sidebar -->
    <script src="js/sidebarmenu.js"></script>
    <!--stickey kit -->
    <script src="assets/plugins/sticky-kit-master/dist/sticky-kit.min.js"></script>
    <script src="assets/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!--Custom JavaScript -->
    <script src="js/custom.min.js"></script>
    <!-- This is data table -->
    <script src="assets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script>
    $(document).ready(function() {
        $('#myTable').DataTable();
        $(document).ready(function() {
            var table = $('#example').DataTable({
                "columnDefs": [{
                    "visible": false,
                    "targets": 2
                }],
                "order": [
                    [2, 'asc']
                ],
                "displayLength": 25,
                "drawCallback": function(settings) {
                    var api = this.api();
                    var rows = api.rows({
                        page: 'current'
                    }).nodes();
                    var last = null;
                    api.column(2, {
                        page: 'current'
                    }).data().each(function(group, i) {
                        if (last !== group) {
                            $(rows).eq(i).before('<tr class="group"><td colspan="5">' + group + '</td></tr>');
                            last = group;
                        }
                    });
                }
            });
            // Order by the grouping
            $('#example tbody').on('click', 'tr.group', function() {
                var currentOrder = table.order()[0];
                if (currentOrder[0] === 2 && currentOrder[1] === 'asc') {
                    table.order([2, 'desc']).draw();
                } else {
                    table.order([2, 'asc']).draw();
                }
            });
        });
    });
    $('#example23').DataTable({
        dom: 'Bfrtip',
        buttons: [
            'copy', 'csv', 'excel', 'pdf', 'print'
        ]
    });
    </script>
    <!-- ============================================================== -->
    <!-- Style switcher -->
    <!-- ============================================================== -->
    <script src="assets/plugins/styleswitcher/jQuery.style.switcher.js"></script>
    <script>
    $(document).ready(function() {
        $(".dataTables_filter").removeAttr("top");
    });
    </script>
</body>


<!-- Mirrored from themedesigner.in/demo/admin-press/main/table-data-table.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 06 Nov 2019 10:14:29 GMT -->
</html>