<?php

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

WpBookingProHtmlBackend::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 esc_attr_e($id_by_name) ?>" class="<?php esc_attr_e($class); ?> field-packages">
        <select name="<?php esc_attr_e($name); ?>" <?php echo ($multiple ? ' multiple ' : ""); ?>
                class="list-package">
            <option value=""><?php esc_html_e('Select package','wpbookingpro'); ?></option>
			<?php foreach ($list as $item) { ?>
                <option <?php echo (in_array($item->id, $list_package_id) ? ' selected ' : null) ?>
                        value="<?php esc_attr_e($item->id); ?>"><?php esc_html_e($item->name); ?></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');