<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->

    <!-- Main content -->
    <section class="content">
        <h4 class="text-center  content_head">Home Page</h4>
        <!-- Small boxes (Stat box) -->
        <!-- Small boxes (Stat box) -->
        <div class="row">

            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-yellow">
                    <div class="inner">
                        <h3><?php echo ($total_services[0]['count'] !== NULL) ? $total_services[0]['count'] : 0; ?></h3>

                        <p>Total Service</p>
                    </div>
                    <div class="icon">
                        <i class="fa fa-folder-open-o"></i>
                    </div>
                    <a href="<?php echo BASE_URL . "service/getAll"; ?>" class="small-box-footer">More info <i
                                class="fa fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-green">
                    <div class="inner">
                        <h3><?php echo ($total_gallery[0]['count'] !== NULL) ? $total_gallery[0]['count'] : 0; ?></h3>

                        <p>Total Gallery</p>
                    </div>
                    <div class="icon">
                        <i class=" fa fa-film"></i>
                    </div>
                    <a href="<?php echo BASE_URL . "gallery/getAll"; ?>" class="small-box-footer">More info <i
                                class="fa fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->

            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-red">
                    <div class="inner">
                        <h3><?php echo $total_employees[0]['count'] ?></h3>

                        <p>All Administrators</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-pie-graph"></i>
                    </div>
                    <a href="<?php echo BASE_URL . "employee/getAll"; ?>" class="small-box-footer">More info <i
                                class="fa fa-arrow-circle-right"></i></a>
                </div>
            </div>
            <!-- ./col -->
            <div class="col-lg-3 col-xs-6">
                <!-- small box -->
                <div class="small-box bg-aqua">
                    <div class="inner">
                        <h3><?php echo $total_messages[0]['count'] ?></h3>

                        <p>Messages</p>
                    </div>
                    <div class="icon">
                        <i class="ion ion-bag"></i>
                    </div>
                    <a href="<?php echo BASE_URL . "messages/getAll"; ?>" class="small-box-footer">More info <i
                                class="fa fa-arrow-circle-right"></i></a>
                </div>
            </div>
        </div>
        <!-- /.row -->

        <!-- start row for companies -->
        <div class="row">

            <div class="col-md-12">
                <!-- Application buttons -->
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title">Informations </h3>
                    </div>
                    <div class="box-body">

                        <a href="<?php echo BASE_URL . "service/getAll"; ?>" class="btn btn-app">
                            <span class="badge bg-yellow"><?php echo $total_services[0]['count'] ?></span>
                            <i class="fa fa-folder-open-o"></i> Services
                        </a>
                        <a href="<?php echo BASE_URL . "employee/getAll"; ?>" class="btn btn-app">
                            <span class="badge bg-teal"><?php echo $total_employees[0]['count'] ?></span>
                            <i class="fa fa-user-secret"></i> Administrators
                        </a>


                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>

        </div>
        <!-- /.row -->
        <!-- end row for companies -->
        <!-- start row for shortcuts -->
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <i class="fa fa-gift"></i>

                        <h3 class="box-title">Shortcuts</h3>

                        <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>
                    <div class="box-body">

                        <!-- Small boxes (Stat box) -->
                        <div class="row divs_for_data">

                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "gallery/add" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "slider.png" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "gallery/add" ?>">Add
                                                Gallery</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->
                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "service/add" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "agent.png" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "service/add" ?>">Add
                                                Service</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->

                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "employee/add" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "download.png" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "employee/add" ?>">Add
                                                Employee</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->
                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "messages/getAll" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "dolly-512.png" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "messages/getAll" ?>">
                                                Messages</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->
                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "about/edit" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "Circle-icons-creditcard.svg.png" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "about/edit" ?>">
                                                About Us</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->
                            <!-- start col -->
                            <div class="col-lg-2 col-xs-6">
                                <!-- small box -->
                                <div class="small-box shortcut_div">
                                    <div class="inner">
                                        <div class="text-center shortcut_img">
                                            <a href="<?php echo BASE_URL . "setting/edit" ?>"><img
                                                        src="<?php echo IMAGES_BACK_END_LINK . "setting.jpg" ?>"
                                                        class="img-responsive"/></a>
                                        </div>
                                        <h3 class="text-center"><a href="<?php echo BASE_URL . "setting/edit" ?>">Edit
                                                Setting</a></h3>
                                    </div>
                                </div>
                            </div>
                            <!-- end col -->


                        </div>
                        <!-- /.row -->
                    </div>
                    <!-- /.box-body-->
                </div>
                <!-- /.box -->
            </div>

        </div>
        <!-- /.row -->
        <!-- end row for shortcuts -->


        <div class="row">
            <div class="col-sm-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title">Recently Added 4 Service</h3>

                        <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="products-list product-list-in-box">
                            <?php
                            if (isset($servicesHome) && is_array($servicesHome)) {
                                foreach ($servicesHome as $key => $value) {
                                    ?>
                                    <li class="item">
                                        <div class="product-img">
                                            <img src="<?php echo UPLOAD_LINK . $value['image'] ?>" alt="Product Image">
                                        </div>
                                        <div class="product-info">
                                            <a href="<?php echo BASE_URL . "service/edit_selected/" . $value['id'] ?>"
                                               class="product-title"><?php echo $value['title']; ?>
                                                <span class="label label-warning pull-right">Edit</span></a>
                                        </div>
                                    </li>
                                    <!-- /.item -->
                                    <?php
                                }
                            }
                            ?>

                        </ul>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer text-center">
                        <a href="<?php echo BASE_URL . "service/getAll" ?>" class="uppercase">View All Service</a>
                    </div>
                    <!-- /.box-footer -->
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="box box-primary">
                    <div class="box-header with-border">
                        <h3 class="box-title ">Show Last 5 Messages</h3>
                    </div>
                    <!-- /.box-header -->
                    <div class="adminform">
                        <div class="text-center">
                            <span onclick="exportToexcel('#all_data')" class="btn btn-success export-btn">Export To Excel</span>
                        </div>

                        <!-- form start -->
                        <table id="all_data"
                               class="table table_for_data table-striped table-bordered dt-responsive nowrap tableData"
                               cellspacing="0" width="100%">
                            <thead>
                            <tr>
                                <th>Id</th>
                                <th>User Name</th>
                                <th>User Email</th>
                                <th>action</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                            if (isset($sum_messages) && is_array($sum_messages)) {
                                foreach ($sum_messages as $key => $data) {
                                    echo '<tr id="row' . $data['id'] . '">
                                                    <td>' . $data['id'] . '</td>
                                                    <td>' . $data['name'] . '</td>
                                                    <td>' . $data['mail'] . '</td>
                                                 ';

                                    echo '</td>
                                                    <td>
                                                        <ul class="actions">
                                                         <li><a href="' . BASE_URL . "messages/show_selected/" . $data['id'] . '" class="" id="' . $data['id'] . '"  title="View"><i class="fa fa-eye" aria-hidden="true"></i></a></li>
                                                        </ul>
                                                    </td>
                                                  </tr>';
                                }
                            } else {
                                echo '<tr><td colspan="4">No Data Found</td></tr>';
                            }
                            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

        <!-- /.row -->


    </section><!-- /.content -->
</div><!-- /.content-wrapper -->

<script>

    $(function () {
        /*
         * Orders CHART
         * ---------
         */

        var bar_data = {
            data: [['<?php echo $before3Day ?>', <?php echo ($before3DayOrders[0]['count'] == NULL) ? 0 : $before3DayOrders[0]['count'];  ?>], ['<?php echo $before2Day ?>', <?php echo ($before2DayOrders[0]['count'] == NULL) ? 0 : $before2DayOrders[0]['count'];  ?>],
                ['<?php echo $before1Day ?>', <?php echo ($before1DayOrders[0]['count'] == NULL) ? 0 : $before1DayOrders[0]['count'];  ?>], ['<?php echo $today_date ?>', <?php echo ($today_orders[0]['count'] == NULL) ? 0 : $today_orders[0]['count'];  ?>],
            ],
            color: '#3c8dbc'
        }
        $.plot('#bar-chart', [bar_data], {
            grid: {
                borderWidth: 1,
                borderColor: '#f3f3f3',
                tickColor: '#f3f3f3'
            },
            series: {
                bars: {
                    show: true,
                    barWidth: 0.5,
                    align: 'center'
                }
            },
            xaxis: {
                mode: 'categories',
                tickLength: 0
            }
        })

        /* END Orders CHART */
        /*
         * DONUT CHART
         * -----------
         */


        var donutData = [
            {label: ' Active', data: <?php echo $activeUsersCount ?>, color: '#3c8dbc'},
            {label: 'Not Active', data: <?php echo $unActiveUsersCount ?>, color: '#0073b7'},
        ]
        $.plot('#donut-chart', donutData, {
            series: {
                pie: {
                    show: true,
                    radius: 1,
                    innerRadius: 0.5,
                    label: {
                        show: true,
                        radius: 2 / 3,
                        formatter: labelFormatter,
                        threshold: 0.1
                    }

                }
            },
            legend: {
                show: false
            }
        })
        /*
         * END DONUT CHART
         */

        /*
         * Orders CHART
         * ---------
         */


        function labelFormatter(label, series) {
            return '<div style="font-size:13px; text-align:center; padding:2px; color: #fff; font-weight: 600;">'
                + label
                + '<br>'
                + Math.round(series.percent) + '%</div>'
        }

    })

</script>
