<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

    <title>Add new products</title>
  </head>
  <body>
    
  <div class="container">

        <div style="margin: 30px;">
        <h2 style="text-align:center">Upload new files</h2>
        </div>
        <div class="row">

            <div class="col-md-12">

                <div class="card">
                    <div class="card-body">
                        <form action="<?php echo base_url('sitepanel/newproducts'); ?>/upload" method="POST" accept-charset="utf-8" enctype="multipart/form-data" id="fileUploadForm">
                        <div class="input-group">
                            <div class="custom-file">
                                <input type="file" class="custom-file-input" id="file-upload" name="excel_file">&nbsp;
                                <input type="hidden" name="action" value="submit_excel">
                                <label class="custom-file-label" for="file-upload">Choose file</label>
                            </div>
                            <div class="input-group-append">
                                <button class="btn btn-outline-secondary" type="submit" id="upload-btn">Upload</button>
                            </div>
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>

        <div style="margin-top: 20px;" class="row">

            <div class="col-md-12">
            
            <table class="table">
    <thead>
      <tr>
        <th>New Category Name</th>
        <th>Product Name</th>
        <th>Product ID</th>
        <th>Customer ID</th>
      </tr>
    </thead>
    <tbody>
    <?php 
        if(isset($worksheet)){
            foreach($worksheet as $item){
                if($item['update_status']==1){
                    $x = '<tr class="table-success">';
                    $x.= '<td>'.$item[3].'</td>'; 
                    $x.= '<td>'.$item[5].'</td>'; 
                    $x.= '<td>'.$item[1].'</td>'; 
                    $x.= '<td>'.$item[4].'</td>';  
                    $x.= '</tr>';
                }else if($item['update_status']==0){
                    $x = '<tr class="table-danger">';
                    $x.= '<td>'.$item[3].'</td>'; 
                    $x.= '<td>'.$item[5].'</td>'; 
                    $x.= '<td>'.$item[1].'</td>'; 
                    $x.= '<td>'.$item[4].'</td>';  
                    $x.= '</tr>';
                }
                echo $x;
            }
        }
    ?>
    </tbody>
            </div>

        </div>

        <!--<div class="row">
  <div class="col-md-6">
    <div class="panel panel-default">
      <div class="panel-body">
        <div class="table-responsive">
          <form action="<?php echo base_url('sitepanel/newproducts'); ?>/upload" id="form" enctype="multipart/form-data" method="post" accept-charset="utf-8">          <table width="100%" align="center" bgcolor="#999999" border="0" cellspacing="1" cellpadding="3">
            <tbody><tr bgcolor="#FFFFFF">
              <td colspan="2" align="left"><strong style="font-size:14px">Upload Bulk Products</strong></td>
            </tr>
            <tr bgcolor="#FFFFFF">
              <td width="30%" align=""><strong>Upload Excel File</strong></td>
              <td width="70%">
                <input type="file" name="excel_file">&nbsp;
                <input type="hidden" name="action" value="submit_excel">
              </td>
            </tr>
            <tr><td colspan="2"><input type="submit" class="btn btn-info" value="Submit">&nbsp;&nbsp;&nbsp; <a href="http://localhost/nti2/assets/sample/sample.xls">Download Sample File</a></td></tr>
          </tbody></table>
          </form>        </div>
      </div>
    </div>
  </div>
</div>-->
  </div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" crossorigin="anonymous"></script>
    <script>
        $(document).ready(function () {
            $('#file-upload').change(function() {
                var file = $('#file-upload')[0].files[0].name;
                $('.custom-file-label').text(file);
            });

            /*$('#upload-btn').click(function(event){
                //stop submit the form, we will post it manually.
                event.preventDefault();

                // Get form
                var form = $('#fileUploadForm')[0];

                // Create an FormData object 
                var data = new FormData(form);

                // disabled the submit button
                $("#upload-btn").prop("disabled", true);

                $.ajax({
                    type: "POST",
                    enctype: 'multipart/form-data',
                    url: "<?php echo base_url('sitepanel/newproducts'); ?>/get",
                    data: data,
                    processData: false,
                    contentType: false,
                    cache: false,
                    timeout: 600000,
                    success: function (data) {
                        console.log("SUCCESS : ", data);
                        $("#btnSubmit").prop("disabled", false);

                    },
                    error: function (e) {
                        $("#result").text(e.responseText);
                        console.log("ERROR : ", e);
                        $("#btnSubmit").prop("disabled", false);

                    }
                });
            });*/
        });

    </script>
  </body>
</html>