<?php
      session_start();
      require('includes/config.php') ?>   
<?php require_once('includes/check-login.php'); ?>
<?php require_once('includes/header.php'); ?>
<?php require_once('includes/menu.php'); ?>

        <link rel="stylesheet" type="text/css" href="files/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="files/css/dataTables.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="files/css/fixedHeader.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="files/css/responsive.bootstrap.min.css">

        <script src="files/js/dataTables.bootstrap.min.js"></script>
        <script src="files/js/dataTables.fixedHeader.min.js"></script>
        <script src="files/js/dataTables.responsive.min.js"></script>
        <script src="files/js/responsive.bootstrap.min.js"></script>  
        <script src="files/js/sweetalert.min.js"></script>

        <div class="content-wrapper">
        	<!-- Content Header (Page header) -->
            <!-- home button -->
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>                    
                    <li class="active"><a href="users.php">Job Request</a></li>           
                </ol>                
            <!-- home button -->
            <div class="box box-form"><p></p>
              <div class="box-header with-border">
                        <h3 class="box-title">Available Service Provider</h3>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
                                <i class="fa fa-minus"></i></button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
                                <i class="fa fa-times"></i></button>
                        </div>
                    
				<!-- data table -->
                    <table id="example" class="table table-striped table-bordered" style="width:100%">
                            <thead>
                            <tr>
                                <th>Id</th>
                                <th>Name</th>
                                <th>Mobile</th>
                                <th>Email</th>                       
                                <th>City</th>         
                                <th>Pincode</th>
                                <th>Approval</th>
                            </tr>
                            </thead>  
                            <tbody>
                                <?php
                                print_r($_GET);

                                $time_val =  strtotime(date("Y-m-d"));              
                                //$cust_id = $_GET['posted_id'];
                                //$pincode = $_GET['pincode'];
                                   $cust_id = 1017;
                                   $pincode = 607202;
                                   $convert_pincode = substr($pincode,0,3);
                                   $pincode_after = $pincode+1; 
                                   $pincode_before = $pincode-1; 

                                   $sql_user_role = "SELECT SPJT.*, jr.job_description AS jdesc, jr.request_id AS job_id 
                                                    FROM 
                                                    job_requests AS jr JOIN 
                                                    service_provider_job_temp AS SPJT 
                                                    ON jr.request_id = SPJT.request_id 
                                                    WHERE
                                                    SPJT.is_rejected = 0 AND jr.request_id = 3";

                                    $result = $con->query($sql_user_role);
                                    if ($result->num_rows > 0) {
                                        while( $row = $result->fetch_assoc() ) {
                                    ?>
                                <tr>
                                    <td><?php echo $row['user_id']; ?></td>
                                    <td><?php echo $row['user_name']; ?></td>
                                   	<td><?php echo $row['phone']; ?></td>
                                    <td><?php echo $row['email']; ?></td>
                                    <td><?php echo $row['city']; ?></td>
                                    <td><?php echo $row['pincode']; ?></td>
                                    <td><button class="btn btn-success" onclick="reselect_sp(<?php echo $_REQUEST['rid']; ?>,<?php echo $row['user_id']; ?>)">Assign job</button></td>
                                </tr>
                                <?php
                                 }
                                    } else {
                                        echo "Your Table is Empty";
                                    }
                                ?>
                              </tbody>  
                    </table> 
                    <script>
                        $(document).ready(function() {
                            var table = $('#example').DataTable( {
                                responsive: true
                            } );
                            new $.fn.dataTable.FixedHeader( table );
                        } );
                    </script>
				<!-- data table -->
            </div>
            <!-- Content Header (Page header) -->
            </div>
        </div>
<script src="js/common.js"></script>  
<script src="js/users/script.js"></script>     
<script src="js/jobRequests/script.js"></script>     
<?php require_once('includes/footer.php'); ?>