}
    ?>
>No</option>           
          </select>
         <em style="font-size:11px;">Default: "Yes". Set to "No" in the case the user have to select various slots in the same date. The price should be set for each total number of slots below (request cost setting).</em>
        </td>
        </tr>           
        
   </table>   

  </div>    
 </div>

 
 <input type="hidden" name="form_structure" id="form_structure" size="180" value="<?php 
    echo str_replace("\r", "", str_replace("\n", "", esc_attr(cpabc_appointment_cleanJSON(cpabc_get_option('form_structure', CPABC_APPOINTMENTS_DEFAULT_form_structure)))));
    ?>
" />
 
 <input type="hidden" name="vs_use_validation" value="1" />
 <input type="hidden" name="vs_text_is_required" value="<?php 
    echo esc_attr(cpabc_get_option('vs_text_is_required', CPABC_APPOINTMENTS_DEFAULT_vs_text_is_required));
    ?>
" />
 <input type="hidden" name="vs_text_is_email" value="<?php 
    echo esc_attr(cpabc_get_option('vs_text_is_email', CPABC_APPOINTMENTS_DEFAULT_vs_text_is_email));
    ?>
" />
 <input type="hidden" name="cv_text_enter_valid_captcha" value="<?php 
    echo esc_attr(cpabc_get_option('cv_text_enter_valid_captcha', CPABC_TDEAPP_DEFAULT_dexcv_text_enter_valid_captcha));
    ?>
function cpabc_appointments_export_csv()
{
    if (!is_admin()) {
        return;
    }
    global $wpdb;
    if (!defined('CP_CALENDAR_ID')) {
        define('CP_CALENDAR_ID', intval($_GET["cal"]));
    }
    $form_data = json_decode(cpabc_appointment_cleanJSON(cpabc_get_option('form_structure', CPABC_APPOINTMENTS_DEFAULT_form_structure)));
    if (@$_GET["cancelled_by"] != '') {
        $cond = '';
    } else {
        $cond = " AND ((is_cancelled<>'1') OR is_cancelled is null)";
    }
    if ($_GET["search"] != '') {
        $cond .= " AND (buffered_date like '%" . esc_sql($_GET["search"]) . "%')";
    }
    if ($_GET["dfrom"] != '') {
        $cond .= " AND (`booked_time_unformatted` >= '" . esc_sql($_GET["dfrom"]) . "')";
    }
    if ($_GET["dto"] != '') {
        $cond .= " AND (`booked_time_unformatted` <= '" . esc_sql($_GET["dto"]) . " 23:59:59')";
    }
    if (@$_GET["added_by"] != '') {
        $cond .= " AND (who_added >= '" . esc_sql($_GET["added_by"]) . "')";
    }
    if (@$_GET["edited_by"] != '') {
        $cond .= " AND (who_edited >= '" . esc_sql($_GET["edited_by"]) . "')";
    }
    if (@$_GET["cancelled_by"] != '') {
        $cond .= " AND (is_cancelled='1' AND who_cancelled >= '" . esc_sql($_GET["cancelled_by"]) . "')";
    }
    if (CP_CALENDAR_ID != 0) {
        $cond .= " AND appointment_calendar_id=" . CP_CALENDAR_ID;
    }
    $events = $wpdb->get_results("SELECT * FROM " . CPABC_TDEAPP_CALENDAR_DATA_TABLE . " INNER JOIN " . CPABC_APPOINTMENTS_CONFIG_TABLE_NAME . " ON " . CPABC_TDEAPP_CALENDAR_DATA_TABLE . ".appointment_calendar_id=" . CPABC_APPOINTMENTS_CONFIG_TABLE_NAME . ".id LEFT JOIN " . CPABC_APPOINTMENTS_TABLE_NAME . " ON " . CPABC_TDEAPP_CALENDAR_DATA_TABLE . ".reference=" . CPABC_APPOINTMENTS_TABLE_NAME . ".id  WHERE 1=1 " . $cond);
    $fields = array("Calendar ID", "Calendar", "Time");
    $values = array();
    foreach ($events as $item) {
        $value = array($item->appointment_calendar_id, $item->uname, $item->datatime);
        $data = array();
        $data = unserialize($item->buffered_date);
        if (!is_array($data)) {
            $data = array('title' => $item->title, 'description' => $item->description);
        }
        $end = count($fields);
        for ($i = 3; $i < $end; $i++) {
            if (isset($data[$fields[$i]])) {
                $value[$i] = $data[$fields[$i]];
                unset($data[$fields[$i]]);
            } else {
                $value[$i] = '';
            }
        }
        foreach ($data as $k => $d) {
            $fields[] = $k;
            $value[] = $d;
        }
        $values[] = $value;
    }
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=bookings.csv");
    $end = count($fields);
    for ($i = 0; $i < $end; $i++) {
        echo '"' . str_replace('"', '""', cpabc_appointments_get_field_name($fields[$i], @$form_data[0])) . '",';
    }
    echo "\n";
    foreach ($values as $item) {
        for ($i = 0; $i < $end; $i++) {
            if (!isset($item[$i])) {
                $item[$i] = '';
            }
            if (is_array($item[$i])) {
                $item[$i] = implode($item[$i], ',');
            }
            echo '"' . str_replace('"', '""', $item[$i]) . '",';
        }
        echo "\n";
    }
    exit;
}