<?php

use WpBookingEvent\Factory as FactoryAlias;
use WpBookingEvent\Html\WpBookingEventHtmlFrontend;
use WpBookingEvent\Language\Text;
use WpBookingEventFrontend\app\helpers\ConfigHelper as ConfigHelperAlias;
$input=FactoryAlias::getInput();
$data=$input->getData();
$doc = FactoryAlias::getDocument();
$doc->addLessStyleSheet('frontend/app/assets/less/view-list-events.less');
$doc->addStyleSheet('frontend/app/assets/nb-font-icon/nb-font-icon.css');
WpBookingEventHtmlFrontend::load_jquery_library('moment');
WpBookingEventHtmlFrontend::load_jquery_library('daterangepicker');
WpBookingEventHtmlFrontend::load_jquery_library('fontawesome');
WpBookingEventHtmlFrontend::load_jquery_library('ui');
WpBookingEventHtmlFrontend::load_jquery_library('slick');
WpBookingEventHtmlFrontend::load_jquery_library('confirm');
WpBookingEventHtmlFrontend::load_jquery_library('validate');
WpBookingEventHtmlFrontend::load_jquery_library('select2');
WpBookingEventHtmlFrontend::load_jquery_library('twbs_pagination');

$page_list_event = ConfigHelperAlias::get_page_list_event();
if ($page_list_event) {
    $this->page_list_event = get_page_link($page_list_event);
} else {
    $this->page_list_event = "";
}
$location_id=$input->getInt('location',0);
$eventtype=$input->getInt('eventtype',0);
$limit=$input->getInt('limit', 6);
$start=$input->getInt('start', 0);

?>
    <form class="list-events"  action="<?php echo( $this->page_list_event) ?>"  method="get" name="pagination">
        <div class="view-list-events">
            <div class="block-confirm"></div>
            <div class="row">
                    <form action="<?php echo( $this->page_list_event) ?>" class="form-search" method="get" name='filter-form'>
                        <div class="row">
                            <div class="col-md-3">
                                <div class="block-sorting-dropdown event-type">
                                    <select  name="eventtype" class="select-eventtype">
                                        <option value=""><?php esc_attr_e('Event Type', 'wpbookingevent'); ?></option>
                                        <?php foreach ($this->event_types as $types) { ?>
                                            <option <?php echo ($eventtype == $types->id ? ' selected ' : '') ?> value="<?php esc_attr_e($types->id); ?>"><?php esc_html_e($types->name); ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-3">
                                <div class="block-select-date">
                                    <input type="text" name="datetimes"/>
                                    <i class="icon-calendar-7"></i>
                                </div>
                            </div>

                             <div class="col-md-3">
                                 <div class="block-select-location">
                                     <select name="location" class="select-location">
                                         <option value=""><?php esc_attr_e('Select Location', 'wpbookingevent'); ?></option>
                                         <?php foreach ($this->list_countries as $country) { ?>
                                             <optgroup label="<?php esc_attr_e($country->countryname); ?>">
                                                 <?php foreach ($country->list_location as $location) {?>
                                                     <option <?php echo ($location_id == $location->location_id ? ' selected ' : '') ?> value="<?php esc_attr_e($location->location_id); ?>"><?php esc_html_e($location->location_name); ?></option>
                                                 <?php } ?>
                                             </optgroup>
                                         <?php } ?>
                                     </select>
                                 </div>
                            </div>

                            <div class="col-md-2">
                                <div class="select-price">
                                    <input type="text" id="amount_1" readonly/>
                                    <div id="slider-container-1"></div>
                                    <input type="hidden" name="price_search">
                                </div>
                            </div>

                            <div class="col-md-1">
                                <div class="wrapper-button">
                                    <button class="btn btn-primary" type="submit"><?php esc_attr_e('Filter', 'wpbookingevent'); ?></button>
                                </div>
                            </div>
                        </div>
                    </form>
            </div>
            <div class="row">
                    <div class="wrapper-list-event">
                        <?php foreach ($this->list as $item) { ?>
                            <?php
                            $this->item = $item;
                            echo $this->loadTemplate('list_item');
                            ?>
                        <?php } ?>
                        <div id="pagination-events"></div>
                    </div>
            </div>
            <input type="hidden" name="start" value="<?php echo $start ?>">
        </div>
    </form>


<?php
$input = FactoryAlias::getInput();
$doc->addScriptApplySelector('.list-events', 'view_list_events', array(
        "total_record"=>$this->totalRecord,
        "limit"=>$limit,
        "start"=>$start,
), "frontend/app/assets/js/view_list_events.js");
?>