
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js"></script>
            <!-- TOP Nav Bar END -->
            <div class="container-fluid">
               <div class="row">
                  <div class="col-sm-12">
                     <div class="iq-card">
                        <div class="iq-card-header d-flex justify-content-between">
                           <div class="iq-header-title">
                              <h4 class="card-title">Employee Report</h4>
                           </div>
                              <span class="table-add float-right mb-3 mr-2">
                              <a href="<?php echo base_url(); ?>employee/export/" class="btn btn-default"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Export</a><a href="javascript:void(0)" class="btn btn-default" data-toggle="modal" data-target="#import_popup"><i class="fa fa-file-excel-o" aria-hidden="true"></i> Import</a>
                              <a href="<?php echo base_url(); ?>employee/add" class="btn btn-sm iq-bg-success"><i
                                 class="ri-add-fill"><span class="pl-1">Add New</span></i>
                              </a>
                              </span>
                        </div>
                        <div class="iq-card-body">
                           <div id="table" class="table-editable">
                              
                               <table id="myTable" class="display table" style="width:100%">
              <thead>
                <tr>
                  <th>SL. No.</th>
                  <!-- <th>Equipment ID</th> -->
                  <th>Employee Name</th>
                  <th>Check In</th>
                  <th>Check Out</th>
                  <th>Booking</th> 
                  <th>Payment Receive</th>     
                  <th>Cash Receive</th>           
                  <th>Advance Receive</th>           
                  <th>Date</th> 
                </tr>
              </thead>
              <tbody>
                <?php  
                $start=0;
                for($i=0;$i<count($recordSet);$i++)
                   { $start++;
                ?>
                <tr class="trBack">
                  <td scope="row"><?php echo $start; ?></td>
                  <td><?php echo $recordSet[$i]['e_name']; ?></td>
                  <td><?php echo $recordSet[$i]['check_in']; ?></td>
                  <td><?php echo $recordSet[$i]['check_out']; ?></td>
                  <td><?php echo $recordSet[$i]['booking']; ?></td>
                  <td><?php echo $recordSet[$i]['payment_receive']; ?></td>
                  <td><?php echo $recordSet[$i]['cash_receive']; ?></td>
                  <td><?php echo $recordSet[$i]['advance_receive']; ?></td>
                  <td><?php echo $recordSet[$i]['date']; ?></td>

                </tr>

              <?php } ?>
              </tbody>
            </table>
                           </div>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
            <!-- Footer -->
      

<style type="text/css">
  table.dataTable thead .sorting, 
table.dataTable thead .sorting_asc, 
table.dataTable thead .sorting_desc {
    background : none;
}
</style>
<script type="text/javascript">
  function delete_function(id) {

$.confirm({
    title: 'Delete!',
    content: 'Are you want to delete this data?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>employee/Delete/",
          data: {id : id }, 
          success: function(html) {
            $.alert("Your data has been successfully deleted");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}

function status_change(id,status){
if (status=='1') {
  var new_status='0';
$.confirm({
    title: 'Change Status!',
    content: 'Are you want to inactive?',
    type: 'red',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-red',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>employee/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });



}
else {
  var new_status='1';

$.confirm({
    title: 'Change Status!',
    content: 'Are you want to active?',
    type: 'green',
    typeAnimated: true,
    buttons: {
        tryAgain: {
            text: 'Yes',
            btnClass: 'btn-green',
            action: function(){
              
              $.ajax({
          type: "POST",
          url: "<?php echo base_url(); ?>employee/status_change/",
          data: {id : id, new_status: new_status }, 
          success: function(html) {
            $.alert("Your Status has been Changed");
            setInterval(function(){
              location.reload();
            }, 3000);
            }
          });
            }
        },
        close: function () {
        }
    }
 });
}
}
</script>
<div class="modal fade" id="import_popup">
  <div class="modal-dialog">
    <div class="modal-content">
      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Import Data</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <div class="alert alert-success Addmsg" style="display: none;">
          <strong>Successfully Imported Your Data!</strong>
        </div>
        <div class="alert alert-danger statusfailed" style="display: none;">
          <strong>Please Try Again </strong>
        </div>
      </div>
      <form id="import_form" method="post">
        <!-- Modal body -->
        <div class="modal-body">
          <div class="row">
          <div class="form-group">
              <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                  <label>Import Data</label>
                  <input type="file" name="import_data" id="import_data" class="form-control" required=""  aria-required="true">
                  <br>
              </div>
          </div>
          <div class="form-group">
              <a href="<?php echo base_url(); ?>img/demo/employee.csv" style="margin-left: 10px;"><i class="fa fa-download" aria-hidden="true"></i> &nbsp; Download CSV Format</a>
          </div>
          </div>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
          <button type="submit" class="btn btn-primary">Save</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
success: "valid"
});
$("#import_form").validate({
rules: {
import_file: {
required: true
}
}
});
</script>
<script>
$(document).ready(function(e) {
$("#import_form").on('submit', function(e) {
e.preventDefault();
var formStatus = $('#import_form').validate().form();
if (true == formStatus) {
$.ajax({
type: 'POST',
url: '<?php echo base_url(); ?>employee/import/',
data: new FormData(this),
contentType: false,
cache: false,
processData: false,
beforeSend: function() {
$('.addbtn').hide();
$('.addload').show();
},
success: function(msg) {
$(".Addmsg").show();
$('.Addmsg').delay(3000).hide(200);
$('.addbtn').show();
$('.addload').hide();
setInterval(function() {
location.reload();
}, 3000);
}
});
}
});
});
</script>