<?php
$data = [
    'title' => 'Home',
    'description' => 'Description',
    'keywords' => 'Keywords',
    'image' => 'image',
];
$this->load->view('layouts/header', $data);
$this->load->view('layouts/sidebar');
$class_name = $this->router->fetch_class();
$method_name = $this->router->fetch_method();
?>

<div class="content-wrapper">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h2><?php echo ucwords(str_replace("_", " ", $class_name . " " . $method_name)); ?></h2>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="<?php echo base_url() ?>">Dashboard </a></li>
                        <li class="breadcrumb-item"><a
                                href="<?php echo base_url($class_name . '/listing') ?>"><?php echo ucwords(str_replace("_", " ", plural($class_name))); ?></a>
                        </li>
                        <li class="breadcrumb-item active"><?php echo ucwords(str_replace("_", " ", $method_name)); ?>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </section>

    <section class="content">
        <form action="<?php echo current_url() ?>" method="post" enctype="multipart/form-data">
            <div class="row">
                <div class="col-12">
                    <?php if ($this->session->flashdata('success')) {
    echo '<div class="alert alert-success">' . $this->session->flashdata('success') . '</div>';
} elseif ($this->session->flashdata('error')) {
    echo '<div class="alert alert-danger">' . $this->session->flashdata('error') . '</div>';
} elseif ($this->session->flashdata('warning')) {
    echo '<div class="alert alert-warning">' . $this->session->flashdata('warning') . '</div>';
}?>
                </div>
                <div class="col-md-8">
                    <div class="card card-secondary">
                        <div class="card-header">
                            <h3 class="card-title">Home Page content</h3>

                        </div>
                        <div class="card-body">

                            <div class="form-group">
                                <label>About us</label>
                                <textarea class="form-control" id="textarea" name="home_about_us"
                                    placeholder="About us"><?php if (isset($result['home_about_us'])) {
    echo $result['home_about_us'];
}
?></textarea>
                            </div>
                            <?php echo form_error('home_about_us'); ?>

                            <div class="form-group">
                                <label>Heading</label>
                                <input type="text" name="heading" class="form-control" placeholder="Heading" value="<?php if (isset($result['heading'])) {
    echo $result['heading'];
}
?>">
                            </div>
                            <?php echo form_error('heading'); ?>

                            <div class="form-group">
                                <label>Sub Heading</label>
                                <input type="text" name="subheading" class="form-control" placeholder="Sub Heading"
                                    value="<?php if (isset($result['subheading'])) {
    echo $result['subheading'];
}
?>">
                            </div>
                            <?php echo form_error('subheading'); ?>




                            <hr>



                            <div class="form-group">
                                <label>Projects Section Heading</label>
                                <input type="text" name="project_section_heading" class="form-control"
                                    placeholder="Heading" value="<?php if (isset($result['project_section_heading'])) {
    echo $result['project_section_heading'];
}
?>">
                            </div>
                            <?php echo form_error('project_section_heading'); ?>

                            <div class="form-group">
                                <label>Sub Heading</label>
                                <input type="text" name="project_section_subheading" class="form-control"
                                    placeholder="Sub Heading" value="<?php if (isset($result['project_section_subheading'])) {
    echo $result['project_section_subheading'];
}
?>">
                            </div>
                            <?php echo form_error('project_section_subheading'); ?>

                            <div class="form-group">
                                <label>Description</label>
                                <textarea class="form-control" id="textarea_1" name="project_section_description"
                                    placeholder="Description"><?php if (isset($result['project_section_description'])) {
    echo $result['project_section_description'];
}
?></textarea>
                            </div>
                            <?php echo form_error('project_section_description'); ?>




                            <div class="form-group">
                                <label>Experience</label>
                                <input type="text" name="experience" class="form-control" placeholder="Experience"
                                    value="<?php if (isset($result['experience'])) {
    echo $result['experience'];
}
?>">
                            </div>
                            <?php echo form_error('experience'); ?>


                            <div class="form-group">
                                <label>Successful Projects</label>
                                <input type="text" name="successful_projects" class="form-control"
                                    placeholder="Successful Projects" value="<?php if (isset($result['successful_projects'])) {
    echo $result['successful_projects'];
}
?>">
                            </div>
                            <?php echo form_error('successful_projects'); ?>

                            <div class="form-group">
                                <label>Happy Clients</label>
                                <input type="text" name="happy_clients" class="form-control" placeholder="Happy Clients"
                                    value="<?php if (isset($result['happy_clients'])) {
    echo $result['happy_clients'];
}
?>">
                            </div>
                            <?php echo form_error('happy_clients'); ?>



                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Image (612 x 612 px)</label>
                                        <input type="file" name="project_section_image" accept="image/*"
                                            class="form-control">
                                    </div>
                                </div>


                            </div>
                            <div class="row ">
                                <div class="col-md-6">
                                    <div>
                                        <?php
if (isset($result['project_section_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['project_section_image']) && $result['project_section_image'] != "") {?>
                                        <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="project_section_image('<?php echo base64_encode($result['id']) ?>', this)"></span>
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['project_section_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                            </div>


                            <hr>
                            <h2 class="heading">Ask Advice Section</h2>


                            <div class="form-group">
                                <label>Heading</label>
                                <input type="text" name="askadvice_name" class="form-control" placeholder="Heading" value="<?php if (isset($result['askadvice_name'])) {
    echo $result['askadvice_name'];
}
?>">
                            </div>
                            <?php echo form_error('askadvice_name'); ?>

                          <!--  <div class="form-group">
                                <label>Sub Heading</label>
                                <input type="text" name="why_subheading" class="form-control" placeholder="Sub Heading"
                                    value="<?php if (isset($result['why_subheading'])) {
    echo $result['why_subheading'];
}
?>">
                            </div>
                            <?php echo form_error('why_subheading'); ?>-->

                            <div class="form-group">
                                <label>Description</label>
                                <textarea class="form-control" id="textarea" name="askadvise_description" rows="10"
                                    placeholder="Description"><?php if (isset($result['askadvise_description'])) {
    echo $result['askadvise_description'];
}
?></textarea>
                            </div>
                            <?php echo form_error('askadvise_description'); ?>



                            <div class="form-group">
                                <label>Option 1</label>
                                <input type="text" name="why_option_heading_1" class="form-control"
                                    placeholder="Heading" value="<?php if (isset($result['why_option_heading_1'])) {
    echo $result['why_option_heading_1'];
}
?>">
                            </div>
                            <?php echo form_error('why_option_heading_1'); ?>

                            <div class="form-group">
                                <label>Description 1</label>
                                <textarea class="form-control" id="textarea_1" name="why_option_des_1" rows="4"
                                    placeholder="Description"><?php if (isset($result['why_option_des_1'])) {
    echo $result['why_option_des_1'];
}
?></textarea>
                            </div>
                            <?php echo form_error('why_option_des_1'); ?>


                            <div class="form-group">
                                <label>Option 2</label>
                                <input type="text" name="why_option_heading_2" class="form-control"
                                    placeholder="Heading" value="<?php if (isset($result['why_option_heading_2'])) {
    echo $result['why_option_heading_2'];
}
?>">
                            </div>
                            <?php echo form_error('why_option_heading_2'); ?>


                            <div class="form-group">
                                <label>Description 2</label>
                                <textarea class="form-control" id="textarea_1" name="why_option_des_2" rows="4"
                                    placeholder="Description"><?php if (isset($result['why_option_des_2'])) {
    echo $result['why_option_des_2'];
}
?></textarea>
                            </div>
                            <?php echo form_error('why_option_des_2'); ?>

                            <div class="form-group">
                                <label>Option 3</label>
                                <input type="text" name="why_option_heading_3" class="form-control"
                                    placeholder="Heading" value="<?php if (isset($result['why_option_heading_3'])) {
    echo $result['why_option_heading_3'];
}
?>">
                            </div>
                            <?php echo form_error('why_option_heading_3'); ?>

                            <div class="form-group">
                                <label>Description 3</label>
                                <textarea class="form-control" id="textarea_1" name="why_option_des_3" rows="4"
                                    placeholder="Description"><?php if (isset($result['why_option_des_3'])) {
    echo $result['why_option_des_3'];
}
?></textarea>
                            </div>
                            <?php echo form_error('why_option_des_3'); ?>




                            <div class="form-group">
                                <label>Option 4</label>
                                <input type="text" name="why_option_heading_4" class="form-control"
                                    placeholder="Heading" value="<?php if (isset($result['why_option_heading_4'])) {
    echo $result['why_option_heading_4'];
}
?>">
                            </div>
                            <?php echo form_error('why_option_heading_4'); ?>










                            <div class="form-group">
                                <label>Description 4</label>
                                <textarea class="form-control" id="textarea_1" name="why_option_des_4" rows="4"
                                    placeholder="Description"><?php if (isset($result['why_option_des_4'])) {
    echo $result['why_option_des_4'];
}
?></textarea>
                            </div>
                            <?php echo form_error('why_option_des_4'); ?>




                            <div class="row">
                                <div class="col">
                                    <div class="form-group">
                                        <label>Icon 1 (50 x 50 px)</label>
                                        <input type="file" name="why_option_image_1" accept="image/*"
                                            class="form-control">
                                    </div>

                                    <div>
                                        <?php
if (isset($result['why_option_image_1'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['why_option_image_1']) && $result['why_option_image_1'] != "") {?>
                                        <!--  <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="why_option_image_1('<?php echo base64_encode($result['id']) ?>', this)"></span> -->
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['why_option_image_1'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>




                                <div class="col">
                                    <div class="form-group">
                                        <label>Icon 2 (50 x 50 px)</label>
                                        <input type="file" name="why_option_image_2" accept="image/*"
                                            class="form-control">
                                    </div>

                                    <div>
                                        <?php
if (isset($result['why_option_image_2'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['why_option_image_2']) && $result['why_option_image_2'] != "") {?>
                                        <!-- <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="why_option_image_2('<?php echo base64_encode($result['id']) ?>', this)"></span> -->
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['why_option_image_2'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                                <div class="col">
                                    <div class="form-group">
                                        <label>Icon 3 (50 x 50 px)</label>
                                        <input type="file" name="why_option_image_3" accept="image/*"
                                            class="form-control">
                                    </div>

                                    <div>
                                        <?php
if (isset($result['why_option_image_3'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['why_option_image_3']) && $result['why_option_image_3'] != "") {?>
                                        <!-- <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="why_option_image_3('<?php echo base64_encode($result['id']) ?>', this)"></span> -->
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['why_option_image_3'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>

                                <div class="col">
                                    <div class="form-group">
                                        <label>Icon 4 (50 x 50 px)</label>
                                        <input type="file" name="why_option_image_4" accept="image/*"
                                            class="form-control">
                                    </div>

                                    <div>
                                        <?php
if (isset($result['why_option_image_4'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['why_option_image_4']) && $result['why_option_image_4'] != "") {?>
                                        <!--  <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="why_option_image_4('<?php echo base64_encode($result['id']) ?>', this)"></span> -->
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['why_option_image_4'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                            </div>




                            <hr>
                            <!--
                            <div class="form-group">
                                <label>Mission</label>
                                <textarea rows="5" class="form-control" name="mission" placeholder="Mission"><?php if (isset($result['mission'])) {
    echo $result['mission'];
}
?></textarea>
                            </div>
                            <?php echo form_error('mission'); ?>


                            <div class="form-group">
                                <label>Vision</label>
                                <textarea rows="5" class="form-control" name="vision" placeholder="Vision"><?php if (isset($result['vision'])) {
    echo $result['vision'];
}
?></textarea>
                            </div>
                            <?php echo form_error('vision'); ?>


 -->

                            <div class="form-group">
                                <label>Meta title</label>
                                <input type="text" name="meta_title" class="form-control" placeholder="Meta title"
                                    value="<?php if (isset($result['meta_title'])) {
    echo $result['meta_title'];
}
?>">
                            </div>
                            <?php echo form_error('meta_title'); ?>

                            <div class="form-group">
                                <label>Meta keywords</label>
                                <input type="text" name="meta_keywords" class="form-control" placeholder="Meta keywords"
                                    value="<?php if (isset($result['meta_keywords'])) {
    echo $result['meta_keywords'];
}
?>">
                            </div>
                            <?php echo form_error('meta_keywords'); ?>

                            <div class="form-group">
                                <label>Meta description</label>
                                <textarea rows="5" class="form-control" name="meta_description"
                                    placeholder="Meta description"><?php if (isset($result['meta_description'])) {
    echo $result['meta_description'];
}
?></textarea>
                            </div>
                            <?php echo form_error('meta_description'); ?>


                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Home Page About us banner (612 x 612 px)</label>
                                        <input type="file" name="home_page_banner" accept="image/*"
                                            class="form-control">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>About us video Youtube URL</label>
                                        <input type="text" name="home_about_section_video_url" class="form-control"
                                            placeholder="About us video Youtube URL"
                                            value="<?php if (isset($result['home_about_section_video_url'])) {echo $result['home_about_section_video_url'];}?>">
                                    </div>
                                    <?php echo form_error('home_about_section_video_url'); ?>
                                </div>

                            </div>
                            <div class="row ">
                                <div class="col-md-6">
                                    <div>
                                        <?php
if (isset($result['home_page_banner'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['home_page_banner']) && $result['home_page_banner'] != "") {?>
                                        <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right"
                                            onclick="delete_home_page_banner('<?php echo base64_encode($result['id']) ?>', this)"></span>
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['home_page_banner'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                            </div>




                            <!--  <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Mission Image</label>
                                        <input type="file" name="mission_image" accept="image/*" class="form-control">
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Vission Image</label>
                                        <input type="file" name="vision_image" accept="image/*" class="form-control">
                                    </div>
                                </div>


                            </div>
                            <div class="row ">
                                <div class="col-md-6">
                                    <div>
                                        <?php
if (isset($result['mission_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['mission_image']) && $result['mission_image'] != "") {?>

                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['mission_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div>
                                        <?php
if (isset($result['vision_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['vision_image']) && $result['vision_image'] != "") {?>

                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['vision_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                            </div> -->



                            <div class="row mt-5">
                                <div class="col-12">
                                    <div class="form-group">
                                        <label>Video Section Heading</label>
                                        <input type="text" name="video_heading" class="form-control"
                                            placeholder="Heading"
                                            value="<?php if (isset($result['video_heading'])) {echo $result['video_heading'];}?>">
                                    </div>
                                    <?php echo form_error('video_heading'); ?>
                                </div>
                                <div class="col-12">
                                    <div class="form-group">
                                        <label>Sub Heading</label>
                                        <input type="text" name="video_sub_heading" class="form-control"
                                            placeholder="Sub Heading"
                                            value="<?php if (isset($result['video_sub_heading'])) {echo $result['video_sub_heading'];}?>">
                                    </div>
                                    <?php echo form_error('video_sub_heading'); ?>
                                </div>
                                <div class="col-6">
                                    <div class="form-group">
                                        <label>Video Section Youtube URL</label>
                                        <input type="text" name="why_video" class="form-control"
                                            placeholder="Why Youtube URL"
                                            value="<?php if (isset($result['why_video'])) {echo $result['why_video'];}?>">
                                    </div>
                                    <?php echo form_error('why_video'); ?>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Video Background</label>
                                        <input type="file" name="video_background_image" accept="image/*"
                                            class="form-control">
                                    </div>
                                    <div>
                                        <?php
if (isset($result['video_background_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['video_background_image']) && $result['video_background_image'] != "") {?>

                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['video_background_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>Why Choose Image</label>
                                        <input type="file" name="why_choose_image" accept="image/*"
                                            class="form-control">
                                    </div>
                                    <div>
                                        <?php
if (isset($result['why_choose_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['why_choose_image']) && $result['why_choose_image'] != "") {?>

                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['why_choose_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>



                            </div>



                        </div>




                    </div>


                    <div class="card card-secondary">
                        <div class="card-header">
                            <h3 class="card-title">About Us</h3>

                        </div>
                        <div class="card-body">

                            <div class="form-group">
                                <label>Content</label>
                                <textarea class="form-control" id="textarea1" name="about_us" placeholder="About us"><?php if (isset($result['about_us'])) {
    echo $result['about_us'];
}
?></textarea>
                            </div>
                            <?php echo form_error('about_us'); ?>

                            <div class="form-group">
                                <label>Meta title</label>
                                <input type="text" name="about_meta_title" class="form-control" placeholder="Meta title"
                                    value="<?php if (isset($result['about_meta_title'])) {
    echo $result['about_meta_title'];
}
?>">
                            </div>
                            <?php echo form_error('about_meta_title'); ?>

                            <div class="form-group">
                                <label>Meta keywords</label>
                                <input type="text" name="about_meta_keywords" class="form-control"
                                    placeholder="Meta keywords" value="<?php if (isset($result['about_meta_keywords'])) {
    echo $result['about_meta_keywords'];
}
?>">
                            </div>
                            <?php echo form_error('about_meta_keywords'); ?>

                            <div class="form-group">
                                <label>Meta description</label>
                                <textarea rows="5" class="form-control" name="about_meta_description"
                                    placeholder="Meta description"><?php if (isset($result['about_meta_description'])) {
    echo $result['about_meta_description'];
}
?></textarea>
                            </div>
                            <?php echo form_error('about_meta_description'); ?>


                            <!--     <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label>About us Image (612 x 612 px)</label>
                                        <input type="file" name="about_us_image" accept="image/*" class="form-control">
                                    </div>
                                </div>


                            </div> -->
                            <div class="row ">
                                <div class="col-md-6">
                                    <div>
                                        <?php
if (isset($result['about_us_image'])) {
    if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $result['about_us_image']) && $result['about_us_image'] != "") {?>
                                        <!-- <span class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm float-right" onclick="delete_home_page_banner('<?php //echo base64_encode($result['id']) ?>', this)"></span>-->
                                        <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $result['about_us_image'] ?>"
                                            alt="" class="img-fluid">
                                        <?php }}?>
                                    </div>
                                </div>


                            </div>


                        </div>
                    </div>









                </div>

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

                    <div class="card card-secondary">
                        <div class="card-body">

                            <div class="form-group">
                                <input type="submit" value="submit" name="submit" class="btn btn-success float-right">
                            </div>
                        </div>
                    </div>


                    <div class="card card-secondary d-none">
                        <div class="card-header">
                            <h3 class="card-title">Gallery</h3>
                            <div class="card-tools">
                            </div>
                        </div>
                        <div class="card-body">
                            <div class="form-group">
                                <input type="file" name="gallery[]" accept="image/*" multiple="" class="form-control">
                            </div>
                            <div class="form-group text-center">
                                <div class="row">
                                    <?php
if ($gallery) {
    foreach ($gallery as $gallery_row) {
        if (file_exists(IMAGE_UPLOAD_URL . $class_name . '/' . $gallery_row->image) && $gallery_row->image != "") {?>
                                    <div class="col-6 ">
                                        <span
                                            class="fas fa-trash-alt gallery-img btn bg-gradient-danger btn-flat btn-sm"
                                            onclick="delete_gallery_img('<?php echo base64_encode($gallery_row->id) ?>', this)"></span>
                                        <div class="gallery-div">
                                            <img src="<?php echo IMAGE_UPLOADED_URL . $class_name . '/' . $gallery_row->image ?>"
                                                alt="<?php if (isset($result['title'])) {
            echo $result['title'];
        }
            ?>" class="img-fluid">
                                        </div>
                                    </div>
                                    <?php }}}?>
                                    <div class="ajax-msg"></div>
                                </div>
                            </div>
                        </div>
                    </div>



                </div>


            </div>
        </form>
    </section>
</div>
<?php $this->load->view('layouts/footer')?>

<script>
function delete_home_page_banner(id, el) {
    if (confirm("Are you sure to delete this image?")) {
        $.ajax({
            url: "<?=base_url($this->router->fetch_class() . '/delete_home_page_banner/');?>" + id,
            type: "POST",
            cache: false,
            beforeSend: function() {
                $(".ajax-msg_1").html(
                    '<div class="alert alert-info"><i class="fa fa-refresh fa-spin"></i> Please wait... </div>'
                );
            },
            success: function(response) {
                var data = jQuery.parseJSON(response);
                if (data.error) {
                    $(".ajax-msg_1").html('<div class="alert alert-danger">' + data.msg + '</div>');
                } else {
                    $(".ajax-msg_1").html('<div class="alert alert-success">' + data.msg + '</div>');
                    $(el).parent().fadeOut();
                }
            },
            complete: function() {
                setTimeout(function() {
                    $(".ajax-msg_1").html('');
                }, 4000);
            },
            error: function(e) {
                $(".ajax-msg_1").html(
                    '<div class="alert alert-danger">Sorry! Please check internet connection</div>');
            }
        });
    }
    return false;
}

function delete_gallery_img(id, el) {
    if (confirm("Are you sure to delete this image?")) {
        $.ajax({
            url: "<?=base_url($this->router->fetch_class() . '/delete_gallery/');?>" + id,
            type: "POST",
            cache: false,
            beforeSend: function() {
                $(".ajax-msg").html(
                    '<div class="alert alert-info"><i class="fa fa-refresh fa-spin"></i> Please wait... </div>'
                );
            },
            success: function(response) {
                var data = jQuery.parseJSON(response);
                if (data.error) {
                    $(".ajax-msg").html('<div class="alert alert-danger">' + data.msg + '</div>');
                } else {
                    $(".ajax-msg").html('<div class="alert alert-success">' + data.msg + '</div>');
                    $(el).parent().fadeOut();
                }
            },
            complete: function() {
                setTimeout(function() {
                    $(".ajax-msg").html('');
                }, 4000);
            },
            error: function(e) {
                $(".ajax-msg").html(
                    '<div class="alert alert-danger">Sorry! Please check internet connection</div>');
            }
        });
    }
    return false;
}
</script>