<?php require_once('../auth/auth.php'); ?>
     <div class="row">
      <div class="col-md-12">
      <div class="card card-primary card-outline direct-chat direct-chat-primary shadow-none" style="border-left:1px solid #969c9d;border-right:1px solid #969c9d;border-bottom:1px solid #969c9d;">
            <div class="card-header" style="padding: 3px 8px;">
              <h3 class="card-title">Bulk Item Add</h3>
              <div class="card-tools m-0">
                <button type="button" class="btn btn-tool" data-card-widget="remove">
                  <i class="fas fa-times"></i>
                </button>
              </div>
            </div>
            <form id="file_form" class="mt-1" autocomplete="off" enctype="multipart/form-data">
              <div class="card-body">
                <div class="row">
                <div class="col-md-4"></div>
                 <div class="col-md-3">
                    <div class="form-group">
                       <label>Select your CSV File</label>
                        <input type="file" name="csv_file" accept=".csv" class="form-control form-control-sm" required="true" style="height:29px;line-height:13px;">
                    </div>
                 </div> 
                 <div class="col-md-2 pl-0">
                    <button type="submit" id="save" class="btn btn-success btn-sm mt-3"><i class="fa fa-upload"></i> Upload File</button>
                 </div>  
                 <div class="col-md-3"></div> 
                 
                </div>            
              </div>
            </form>
            <div class="col-md-12"><hr style="margin-top:-5px;margin-bottom: 7px;"> <div id="csv_file_data"></div></div> 
          </div>
        </div>
      </div>
<script>
$(document).ready(function() {
  $('#file_form').on('submit', function(e){
  e.preventDefault(); 
  $('#save').prop('disabled', true);
  $('#save').html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> '+'Loading...');
  $.ajax({
   url:"../itemstock/csv_importb.php",
   method:"POST",
   data:new FormData(this),
   contentType:false,
   cache:false,
   processData:false,
   success:function(data){
    $('#save').prop('disabled', false);
    $('#save').html('Upload File'); 
    $('#csv_file_data').html('<div class="alert alert-success">Data Imported Successfully</div>');
    pagecall('../itemstock/item_view.php','#item_v'); 
    } 
  })
 }); 
});  
</script>
