<?php
use WpBookingEvent\Factory;
use WpBookingEvent\Html\WpBookingEventHtmlFrontend;
use WpBookingEvent\Mvc\Model\Model;

defined('_WPBOOKINGEVENT_EXEC') or die;
extract($displayData);


$id_by_name = "element_field_". $name;
$name_format = str_replace(array('[', ']'), '_', $name);
$activitiesModel = Model::getInstance('activities');
$list_location = $activitiesModel->getList_activity_public();
$list_selected = is_array($value) ? $value : array();


?>
    <div id="<?php esc_attr_e($id_by_name) ?>"
         class="<?php esc_attr_e($class); ?> field-activities-<?php esc_attr_e($name_format) ?> field-activities">
        <select name="<?php esc_attr_e($name); ?>" <?php echo ($multiple ? ' multiple ' : ""); ?>
                class="form-control list-activities">
            <option value=""> <?php esc_attr_e('Select activities','wpbookingevent') ?></option>
			<?php foreach ($list_location as $activity) { ?>
                <option <?php echo (in_array($activity->id, $list_selected) ? " selected " : "") ?>
                        value="<?php esc_attr_e($activity->id); ?>"><?php esc_html_e($activity->name); ?></option>
			<?php } ?>
        </select>
    </div>
<?php
$doc = Factory::getDocument();
WpBookingEventHtmlFrontend::load_jquery_library('select2');
$doc->addLessStylesheet('admin/app/layouts/WooBooking/form/field/activities/activities.less');
$doc->addScriptApplySelector('.field-activities','field_activities',array(
    "field_name"=>  $name,
),'admin/app/layouts/WooBooking/form/field/activities/activities.jquery.js');
