

<?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
}
?>
<?php
foreach($records as $row){
    $id = $row->id;
    $type = $row->caption;
    $image_path = $row->image_path;   
}

?>
<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="hidden" name="id" value="<?= $id ?>" />
                            <input type="text" name="type" id="type" class="form-control"  value="<?= $type ?>" 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-4 form-group">
                            <label>Image</label><span class="mandatory">*</span>                            
                            <input name="banner" id="banner" type="file" class="form-control" >                            
                            <input type="hidden" name="old_file" value="<?= $image_path ?>" />
                        </div> 
                        <div class="col-md-2 form-group">
                            <label>Image</label><span class="mandatory">*</span>                            
                            <img src="<?= $image_path ?>" width="120px" />
                        </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>




<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>