<?php require_once('header.php'); ?>
<?php if($session_id==1 || $allPermissions['pickup_points']['read']=="1"){ ?>
<section class="content" style="background-color: white;">
    
    
    
    <div class="row">
		<div class="col-md-4" style="text-align: left;">
			<h4><i class="fa fa-map-marker"></i> Pickup Points Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
		<?php if($session_id==1 || $allPermissions['pickup_points']['create']=="1"){ ?>
		    <a href="pickup_points.php" class="btn btn-success btn-sm"><i class="fa fa-plus"></i> Create New Pickup Points</a>
		    <?php } ?>
		    <a href="index.php" class="btn btn-warning btn-sm"><i class="fa fa-filter"></i> Show/Hide Filter</a>
		</div>
	</div> 
	
	
	<div class="row" id="filter">
    
    
    <div class='col-md-3 col-sm-6'>
            <label for="to">Select Branch:</label>
                <select class="form-control select2" name="branch_id" id="branch_id">
                </select>
    </div>
    
    <div class="col-md-3">
        <div class="form-group">
            <label class="" for="status">Status</label>
            <select name="status" id="status" class="form-control select2">
                <option value="">Select Status</option>
                <option value="1">Active</option>
                <option value="0">In-Active</option>
			</select>
        </div>
    </div>
    
    </div>
    
    
	<div class="row">
		<div class="col-md-12">
			<div class="box box-warning" <?=$border_style?>>
			<div class="box-body table-responsive">
					<table id="employee-grid"  class="table table-bordered table-striped">
						<thead>
							<tr>
								<th width="30">S.No</th>
								<th>Actions</th>
								<th>Branch Name</th>
								<th>Location Name</th>
								<th>Location Details</th>
								<th>Status</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>
</section>

<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">Are you sure?</h4>
            </div>
            <div class="modal-body">
                <p>Are you sure want to delete this item?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <a class="btn btn-danger btn-ok">Delete</a>
            </div>
        </div>
    </div>
</div>
<?php } ?>

<?php require_once('footer.php'); ?>

<script type="text/javascript">
$(document).ready(function(){
    getData();
    get_branch();
    
    $('#status,#branch_id').change(function() {
            getData();
    });
        
});

function get_branch(){
    $('#branch_id').empty();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_branch_dropdown'},
         success:function(response){
            $('#branch_id').empty();
            $('#branch_id').append(response);
            get_client();
            get_new_client();
        }
    });
}
function getData(){
    var branch_id = $("#branch_id").val();
    var status = $("#status").val();
    
    
	var dataTable = $('#employee-grid').DataTable( {
		"processing": true,
		"serverSide": true,    
        "destroy":true,
        "ajax":{
			url : "data-tables/pickup-points-data-table.php",
			type: "post", 
			data: {branch_id:branch_id, status:status},
			error: function(){ 
				$(".employee-grid-error").html("");
				$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="10" style="text-align;center;">No data found in the server</th></tr></tbody>');
				$("#employee-grid_processing").css("display","none");
			}
		}
	} );
}


function delete_Details(id){
            var result = confirm("Confirm Want to In-Active This Customer?");
            if (result) {
                    $.ajax({
                    type: 'POST',
                    url: 'api/delete.php',
                    data: {type:'soft_delete',delete_id:id, table:'tbl_customers'},                  
                    success: function(response) {
                        console.log(response); 
                        emp_datas();
                    }
                });
            }
    }
    function DynamicActive(id){
            var result = confirm("Confirm Want to Active This Customer?");
            if (result) {
                $.ajax({
                    type: 'POST',
                    url: 'api/delete.php',
                    data: {type:'dynamic_active',delete_id:id, table:'tbl_customers'},                  
                    success: function(response) {
                        console.log(response); 
                        emp_datas();
                    }
                });
            }
    }
</script>



<script>
    $(document).ready(function(){
      
        $('.filter').click(function(){
            $("#filter").slideToggle();
            return false;
        });
    });
</script>