/** @see WP_Widget::form */
    function form($instance)
    {
        if (isset($instance['booking_widget_title'])) {
            $booking_widget_title = esc_attr($instance['booking_widget_title']);
        } else {
            $booking_widget_title = '';
        }
        if (isset($instance['booking_widget_show'])) {
            $booking_widget_show = esc_attr($instance['booking_widget_show']);
        } else {
            $booking_widget_show = '';
        }
        if (class_exists('wpdev_bk_personal') && isset($instance['booking_widget_type'])) {
            $booking_widget_type = esc_attr($instance['booking_widget_type']);
        } else {
            $booking_widget_type = 1;
        }
        if (isset($instance['booking_widget_calendar_count'])) {
            $booking_widget_calendar_count = esc_attr($instance['booking_widget_calendar_count']);
        } else {
            $booking_widget_calendar_count = 1;
        }
        if (isset($instance['booking_widget_last_field'])) {
            $booking_widget_last_field = esc_attr($instance['booking_widget_last_field']);
        } else {
            $booking_widget_last_field = '';
        }
        ?>

        <p>
            <label for="<?php 
        echo $this->get_field_id('booking_widget_title');
        ?>
"><?php 
        _e('Title', 'wpdev-booking');
        ?>
:</label><br/>
            <input value="<?php 
        echo $booking_widget_title;
        ?>
"
                   name="<?php 
        echo $this->get_field_name('booking_widget_title');
        ?>
"
                   id="<?php 
        echo $this->get_field_id('booking_widget_title');
        ?>
"
                   type="text" class="widefat" style="width:100%;line-height: 1.5em;" />
        </p>

        <p>
            <label for="<?php 
        echo $this->get_field_id('booking_widget_show');
        ?>
"><?php 
        _e('Show', 'wpdev-booking');
        ?>
:</label><br/>
            <select
                   name="<?php 
        echo $this->get_field_name('booking_widget_show');
        ?>
"
                   id="<?php 
        echo $this->get_field_id('booking_widget_show');
        ?>
" style="width:100%;line-height: 1.5em;">
                <option <?php 
        if ($booking_widget_show == 'booking_form') {
            echo "selected";
        }
        ?>
 value="booking_form"><?php 
        _e('Booking form with calendar', 'wpdev-booking');
        ?>
</option>
                <option <?php 
        if ($booking_widget_show == 'booking_calendar') {
            echo "selected";
        }
        ?>
 value="booking_calendar"><?php 
        _e('Only availability calendar', 'wpdev-booking');
        ?>
</option>
            </select>
        </p>


        <?php 
        if (class_exists('wpdev_bk_personal')) {
            $types_list = get_bk_types(false, false);
            ?>
            <p>
                <label for="<?php 
            echo $this->get_field_id('booking_widget_type');
            ?>
"><?php 
            _e('Booking resource', 'wpdev-booking');
            ?>
:</label><br/>
                <!--input id="calendar_type"  name="calendar_type" class="input" type="text" -->
                <select
                       name="<?php 
            echo $this->get_field_name('booking_widget_type');
            ?>
"
                       id="<?php 
            echo $this->get_field_id('booking_widget_type');
            ?>
"
                       style="width:100%;line-height: 1.5em;">
                            <?php 
            foreach ($types_list as $tl) {
                ?>
                    <option  <?php 
                if ($booking_widget_type == $tl->id) {
                    echo "selected";
                }
                ?>
                        style="<?php 
                if (isset($tl->parent)) {
                    if ($tl->parent == 0) {
                        echo 'font-weight:bold;';
                    } else {
                        echo 'font-size:11px;padding-left:20px;';
                    }
                }
                ?>
"
                        value="<?php 
                echo $tl->id;
                ?>
"><?php 
                echo $tl->title;
                ?>
</option>
                                <?php 
            }
            ?>
                </select>

            </p>
        <?php 
        }
        ?>

        <p>
            <label for="<?php 
        echo $this->get_field_id('booking_widget_calendar_count');
        ?>
"><?php 
        _e('Visible months', 'wpdev-booking');
        ?>
:</label><br/>

            <select style="width:100%;line-height: 1.5em;"
                    name="<?php 
        echo $this->get_field_name('booking_widget_calendar_count');
        ?>
"
                    id="<?php 
        echo $this->get_field_id('booking_widget_calendar_count');
        ?>
"
            >
            <?php 
        foreach (array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) as $tl) {
            ?>
                <option  <?php 
            if ($booking_widget_calendar_count == $tl) {
                echo "selected";
            }
            ?>
                        style="font-weight:bold;"
                        value="<?php 
            echo $tl;
            ?>
"><?php 
            echo $tl;
            ?>
</option>
            <?php 
        }
        ?>
            </select>
        </p>

        <p>
            <label for="<?php 
        echo $this->get_field_id('booking_widget_last_field');
        ?>
"><?php 
        _e('Footer', 'wpdev-booking');
        ?>
:</label><br/>
            <input value="<?php 
        echo $booking_widget_last_field;
        ?>
"
                   name="<?php 
        echo $this->get_field_name('booking_widget_last_field');
        ?>
"
                   id="<?php 
        echo $this->get_field_id('booking_widget_last_field');
        ?>
"
                   type="text" style="width:100%;line-height: 1.5em;" /><br/>
            <em style="font-size:11px;"><?php 
        printf(__("Example: %sMake booking here%s", 'wpdev-booking'), "<code>&lt;a href='" . get_site_url() . "'&gt;", '&lt;/a&gt;</code>');
        ?>
</em>
        </p>

        <p style="font-size:10px;" > 
                    <?php 
        printf(__("%sImportant!!!%s Please note, if you show booking calendar (inserted into post/page) with widget at the same page, then the last will not be visible.", 'wpdev-booking'), '<strong>', '</strong>');
        ?>

                    <?php 
        if (!class_exists('wpdev_bk_personal')) {
            ?>

                            <em><?php 
            printf(__("%sSeveral widgets are supported at %spaid versions%s.", 'wpdev-booking'), '<span style="">', '<a href="http://wpbookingcalendar.com/" target="_blank" style="text-decoration:none;color:#3A5670;">', '</a>', '</span>');
            ?>
</em>

                    <?php 
        }
        ?>
</p><?php 
    }
function wpdev_bk_custom_button_dalog_structure_DIV()
{
    ?>
    <div class="hidden">
        <div id="wpdev_bk-dialog" style="width:90%;height:90%;">
            <div class="wpdev_bk-dialog-content">
                <div class="wpdev_bk-dialog-inputs">
                    <?php 
    $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin');
    if ($is_can) {
        make_bk_action('show_tabs_inside_insertion_popup_window');
    }
    ?>
                    <div id="popup_new_reservation" style="display:block;" class="booking_configuration_dialog">

                      <div id="popup_new_reservation_main_content"><?php 
    if (get_bk_version() !== 'free') {
        $types_list = get_bk_types(false, false);
        ?>
<div class="field">
                                  <fieldset>
                                        <label for="calendar_type"><?php 
        _e('Booking resource:', 'booking');
        ?>
</label>
                                        <select id="calendar_type" name="calendar_type">
                                            <?php 
        foreach ($types_list as $tl) {
            ?>
                                            <option value="<?php 
            echo $tl->id;
            ?>
"
                                                        style="<?php 
            if (isset($tl->parent)) {
                if ($tl->parent == 0) {
                    echo 'font-weight:bold;';
                } else {
                    echo 'font-size:11px;padding-left:20px;';
                }
            }
            ?>
"
                                                    ><?php 
            echo $tl->title;
            ?>
</option>
                                            <?php 
        }
        ?>
                                        </select>
                                      <span class="description"><?php 
        _e('Select booking resource', 'booking');
        ?>
</span>
                                  </fieldset>
                              </div>                              
                        <?php 
    }
    ?>

                        <?php 
    if ($is_can || WP_BK_CUSTOM_FORMS_FOR_REGULAR_USERS) {
        make_bk_action('wpdev_show_bk_form_selection');
    }
    ?>

                        <div class="field">
                            <fieldset>
                                <label for="calendar_count"><?php 
    _e('Visible months:', 'booking');
    ?>
</label>
                                <select  id="calendar_count"  name="calendar_count" >
                                    <option value="1" <?php 
    if (get_bk_option('booking_client_cal_count') == '1') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >1</option>
                                    <option value="2" <?php 
    if (get_bk_option('booking_client_cal_count') == '2') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >2</option>
                                    <option value="3" <?php 
    if (get_bk_option('booking_client_cal_count') == '3') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >3</option>
                                    <option value="4" <?php 
    if (get_bk_option('booking_client_cal_count') == '4') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >4</option>
                                    <option value="5" <?php 
    if (get_bk_option('booking_client_cal_count') == '5') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >5</option>
                                    <option value="6" <?php 
    if (get_bk_option('booking_client_cal_count') == '6') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >6</option>
                                    <option value="7" <?php 
    if (get_bk_option('booking_client_cal_count') == '7') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >7</option>
                                    <option value="8" <?php 
    if (get_bk_option('booking_client_cal_count') == '8') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >8</option>
                                    <option value="9" <?php 
    if (get_bk_option('booking_client_cal_count') == '9') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >9</option>
                                    <option value="10" <?php 
    if (get_bk_option('booking_client_cal_count') == '10') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >10</option>
                                    <option value="11" <?php 
    if (get_bk_option('booking_client_cal_count') == '11') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >11</option>
                                    <option value="12" <?php 
    if (get_bk_option('booking_client_cal_count') == '12') {
        echo ' selected="SELECTED" ';
    }
    ?>
 >12</option>
                                </select>
                                <span class="description"><?php 
    _e('Select number of month to show for calendar.', 'booking');
    ?>
</span>
                            </fieldset>
                        </div>

                        <div class="field">
                            <fieldset>
                                <label for="start_month_active"><?php 
    _e('Start month:', 'booking');
    ?>
</label>
                                <input id="start_month_active"  name="start_month_active" type="checkbox" 
                                       onchange="javascript:if(! this.checked){ jQuery('select.start_month').attr('disabled', 'disabled'); } else {jQuery('select.start_month').removeAttr('disabled');}" 
                                        />
                                <?php 
    $start_year = date('Y');
    $start_month = date('m');
    ?>
                                <select class="start_month" id="year_start_month" disabled="DISABLED" name="year_start_month" style="width:65px;" > <?php 
    for ($mi = $start_year; $mi < $start_year + 11; $mi++) {
        echo '<option value="' . $mi . '" >' . $mi . '</option>';
    }
    ?>
 </select> /
                                <select class="start_month"  id="month_start_month" disabled="DISABLED"  name="month_start_month" style="width:50px;" > <?php 
    for ($mi = 1; $mi < 13; $mi++) {
        if ($mi < 10) {
            $mi = '0' . $mi;
        }
        echo '<option value="' . $mi . '" ' . ($start_month == $mi ? ' selected="SELECTED" ' : '') . ' >' . $mi . '</option>';
    }
    ?>
 </select>
                                <span class="description"><?php 
    _e('Select start month of calendar', 'booking');
    ?>
</span>
                            </fieldset>
                        </div>

                        <div class="field">
                            <fieldset>
                                <div style="float:left;">
                                <label for="calendar_or_form"><?php 
    _e('Show in the page:', 'booking');
    ?>
</label>
                                </div>
                                <div style="float:left;">
                                <select id="calendar_or_form"  name="calendar_or_form" onchange="
                                javascript: if(this.value=='onlyform') document.getElementById('dates_for_form').style.display='block'; else  document.getElementById('dates_for_form').style.display='none';
                                ">
                                    <option value="form"><?php 
    _e('Booking form with calendar', 'booking');
    ?>
</option>
                                    <option value="calendar"><?php 
    _e('Only availability calendar', 'booking');
    ?>
</option>
                                    <?php 
    if (class_exists('wpdev_bk_biz_l')) {
        ?>
<option value="onlyform"><?php 
        _e('Only booking form', 'booking');
        ?>
</option><?php 
    }
    ?>
                                </select>
                                </div>
                                <div style="float:left;">
                                <?php 
    if (class_exists('wpdev_bk_biz_l')) {
        ?>
<span style="margin-left:5px;display:none;" id="dates_for_form"> <?php 
        _e('for', 'booking');
        ?>
                                        <select  id="year_popup"  name="year_popup" style="width:65px;" > <?php 
        for ($mi = $start_year; $mi < $start_year + 11; $mi++) {
            echo '<option value="' . $mi . '" >' . $mi . '</option>';
        }
        ?>
 </select> /
                                        <select  id="month_popup"  name="month_popup" style="width:50px;" > <?php 
        for ($mi = 1; $mi < 13; $mi++) {
            if ($mi < 10) {
                $mi = '0' . $mi;
            }
            echo '<option value="' . $mi . '" ' . ($start_month == $mi ? ' selected="SELECTED" ' : '') . '  >' . $mi . '</option>';
        }
        ?>
 </select> /
                                        <select  id="day_popup"  name="day_popup" style="width:50px;" > <?php 
        for ($mi = 1; $mi < 32; $mi++) {
            if ($mi < 10) {
                $mi = '0' . $mi;
            }
            echo '<option value="' . $mi . '" >' . $mi . '</option>';
        }
        ?>
 </select> <?php 
        _e('date', 'booking');
        ?>
.
                                    </span><?php 
    }
    ?>
                                </div>
                                <div class="clear"></div>
                                <p class="description"><?php 
    _e('Select to show the entire booking form or the availability calendar only.', 'booking');
    ?>
</p>
                            </fieldset>
                        </div>                              
                        <?php 
    make_bk_action('show_additional_arguments_for_shortcode');
    ?>
  

                      </div>

                      <div style="height:1px;clear:both;width:100%;"></div>


                        <div style="color:#21759B;cursor: pointer;font-weight: bold;float:left;"
                           onclick="javascript: jQuery('.bk_show_options_parameter').toggle(1);
                                                jQuery('#togle_options_parameter').slideToggle('normal');
                                                jQuery('#popup_new_reservation_main_content').slideToggle('normal');"
                           style="text-decoration: none;font-weight: bold;font-size: 11px;">
                            <span class="bk_show_options_parameter">+ <span style="border-bottom:1px dashed #21759B;"><?php 
    _e('Show advanced settings', 'booking');
    ?>
</span></span>
                            <span class="bk_show_options_parameter" style="display:none;">- <span style="border-bottom:1px dashed #21759B;"><?php 
    _e('Hide advanced settings', 'booking');
    ?>
</span></span>
                        </div>

                        <div class="bk_show_options_parameter description" style="color: #777777;float: right;width: 475px;"><?php 
    printf(__('Setting advanced parameters of the calendar. %sLike width, height and structure %s', 'booking'), '<em>', '</em>');
    if (class_exists('wpdev_bk_biz_m')) {
        printf(__('%s or minimum and fixed number of days selection for the specific day of week or season.%s', 'booking'), '<em>', '</em>');
    }
    ?>
</div>

                      <div style="height:1px;clear:both;width:100%;"></div>

                      <div class="field0" id="togle_options_parameter" style="display:none;margin:10px;">
                            <div class="bk_help_message" style="margin:5px 0px;"><?php 
    printf(__('Please read more about the possible customizations of these %soptions%s %shere%s', 'booking'), '<strong>', '</strong>', '<a href="http://wpbookingcalendar.com/help/booking-calendar-shortcodes/" target="_blank">', '</a>');
    ?>
</div>                                     
                            <strong><span for="bookingcalendar_options"><?php 
    _e('Options:', 'booking');
    ?>
</span></strong><br/>
                            <textarea id="bookingcalendar_options"  name="bookingcalendar_options" style="width:100%; height:50px;"></textarea>
                            <span class="description" style="width:99%;">
                                <?php 
    printf(__('Specify the full width of calendar, height of date cell and number of months in one row. ', 'booking'));
    ?>
<br/>
                                <div style="margin-left:35px;">
                                    <strong><?php 
    _e('Description', 'booking');
    ?>
: </strong>
                                        "<?php 
    echo __('Calendar have 2 months in a row, the cell height is 30px and calendar full width 568px (possible to use percentage for width: 100%)', 'booking');
    ?>
"<br/>
                                    <strong><?php 
    _e('Code Example', 'booking');
    ?>
: </strong>
                                        <?php 
    echo '<code>{calendar months_num_in_row=2 width=568px cell_height=30px}</code>';
    ?>
                                </div><br/>
                                <?php 
    if (class_exists('wpdev_bk_biz_m')) {
        ?>
                                    <?php 
        printf(__('Specify that during certain seasons (or days of week), the specific minimum number of days must be booked. ', 'booking'));
        ?>
<br/>
                                    <div style="margin-left:35px;">
                                        <strong><?php 
        _e('Description', 'booking');
        ?>
: </strong>
                                            "<?php 
        printf(__('Visitor can select only 4 days starting at Monday, 3 or 7 days – Friday, 2 days – Saturday, etc…', 'booking'));
        ?>
"<br/>
                                        <strong><?php 
        _e('Code Example', 'booking');
        ?>
: </strong>
                                            <?php 
        echo '<code>{select-day condition="weekday" for="1" value="4"},{select-day condition="weekday" for="5" value="3,7"},{select-day condition="weekday" for="6" value="2"}</code>';
        ?>
                                    </div>
                                <?php 
    }
    ?>
                            </span>                                
                      </div>

                    </div>

                    <?php 
    make_bk_action('show_insertion_popup_shortcode_for_bookingedit');
    ?>

                    <input id="calendar_tag_name"   name="calendar_tag_name"    type="hidden" >
                    <input id="calendar_tag_close"  name="calendar_tag_close"   type="hidden" >
                </div>
            </div>
        </div>
    </div>
    <?php 
}