<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
<?php if (check_user_permission('admin_panel')): ?>
    <!-- Small boxes (Stat box) -->
    <div class="row">
        <div class="col-lg-3 col-xs-6">
            <!-- small box -->
            <div class="small-box admin-small-box bg-success">
                <div class="inner">
                    <h3 class="increase-count"><?php echo $post_count; ?></h3>
                    <a href="<?php echo admin_url(); ?>posts">
                        <p><?php echo trans("posts"); ?></p>
                    </a>
                </div>
                <div class="icon">
                    <a href="<?php echo admin_url(); ?>posts">
                        <i class="fa fa-file"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <!-- small box -->
            <div class="small-box admin-small-box bg-danger">
                <div class="inner">
                    <h3 class="increase-count"><?php echo $pending_post_count; ?></h3>
                    <a href="<?php echo admin_url(); ?>pending-posts">
                        <p><?php echo trans("pending_posts"); ?></p>
                    </a>
                </div>
                <div class="icon">
                    <a href="<?php echo admin_url(); ?>pending-posts">
                        <i class="fa fa-low-vision"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <!-- small box -->
            <div class="small-box admin-small-box bg-purple">
                <div class="inner">
                    <h3 class="increase-count"><?php echo $drafts_count; ?></h3>
                    <a href="<?php echo admin_url(); ?>drafts">
                        <p><?php echo trans("drafts"); ?></p>
                    </a>
                </div>
                <div class="icon">
                    <a href="<?php echo admin_url(); ?>drafts">
                        <i class="fa fa-file-text-o"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="col-lg-3 col-xs-6">
            <!-- small box -->
            <div class="small-box admin-small-box bg-warning">
                <div class="inner">
                    <h3 class="increase-count"><?php echo $scheduled_post_count; ?></h3>
                    <a href="<?php echo admin_url(); ?>scheduled-posts">
                        <p><?php echo trans("scheduled_posts"); ?></p>
                    </a>
                </div>
                <div class="icon">
                    <a href="<?php echo admin_url(); ?>scheduled-posts">
                        <i class="fa fa-clock-o"></i>
                    </a>
                </div>
            </div>
        </div>
    </div>
    <!-- /.row -->
<?php endif; ?>

<div class="row">
    <div class="col-sm-12 no-padding">
        <?php if (check_user_permission('comments_contact')): ?>

            <?php if ($this->general_settings->comment_approval_system != 1): ?>
                <div class="col-lg-6 col-sm-12 col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title"><?php echo trans("comments"); ?></h3>
                            <br>
                            <small><?php echo trans("recently_added_comments"); ?></small>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                            class="fa fa-minus"></i>
                                </button>
                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i
                                            class="fa fa-times"></i>
                                </button>
                            </div>
                        </div><!-- /.box-header -->

                        <div class="box-body index-table">
                            <div class="table-responsive">
                                <table class="table no-margin">
                                    <thead>
                                    <tr>
                                        <th><?php echo trans("id"); ?></th>
                                        <th><?php echo trans("name"); ?></th>
                                        <th style="width: 60%"><?php echo trans("comment"); ?></th>
                                        <th style="min-width: 13%"><?php echo trans("date"); ?></th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <?php foreach ($last_comments as $item): ?>

                                        <tr>
                                            <td> <?php echo html_escape($item->id); ?> </td>
                                            <td>
                                                <?php echo html_escape($item->name); ?>
                                            </td>
                                            <td style="width: 60%" class="break-word">
                                                <?php echo html_escape($item->comment); ?>
                                            </td>
                                            <td class="nowrap"><?php echo formatted_date($item->created_at); ?></td>
                                        </tr>

                                    <?php endforeach; ?>

                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>

                        <div class="box-footer clearfix">
                            <a href="<?php echo admin_url(); ?>comments"
                               class="btn btn-sm btn-default btn-flat pull-right"><?php echo trans("view_all"); ?></a>
                        </div>
                    </div>
                </div>
            <?php else: ?>
                <div class="col-lg-6 col-sm-12 col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title"><?php echo trans("pending_comments"); ?></h3>
                            <br>
                            <small><?php echo trans("recently_added_unapproved_comments"); ?></small>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                            class="fa fa-minus"></i>
                                </button>
                                <button type="button" class="btn btn-box-tool" data-widget="remove"><i
                                            class="fa fa-times"></i>
                                </button>
                            </div>
                        </div><!-- /.box-header -->

                        <div class="box-body index-table">
                            <div class="table-responsive">
                                <table class="table no-margin">
                                    <thead>
                                    <tr>
                                        <th><?php echo trans("id"); ?></th>
                                        <th><?php echo trans("name"); ?></th>
                                        <th style="width: 60%"><?php echo trans("comment"); ?></th>
                                        <th style="min-width: 13%"><?php echo trans("date"); ?></th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <?php foreach ($last_pending_comments as $item): ?>

                                        <tr>
                                            <td> <?php echo html_escape($item->id); ?> </td>
                                            <td>
                                                <?php echo html_escape($item->name); ?>
                                            </td>
                                            <td style="width: 60%" class="break-word">
                                                <?php echo html_escape($item->comment); ?>
                                            </td>
                                            <td class="nowrap"><?php echo formatted_date($item->created_at); ?></td>
                                        </tr>

                                    <?php endforeach; ?>

                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>

                        <div class="box-footer clearfix">
                            <a href="<?php echo admin_url(); ?>pending-comments"
                               class="btn btn-sm btn-default btn-flat pull-right"><?php echo trans("view_all"); ?></a>
                        </div>
                    </div>
                </div>
            <?php endif; ?>

            <div class="col-lg-6 col-sm-12 col-xs-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo trans("last_contact_messages"); ?></h3>
                        <br>
                        <small><?php echo trans("recently_added_contact_messages"); ?></small>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                        class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i
                                        class="fa fa-times"></i>
                            </button>
                        </div>
                    </div><!-- /.box-header -->

                    <div class="box-body index-table">
                        <div class="table-responsive">
                            <table class="table no-margin">
                                <thead>
                                <tr>
                                    <th><?php echo trans("id"); ?></th>
                                    <th><?php echo trans("name"); ?></th>
                                    <th style="width: 60%"><?php echo trans("message"); ?></th>
                                    <th style="min-width: 13%"><?php echo trans("date"); ?></th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php foreach ($last_contacts as $item): ?>
                                    <tr>
                                        <td>
                                            <?php echo html_escape($item->id); ?>
                                        </td>
                                        <td>
                                            <?php echo html_escape($item->name); ?>
                                        </td>
                                        <td style="width: 60%" class="break-word">
                                            <?php echo html_escape($item->message); ?>
                                        </td>
                                        <td style="min-width: 16%" class="nowrap">
                                            <?php echo formatted_date($item->created_at); ?>
                                        </td>
                                    </tr>

                                <?php endforeach; ?>

                                </tbody>
                            </table>
                        </div>
                        <!-- /.table-responsive -->
                    </div>

                    <div class="box-footer clearfix">
                        <a href="<?php echo admin_url(); ?>contact-messages"
                           class="btn btn-sm btn-default btn-flat pull-right"><?php echo trans("view_all"); ?></a>
                    </div>
                </div>
            </div>
        <?php endif; ?>
    </div>
</div>
<!-- /.row -->
<?php if (check_user_permission('users')): ?>
    <div class="row">
        <div class="no-padding margin-bottom-20">
            <div class="col-lg-6 col-sm-12 col-xs-12">
                <!-- USERS LIST -->
                <div class="box box-primary box-sm">
                    <div class="box-header with-border">
                        <h3 class="box-title"><?php echo trans("latest_users"); ?></h3>
                        <br>
                        <small><?php echo trans("recently_registered_users"); ?></small>
                        <div class="box-tools pull-right">
                            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                        class="fa fa-minus"></i>
                            </button>
                            <button type="button" class="btn btn-box-tool" data-widget="remove"><i
                                        class="fa fa-times"></i>
                            </button>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body">
                        <ul class="users-list clearfix">

                            <?php foreach ($last_users as $item) : ?>
                                <li>
                                    <a href="<?php echo generate_profile_url($item->slug); ?>">
                                        <img src="<?php echo get_user_avatar($item); ?>" alt="user" class="img-responsive">
                                    </a>
                                    <a href="<?php echo generate_profile_url($item->slug); ?>" class="users-list-name"><?php echo html_escape($item->username); ?></a>
                                    <span class="users-list-date"><?php echo time_ago($item->created_at); ?></span>
                                </li>

                            <?php endforeach; ?>
                        </ul>
                        <!-- /.users-list -->
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer text-center">
                        <a href="<?php echo admin_url(); ?>users" class="btn btn-sm btn-default btn-flat pull-right"><?php echo trans("view_all"); ?></a>
                    </div>
                    <!-- /.box-footer -->
                </div>
                <!--/.box -->
            </div>
        </div>
    </div>
<?php endif; ?>
<!-- /.row -->