<div class="container-fluid">
    <div class="block-header">
        <h2>Blogs > Manage articles</h2>
    </div>
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="header">
                    <h2>Manage & Edit blog articles</h2>
                </div>
                <div class="body">
                    <div class="table-responsive1">
                        <table class="table table-bordered table-striped table-hover">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>Thumbnail</th>
                                <th>Category</th>
                                <th>Title</th>
                                <th>Description</th>
                                <th>Views</th>
                                <th>Created</th>
                                <th>Action</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach (GetBlogArticles() as $wo['article']) { ?>
                                <tr class="setting-postlist" id="<?php echo $wo['article']['id'];?>">
                                    <td width="5%"><?php echo $wo['article']['id'];?></td>
                                    <td width="10%"><img src="<?php echo getMedia($wo['article']['thumbnail']);?>" width="100" height="75"></td>
                                    <td width="10%"><?php echo blog_categories()[$wo['article']['category']];?></td>
                                    <td width="10%"><?php echo $wo['article']['title'];?></td>
                                    <td width="15%"><?php echo substr($wo['article']['description'], 0, 150);?></td>
                                    <td width="10%"><?php echo $wo['article']['view'];?></td>
                                    <td width="10%"><?php echo Time_Elapsed_String($wo['article']['created_at']);?></td>
                                    <td width="20%">
                                        <a class="btn btn-info waves-effect waves-light" href="<?php echo LoadAdminLinkSettings('edit-article?id=' . $wo['article']['id']); ?>">EDIT</a>
                                        <button class="btn btn-danger waves-effect waves-light" onclick="Wo_DeleteArticle(<?php echo $wo['article']['id']?>,'<?php echo $wo["article"]["thumbnail"]?>');">DELETE</button>
                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</div>
<!-- #END# Vertical Layout -->
<script>
    $(function () {
        $('table').DataTable({
            "order" : [[ 1, "desc" ]]
        });
    });
    function Wo_DeleteArticle(id,thumbnail) {
        if (id == '') {
            return false;
        }
        if (!confirm('Are you sure you want to delete this Article?')) {
            return false;
        }
        var hash_id = '<?php echo createMainSession();?>';
        $('#' + id).fadeOut(300, function () {
            $(this).remove();
        });
        $.get('{{CONFIG ajax_url}}/ap/delete_blog_article', { id:id, thumbnail:thumbnail, hash_id: hash_id});
    }
</script>