<?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,-6,6,true));
$key = array_column($list_event,'total_order');
array_multisort($key,SORT_DESC,$list_event);
$six_event=array_slice($list_event,0,6,false);
$list_event_reverse=array_reverse($list_event);
$six_top_event=array_slice($list_top_event,0,6,false);
$style_block_top_event=block_top_event_helper::get_style_block_top_event();
$i=0;
$j=0;
$k=0;
?>
<div class="block_top_event_default6">
    <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">
        <div class="row">
            <?php foreach ($six_event_new as $item){?>
                <div class="col-md-4 col-sm-6">
                    <?php $i=$i+1 ?>
                    <div class="each-event <?php esc_attr_e('event','wpbookingpro');?><?php esc_html_e($i) ?>">
                        <a class="link" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Link','wpbookingpro') ?></a>
                        <div class="date-open-price">
                            <div class="date-open">
                                <?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 class="price">
                                <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                            </div>
                        </div>
                        <div class="name-event">
                            <?php
                                $name_event=$item->name;
                                if(strlen($name_event)>35){?>
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span title="<?php esc_html_e($name_event) ?>"><?php esc_html_e(substr($name_event,0,35)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span></a>
                                <?php } else { ?>
                                    <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($name_event) ?></span></a>
                                <?php }
                            ?>
                        </div>
                        <div class="capacity-hour-location">
                            <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">
                                <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>
                                <?php
                                    $location_name= $item->location_name;
                                    if(strlen($location_name)>35){?>
                                        <span><?php esc_html_e(substr($location_name,0,32)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span>
                                    <?php } else{ ?>
                                        <span><?php esc_html_e($item->location_name) ?></span>
                                    <?php }
                                ?>
                            </div>
                        </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 class="book-service" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>
    <div class="list-event-top">
        <div class="row">
            <?php foreach ($six_event as $item){?>
                <div class="col-md-4 col-sm-6">
                    <?php $j=$j+1 ?>
                    <div class="each-event <?php esc_attr_e('event','wpbookingpro');?><?php esc_html_e($j) ?>">
                        <a class="link" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Link','wpbookingpro') ?></a>
                        <div class="date-open-price">
                            <div class="date-open">
                                <?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 class="price">
                                <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                            </div>
                        </div>
                        <div class="name-event">
                            <?php
                            $name_event=$item->name;
                            if(strlen($name_event)>35){?>
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span title="<?php esc_html_e($name_event) ?>"><?php esc_html_e(substr($name_event,0,35)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span></a>
                            <?php } else { ?>
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($name_event) ?></span></a>
                            <?php }
                            ?>
                        </div>
                        <div class="capacity-hour-location">
                            <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">
                                <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>
                                <?php
                                $location_name= $item->location_name;
                                if(strlen($location_name)>35){?>
                                    <span><?php esc_html_e(substr($location_name,0,32)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span>
                                <?php } else{ ?>
                                    <span><?php esc_html_e($item->location_name) ?></span>
                                <?php }
                                ?>
                            </div>
                        </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 class="book-service" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>
    <div class="list-event-best">
        <div class="row">
            <?php foreach ($six_top_event as $item){?>
                <div class="col-md-4 col-sm-6">
                    <?php $k=$k+1 ?>
                    <div class="each-event <?php esc_attr_e('event','wpbookingpro');?><?php esc_html_e($k) ?>">
                        <a class="link" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Link','wpbookingpro') ?></a>
                        <div class="date-open-price">
                            <div class="date-open">
                                <?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 class="price">
                                <span><?php esc_html_e(FrontendHelper::format_currency($item->price)) ?></span>
                            </div>
                        </div>
                        <div class="name-event">
                            <?php
                            $name_event=$item->name;
                            if(strlen($name_event)>35){?>
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span title="<?php esc_html_e($name_event) ?>"><?php esc_html_e(substr($name_event,0,35)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span></a>
                            <?php } else { ?>
                                <a href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><span><?php esc_html_e($name_event) ?></span></a>
                            <?php }
                            ?>
                        </div>
                        <div class="capacity-hour-location">
                            <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">
                                <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>
                                <?php
                                $location_name= $item->location_name;
                                if(strlen($location_name)>35){?>
                                    <span><?php esc_html_e(substr($location_name,0,32)) ?><?php esc_attr_e('...', 'wpbookingpro') ?></span>
                                <?php } else{ ?>
                                    <span><?php esc_html_e($item->location_name) ?></span>
                                <?php }
                                ?>
                            </div>
                        </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 class="book-service" href="<?php echo($this->page_event_detail.'?event_id='.$item->id); ?>"><?php esc_attr_e('Book now', 'wpbookingpro') ?></a>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
        </div>
    </div>
</div>
