<?php

use WpBookingEvent\Factory;
use WpBookingEvent\Html\WpBookingEventHtmlFrontend;
use WpBookingEvent\Language\Text;
use WpBookingEvent\Mvc\Model\Model;
use WpBookingEvent\Utilities\Utility;
defined('_WPBOOKINGEVENT_EXEC') or die;
extract($displayData);


$id_by_name = "element_field_". $name;
$locationsModel = Model::getInstance('locations');
$list_location = $locationsModel->getList();
?>
    <div id="<?php esc_attr_e($id_by_name) ?>" class="<?php esc_attr_e($class); ?> field-location">
        <select name="<?php esc_attr_e($name); ?>" <?php $multiple ? ' multiple ' : null ?>
                class="form-control list-location">
            <option value="">Select location</option>
			<?php foreach ($list_location as $location) { ?>
                <option <?php echo ($value == $location->id ? ' selected ' : '') ?>
                        value="<?php esc_attr_e($location->id); ?>"><?php esc_html_e($location->address); ?></option>
			<?php } ?>
        </select>
    </div>
<?php
$doc = Factory::getDocument();
WpBookingEventHtmlFrontend::load_jquery_library('select2');
$doc->addLessStyleSheet('frontend/app/layouts/WooBooking/form/field/location/location.less');
$doc->addStyleSheet('frontend/app/assets/nb-font-icon/nb-font-icon.css');
$doc->addScriptApplySelector('.field-location','field_location',array(
),'frontend/app/layouts/WooBooking/form/field/location/location.jquery.js');
