<?php 
require_once('header.php'); 
?>
<script type="text/javascript" language="javascript" >
	/*$(document).ready(function() {
	    
	    $('#select_all').on('click',function(){
        if(this.checked){
            $('.checkbox').each(function(){
                this.checked = true;
            });
        }else{
             $('.checkbox').each(function(){
                this.checked = false;
            });
        }
        });
         $('.checkbox').on('click',function(){
            if($('.checkbox:checked').length == $('.checkbox').length){
                $('#select_all').prop('checked',true);
            }else{
                $('#select_all').prop('checked',false);
            }
        });
	    
	    
	    
	    
	  
		     function getData(){
			   var cid=$('#excel_client_id').val();
			     var role= $('#role').val();   
                var role_id= $('#role_id').val();  
                var branch_id= $('#branch_id').val();  
				var dataTable = $('#employee-grid').DataTable( {
					"processing": true,
					"serverSide": true,
                    "destroy":true,
                    "ajax":{
						url :"data-tables/customer_dt.php", // json datasource
						data: {cid:cid,role:role,role_id:role_id,branch_id:branch_id},
						type: "post",  // method  , by default get
						error: function(){  // error handling
							$(".employee-grid-error").html("");
							$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
							$("#employee-grid_processing").css("display","none");
						}
					}
				} );
			    }
			    getData();
			  $('#btnconvert').click(function(){
			        getData();
			      
			  } );
			
			  
			  
		$('#btnconvert').click(function(){
            var checkValues = $('input[name=checkboxlist]:checked').map(function()
            {
                return $(this).val();
            }).get();
             if(checkValues!=""){
           //alert(checkValues);
                  $.ajax({
                        url: 'customer-convert.php',
                        type: 'post',
                        data: {customer_ids:checkValues},
                         success:function(response){
                             console.log("convert ids:"+response);
                            getData();
                        }
                    });
                }
                    else{
                        alert('No Value Selected');
                    }
                    getData();
                });
			  
			  
			  
			} );*/
		</script>

	
<section class="content-header">
    <div class='box-body' style="margin: 0px 0px;box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;background-color: white;">
    <div class="row">
		<div class="col-md-4" style="text-align: left;">
			<h4><i class="fa fa-list"></i> Consignee Details</h4>
		</div>
		<div class="col-md-8" style="text-align: right;"> 
		
		<?php if($session_id==1 || $allPermissions['consignee']['create']=="1"){ ?>
		    <a href="customer-add.php" class="btn btn-success btn-sm" style="cursor: pointer;"><i class="fa fa-plus"></i> Add Consignee</a>
		    
		    <!--<a href="customer_bulk_upload.php" class="btn btn-warning btn-sm"><i class="fa fa-upload"></i> Bulk Upload</a>-->
		    <a href="consignee_bluk.php" class="btn btn-warning btn-sm"><i class="fa fa-upload"></i> Bulk Upload</a>
		    
		<?php } ?>
		</div>
	</div>     
        
      <!--<div class="row">
            <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">
                <label>Select Client <span style='color:red;'>*</span></label>
                <select name="new_client" id="new_client" class="form-control select2">
    					
    			</select>
            </div>
            
            
            <div class='col-md-3 col-sm-6'>
                    <label for="to">Select Consigner:</label>
                        <select class="form-control select2" name="client_id" id="client_id">
                        </select>
            </div>
            <div class='col-md-3 col-sm-6'>
                 <label for="to">Action :</label><br>
                 <span id="get_report" name="sd" class="btn btn-sm btn-warning"><i class="fa fa-filter"></i> Filter</span>
                 
            </div>
           
      </div>
    	<br> -->
    </div>
</section>	
	
	
	

	<section class="content-header">
    <div class='box-body' style="margin: 0px 0px;box-shadow: rgba(0, 0, 0, 0.19) 0px 10px 20px, rgba(0, 0, 0, 0.23) 0px 6px 6px;background-color: white;">
				<div class="box-body table-responsive">
    				<div class="table-responsive">
    					<table id="employee-grid" class="table table-bordered table-striped">
    						<thead>
    							<tr>
    								<th width="30">SL</th>
    								<th>Action</th>
    								<th>Status</th>
    								<th>Name</th>
    								<th>Code</th>
    								<th>City</th>
    								<th>Pincode</th>
    								<th>Address</th>
    								<th>Destination City</th>
    								
    							</tr>
    						</thead>
    					
    					</table>
    				</div>
    				
    				<!--<center><button id='btnconvert' class=" btn btn-warning btn-sm"><i class="fa fa-download" aria-hidden="true"></i> Converted to Regular Customer</button></center><br>-->
				
			</div>
		</div>
	</section>

<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <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">Delete Confirmation</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>


<script>
/*  
$(document).ready(function() {
    
    get_branch();
   
    $('#branch_id').on('change', function(){
             get_client();
             get_new_client();
    });
    
    
    $('#new_client').on('change', function(){
            get_client();
    });
    
    $('#get_report').on('click', 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);
            <?php 
            if(isset($_GET['branch_id']) && $_GET['branch_id']!='all' && $_GET['branch_id']!=''){ ?>
			$('#branch_id').val(<?=$_GET['branch_id']?>);
			$('#branch_id').trigger('change');
		<?php	}
            
            ?>
            get_client();
            get_new_client();
        }
    });
}


function get_client(){
    $('#client_id').empty();
    var branch_id=$('#branch_id').val();
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_client_dropdown',branch_id:branch_id},
         success:function(response){
            $('#client_id').empty();
            $('#client_id').append(response);
        }
    });
}



function get_new_client(){
    $('#new_client').empty();
     
    var branch_id=$('#branch_id').val();
    console.log('New Client Id Change');
    $.ajax({
        url: 'apis/get-drop-down-list.php',
        type: 'post',
        data: {type:'get_new_client_dropdown',branch_id:branch_id},
         success:function(response){
            $('#new_client').empty();
            $('#new_client').append(response);
            
            <?php 
            if(isset($_GET['new_client']) && $_GET['new_client']!='all' && $_GET['new_client']!=''){ ?>
			$('#new_client').val(<?=$_GET['new_client']?>);
			$('#new_client').trigger('change');
		<?php	}
            
            ?>
            
           
        }
    });
}*/

</script>



<script>
$(document).ready(function() {
    getData();
});
function getData()
{
   
  /*  var branch_id=$('#branch_id').val();
    var new_client=$('#new_client').val();
    var client_id=$('#client_id').val();*/
    
    var dataTable = $('#employee-grid').DataTable( {
    	"processing": true,
    	"serverSide": true,
    	"bDestroy": true,
    	"aaSorting":[[0,'desc']],
    	"ajax":{
    		url :"data-tables/customer_dt.php", 
    		data: {customer_type:1},
    		type: "post",
    		error: function(){  
    			$(".employee-grid-error").html("");
    			$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">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: 'apis/delete.php',
                    data: {type:'soft_delete',delete_id:id, table: 'tbl_customer'},                  
                    success: function(response) {
                        console.log(response); 
                        getData();
                    }
                });
            }
    }
    function DynamicActive(id){
            var result = confirm("Confirm Want to Active This Customer?");
            if (result) {
                $.ajax({
                    type: 'POST',
                    url: 'apis/delete.php',
                    data: {type:'dynamic_active',delete_id:id, table:'tbl_customer'},                  
                    success: function(response) {
                        console.log(response); 
                        getData();
                    }
                });
            }
    }
</script>
<?php require_once('footer.php'); ?>