<?php

use WpBookingEvent\Factory;
use WpBookingEvent\Language\Text;
use WpBookingEventBlock\block_top_event\block_top_event_helper;
use WpBookingEventFrontend\app\helpers\FrontendHelper;
use WpBookingEvent\Factory as FactoryAlias;
use WpBookingEventFrontend\app\helpers\ConfigHelper as ConfigHelperAlias;
$six_event_new=array_reverse(array_slice($list_event,-4,4,false));
$key = array_column($list_event,'total_order');
array_multisort($key,SORT_DESC,$list_event);
$six_event=array_slice($list_event,0,4,false);
$list_event_reverse=array_reverse($list_event);
$list_top_event=array_slice($list_event,0,4,false);
$page_event_detail = block_top_event_helper::get_page_event_detail();
$this->page_event_detail = get_page_link($page_event_detail);
$list_event_reverse=array_reverse($list_event);
$doc= FactoryAlias::getDocument();


?>
<div class="block_top_event_default4">
    <div class="title">
        <p><?php esc_attr_e('our plugin','wpbookingpro');?></p>
        <h1><?php esc_attr_e('amazing listing','wpbookingpro');?></h1>
    </div>
    <div class="link">
        <p class=" my-choice newest active"><?php esc_attr_e('Newest Event','wpbookingpro');?></p>
        <p class="my-choice top"><?php esc_attr_e('Top Seller','wpbookingpro');?></p>
        <p class="my-choice best"><?php esc_attr_e('Best Choice','wpbookingpro');?></p>
    </div>

    <div class="list-event-newest">
        <?php foreach ($six_event_new as $item){ ?>
                <div class="each-event-list">
                    <div class="row">
                        <div class="col-md-2 col-sm-3">
                            <div class="image-open-date">
                                <div class="open-date">
                                    <?php
                                    $date_open = date('d',strtotime($item->open_date));
                                    $month_open = date(' F',strtotime($item->open_date));
                                    ?>
                                    <span class="day"><?php esc_html_e($date_open) ?></span>
                                    <span class="month"><?php esc_html_e($month_open) ?></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-8 col-sm-6">
                            <div class="information">
                                <div class="name-event">
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($item->name) ?></span></a>
                                </div>
                                <div class="sub-information">
                                <div class="capacity">
                                    <i class="icon-nb-user-2"></i>
                                    <span><?php esc_attr_e('Capacity','wpbookingpro'); ?>-</span>
                                    <span><?php esc_html_e($item->min_allowed_person) ?>/<?php esc_html_e($item->max_allowed_person) ?></span>
                                </div>
                                <div class="hour-duration">
                                    <i class="icon-nb-clock"></i>
                                    <span class="hour">
                                    <?php esc_html_e($item->duration) ?> <?php ($item->duration) <=1 ? esc_attr_e('Hour','wpbookingpro') : esc_attr_e('Hours','wpbookingpro') ; ?>
                                </span>
                                </div>
                                <div class="location">
                                    <i class="icon-nb-pin"></i>
                                    <span><?php esc_html_e($item->location_name) ?></span>
                                </div>
                                </div>

                            </div>
                        </div>
                        <div class="col-md-2 col-sm-3">
                            <div class="price-heart-booknow">
                                <div class="price-booknow">
                                    <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                                </div>
                                <div class="wrapper-button-action">
                                    <a class="div-link" href="<?php echo($this->page_event_detail . '?event_id=' . $item->id); ?>"><?php esc_attr_e('Link', 'wpbookingpro') ?></a>
                                    <div class="btn-booknow">
                                        <a><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
        <?php } ?>
            </div>

    <div class="list-event-top">
        <div class="row">
        <?php foreach ($six_event as $item){ ?>
            <div class="each-event-list">
                <div class="row">
                    <div class="col-md-2 col-sm-3">
                        <div class="image-open-date">
                            <div class="open-date">
                                <?php
                                $date_open = date('d',strtotime($item->open_date));
                                $month_open = date(' F',strtotime($item->open_date));
                                ?>
                                <span class="day"><?php esc_html_e($date_open) ?></span>
                                <span class="month"><?php esc_html_e($month_open) ?></span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-8 col-sm-6">
                        <div class="information">
                            <div class="name-event">
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($item->name) ?></span></a>
                            </div>
                            <div class="sub-information">
                                <div class="capacity">
                                    <i class="icon-nb-user-2"></i>
                                    <span><?php esc_attr_e('Capacity','wpbookingpro'); ?>-</span>
                                    <span><?php esc_html_e($item->min_allowed_person) ?>/<?php esc_html_e($item->max_allowed_person) ?></span>
                                </div>
                                <div class="hour-duration">
                                    <i class="icon-nb-clock"></i>
                                    <span class="hour">
                                    <?php esc_html_e($item->duration) ?> <?php ($item->duration) <=1 ? esc_attr_e('Hour','wpbookingpro') : esc_attr_e('Hours','wpbookingpro') ; ?>
                                </span>
                                </div>
                                <div class="location">
                                    <i class="icon-nb-pin"></i>
                                    <span><?php esc_html_e($item->location_name) ?></span>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="col-md-2 col-sm-3">
                        <div class="price-heart-booknow">
                            <div class="price-booknow">
                                <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                            </div>
                            <div class="wrapper-button-action">
                                <a class="div-link" href="<?php echo($this->page_event_detail . '?event_id=' . $item->id); ?>"><?php esc_attr_e('Link', 'wpbookingpro') ?></a>
                                <div class="btn-booknow">
                                    <a><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>
        </div>
    </div>
    <div class="list-event-best">
        <div class="row">
        <?php foreach ($list_top_event as $item){ ?>
            <div class="each-event-list">
                <div class="row">
                    <div class="col-md-2 col-sm-3">
                        <div class="image-open-date">
                            <div class="open-date">
                                <?php
                                $date_open = date('d',strtotime($item->open_date));
                                $month_open = date(' F',strtotime($item->open_date));
                                ?>
                                <span class="day"><?php esc_html_e($date_open) ?></span>
                                <span class="month"><?php esc_html_e($month_open) ?></span>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-8 col-sm-6">
                        <div class="information">
                            <div class="name-event">
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($item->name) ?></span></a>
                            </div>
                            <div class="sub-information">
                                <div class="capacity">
                                    <i class="icon-nb-user-2"></i>
                                    <span><?php esc_attr_e('Capacity','wpbookingpro'); ?>-</span>
                                    <span><?php esc_html_e($item->min_allowed_person) ?>/<?php esc_html_e($item->max_allowed_person) ?></span>
                                </div>
                                <div class="hour-duration">
                                    <i class="icon-nb-clock"></i>
                                    <span class="hour">
                                    <?php esc_html_e($item->duration) ?> <?php ($item->duration) <=1 ? esc_attr_e('Hour','wpbookingpro') : esc_attr_e('Hours','wpbookingpro') ; ?>
                                </span>
                                </div>
                                <div class="location">
                                    <i class="icon-nb-pin"></i>
                                    <span><?php esc_html_e($item->location_name) ?></span>
                                </div>
                            </div>

                        </div>
                    </div>
                    <div class="col-md-2 col-sm-3">
                        <div class="price-heart-booknow">
                            <div class="price-booknow">
                                <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                            </div>
                            <div class="wrapper-button-action">
                                <a class="div-link" href="<?php echo($this->page_event_detail . '?event_id=' . $item->id); ?>"><?php esc_attr_e('Link', 'wpbookingpro') ?></a>
                                <div class="btn-booknow">
                                    <a><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        <?php } ?>

        </div>
    </div>


</div>
