<script type="text/javascript">
    function security_code_refresh() {
        $.post("<?php echo site_url('security/image_refresh'); ?>", function (data) {
            // console.log('data ' );
            $("#security_code_refresh_img").html(data);
            // security_code_refresh_img
        });
    }
</script>
<?php
$current_url = current_url();
$meta_tags = $this->common_model->getMetaTitle($current_url);
$header_image = $this->config->item('uploads') . 'header_images/' . $meta_tags['header_image'];
$background_image = $this->config->item('uploads') . 'background_images/' . $meta_tags['background_image'];
?>
<section class="page-heading" <?php if ($meta_tags['header_image'] != '') { ?> style='background-image: url("<?= $header_image ?>");' <?php } ?> >
    <div class="container">
        <h1>Blog</h1>
        <ol class="breadcrumb">
            <li><a href="<?= site_url() ?>"><i class="fa fa-home"></i></a></li>
            <li class="active"><?php echo trim($breadcumb, '/ ') ?></li>
        </ol>
    </div>
</section>  
<section class="MainContent" <?php if ($meta_tags['background_image'] != '') { ?> style='background-image: url("<?= $background_image ?>");' <?php } ?>>
    <div class="container">
        <h2 class="section-heading"><?= $blog_data['blog_title'] ?></h2>
        <div class="row">
            <div class="col-md-9">
                <article class="blog_detail">
                    <h6>
                        Posted On
                        <i class="fa fa-calendar"></i> <?= date('d  M,  Y', $blog_data['add_time']) ?> <i class="fa fa-user"></i> By <?= $blog_data['added_by'] ?> <i class="fa fa-tag"></i> On
                        <a href="<?= site_url() ?>blog/<?= $blog_data['slug'] ?>">Blog</a>
                    </h6>
                    <?php
                    $file_path = FCPATH . "assets/uploads/blog_images/" . $blog_data['blog_image'];
                    if ($blog_data['blog_image'] != '' && file_exists($file_path)) {
                        ?>
                        <img src="<?= $this->config->item('uploads') ?>blog_images/<?= $blog_data['blog_image'] ?>" class="blog_img"  /> 
                    <?php } ?>
                    <?php echo $blog_data['blog_description'] ?>

                    <?php if (sizeof($blog_comment) > 0) { ?>
                        <div class="comment-box">
                            <h2>Comments (<?= count($blog_comment) ?>)</h2>
                            <?php
                            if ($blog_comment)
                                foreach ($blog_comment as $comments) {
                                    ?>
                                    <blockquote>
                                        <span><i class="fa fa-user"></i> <?= $comments['comment_by'] ?></span>
                                        "<?= $comments['comment'] ?>"
                                    </blockquote>
                                <?php } ?>
                        </div>
                    <?php } else { ?>
                        <div class="comment-box">
                            <h3 class="heading">No Comments</h3>
                        </div>
                    <?php } ?>

                    <div class="comment_Form">
                        <h4>Leave Comment</h4>
                        <form method="post" role="form">
                            <?php if ($this->session->flashdata('CommentSuccessMessage')) { ?>
                                <div class="alert alert-success">                                         
                                    <strong>Success!</strong>  <?= $this->session->flashdata('CommentSuccessMessage') ?>    
                                </div>
                            <?php } ?>
                            <div class="row form-group">
                                <div class="col-md-6">
                                    <input class="form-control" type="text" value="<?= $comment_by ?>" placeholder="Name" name="comment_by">
                                    <p style="color: red;"><?= strip_tags(form_error('comment_by')) ?></p>
                                </div>
                                <div class="col-md-6">
                                    <input class="form-control" type="text" value="<?= $email ?>" placeholder="Email" name="email">
                                    <p style="color: red;"><?= strip_tags(form_error('email')) ?></p>
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="col-md-6">
                                    <input class="form-control" type="text" value="<?= $phone ?>" placeholder="Phone" name="phone">
                                    <p style="color: red;"><?= strip_tags(form_error('phone')) ?></p>
                                </div>
                                <div class="col-md-6">
                                    <input class="form-control" type="text" value="<?= $subject ?>" placeholder="Subject" name="subject">
                                    <p style="color: red;"><?= strip_tags(form_error('subject')) ?></p>
                                </div>
                            </div>
                            <div class="row form-group">
                                <div class="device_full col-sm-6">
                                    <textarea class="form-control" placeholder="Comment" name="comment" rows="5"><?= $comment ?></textarea>
                                    <p style="color: red;"><?= strip_tags(form_error('comment')) ?></p>
                                </div>
                                <div class="device_full col-sm-6">
                                    <table class="captcha_table">
                                        <tbody>
                                            <tr>
                                                <td width="150"><span id="security_code_refresh_img"><?= $captcha_image ?></span></td>                                            
                                                <td>
                                                    <div class="input-group">
                                                        <span class="input-group-btn">
                                                            <div class="btn btn-default" src="<?php echo $this->config->item('frontassets'); ?>img/refresh-2-icon.png" onclick="security_code_refresh();">
                                                                <i class="fa fa-refresh"></i>
                                                            </div>
                                                        </span>
                                                        <input  id="captcha" type="text" name="captcha" value="" class="form-control <?php if (form_error('captcha') != "") { ?>error <?php } ?>" />
                                                    </div>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <?php if (form_error('captcha') != "") { ?>
                                        <p style="color: red;"><?php echo strip_tags(form_error('captcha')); ?></p>
                                    <?php } ?>
                                    <br>
                                    <input class="btn btn-primary" type="submit" value="Post Comment" name="submit">
                                </div>
                            </div>
                        </form>
                    </div>
                </article>
            </div>
            <?php echo $this->load->view($this->config->item('template') . '/blog_widget'); ?>  
        </div>
</section>