<?php
use WpBookingEvent\Factory;
use WpBookingEvent\Html\WpBookingEventHtmlFrontend as WpBookingEventHtmlFrontendAlias;
defined('_WPBOOKINGEVENT_EXEC') or die;
extract($displayData);

WpBookingEventHtmlFrontendAlias::load_jquery_library('moment');
WpBookingEventHtmlFrontendAlias::load_jquery_library('timepicker');
WpBookingEventHtmlFrontendAlias::load_jquery_library('validate');
WpBookingEventHtmlFrontendAlias::load_jquery_library('ui');
WpBookingEventHtmlFrontendAlias::load_jquery_library('daterangepicker');
WpBookingEventHtmlFrontendAlias::load_jquery_library('icheck');

$id_by_name = "element_field_" . str_replace(array('[', ']'), '_', $name);
$name_format = str_replace(array('[', ']'), '_', $name);
$data = $displayData['field']->getForm()->getData();
$list_employee = $value;
$week = array('Sunday','Monday','Tuesday' ,'Wednesday' ,'Thursday' ,'Friday','Saturday');
$repeat = array('does not repeat','Daily' ,'Weekly' ,'Monthly');
$day = array('1','2' ,'3' ,'4' ,'5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
if(isset($value) && trim($value) != '') {
    $arr_value= json_decode($value);
} else {
    $arr_value=array();
}
$i=-1;
$j=0;
?>
    <div id="<?php esc_html_e($id_by_name) ?>" class="field-calendardatetime">
        <div id="changeform">
            <div class="start-date-end-date">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="start-date"><?php esc_html_e('Date','wpbookingevent') ?></label>
                            <input type="text" class="form-control start-date" id="start-date" name="start_date"  placeholder="Date">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="start-time"><?php esc_html_e('Start time','wpbookingevent') ?></label>
                            <input type="text" class="form-control start-time" id="start-time"  placeholder="start time" name="start_time">
                        </div>
                    </div>
                </div>
            </div>
            <div class="select-repeat">
                <div class="row">
                    <div class="col-md-2">
                        <h6><?php esc_html_e('Repeat','wpbookingevent') ?></h6>
                    </div>
                    <div class="col-md-10">

                            <label class="name-repeat not">
                                <input type="radio" class="repeat" name="repeat" value="does not repeat" checked/>
                                does not repeat
                            </label>
                            <label class="name-repeat daily">
                                <input type="radio" class="repeat" name="repeat" value="daily" />
                                Daily
                            </label>
                            <label class="name-repeat weekly">
                                <input type="radio" class="repeat" name="repeat" value="weekly"/>
                                Weekly
                            </label>
                            <label class="name-repeat monthly">
                                <input type="radio" class="repeat" name="repeat" value="monthly"/>
                                Monthly
                            </label>

                    </div>
                </div>
            </div>

            <div class="select-day-of-week">
                <div class="row">
                    <div class="col-md-2">
                        <h6><?php esc_html_e('Day of week','wpbookingevent') ?></h6>
                    </div>
                    <div class="col-md-10">
                        <?php foreach ($week as $dayName) {?>
                            <?php $i=$i+1  ?>
                            <label class="name-day-of-week">
                                <input type='checkbox' class="day-of-week" name="day_of_week[]" value="<?php esc_html_e($i);?>"/>
                                <?php esc_html_e($dayName);?>
                            </label>
                        <?php }?>
                    </div>
                </div>
            </div>

            <div class="select-day-of-month">
                <div class="row">
                    <div class="col-md-2">
                        <h6><?php esc_html_e('Day of month','wpbookingevent') ?></h6>
                    </div>
                    <div class="col-md-10">
                        <?php foreach ($day as $dayName) {?>
                            <?php $j=$j+1; ?>
                            <label class="name-day-of-month">
                                <input type='checkbox' class="day-of-month" name="day_of_month[]" value="<?php esc_html_e($j);?>" <?php echo(in_array($dayName,$arr_value)? 'checked':''); ?>/>
                                <?php esc_html_e($dayName);?>
                            </label>
                        <?php }?>
                    </div>
                </div>
            </div>


            <div class="start-date-end-date-recurring">
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="start-date"><?php esc_html_e('Start recurring date','wpbookingevent') ?></label>
                            <input type="text" class="form-control start-date" name="start_date_recurring" id="start-date-recurring" value="" placeholder="Start date ">
                        </div>
                        <div class="form-group">
                            <label for="end-date"><?php esc_html_e('End recurring date','wpbookingevent') ?></label>
                            <input type="text" class="form-control end-date" name="end_date_recurring" id="end-date-recurring"  placeholder="End date ">
                        </div>

                    </div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="start-time"><?php esc_html_e('Start recurring time','wpbookingevent') ?></label>
                            <input type="text" class="form-control start-time" name="start_time_recurring" id="start-time-recurring"  placeholder="start time">
                        </div>
                    </div>
                </div>
            </div>
            <input type="hidden" class="mirror_field" name="<?php esc_html_e($name);?>">
        </div>
    </div>
<?php
$doc = Factory::getDocument();
$doc->addLessStylesheet('frontend/app/layouts/WooBooking/form/field/calendardatetime/calendardatetime.less');
$doc->addStyleSheet('frontend/app/assets/nb-font-icon/nb-font-icon.css');
$doc->addScriptApplySelector('.field-calendardatetime','field_calendardatetime',array(
    "field_name"=>  $name
),'frontend/app/layouts/WooBooking/form/field/calendardatetime/calendardatetime.js');