<?php

use WpBookingEvent\Factory;
use WpBookingEvent\Html\WpBookingEventHtmlBackend;
use WpBookingEvent\Utilities\Utility;
use WpBookingEvent\Language\Text;
use WpBookingEventAdmin\app\Html\HtmlBackend;

$doc = Factory::getDocument();
WpBookingEventHtmlBackend::load_jquery_library('chart_js');
WpBookingEventHtmlBackend::load_jquery_library('bootstrap_tabs');
$doc->addLessStyleSheet('admin/app/assets/less/view_db_appointments_dashboard.less');
$doc->addStyleSheet('admin/app/assets/nb-font-icon/nb-font-icon.css');
$ten_new_customer=array_slice(array_reverse($this->list_customer),0,10,false);
$number_user= count((array)$ten_new_customer);
$number_month=count((array)$this->list_order_by_month);
$number_month_order=count((array)$this->list_order_by_month,1);
$number_oder= $number_month_order - $number_month;
$six_new_categories=array_slice(array_reverse($this->list_categories),0,6,false);
$number_categories= count((array)$six_new_categories);
$total=0;
?>
    <div class="view-db-appointments-dashboard">
        <div class="title"><i class="icon-nb_logo_dashboard"></i><p> <?php esc_attr_e('WP','wpbookingevent') ?></p><h2><?php esc_attr_e('Event','wpbookingevent') ?></h2></div>
        <div class="row">
            <div class="col-md-3">
                <div class="block-item-widget user">
                    <div class="icon-block">
                        <i class="fas fa-user-friends"></i>
                    </div>
                    <div class="content-block">
                        <h4> <?php esc_attr_e('New users','wpbookingevent') ?></h4>
                        <p><?php echo ($number_user?$number_user:0); ?> <?php esc_attr_e('New users','wpbookingevent') ?></p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="block-item-widget order">
                    <div class="icon-block">
                        <i class="fas fa-cart-plus"></i>
                    </div>
                    <div class="content-block">
                        <h4><?php esc_attr_e('New orders','wpbookingevent') ?></h4>
                        <p><?php esc_html_e($number_oder);  ?> <?php esc_attr_e('new orders','wpbookingevent') ?></p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="block-item-widget delivery">
                    <div class="icon-block">
                        <i class="fas fa-shopping-bag"></i>
                    </div>
                    <div class="content-block">
                        <h4><?php esc_attr_e('Categories','wpbookingevent') ?></h4>
                        <p><?php esc_html_e($number_categories);  ?> <?php esc_attr_e('Categories','wpbookingevent') ?></p>
                    </div>
                </div>
            </div>
            <div class="col-md-3">
                <div class="block-item-widget monthly">
                    <div class="icon-block">
                        <i class="fas fa-dollar-sign"></i>
                    </div>
                    <div class="content-block">
                        <?php foreach ($this->list_order_in_year as $item) { ?>
                            <?php $total += $item->total ?>
                        <?php } ?>
                        <h4><?php esc_attr_e('Yearly_profits','wpbookingevent') ?></h4>
                        <p><?php echo (HtmlBackend::render_price($total)); ?> <?php esc_attr_e('This year','wpbookingevent') ?></p>
                    </div>
                </div>
            </div>

        </div>
        <div class="total-order">
            <h3><?php esc_attr_e('Total order','wpbookingevent') ?></h3>
            <canvas class="order-this-week"></canvas>
        </div>
        <div class="monthly-profits">
            <h3><?php esc_attr_e('Month profits','wpbookingevent') ?></h3>
            <canvas class="employee-chart"></canvas>
        </div>
        <div class="row">
            <div class="col-md-6">
                <div class="new-customer">
                    <h3><?php esc_attr_e('New customer','wpbookingevent') ?></h3>
                    <table class="table table-responsive">
                        <thead>
                        <tr>
                            <th class="nowrap"><?php esc_attr_e('Id','wpbookingevent') ?></th>
                            <th class="nowrap"><?php esc_attr_e('Name','wpbookingevent') ?></th>
                            <th class="nowrap"><?php esc_attr_e('Phone','wpbookingevent') ?></th>
                            <th class="nowrap"><?php esc_attr_e('Order time','wpbookingevent') ?> </th>
                        </tr>
                        </thead>
                        <tbody class="list-wbcustomer main-table">
                        <?php foreach ($ten_new_customer as $item) { ?>
                            <?php $this->item = $item ?>
                            <?php $this->loadTemplate('list_item_customer') ?>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="col-md-6">
                <div class="list-category">
                    <h3><?php esc_attr_e('List Categories','wpbookingevent') ?></h3>
                    <table class="table table-responsive">
                        <thead>
                        <tr>
                            <th class="view-list-category-th nowrap"><?php esc_attr_e('Id','wpbookingevent') ?></th>
                            <th class="view-list-category-th nowrap"><?php esc_attr_e('Name','wpbookingevent') ?></th>
                            <th class="view-list-category-th nowrap"><?php esc_attr_e('Image','wpbookingevent') ?></th>
                        </tr>
                        </thead>
                        <tbody class="list-category main-table">
                        <?php foreach ($six_new_categories as $item) { ?>
                            <?php $this->item = $item ?>
                            <?php $this->loadTemplate('list_item_category') ?>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
<?php
$doc->addScriptApplySelector('.view-db-appointments-dashboard','view_db_appointments_dashboard',array(
    "list_order_by_month"=>$this->list_order_by_month
),'admin/app/assets/js/view_db_appointments_dashboard.js');