<?php
$this->load->view($left);
$this->load->view($header);
?>
<style type="text/css">
    .ibox-content {
        border-style : none;
    }

    .hr-line-dashed {
        margin: 5px 0;
    }
</style>
<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2><?php echo (@$shape_row->id == '') ? 'New Uploads' : 'Edit Uploads'; ?></h2>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row text-center animated fadeInRightBig">
        <form method="post" action="<?= base_url() ?>Import_products/addimports" class="form-horizontal" id="size_data" enctype="multipart/form-data">
            <div class="col-lg-12">            
                <input type="hidden" name="id" id="id" class="form-control" value="<?= @$shape_row->id ?>">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">Vendor</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="vendor" id="vendor" required>
                                    <option value="">Select Vendor</option>
                                    <?php
                                    if (count($vendor_list) > 0) {
                                        foreach ($vendor_list as $key => $value) {
                                            ?>
                                            <option value="<?php echo $value->id; ?>" ><?php echo $value->vendor_name; ?></option>
                                            <?php
                                        }
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>              
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">upload CSV</label>
                            <div class="col-sm-10">
                                <input type="file" name="file" id="file" class="form-control" placeholder="" value="" required="">
                            </div>
                        </div> 
                    </div>
                </div>              

            </div>

            <div class="ibox">
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-lg-6 pull-right">
                            <div class="form-group">
                                <div class="col-sm-12 col-sm-offset-2">
                                    <button class="btn btn-primary save_bank_details" type="button" data-status="1"><span class="m-l-xs">Save</span></button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row text-center animated fadeInRightBig">
        <table class="table" id="myTable">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Vendor Name</th>
                    <th>File URL</th>
                    <th>File Name</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                <?php
                if (!empty($import_list)) {
                    $i = 1;
                    foreach ($import_list->result() as $rest) {
                        ?>
                        <tr>
                            <td><?= $i; ?></td>
                            <td><?= $rest->vendor_name; ?></td>
                            <td><?= base_url() . $rest->file; ?></td>
                            <td><?= $rest->file_name; ?></td>
                            <td>                                
                                <!--<a href="#" onclick="editQuality('<?= $rest->id ?>')"><button class="btn btn-info btn-xs"><i class="fa fa-edit"></i></button></a>-->
                                <a href="#" onclick="deleteimports('<?= $rest->id ?>');"><button class="btn btn-danger btn-xs"><i class="fa fa-trash"></i></button></a>
                            </td>
                        </tr>
                        <?php
                        $i++;
                    }
                }
                ?>
            </tbody>
        </table>
    </div>
</div>

<?php $this->load->view($footer); ?>

<script>
    $('.save_bank_details').on('click', function () {
        if ($('#vendor').val() == '') {
            $('#vendor').parent().parent().addClass('has-error');
            return false;
        } else {
            $('#vendor').parent().parent().removeClass('has-error');
            $("#size_data").submit();
        }

    });

</script>    
<script>
    function deleteimports(id) {
        $('#token').val(id);
        $('#frm').attr('action', '<?= base_url() ?>Import_products/deluploads');
        $('#frm').submit();

    }
</script>    
<form id="frm" method="post">
    <input type="hidden" id="token" name="token">
</form>

