

<?php
if ($this->session->flashdata('alert_success')) {
    ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_success'); ?>
</div>
<?php
}

if ($this->session->flashdata('alert_danger')) {
    ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_danger'); ?>
</div>
<?php
}

if ($this->session->flashdata('alert_warning')) {
    ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
        <span aria-hidden="true">×</span>
    </button>
    <strong>Success!</strong> <?php echo $this->session->flashdata('alert_warning'); ?>
</div>
<?php
}
if (validation_errors()) {
    ?>
<!-- <div class="alert alert-danger alert-dismissible fade show" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<?php echo validation_errors(); ?>
</div> -->
<?php
}
?>

<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-body">
                <form action="<?php echo $actionUrl; ?>" method="post" enctype="multipart/form-data">
                    <h3 id="Title"></h3>
                    <div class="row">
                    <div class="col-md-6 form-group">
                            <label>Caption</label><span class="mandatory">*</span>
                            <input type="text" name="type" id="type" class="form-control" required>
                               
                            <?php if (form_error('type')) {?>
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">×</span>
                                </button>
                                <?php echo form_error('type'); ?>
                            </div>
                            <?php }?>
                        </div>
                        <div class="col-md-6 form-group">
                            <label>Image</label><span class="mandatory">*</span>                            
                            <input multiple name="banner[]" id="banner" type="file" class="form-control" required>                            
                        </div>

                        
                    </div>



                    <div class="form-group mb-0">
                        <div>
                            <button name="submit" type="submit" class="btn btn-primary waves-effect waves-light mr-1">
                                Submit
                            </button>
                            <button type="reset" class="btn btn-secondary waves-effect"
                                onclick="window.location.reload()">
                                Cancel
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <!-- <button type="button" class="btn btn-info btn-sm" id="excel" onclick="exportReportToExcel(this)">Export to Excel</button>  -->
                <table id="dmstable" class="table table-striped table-bordered dt-responsive nowrap"
                    style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                    <thead>
                        <tr>
                            <th>S.No</th>
                            <th>Caption</th>
                            <th>Image</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if(isset($records)){ 
                        $i=1;
                        foreach($records as $row){  
                    ?>
                        <tr>
                            <td><?= $i ?></td>
                            <td><?= $row->caption ?></td>
                            <td><img width="120px" src="<?= $row->video_path ?>"></td>
                            <td><a href="<?= base_url() ?>SettingsController/edituploadPhoto/<?= $row->id ?>" class="btn-sm btn-info"><i class="ti-pencil-alt"></i></a>
                                <a href="javascript:deletePhoto('<?= $row->id ?>')" class="btn-sm btn-danger"><i class="ti-trash"></i></a>
                            </td>
                        </tr>
                        <?php  $i++; } }?>

                    </tbody>
                </table>
                <?php
       // if (empty($result)) {?>
                <!-- <tr>
                <h4 style="text-align:center;">NO RESULT FOUND</h4>
            </tr> -->
                <?php // }
        ?>
            </div>
        </div>
    </div>
</div>


<script>



function deleteYear(id) {
    if (confirm("If you want to delete?") === true) {
        $.ajax({
            url: "<?php echo site_url() ?>/settingsController/deleteYear/" + id,
            method: "GET",
            success: function(result) {
                if (result > 0) {
                    window.location.reload();
                }
            },
            error: function(error) {
                console.log(error);
            }
        });
    }
}

$('#dmstable').DataTable();


</script>