<!DOCTYPE html>
<html>
<head>
<!-- TABLES CSS CODE -->
<?php include"comman/code_css_form.php"; ?>
<!-- </copy> -->  
</head>
<body class="hold-transition skin-blue sidebar-mini">


<div class="wrapper">
 
 <?php include"sidebar.php"; ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <?=$page_title;?>
        <small></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="<?php echo $base_url; ?>dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active"><?=$page_title;?></li>
      </ol>
    </section>
    <!-- /.content -->
    <section class="content">
      <div class="row">
        <!-- right column -->
        <div class="col-md-12">
         
          <div class="box">
            <div class="box-header">
              <h3 class="box-title"><?= $this->lang->line('records_table'); ?></h3>
              <!-- <button type="button" class="btn btn-info pull-right btnExport" title="Download Data in Excel Format">Excel</button> -->
            </div>
            <!-- /.box-header -->
            <div class="box-body table-responsive no-padding">
              
              <table class="table table-bordered table-hover " id="report-data" >
                <thead>
                <tr class="bg-blue">
                  <th class="text-center">#</th>
                  <th>Item Name</th>
                  <th>SKU</th>
                  <th>Stock QTY Old</th>
                  <th>Stock QTY New</th>
                  <th>Cost Price Old</th>
                  <th>Cost Price New</th>
                  <th>Sale Price 1 Old</th>
                  <th>Sale Price 1 New</th>
                  <th>Sale Price 2 Old</th>
                  <th>Sale Price 2 New</th>
                  <th>Sale Price 3 Old</th>
                  <th>Sale Price 3 New</th>
                  <th>Change Date time</th>
                </tr>
                </thead>
                <tbody id="tbodyid">
                
              </tbody>
              </table>
              
              
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
      </div>
    </section>
  </div>
  <!-- /.content-wrapper -->
  
 <?php include"footer.php"; ?>

 
  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- SOUND CODE -->
<?php include"comman/code_js_sound.php"; ?>
<!-- TABLES CODE -->
<?php include"comman/code_js_form.php"; ?>

<?php include"comman/code_js_datatable.php"; ?>

<!-- <script src="<?php echo $theme_link; ?>js/sheetjs.js" type="text/javascript"></script> -->

<script>
  function fill_tbData(){

      $.ajax({
        url:"<?php echo site_url('stock/history_details_get')?>",
        type: 'post',
        //data: {payment_type:payment_type,agent_id:agent_id,to_date:to_date,from_date:from_date,platform_id:platform_id},
        dataType: 'json',
        success: function (data) {

          var table;
          table = $('#report-data').DataTable();
          table.clear(); 

          // $.each(data.data_count_info, function(){
          //   var dataCount =parseInt(this['d_count']);
          //   console.log(dataCount);
          //   if(dataCount>0) { 
              var indexNo = 1; 
              $.each(data.st_info, function(){
                table.row.add([indexNo,this['item_name'],this['sku'], this['stock_qty_old'], this['stock_qty_new'], this['cost_price_old'], this['cost_price_new'], this['sale_price_1_old'], this['sale_price_1_new'], this['sale_price_2_old'], this['sale_price_2_new'], this['sale_price_3_old'], this['sale_price_3_new'], this['changeDate'] ]);
                indexNo++;
              });
              table.draw();
            // }else {
            //    $('#example2').DataTable();
            //    //swal("Something Wrong","Data Not Found !!","warning");
            //    toastr["warning"]("Something Wrong! , Data Not Found. ");
            // }
        //  });
          
        },
        error: function (xhr, ajaxOptions, thrownError) {
          console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
        }
      });
  }
</script> 
<script>
    $(document).ready(function(){
      fill_tbData();
    });
</script>
<!-- <script>
function convert_excel(type, fn, dl) {
    var elt = document.getElementById('report-data');
    var wb = XLSX.utils.table_to_book(elt, {sheet:"Sheet JS"});
    return dl ?
        XLSX.write(wb, {bookType:type, bookSST:true, type: 'base64'}) :
        XLSX.writeFile(wb, fn || ('Expred-Items-Report.' + (type || 'xlsx')));
}
$(".btnExport").click(function(event) {
 convert_excel('xlsx');
});
</script>

<script src="<?php echo $theme_link; ?>js/report-expired-items.js"></script> -->

<!-- Make sidebar menu hughlighter/selector -->
<script>$(".<?php echo basename(__FILE__,'.php');?>-active-li").addClass("active");</script>
    
    
</body>
</html>
