<?php

use WpBookingHotel\Factory;
use WpBookingHotel\Language\Text;
defined('_WPBOOKINGHOTEL_EXEC') or die;
use WpBookingHotel\Utilities\Utility;
extract($displayData);

WpBookingHotelHtmlBackend::load_jquery_library('select2');


$id_by_name = "element_field_". $name;
$data = $displayData['field']->getForm()->getData();
$modelPackages = Model::getInstance('packages');
$list = $modelPackages->getList();
$list_time = [];
$list_package_id = [];
if (!is_array($value)) {
	$list_package_id[] = $value;
} else {
	$list_package_id = $value;
}
?>
    <div id="<?php echo (esc_attr($id_by_name)) ?>" class="<?php echo (esc_attr($class)); ?> field-packages">
        <select name="<?php echo (esc_attr($name)); ?>" <?php echo ($multiple ? ' multiple ' : ""); ?>
                class="list-package">
            <option value=""><?php esc_html_e('Select package','wpbookinghotel'); ?></option>
			<?php foreach ($list as $item) { ?>
                <option <?php echo (in_array($item->id, $list_package_id) ? ' selected ' : null) ?>
                        value="<?php echo (esc_attr($item->id)); ?>"><?php esc_html_e($item->name,'wpbookinghotel'); ?></option>
			<?php } ?>
        </select>
    </div>
<?php
$doc = Factory::getDocument();
$doc->addScriptApplySelector('.field-packages','field_categories',array(
),'admin/nb_apps/nb_woobooking/layouts/WooBooking/form/field/packages/packages.jquery.js');