<?php $user_id=$this->session->userdata('user_id');
if(!$user_id){
  redirect('user/login_view', 'refresh');
}
?>
<!DOCTYPE html>
<html lang="en">

        <?php
        $this->load->view('head.php');
         ?>

<body>

    <div id="wrapper">

      <div class="admin-title">
      <div class="row">
        <?php $this->load->view('header.php'); ?>
      </div>
    </div>
        
     <div class="content-area">
      <div class="row">
       
          <div class="admin-menu">
            <?php $this->load->view('sidebar.php'); ?>
          </div>
       <div class="content-menu">
           <div class="panel-heading headingnone">
              <h2 class="transac"> Loan Category</h2>
              
            </div>
        </div>
      
          <div class="main-content">
            
         <div class="row">

     <form method="post" action="<?php echo site_url('loan/add');?>">
    <input type="hidden" name="seting" value="">
         
     <div class="form-group type">
      <label for="usr">Category:</label>
      <input type="text" class="form-control" name="cat" id="cat_type">
     </div>
       
    
    <input type="submit"  class="btn btn-primary cat"  value="save">
  </form>
    </div>

            <div class="panel-body cattable" id="printableArea" >

              <div class="tab-content">

                <div id="home" class="tab-pane fade in active">


             
                            <table width="100%" class="table table-striped table-bordered table-hover mytable" id="dataTables-example">
                               
                                <thead>
                                    <tr>
                                     
                                       
                                    
                                        <th class="type-center">Category</th>
                                       
                                        <th class="type-center">ACTION</th>
                                    </tr>
                                </thead>
                                <tbody>
                                   
                    
                                   
     
    

                                    
                                     <?php $k=1;
                                    
                                    foreach ($category as $list){
                                    ?>
                                      <tr class="delete_mem<?php echo $list->id; ?>">
                                  
                                       
                                     
                                      
                                        <td class="type-center"><?php echo ucfirst($list->category); ?></td>
                                       
                                       
                                        <td class="action type-center"><a class="btn edit"  data-toggle="modal" data-target="#myModal" onclick="edit(<?php echo $list->id;?>)">Edit</a> <!--<a id="printpagebutton" class="btn btn-danger btn-xs" onclick="myFunction(<?php// echo $list->id;?>)" >Delete</a>--></td>
                                        
                                    </tr>
                                 <?php  } ?>
                               
                                </tbody>
                            </table>
                        
                        
                    </div>

                      </div>
                <div class="pagi" style ="float:right;">
           <?php echo $this->pagination->create_links(); ?>   
          </div>
                    </div>


     
      
                  </div>
               
              </div>
            </div>
    

    </div>
     
          <?php $this->load->view('footer.php'); ?>
   <div class="modal fade" id="myModal" role="dialog">
    
      <div class="modal-dialog mymodal">
    
      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Loan Category Update</h4>
         
        </div>
        <div class="modal-body">
          <form method="post" action="<?php echo site_url('loan/add');?>">
           
          <input type="hidden" name="id" value="<?php echo $this->session->userdata('user_id'); ?>">
         
   
  
    
    <div class="form-group ">
      <label for="pwd">Category:</label>
      <input type="text" class="form-control catfield" name="cat" id="type" value=" " >
      <input type="hidden" class="form-control" name="id"  id="id" value="">
    </div>
  
    
    <input type="submit"  class="btn btn-success" value="update">
  </form>
        </div>
         <div class="modal-footer">
          
          <button type="button"  class="btn btn-danger" data-dismiss="modal">Close</button>
        </div>
      </div>
      
    </div>
    </div>
    

  
    
  <script type="text/javascript" src="<?= base_url() ?>assets/admin/js/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/my.js"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/admin/js/bootstrap-datetimepicker.fr.js" charset="UTF-8"></script>
    <script>
         $('.cat').click(function(){
     
   if($('#cat_type').val() == ''){
   swal("You Have To  select a Data!");
       return false;
   }
             else{
                  return true; 
             }
    });
    </script>
    <script>
    function myFunction(ref) {
        swal({
          
  title: "Are you sure?",
  text: "Your will not be able to recover this imaginary file!",
  type: "warning",
  showCancelButton: true,
  confirmButtonClass: "btn-danger",
  confirmButtonText: "Yes, delete it!",
  closeOnConfirm: false
},
function(){
              var datastr=ref;
      
        //var datastr='ref='+ encodeURIComponent(ref)
       
            $.ajax({
            url: "<?php echo base_url()?>loan/delete", 
            type: "POST",
            data    : {'uristring':datastr},
           success: function(data){
    
    
      
  }
        });
  swal("Deleted!", "Your imaginary file has been deleted.", "success");
          $(".delete_mem" + ref).fadeOut('slow');
    
});
  
      // alert(ref);
       
      
 
    }

    </script>
    <script>
             function edit(ref) {
                var datastr=ref;
      
            $.ajax({
            url: "<?php echo base_url()?>loan/edit", 
            type: "POST",
            data    : {'uristring':datastr},
                dataType: 'json',
            success: function(data){
               
                $('#type').val(data.type);
               
                $('#id').val(data.id);
              
            }
        });    
}

    </script>
 <style>
     .type-center{
         text-align: center;
         width: 34%;
     }
     .action{
         width: 20%;
     }
    </style>
</body>

</html>
