<?php

use WpBookingEvent\Factory;
use WpBookingEvent\Language\Text;
use WpBookingEventBlock\block_top_event\block_top_event_helper;
use WpBookingEventFrontend\app\helpers\FrontendHelper;
use WpBookingEventFrontend\app\helpers\ConfigHelper as ConfigHelperAlias;
$page_event_detail = ConfigHelperAlias::get_page_event_detail();
$this->page_event_detail = get_page_link($page_event_detail);
$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);
$style_block_top_event=block_top_event_helper::get_style_block_top_event();
?>
<div class="block_top_event_default3">
    <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 newest-list">
        <?php foreach ($six_event_new as $item){?>
            <div class="col-md-6 col-xs-12">
                <div class="each-event-list">
                <div class="table">
            <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <div class="image-open-date">
                                <div class="image-service">
                                    <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                    <div class="name-eventtype">
                                        <span><?php esc_html_e($item->eventtype_name) ?></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3 col-xs-3">
                            <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 class="col-md-9 col-xs-9">
                            <div class="information">
                                <div class="name-event">
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>">
                                        <span>
                                            <?php
                                            $name= $item->name;
                                            if(strlen($name)>45){?>
                                                <span><?php esc_html_e(substr($name,0,45)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span>
                                            <?php } else{ ?>
                                                <span><?php esc_html_e($name) ?></span>
                                            <?php }
                                            ?>
                                        </span>
                                    </a>
                                </div>
                                <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 class="button-book">
                                <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>
                </div>
                    <div class="table-mobile">
                        <div class="row">
                        <div class="col-md-12 col-xs-12">
                            <div class="image-open-date">
                                <div class="image-service">
                                    <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                    <div class="name-eventtype">
                                        <span><?php esc_html_e($item->eventtype_name) ?></span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12 col-xs-12">
                            <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 class="col-md-12 col-xs-12">
                            <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="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 class="button-book">
                                <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>
                    </div>
                </div>
             </div>
        <?php } ?>
            </div>

    <div class="list-event-top top-list">
        <?php foreach ($six_event as $item){?>
            <div class="col-md-6 col-xs-12">
                <div class="each-event-list">
                    <div class="table">
                        <div class="row">
                            <div class="col-md-12 col-xs-12">
                                <div class="image-open-date">
                                    <div class="image-service">
                                        <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                        <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                        <div class="name-eventtype">
                                            <span><?php esc_html_e($item->eventtype_name) ?></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xs-3">
                                <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 class="col-md-9 col-xs-9">
                                <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="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 class="button-book">
                                    <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>
                    </div>
                    <div class="table-mobile">
                        <div class="row">
                            <div class="col-md-12 col-xs-12">
                                <div class="image-open-date">
                                    <div class="image-service">
                                        <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                        <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                        <div class="name-eventtype">
                                            <span><?php esc_html_e($item->eventtype_name) ?></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12">
                                <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 class="col-md-12 col-xs-12">
                                <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="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 class="button-book">
                                    <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>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>

    <div class="list-event-best best-list">
        <?php foreach ($list_top_event as $item){?>
            <div class="col-md-6 col-xs-12">
                <div class="each-event-list">
                    <div class="table">
                        <div class="row">
                            <div class="col-md-12 col-xs-12">
                                <div class="image-open-date">
                                    <div class="image-service">
                                        <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                        <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                        <div class="name-eventtype">
                                            <span><?php esc_html_e($item->eventtype_name) ?></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 col-xs-3">
                                <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 class="col-md-9 col-xs-9">
                                <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="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 class="button-book">
                                    <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>
                    </div>
                    <div class="table-mobile">
                        <div class="row">
                            <div class="col-md-12 col-xs-12">
                                <div class="image-open-date">
                                    <div class="image-service">
                                        <img class="" src="<?php echo(Factory::getRootUrlPlugin().'/'.$item->image) ?>">
                                        <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><div class="border-full"></div></a>
                                        <div class="name-eventtype">
                                            <span><?php esc_html_e($item->eventtype_name) ?></span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12 col-xs-12">
                                <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 class="col-md-12 col-xs-12">
                                <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="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 class="button-book">
                                    <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>
                    </div>
                </div>
            </div>
        <?php } ?>
    </div>
</div>
