コード例 #1
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     extract($args);
     $booking_widget_title = apply_filters('widget_title', $instance['booking_widget_title']);
     if (function_exists('icl_translate')) {
         $booking_widget_title = icl_translate('wpml_custom', 'wpbc_custom_widget_booking_title1', $booking_widget_title);
     }
     $booking_widget_show = $instance['booking_widget_show'];
     $booking_widget_type = $instance['booking_widget_type'];
     if (empty($booking_widget_type)) {
         $booking_widget_type = 1;
     }
     $booking_widget_calendar_count = $instance['booking_widget_calendar_count'];
     $booking_widget_last_field = $instance['booking_widget_last_field'];
     echo $before_widget;
     if (isset($_GET['booking_hash'])) {
         _e('You need to use special shortcode [bookingedit] for booking editing.', 'wpdev-booking');
         echo $after_widget;
         return;
     }
     if ($booking_widget_title != '') {
         echo $before_title . htmlspecialchars_decode($booking_widget_title) . $after_title;
     }
     echo "<div class='widget_wpdev_booking months_num_in_row_1'>";
     if ($booking_widget_show == 'booking_form') {
         // do_action('wpdev_bk_add_form', $booking_widget_type , $booking_widget_calendar_count);
         $my_booking_form_name = apply_bk_filter('wpdev_get_default_booking_form_for_resource', 'standard', $booking_widget_type);
         make_bk_action('wpdevbk_add_form', $booking_widget_type, $booking_widget_calendar_count, true, $my_booking_form_name);
     } else {
         do_action('wpdev_bk_add_calendar', $booking_widget_type, $booking_widget_calendar_count);
     }
     if ($booking_widget_last_field !== '') {
         echo '<br/>' . htmlspecialchars_decode($booking_widget_last_field);
     }
     echo "</div>";
     echo $after_widget;
 }
コード例 #2
0
 function wpdev_booking_deactivate()
 {
     // set execution time to 15 minutes, its not worked if we have SAFE MODE ON at PHP
     if (function_exists('set_time_limit')) {
         if (!in_array(ini_get('safe_mode'), array('1', 'On'))) {
             set_time_limit(900);
         }
     }
     $is_delete_if_deactive = get_bk_option('booking_is_delete_if_deactive');
     // check
     if ($is_delete_if_deactive == 'On') {
         // Delete here tables and options, which are needed for using plugin
         delete_bk_option('booking_version_num');
         delete_bk_option('booking_skin');
         delete_bk_option('bookings_num_per_page');
         delete_bk_option('booking_sort_order');
         delete_bk_option('booking_sort_order_direction');
         delete_bk_option('booking_default_toolbar_tab');
         delete_bk_option('bookings_listing_default_view_mode');
         delete_bk_option('booking_view_days_num');
         delete_bk_option('booking_max_monthes_in_calendar');
         delete_bk_option('booking_admin_cal_count');
         delete_bk_option('booking_client_cal_count');
         delete_bk_option('booking_start_day_weeek');
         delete_bk_option('booking_title_after_reservation');
         delete_bk_option('booking_title_after_reservation_time');
         delete_bk_option('booking_type_of_thank_you_message', 'message');
         delete_bk_option('booking_thank_you_page_URL', site_url());
         delete_bk_option('booking_is_use_autofill_4_logged_user');
         delete_bk_option('booking_form_is_using_bs_css');
         delete_bk_option('booking_form_format_type');
         delete_bk_option('booking_form_field_active1');
         delete_bk_option('booking_form_field_required1');
         delete_bk_option('booking_form_field_label1');
         delete_bk_option('booking_form_field_active2');
         delete_bk_option('booking_form_field_required2');
         delete_bk_option('booking_form_field_label2');
         delete_bk_option('booking_form_field_active3');
         delete_bk_option('booking_form_field_required3');
         delete_bk_option('booking_form_field_label3');
         delete_bk_option('booking_form_field_active4');
         delete_bk_option('booking_form_field_required4');
         delete_bk_option('booking_form_field_label4');
         delete_bk_option('booking_form_field_active5');
         delete_bk_option('booking_form_field_required5');
         delete_bk_option('booking_form_field_label5');
         delete_bk_option('booking_date_format');
         delete_bk_option('booking_date_view_type');
         delete_bk_option('booking_is_delete_if_deactive');
         // check
         delete_bk_option('booking_wpdev_copyright_adminpanel');
         // check
         delete_bk_option('booking_is_show_powered_by_notice');
         // check
         delete_bk_option('booking_is_use_captcha');
         delete_bk_option('booking_is_show_legend');
         delete_bk_option('booking_legend_is_show_item_available');
         delete_bk_option('booking_legend_text_for_item_available');
         delete_bk_option('booking_legend_is_show_item_pending');
         delete_bk_option('booking_legend_text_for_item_pending');
         delete_bk_option('booking_legend_is_show_item_approved');
         delete_bk_option('booking_legend_text_for_item_approved');
         if (class_exists('wpdev_bk_biz_s')) {
             delete_bk_option('booking_legend_is_show_item_partially');
             delete_bk_option('booking_legend_text_for_item_partially');
         }
         delete_bk_option('booking_dif_colors_approval_pending');
         delete_bk_option('booking_is_use_hints_at_admin_panel');
         delete_bk_option('booking_is_not_load_bs_script_in_client');
         delete_bk_option('booking_is_not_load_bs_script_in_admin');
         delete_bk_option('booking_multiple_day_selections');
         delete_bk_option('booking_type_of_day_selections');
         delete_bk_option('booking_unavailable_days_num_from_today');
         delete_bk_option('booking_unavailable_day0');
         delete_bk_option('booking_unavailable_day1');
         delete_bk_option('booking_unavailable_day2');
         delete_bk_option('booking_unavailable_day3');
         delete_bk_option('booking_unavailable_day4');
         delete_bk_option('booking_unavailable_day5');
         delete_bk_option('booking_unavailable_day6');
         delete_bk_option('booking_user_role_booking');
         delete_bk_option('booking_user_role_addbooking');
         delete_bk_option('booking_user_role_resources');
         delete_bk_option('booking_user_role_settings');
         delete_bk_option('booking_email_reservation_adress');
         delete_bk_option('booking_email_reservation_from_adress');
         delete_bk_option('booking_email_reservation_subject');
         delete_bk_option('booking_email_reservation_content');
         delete_bk_option('booking_email_approval_adress');
         delete_bk_option('booking_email_approval_subject');
         delete_bk_option('booking_email_approval_content');
         delete_bk_option('booking_email_deny_adress');
         delete_bk_option('booking_email_deny_subject');
         delete_bk_option('booking_email_deny_content');
         delete_bk_option('booking_is_email_reservation_adress');
         delete_bk_option('booking_is_email_approval_adress');
         delete_bk_option('booking_is_email_deny_adress');
         delete_bk_option('booking_widget_title');
         delete_bk_option('booking_widget_show');
         delete_bk_option('booking_widget_type');
         delete_bk_option('booking_widget_calendar_count');
         delete_bk_option('booking_widget_last_field');
         global $wpdb;
         $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}booking");
         $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}bookingdates");
         // Delete all users booking windows states
         if (false === $wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE meta_key LIKE '%booking_%'")) {
             // All users data
             bk_error('Error during deleting user meta at DB', __FILE__, __LINE__);
             die;
         }
         // Delete or Drafts and Pending from demo sites
         if (wpdev_bk_is_this_demo()) {
             // Delete all temp posts at the demo sites: (post_status = pending || draft) && ( post_type = post ) && (post_author != 1)
             $postss = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ( post_status = 'pending' OR  post_status = 'draft' OR  post_status = 'auto-draft' OR  post_status = 'trash' OR  post_status = 'inherit' ) AND ( post_type='post' OR  post_type='revision') AND post_author != 1");
             foreach ($postss as $pp) {
                 wp_delete_post($pp->ID, true);
             }
         }
         make_bk_action('wpdev_booking_deactivation');
     }
 }
コード例 #3
0
function wpdev_bk_insert_new_booking()
{
    make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]);
    global $wpdb;
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Define init variables
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $dates = $_POST["dates"];
    $bktype = $_POST["bktype"];
    $formdata = $_POST["form"];
    $formdata = escape_any_xss($formdata);
    $is_send_emeils = 1;
    if (isset($_POST["is_send_emeils"])) {
        $is_send_emeils = $_POST["is_send_emeils"];
    }
    $my_booking_id = 0;
    $my_booking_hash = '';
    if (isset($_POST['my_booking_hash'])) {
        $my_booking_hash = $_POST['my_booking_hash'];
        if ($my_booking_hash != '') {
            $my_booking_id_type = false;
            $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash);
            if ($my_booking_id_type !== false) {
                $my_booking_id = $my_booking_id_type[0];
                $bktype = $my_booking_id_type[1];
            }
        }
    }
    if (strpos($dates, ' - ') !== FALSE) {
        $dates = explode(' - ', $dates);
        $dates = createDateRangeArray($dates[0], $dates[1]);
    }
    ///  CAPTCHA CHECKING   //////////////////////////////////////////////////////////////////////////////////////
    $the_answer_from_respondent = $_POST['captcha_user_input'];
    $prefix = $_POST['captcha_chalange'];
    if (!($the_answer_from_respondent == '' && $prefix == '')) {
        $captcha_instance = new wpdevReallySimpleCaptcha();
        $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
        if (!$correct) {
            $word = $captcha_instance->generate_random_word();
            $prefix = mt_rand();
            $captcha_instance->generate_image($prefix, $word);
            $filename = $prefix . '.png';
            $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename;
            $ref = substr($filename, 0, strrpos($filename, '.'));
            ?>
 <script type="text/javascript">
                        document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').value = '';
                        // chnage img
                        document.getElementById('captcha_img<?php 
            echo $bktype;
            ?>
').src = '<?php 
            echo $captcha_url;
            ?>
';
                        document.getElementById('wpdev_captcha_challenge_<?php 
            echo $bktype;
            ?>
').value = '<?php 
            echo $ref;
            ?>
';
                        document.getElementById('captcha_msg<?php 
            echo $bktype;
            ?>
').innerHTML =
                            '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Your entered code is incorrect', 'wpdev-booking');
            ?>
</div>';
                        document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML ='';
                        jQuery('#captcha_input<?php 
            echo $bktype;
            ?>
')
                        .fadeOut( 350 ).fadeIn( 300 )
                        .fadeOut( 350 ).fadeIn( 400 )
                        .animate( {opacity: 1}, 4000 )
                        ;  // mark red border
                        jQuery(".wpdev-help-message div")
                        .css( {'color' : 'red'} )
                        .animate( {opacity: 1}, 10000 )
                        .fadeOut( 2000 );   // hide message
                        document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').focus();    // make focus to elemnt

                    </script> <?php 
            die;
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    $booking_form_show = get_form_content($formdata, $bktype);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'";
    // Localize booking modification date
    $my_modification_date = 'NOW()';
    // Server value modification date
    if ($my_booking_id > 0) {
        // Edit exist booking
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) {
            ?>
 <script type="text/javascript">
                        document.getElementById('ajax_working').innerHTML =
                            '<div class="info_message ajax_message" id="ajax_message">\n\
                                            <div style="float:left;"><?php 
            echo __('Updating...', 'wpdev-booking');
            ?>
</div> \n\
                                            <div  style="float:left;width:80px;margin-top:-3px;">\n\
                                                   <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
                                            </div>\n\
                                        </div>';
                    </script> <?php 
        }
        $update_sql = "UPDATE " . $wpdb->prefix . "booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date=" . $my_modification_date . " WHERE bk.booking_id={$my_booking_id};";
        if (false === $wpdb->query($wpdb->prepare($update_sql))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking in BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Check if dates already aproved or no
        $slct_sql = "SELECT approved FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1";
        $slct_sql_results = $wpdb->get_results($wpdb->prepare($slct_sql));
        if (count($slct_sql_results) > 0) {
            $is_approved_dates = $slct_sql_results[0]->approved;
        }
        $delete_sql = "DELETE FROM " . $wpdb->prefix . "bookingdates WHERE booking_id IN ({$my_booking_id})";
        if (false === $wpdb->query($wpdb->prepare($delete_sql))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking for deleting dates in BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        $booking_id = (int) $my_booking_id;
        //Get ID  of reservation
    } else {
        // Add new booking
        $sql_insertion = "INSERT INTO " . $wpdb->prefix . "booking (form, booking_type, modification_date) VALUES ('{$formdata}',  {$bktype}, " . $my_modification_date . " )";
        //debuge($formdata);
        if (false === $wpdb->query($wpdb->prepare($sql_insertion))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Make insertion into BOOKINGDATES
        $booking_id = (int) $wpdb->insert_id;
        //Get ID  of reservation
        $is_approved_dates = '0';
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            $is_approved_dates = '1';
        }
    }
    $sdform = $_POST['form'];
    $my_dates = explode(",", $dates);
    $i = 0;
    foreach ($my_dates as $md) {
        $my_dates[$i] = trim($my_dates[$i]);
        $i++;
    }
    $start_end_time = get_times_from_bk_form($sdform, $my_dates, $bktype);
    $start_time = $start_end_time[0];
    $end_time = $start_end_time[1];
    $my_dates = $start_end_time[2];
    make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time));
    $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id);
    $i = 0;
    foreach ($my_dates as $md) {
        // Set in dates in such format: yyyy.mm.dd
        if ($md != '') {
            $md = explode('.', $md);
            $my_dates[$i] = $md[2] . '.' . $md[1] . '.' . $md[0];
        } else {
            unset($my_dates[$i]);
        }
        // If some dates is empty so remove it   // This situation can be if using several bk calendars and some calendars is not checked
        $i++;
    }
    sort($my_dates);
    // Sort dates
    $my_dates4emeil = '';
    $i = 0;
    $insert = '';
    $my_date_previos = '';
    foreach ($my_dates as $my_date) {
        $i++;
        // Loop through all dates
        if (strpos($my_date, '.') !== false) {
            if (get_bk_option('booking_recurrent_time') !== 'On') {
                $my_date = explode('.', $my_date);
                if ($i == 1) {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                } elseif ($i == count($my_dates)) {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                } else {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00');
                }
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            } else {
                if ($my_date_previos == $my_date) {
                    continue;
                }
                // escape for single day selections.
                $my_date_previos = $my_date;
                $my_date = explode('.', $my_date);
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            }
        }
    }
    $my_dates4emeil = substr($my_dates4emeil, 0, -1);
    $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil);
    $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
    $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
    /* // This add 1 more day for check out day
       $my_check_out_date = $my_dates4emeil_check_in_out[ count($my_dates4emeil_check_in_out)-1 ];
       $dt = trim($my_check_out_date);
       $dta = explode(' ',$dt);
       $dta = $dta[0];
       $dta = explode('-',$dta);
       $my_check_out_date = date('Y-m-d H:i:s' , mktime(0, 0, 0, $dta[1], ($dta[2]+1), $dta[0] ));
       $my_check_out_date = change_date_format($my_check_out_date);
       /**/
    if (!empty($insert)) {
        if (false === $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "bookingdates (booking_id, booking_date, approved) VALUES " . $insert))) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
    }
    if (function_exists('get_booking_title')) {
        $bk_title = get_booking_title($bktype);
    } else {
        $bk_title = '';
    }
    if ($my_booking_id > 0) {
        // For editing exist booking
        $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_modification_adress'));
        $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_modification_subject'));
        $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_modification_content'));
        $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
        $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
        if (function_exists('get_booking_title')) {
            $bk_title = get_booking_title($bktype);
        } else {
            $bk_title = '';
        }
        $booking_form_show = get_form_content($formdata, $bktype);
        $mail_body_to_send = str_replace('[bookingtype]', $bk_title, $mail_body);
        if (get_bk_option('booking_date_view_type') == 'short') {
            $my_dates_4_send = get_dates_short_format(get_dates_str($booking_id));
        } else {
            $my_dates_4_send = change_date_format(get_dates_str($booking_id));
        }
        $mail_body_to_send = str_replace('[dates]', $my_dates_4_send, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_in_date]', $my_check_in_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_out_date]', $my_check_out_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[id]', $booking_id, $mail_body_to_send);
        $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send);
        if (!isset($denyreason)) {
            $denyreason = '';
        }
        $mail_body_to_send = str_replace('[denyreason]', $denyreason, $mail_body_to_send);
        $mail_body_to_send = str_replace('[name]', $booking_form_show['name'], $mail_body_to_send);
        $mail_body_to_send = str_replace('[cost]', $my_cost, $mail_body_to_send);
        if (isset($booking_form_show['secondname'])) {
            $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send);
        }
        $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body_to_send);
        $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $booking_id);
        $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
        if (isset($booking_form_show['secondname'])) {
            $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
        }
        $mail_recipient = $booking_form_show['email'];
        $mail_headers = "From: {$mail_sender}\n";
        $mail_headers .= "Content-Type: text/html\n";
        if (get_bk_option('booking_is_email_modification_adress') != 'Off') {
            // Send to the Visitor
            if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                if ($is_send_emeils != 0) {
                    @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers);
                }
            }
            // Send to the Admin also
            $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
            $is_email_modification_send_copy_to_admin = get_bk_option('booking_is_email_modification_send_copy_to_admin');
            if ($is_email_modification_send_copy_to_admin == 'On') {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                    if ($is_send_emeils != 0) {
                        @wp_mail($mail_recipient, $mail_subject, $mail_body_to_send, $mail_headers);
                    }
                }
            }
        }
        //debuge($_SERVER);
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
        }
        ?>
 <script type="text/javascript">
                <?php 
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            ?>
                            //document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div class=\"submiting_content\" ><?php 
            echo get_bk_option('booking_title_after_reservation');
            ?>
</div>';
                            //jQuery('.submiting_content').fadeOut(<?php 
            echo get_bk_option('booking_title_after_reservation_time');
            ?>
);
                            setReservedSelectedDates('<?php 
            echo $bktype;
            ?>
');
                    <?php 
        } else {
            ?>
                            document.getElementById('ajax_message').innerHTML = '<?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
';
                            jQuery('#ajax_message').fadeOut(1000);
                            document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
</div>';
                            location.href='admin.php?page=<?php 
            echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME;
            ?>
wpdev-booking&booking_type=<?php 
            echo $bktype;
            ?>
&booking_id_selection=<?php 
            echo $my_booking_id;
            ?>
';
                    <?php 
        }
        ?>
                    </script> <?php 
    } else {
        if (count($my_dates) > 0) {
            //// For inserting NEW booking
            // Sending mail ///////////////////////////////////////////////////////
            $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_reservation_from_adress'));
            //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
            $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
            //'"Booking receipent" <' .get_option('admin_email').'>';
            $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_reservation_subject'));
            $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_reservation_content'));
            $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
            $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
            $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body);
            if (get_bk_option('booking_date_view_type') == 'short') {
                $my_dates_4_send = get_dates_short_format($my_dates4emeil);
            } else {
                $my_dates_4_send = change_date_format($my_dates4emeil);
            }
            $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body);
            $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body);
            $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body);
            $mail_body = str_replace('[id]', $booking_id, $mail_body);
            $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body);
            $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body);
            $mail_body = str_replace('[cost]', $my_cost, $mail_body);
            $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body);
            $mail_body = str_replace('[moderatelink]', htmlspecialchars_decode('<a href="' . site_url() . '/wp-admin/admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking&booking_type=' . $bktype . '&moderate_id=' . $booking_id . '">' . __('here', 'wpdev-booking') . '</a>'), $mail_body);
            $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id);
            if (isset($booking_form_show['secondname'])) {
                $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body);
            }
            $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
            if (isset($booking_form_show['secondname'])) {
                $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
            }
            $mail_headers = "From: {$mail_sender}\n";
            $mail_headers .= "Content-Type: text/html\n";
            if (strpos($mail_recipient, '[visitoremeil]') !== false) {
                $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient);
            }
            if (get_bk_option('booking_is_email_reservation_adress') != 'Off') {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) {
                    if ($is_send_emeils != 0) {
                        @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers);
                    }
                }
            }
            /////////////////////////////////////////////////////////////////////////
            if (get_bk_option('booking_is_email_newbookingbyperson_adress') == 'On') {
                $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_adress'));
                //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
                $mail_recipient = $booking_form_show['email'];
                $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_subject'));
                $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_newbookingbyperson_content'));
                $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
                $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
                $mail_body = str_replace('[bookingtype]', $bk_title, $mail_body);
                if (get_bk_option('booking_date_view_type') == 'short') {
                    $my_dates_4_send = get_dates_short_format($my_dates4emeil);
                } else {
                    $my_dates_4_send = change_date_format($my_dates4emeil);
                }
                $mail_body = str_replace('[dates]', $my_dates_4_send, $mail_body);
                $mail_body = str_replace('[check_in_date]', $my_check_in_date, $mail_body);
                $mail_body = str_replace('[check_out_date]', $my_check_out_date, $mail_body);
                $mail_body = str_replace('[id]', $booking_id, $mail_body);
                $mail_body = str_replace('[content]', $booking_form_show['content'], $mail_body);
                $mail_body = str_replace('[name]', $booking_form_show['name'], $mail_body);
                $mail_body = str_replace('[cost]', $my_cost, $mail_body);
                $mail_body = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body);
                $mail_body = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body, $booking_id);
                if (isset($booking_form_show['secondname'])) {
                    $mail_body = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body);
                }
                $mail_subject = str_replace('[name]', $booking_form_show['name'], $mail_subject);
                if (isset($booking_form_show['secondname'])) {
                    $mail_subject = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject);
                }
                $mail_headers = "From: {$mail_sender}\n";
                $mail_headers .= "Content-Type: text/html\n";
                if (strpos($mail_recipient, '[visitoremeil]') !== false) {
                    $mail_recipient = str_replace('[visitoremeil]', $booking_form_show['email'], $mail_recipient);
                }
                if (strpos($mail_recipient, '@blank.com') === false) {
                    if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body, '*****@*****.**') === false) {
                        if ($is_send_emeils != 0) {
                            @wp_mail($mail_recipient, $mail_subject, $mail_body, $mail_headers);
                        }
                    }
                }
            }
        }
        do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
        ?>
 <script type="text/javascript"> setReservedSelectedDates('<?php 
        echo $bktype;
        ?>
'); </script>  <?php 
    }
    // ReUpdate booking resource TYPE if its needed here
    if (!empty($dates)) {
        // check to have dates not empty
        make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $sdform);
    }
}
コード例 #4
0
ファイル: wpdev-booking-ajax.php プロジェクト: dev-lav/htdocs
function wpdev_bk_insert_new_booking()
{
    global $wpdb;
    make_bk_action('check_multiuser_params_for_client_side', $_POST["bktype"]);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Define init variables
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $dates = $_POST["dates"];
    $bktype = intval($_POST["bktype"]);
    if ($bktype == 0) {
        // Error
        ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
        echo $bktype;
        ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
        bk_error('Error od saving data into DB. Unknown booking resource.', __FILE__, __LINE__);
        ?>
</div>'; </script> <?php 
        die;
    }
    $formdata = $_POST["form"];
    $formdata = escape_any_xss($formdata);
    $is_send_emeils = 1;
    if (isset($_POST["is_send_emeils"])) {
        $is_send_emeils = $_POST["is_send_emeils"];
    }
    $my_booking_id = 0;
    $my_booking_hash = '';
    if (function_exists('get_booking_title')) {
        $bk_title = get_booking_title($bktype);
    } else {
        $bk_title = '';
    }
    if (isset($_POST['my_booking_hash'])) {
        $my_booking_hash = $_POST['my_booking_hash'];
        if ($my_booking_hash != '') {
            $my_booking_id_type = false;
            $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id', false, $my_booking_hash);
            if ($my_booking_id_type !== false) {
                $my_booking_id = $my_booking_id_type[0];
                $bktype = $my_booking_id_type[1];
            }
        }
    }
    if (strpos($dates, ' - ') !== FALSE) {
        $dates = explode(' - ', $dates);
        $dates = createDateRangeArray($dates[0], $dates[1]);
    }
    //debuge($_POST);
    ///  CAPTCHA CHECKING   //////////////////////////////////////////////////////////////////////////////////////
    $the_answer_from_respondent = $_POST['captcha_user_input'];
    $prefix = $_POST['captcha_chalange'];
    if (!($the_answer_from_respondent == '' && $prefix == '')) {
        $captcha_instance = new wpdevReallySimpleCaptcha();
        $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
        if (!$correct) {
            $word = $captcha_instance->generate_random_word();
            $prefix = mt_rand();
            $captcha_instance->generate_image($prefix, $word);
            $filename = $prefix . '.png';
            $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' . $filename;
            $ref = substr($filename, 0, strrpos($filename, '.'));
            ?>
 <script type="text/javascript">
                document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').value = '';
                // chnage img
                document.getElementById('captcha_img<?php 
            echo $bktype;
            ?>
').src = '<?php 
            echo $captcha_url;
            ?>
';
                document.getElementById('wpdev_captcha_challenge_<?php 
            echo $bktype;
            ?>
').value = '<?php 
            echo $ref;
            ?>
';
                document.getElementById('captcha_msg<?php 
            echo $bktype;
            ?>
').innerHTML =
                    '<span class="alert" style="padding: 5px 5px 4px;vertical-align: middle;text-align:center;margin:5px;"><?php 
            echo __('The code you entered is incorrect', 'wpdev-booking');
            ?>
</span>';
                document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML ='';
                jQuery('#captcha_input<?php 
            echo $bktype;
            ?>
')
                .fadeOut( 350 ).fadeIn( 300 )
                .fadeOut( 350 ).fadeIn( 400 )
                .animate( {opacity: 1}, 4000 )
                ;  // mark red border
                jQuery("span.wpdev-help-message span.alert")
                .fadeIn( 1 )
                //.css( {'color' : 'red'} )
                .animate( {opacity: 1}, 10000 )
                .fadeOut( 2000 );   // hide message
                document.getElementById('captcha_input<?php 
            echo $bktype;
            ?>
').focus();    // make focus to elemnt
                jQuery('#booking_form_div<?php 
            echo $bktype;
            ?>
 input[type=button]').prop("disabled", false);
            </script> <?php 
            die;
        }
    }
    //////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'";
    // Localize booking modification date
    //$my_modification_date = 'NOW()';                                  // Server value modification date
    if ($my_booking_id > 0) {
        // Edit exist booking
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') !== false) {
            ?>
 <script type="text/javascript">
                document.getElementById('ajax_working').innerHTML =
                    '<div class="updated ajax_message" id="ajax_message">\n\
                        <div style="float:left;"><?php 
            echo __('Updating...', 'wpdev-booking');
            ?>
</div> \n\
                        <div class="wpbc_spin_loader">\n\
                               <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
                        </div>\n\
                    </div>';
            </script> <?php 
        }
        $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype} , bk.modification_date={$my_modification_date} WHERE bk.booking_id={$my_booking_id};";
        if (false === $wpdb->query($update_sql)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking in DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Check if dates already aproved or no
        $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id}) LIMIT 0,1";
        $slct_sql_results = $wpdb->get_results($slct_sql);
        if (count($slct_sql_results) > 0) {
            $is_approved_dates = $slct_sql_results[0]->approved;
        }
        $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$my_booking_id})";
        if (false === $wpdb->query($delete_sql)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking for deleting dates in DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        $booking_id = (int) $my_booking_id;
        //Get ID  of reservation
    } else {
        // Add new booking
        $sql_insertion = "INSERT INTO {$wpdb->prefix}booking (form, booking_type, modification_date) VALUES ('{$formdata}',  {$bktype}, {$my_modification_date} )";
        if (false === $wpdb->query($sql_insertion)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into DB', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
        // Make insertion into BOOKINGDATES
        $booking_id = (int) $wpdb->insert_id;
        //Get ID  of reservation
        $is_approved_dates = '0';
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            $is_approved_dates = '1';
        }
    }
    $my_dates = explode(",", $dates);
    $i = 0;
    foreach ($my_dates as $md) {
        $my_dates[$i] = trim($my_dates[$i]);
        $i++;
    }
    $start_end_time = get_times_from_bk_form($formdata, $my_dates, $bktype);
    $start_time = $start_end_time[0];
    $end_time = $start_end_time[1];
    $my_dates = $start_end_time[2];
    make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time));
    $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id);
    $i = 0;
    foreach ($my_dates as $md) {
        // Set in dates in such format: yyyy.mm.dd
        if ($md != '') {
            $md = explode('.', $md);
            $my_dates[$i] = $md[2] . '.' . (intval($md[1]) < 10 ? '0' . intval($md[1]) : $md[1]) . '.' . (intval($md[0]) < 10 ? '0' . intval($md[0]) : $md[0]);
        } else {
            unset($my_dates[$i]);
        }
        // If some dates is empty so remove it   // This situation can be if using several bk calendars and some calendars is not checked
        $i++;
    }
    //debuge($my_dates);
    sort($my_dates);
    // Sort dates
    //debuge($my_dates);
    $my_dates4emeil = '';
    $i = 0;
    $insert = '';
    $my_date_previos = '';
    foreach ($my_dates as $my_date) {
        $i++;
        // Loop through all dates
        if (strpos($my_date, '.') !== false) {
            if (get_bk_option('booking_recurrent_time') !== 'On') {
                $my_date = explode('.', $my_date);
                if ($i == 1) {
                    if (!isset($start_time[0]) || empty($start_time[0])) {
                        $start_time[0] = '00';
                    }
                    if (!isset($start_time[1]) || empty($start_time[1])) {
                        $start_time[1] = '00';
                    }
                    if ($start_time[0] == '00' && $start_time[1] == '00') {
                        $start_time[2] = '00';
                    }
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                } elseif ($i == count($my_dates)) {
                    if (!isset($end_time[0]) || empty($end_time[0])) {
                        $end_time[0] = '00';
                    }
                    if (!isset($end_time[1]) || empty($end_time[1])) {
                        $end_time[1] = '00';
                    }
                    if ($end_time[0] == '00' && $end_time[1] == '00') {
                        $end_time[2] = '00';
                    }
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                } else {
                    $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00');
                }
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            } else {
                if ($my_date_previos == $my_date) {
                    continue;
                }
                // escape for single day selections.
                $my_date_previos = $my_date;
                $my_date = explode('.', $my_date);
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $start_time[0], $start_time[1], $start_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
                $date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], $end_time[0], $end_time[1], $end_time[2]);
                $my_dates4emeil .= $date . ',';
                if (!empty($insert)) {
                    $insert .= ', ';
                }
                $insert .= "('{$booking_id}', '{$date}', '{$is_approved_dates}' )";
            }
        }
    }
    $my_dates4emeil = substr($my_dates4emeil, 0, -1);
    $my_dates4emeil_check_in_out = explode(',', $my_dates4emeil);
    $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
    $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
    // Save the sort date
    $sql_sort_date = "UPDATE {$wpdb->prefix}booking SET sort_date = '" . $my_dates4emeil_check_in_out[0] . "' WHERE booking_id  = " . $booking_id . " ";
    $wpdb->query($sql_sort_date);
    if (!empty($insert)) {
        if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert)) {
            ?>
 <script type="text/javascript"> document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__);
            ?>
</div>'; </script> <?php 
            die;
        }
    }
    if ($my_booking_id > 0) {
        // For editing exist booking
        if ($is_send_emeils != 0) {
            sendModificationEmails($booking_id, $bktype, $formdata);
        }
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
        }
        ?>
 <script type="text/javascript">
        <?php 
        if (strpos($_SERVER['HTTP_REFERER'], 'wp-admin/admin.php?') === false) {
            ?>
                    setReservedSelectedDates('<?php 
            echo $bktype;
            ?>
');
            <?php 
        } else {
            ?>
                    document.getElementById('ajax_message').innerHTML = '<?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
';
                    jQuery('#ajax_message').fadeOut(1000);
                    document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            echo __('Updated successfully', 'wpdev-booking');
            ?>
</div>';
                    if ( jQuery('#wpdev_http_referer').length > 0 ) {
                           location.href=jQuery('#wpdev_http_referer').val();
                    } else location.href='admin.php?page=<?php 
            echo WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME;
            ?>
wpdev-booking&view_mode=vm_listing&tab=actions&wh_booking_id=<?php 
            echo $my_booking_id;
            ?>
';
            <?php 
        }
        ?>
            </script> <?php 
    } else {
        // For inserting NEW booking
        if (count($my_dates) > 0) {
            if ($is_send_emeils != 0) {
                sendNewBookingEmails($booking_id, $bktype, $formdata);
            }
        }
        do_action('wpdev_new_booking', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
        /*
                // Start Mail Chimp Customization
                $booking_form_show = get_form_content ($formdata , $bktype );
                if ( ( isset ($booking_form_show['subscribe_me'] )) && ( $booking_form_show['subscribe_me'] == 'yes') ) {
        
                    if (file_exists(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php')) { // Include MailChimp class (You can download it from  here https://github.com/drewm/mailchimp-api/ )
                        require_once(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php' ); 
        
                        $MailChimp = new MailChimp('key-my');                          // You are need to specify here YOUR KEY !!!!
        
                        $result = $MailChimp->call('lists/subscribe', array(
                                        'id'                => 'id' . $booking_id ,          
                                        'email'             => array('email'=>$booking_form_show['email']),
                                        'merge_vars'        => array('FNAME'=>$booking_form_show['name'], 'LNAME'=>$booking_form_show['secondname']),
                                        'double_optin'      => false,
                                        'update_existing'   => true,
                                        'replace_interests' => false,
                                        'send_welcome'      => false,
                                    ));
                        // print_r($result);
                    }
                } // End Mail Chimp Customization
                /**/
        $auto_approve_new_bookings_is_active = get_bk_option('booking_auto_approve_new_bookings_is_active');
        if (trim($auto_approve_new_bookings_is_active) == 'On') {
            sendApproveEmails($booking_id, 1);
        }
        ?>
 <script type="text/javascript"> setReservedSelectedDates('<?php 
        echo $bktype;
        ?>
'); </script>  <?php 
    }
    // ReUpdate booking resource TYPE if its needed here
    if (!empty($dates)) {
        // check to have dates not empty
        make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, str_replace('|', ',', $dates), array($start_time, $end_time), $formdata);
    }
}
コード例 #5
0
ファイル: wpdev-bk-lib.php プロジェクト: RetinaInc/booking-2
function booking_listing_table($bookings, $booking_types)
{
    //debuge($_REQUEST);
    $user = wp_get_current_user();
    $user_bk_id = $user->ID;
    $bk_url_listing = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking';
    $bk_url_add = $bk_url_listing . '-reservation';
    $bk_url_resources = $bk_url_listing . '-resources';
    $bk_url_settings = $bk_url_listing . '-option';
    $bk_admin_url = get_params_in_url(array('page_num', 'wh_booking_type'));
    $booking_date_view_type = get_bk_option('booking_date_view_type');
    if ($booking_date_view_type == 'short') {
        $wide_days_class = ' hidden_items ';
        $short_days_class = '';
    } else {
        $wide_days_class = '';
        $short_days_class = ' hidden_items ';
    }
    $version = get_bk_version();
    if ($version == 'free') {
        $is_free = true;
    } else {
        $is_free = false;
    }
    ?>
         <div id="listing_visible_bookings">
          <?php 
    if (count($bookings) > 0) {
        ?>
          <div class="row-fluid booking-listing-header">
              <div class="booking-listing-collumn span1 wpbc_column_1" style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" onclick="javascript:setCheckBoxInTable(this.checked, 'booking_list_item_checkbox');">&nbsp;&nbsp;&nbsp;<?php 
        echo 'ID';
        ?>
</div>
              <div class="booking-listing-collumn span<?php 
        echo $is_free ? '1' : '2';
        ?>
 wpbc_column_2"><?php 
        _e('Labels', 'wpdev-booking');
        if (!$is_free) {
            echo ' / ';
            _e('Actions', 'wpdev-booking');
        }
        ?>
</div>
              <div class="booking-listing-collumn span<?php 
        echo $is_free ? '5' : '6';
        ?>
 wpbc_column_4"><?php 
        _e('Booking Data', 'wpdev-booking');
        ?>
</div>
              <div class="booking-listing-collumn span3 wpbc_column_5"><?php 
        _e('Booking Dates', 'wpdev-booking');
        ?>
&nbsp;&nbsp;&nbsp;
                  <a href="javascript:void(0)" id="booking_dates_full" onclick="javascript:
                            jQuery('#booking_dates_full').hide();
                            jQuery('#booking_dates_small').show();
                            jQuery('.booking_dates_small').hide();
                            jQuery('.booking_dates_full').show();" data-original-title="<?php 
        _e('Show ALL dates of booking', 'wpdev-booking');
        ?>
"  rel="tooltip" class="tooltip_top <?php 
        echo $short_days_class;
        ?>
 "><i class="icon-resize-full" style=" margin-top: 2px;"></i></a>
                  <a href="javascript:void(0)" id="booking_dates_small" onclick="javascript:
                            jQuery('#booking_dates_small').hide();
                            jQuery('#booking_dates_full').show();
                            jQuery('.booking_dates_small').show();
                            jQuery('.booking_dates_full').hide();" data-original-title="<?php 
        _e('Show only check in/out dates', 'wpdev-booking');
        ?>
"  rel="tooltip" class="tooltip_top <?php 
        echo $wide_days_class;
        ?>
 " ><i class="icon-resize-small" style=" margin-top: 2px;"></i></a>
              </div>
              <?php 
        if ($is_free) {
            ?>
              <div class="booking-listing-collumn span2 wpbc_column_5"><?php 
            _e('Actions', 'wpdev-booking');
            ?>
</div>
              <?php 
        }
        ?>
          </div>
          <?php 
    } else {
        echo '<center><h3>' . __('Nothing found!', 'wpdev-booking') . '</h3></center>';
    }
    ?>
        <?php 
    // P
    $print_data = apply_bk_filter('get_bklist_print_header', array(array()));
    $is_alternative_color = true;
    $id_of_new_bookings = array();
    foreach ($bookings as $bk) {
        $is_selected_color = 0;
        //rand(0,1);
        $is_alternative_color = !$is_alternative_color;
        $booking_id = $bk->booking_id;
        // 100
        $is_new = isset($bk->is_new) ? $bk->is_new : '0';
        // 1
        $bk_modification_date = isset($bk->modification_date) ? $bk->modification_date : '';
        // 2012-02-29 16:01:58
        $bk_form = $bk->form;
        // select-one^rangetime5^10:00 - 12:00~text^name5^Jonny~text^secondname5^Smith~email^ ....
        $bk_form_show = $bk->form_show;
        // First Name:Jonny   Last Name:Smith   Email:email@server.com  Country:GB  ....
        $bk_form_data = $bk->form_data;
        // Array ([name] => Jonny... [_all_] => Array ( [rangetime5] => 10:00 - 12:00 [name5] => Jonny ... ) .... )
        $bk_dates = $bk->dates;
        // Array ( [0] => stdClass Object ( [booking_id] => 8 [booking_date] => 2012-04-16 10:00:01 [approved] => 0 [type_id] => )
        $bk_dates_short = $bk->dates_short;
        // Array ( [0] => 2012-04-16 10:00:01 [1] => - [2] => 2012-04-20 12:00:02 [3] => , [4] => 2012-04-16 10:00:01 ....
        //P
        $bk_booking_type = isset($bk->booking_type) ? $bk->booking_type : '1';
        // 3
        if (!class_exists('wpdev_bk_personal')) {
            $bk_booking_type_name = '<span class="label_resource_not_exist">' . __('Default', 'wpdev-booking') . '</span>';
        } else {
            if (isset($booking_types[$bk_booking_type])) {
                $bk_booking_type_name = $booking_types[$bk_booking_type]->title;
                // Default
                if (strlen($bk_booking_type_name) > 19) {
                    //$bk_booking_type_name = substr($bk_booking_type_name, 0,  13) . ' ... ' . substr($bk_booking_type_name, -3 );
                    $bk_booking_type_name = '<span style="cursor:pointer;" rel="tooltip" class="tooltip_top"  data-original-title="' . $bk_booking_type_name . '">' . substr($bk_booking_type_name, 0, 13) . ' ... ' . substr($bk_booking_type_name, -3) . '</span>';
                }
            } else {
                $bk_booking_type_name = '<span class="label_resource_not_exist">' . __('Resource not exist', 'wpdev-booking') . '</span>';
            }
        }
        $bk_hash = isset($bk->hash) ? $bk->hash : '';
        // 99c9c2bd4fd0207e4376bdbf5ee473bc
        $bk_remark = isset($bk->remark) ? $bk->remark : '';
        //
        //BS
        $bk_cost = isset($bk->cost) ? $bk->cost : '';
        // 150.00
        $bk_pay_status = isset($bk->pay_status) ? $bk->pay_status : '';
        // 30800
        $bk_pay_request = isset($bk->pay_request) ? $bk->pay_request : '';
        // 0
        $bk_status = isset($bk->status) ? $bk->status : '';
        //BL
        $bk_dates_short_id = array();
        if (count($bk->dates) > 0) {
            $bk_dates_short_id = isset($bk->dates_short_id) ? $bk->dates_short_id : array();
        }
        // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 )
        $is_approved = 0;
        if (count($bk->dates) > 0) {
            $is_approved = $bk->dates[0]->approved;
        }
        //BS
        $is_paid = 0;
        $payment_status_titles_current = '';
        if (class_exists('wpdev_bk_biz_s')) {
            if (is_payment_status_ok(trim($bk_pay_status))) {
                $is_paid = 1;
            }
            $payment_status_titles = get_payment_status_titles();
            $payment_status_titles_current = array_search($bk_pay_status, $payment_status_titles);
            if ($payment_status_titles_current === FALSE) {
                $payment_status_titles_current = $bk_pay_status;
            }
        }
        if ($is_new == 1) {
            $id_of_new_bookings[] = $booking_id;
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Get SHORT Dates showing data ////////////////////////////////////////////////////////////////////////////////////////////////////
        //$short_dates_content = wpdevbk_get_str_from_dates_short($bk_dates_short, $is_approved , $bk_dates_short_id , $booking_types );
        $short_dates_content = '';
        $dcnt = 0;
        foreach ($bk_dates_short as $dt) {
            if ($dt == '-') {
                $short_dates_content .= '<span class="date_tire"> - </span>';
            } elseif ($dt == ',') {
                $short_dates_content .= '<span class="date_tire">, </span>';
            } else {
                $short_dates_content .= '<a href="javascript:void(0)" class="field-booking-date ';
                if ($is_approved) {
                    $short_dates_content .= ' approved';
                }
                $short_dates_content .= '">';
                $bk_date = wpdevbk_get_date_in_correct_format($dt);
                $short_dates_content .= $bk_date[0];
                $short_dates_content .= '<sup class="field-booking-time">' . $bk_date[1] . '</sup>';
                // BL
                if (class_exists('wpdev_bk_biz_l')) {
                    if (!empty($bk_dates_short_id[$dcnt])) {
                        $bk_booking_type_name_date = $booking_types[$bk_dates_short_id[$dcnt]]->title;
                        // Default
                        if (strlen($bk_booking_type_name_date) > 19) {
                            $bk_booking_type_name_date = substr($bk_booking_type_name_date, 0, 13) . '...' . substr($bk_booking_type_name_date, -3);
                        }
                        $short_dates_content .= '<sup class="field-booking-time date_from_dif_type"> ' . $bk_booking_type_name_date . '</sup>';
                    }
                }
                $short_dates_content .= '</a>';
            }
            $dcnt++;
        }
        // Get WIDE Dates showing data /////////////////////////////////////////////////////////////////////////////////////////////////////
        $wide_dates_content = '';
        $dates_count = count($bk_dates);
        $dcnt = 0;
        foreach ($bk_dates as $dt) {
            $dcnt++;
            $wide_dates_content .= '<a href="javascript:void(0)" class="field-booking-date ';
            if ($is_approved) {
                $wide_dates_content .= ' approved';
            }
            $wide_dates_content .= ' ">';
            $bk_date = wpdevbk_get_date_in_correct_format($dt->booking_date);
            $wide_dates_content .= $bk_date[0];
            $wide_dates_content .= '<sup class="field-booking-time">' . $bk_date[1] . '</sup>';
            // BL
            if (class_exists('wpdev_bk_biz_l')) {
                if ($dt->type_id != '' && isset($booking_types[$dt->type_id])) {
                    $bk_booking_type_name_date = $booking_types[$dt->type_id]->title;
                    // Default
                    if (strlen($bk_booking_type_name_date) > 19) {
                        $bk_booking_type_name_date = substr($bk_booking_type_name_date, 0, 13) . '...' . substr($bk_booking_type_name_date, -3);
                    }
                    $wide_dates_content .= '<sup class="field-booking-time date_from_dif_type"> ' . $bk_booking_type_name_date . '</sup>';
                }
            }
            $wide_dates_content .= '</a>';
            if ($dcnt < $dates_count) {
                $wide_dates_content .= '<span class="date_tire">, </span>';
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // BS
        $pay_print_status = '';
        if (class_exists('wpdev_bk_biz_s')) {
            if ($is_paid) {
                $pay_print_status = __('Paid OK', 'wpdev-booking');
                if ($payment_status_titles_current == 'Completed') {
                    $pay_print_status = $payment_status_titles_current;
                }
            } else {
                if (is_numeric($bk_pay_status) || $bk_pay_status == '') {
                    $pay_print_status = __('Unknown', 'wpdev-booking');
                } else {
                    $pay_print_status = $payment_status_titles_current;
                }
            }
        }
        ///// Print data  //////////////////////////////////////////////////////////////////////////////
        $print_data[] = apply_bk_filter('get_bklist_print_row', array(), $booking_id, $is_approved, $bk_form_show, $bk_booking_type_name, $is_paid, $pay_print_status, $booking_date_view_type == 'short' ? '<div class="booking_dates_small">' . $short_dates_content . '</div>' : '<div class="booking_dates_full">' . $wide_dates_content . '</div>', $bk_cost);
        //////////////////////////////////////////////////////////////////////////////////////////////
        ?>
          <div id="booking_mark_<?php 
        echo $booking_id;
        ?>
"  class="<?php 
        if ($is_new != '1') {
            echo ' hidden_items ';
        }
        ?>
 new-label clearfix-height">
              <a href="javascript:void(0)"  class="tooltip_bottom approve_bk_link  <?php 
        //if ($is_approved) echo ' hidden_items ';
        ?>
 "
                       onclick="javascript:mark_read_booking( '<?php 
        echo $booking_id;
        ?>
' ,
                                                      0, <?php 
        echo $user_bk_id;
        ?>
, '<?php 
        echo getBookingLocale();
        ?>
' );"
                       data-original-title="<?php 
        _e('Mark', 'wpdev-booking');
        echo ' ';
        _e('Unread', 'wpdev-booking');
        ?>
"  rel="tooltip" >
                        <img src="<?php 
        echo WPDEV_BK_PLUGIN_URL;
        ?>
/img/label_new_blue.png" style="width:24px; height:24px;"></a>
          </div>
          <div id="booking_row_<?php 
        echo $booking_id;
        ?>
"  class="row-fluid booking-listing-row clearfix-height<?php 
        if ($is_alternative_color) {
            echo ' row_alternative_color ';
        }
        if ($is_selected_color) {
            echo ' row_selected_color ';
        }
        //if ($is_new) echo ' row_unread_color ';
        $date_format = get_bk_option('booking_date_format');
        $time_format = get_bk_option('booking_time_format');
        if (empty($date_format)) {
            $date_format = "m / d / Y, D";
        }
        if (empty($time_format)) {
            $time_format = 'h:i a';
        }
        $cr_date = date_i18n($date_format, mysql2date('U', $bk_modification_date));
        $cr_time = date_i18n($time_format, mysql2date('U', $bk_modification_date));
        ?>
" >

              <div class="wpbc_column_1 booking-listing-collumn bktextcenter span1">
                    <input type="checkbox" class="booking_list_item_checkbox" 
                           onclick="javascript: if (jQuery(this).attr('checked') !== undefined ) { jQuery(this).parent().parent().addClass('row_selected_color'); } else {jQuery(this).parent().parent().removeClass('row_selected_color');}"
                           <?php 
        if ($is_selected_color) {
            echo ' checked="CHECKED" ';
        }
        ?>
                           id="booking_id_selected_<?php 
        echo $booking_id;
        ?>
"  name="booking_appr_<?php 
        $booking_id;
        ?>
"
                           /><span class="wpbc_mobile_legend clear" style="margin:0 -5px 0 25px"><?php 
        _e('ID', 'wpdev-booking');
        ?>
: </span><span class="field-id"><?php 
        echo $booking_id;
        ?>
</span>                  
              </div>

              <div class="wpbc_column_2 booking-listing-collumn bktextleft booking-labels span<?php 
        echo $is_free ? '1' : '2';
        ?>
 ">
                  <?php 
        make_bk_action('wpdev_bk_listing_show_resource_label', $bk_booking_type_name, $bk_admin_url . '&wh_booking_type=' . $bk_booking_type);
        ?>
                  <?php 
        make_bk_action('wpdev_bk_listing_show_payment_label', $is_paid, $pay_print_status, $payment_status_titles_current);
        ?>
                  <span class="label label-pending <?php 
        if ($is_approved) {
            echo ' hidden_items ';
        }
        ?>
 "><?php 
        _e('Pending', 'wpdev-booking');
        ?>
</span>
                  <span class="label label-approved <?php 
        if (!$is_approved) {
            echo ' hidden_items ';
        }
        ?>
"><?php 
        _e('Approved', 'wpdev-booking');
        ?>
</span>
              </div>

              <div class="wpbc_column_3 booking-listing-collumn bktextjustify span<?php 
        echo $is_free ? '5' : '6';
        ?>
 ">
                    <div style="text-align:left"><?php 
        echo $bk_form_show;
        ?>
</div>
              </div>

              <div class="wpbc_column_4 booking-listing-collumn bktextleft booking-dates span3">

                <div class="booking_dates_small <?php 
        echo $short_days_class;
        ?>
"><?php 
        echo $short_dates_content;
        ?>
</div>
                <div class="booking_dates_full  <?php 
        echo $wide_days_class;
        ?>
" ><?php 
        echo $wide_dates_content;
        ?>
</div>

              </div>

              <?php 
        $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1';
        ?>

              <div class="wpbc_column_5 booking-listing-collumn booking-actions<?php 
        echo $is_free ? '0 span2 bktextcenter' : ' bktextleft ';
        ?>
 ">

                <?php 
        $is_can = true;
        //current_user_can( 'edit_posts' );
        if ($is_can) {
            ?>
                  
                  
                  <?php 
            make_bk_action('wpdev_bk_listing_show_cost_btn', $booking_id, $bk_cost);
            ?>
                  
                  <div class="actions-fields-group">
                    <?php 
            make_bk_action('wpdev_bk_listing_show_edit_btn', $booking_id, $edit_booking_url, $bk_remark, $bk_booking_type);
            ?>
<a    href="javascript:void(0)"  class="tooltip_top approve_bk_link button-secondary button  <?php 
            if ($is_approved) {
                echo ' hidden_items ';
            }
            ?>
 "
                            onclick="javascript:approve_unapprove_booking(<?php 
            echo $booking_id;
            ?>
,1, <?php 
            echo $user_bk_id;
            ?>
, '<?php 
            echo getBookingLocale();
            ?>
' , 1  );"
                            data-original-title="<?php 
            _e('Approve', 'wpdev-booking');
            ?>
"  rel="tooltip" 
                       ><i class="icon-ok-circle"></i><?php 
            /** ?><img src="<?php echo WPDEV_BK_PLUGIN_URL; ?>/img/accept-24x24.gif" style="width:14px; height:14px;"><?php /**/
            ?>
</a><a                     
                            href="javascript:void(0)"  class="tooltip_top pending_bk_link button-secondary button  <?php 
            if (!$is_approved) {
                echo ' hidden_items ';
            }
            ?>
 "
                            onclick="javascript:if ( bk_are_you_sure('<?php 
            echo esc_js(__('Do you really want to set booking as pending ?', 'wpdev-booking'));
            ?>
') ) approve_unapprove_booking(<?php 
            echo $booking_id;
            ?>
,0, <?php 
            echo $user_bk_id;
            ?>
, '<?php 
            echo getBookingLocale();
            ?>
' , 1  );"
                            data-original-title="<?php 
            _e('Reject', 'wpdev-booking');
            ?>
"  rel="tooltip" 
                        ><i class="icon-ban-circle"></i><?php 
            /** ?><img src="<?php echo WPDEV_BK_PLUGIN_URL; ?>/img/remove-16x16.png" style="width:15px; height:15px;"><?php /**/
            ?>
</a><a                     
                            href="javascript:void(0)" 
                            onclick="javascript:if ( bk_are_you_sure('<?php 
            echo esc_js(__('Do you really want to delete this booking ?', 'wpdev-booking'));
            ?>
') ) delete_booking(<?php 
            echo $booking_id;
            ?>
, <?php 
            echo $user_bk_id;
            ?>
, '<?php 
            echo getBookingLocale();
            ?>
' , 1   );"
                            data-original-title="<?php 
            _e('Delete', 'wpdev-booking');
            ?>
"  rel="tooltip" 
                            class="tooltip_top button-secondary button"
                        ><i class="icon-trash"></i><?php 
            /** ?><img src="<?php echo WPDEV_BK_PLUGIN_URL; ?>/img/delete_type.png" style="width:13px; height:13px;"><?php /**/
            ?>
</a><?php 
            make_bk_action('wpdev_bk_listing_show_print_btn', $booking_id);
            make_bk_action('wpdev_bk_listing_show_payment_status_btn', $booking_id);
            ?>
                      
                    <div class="field-date" style="<?php 
            echo $is_free ? 'margin-top:5px;float: none;white-space: normal;' : '';
            ?>
"><span ><?php 
            _e('Created', 'wpdev-booking');
            ?>
:</span> <span><?php 
            echo $cr_date, ' ', $cr_time;
            ?>
</span></div>
                  </div>
              <?php 
        }
        ?>
              </div>
       
              <?php 
        make_bk_action('wpdev_bk_listing_show_edit_fields', $booking_id, $bk_remark);
        ?>

              <?php 
        make_bk_action('wpdev_bk_listing_show_payment_status_cost_fields', $booking_id, $bk_pay_status);
        ?>
              
          </div>
        <?php 
    }
    ?>
        </div>

        <?php 
    //if  ( wpbc_is_field_in_table_exists('booking','is_new') != 0 )  renew_NumOfNewBookings($id_of_new_bookings); // Update num status if supported
    ?>

        <?php 
    make_bk_action('wpdev_bk_listing_show_change_booking_resources', $booking_types);
    ?>

        <?php 
    if (function_exists('wpdevbk_generate_print_loyout')) {
        wpdevbk_generate_print_loyout($print_data);
    }
}
コード例 #6
0
function sendApproveEmails($approved_id_str, $is_send_emeils, $denyreason = '')
{
    global $wpdb;
    $sql = "SELECT * FROM {$wpdb->prefix}booking as bk WHERE bk.booking_id IN ({$approved_id_str})";
    $result = $wpdb->get_results($sql);
    $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_approval_adress'));
    //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
    $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_approval_subject'));
    $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_approval_content'));
    $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
    $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
    foreach ($result as $res) {
        $mail_body_to_send = $mail_body;
        $mail_subject_to_send = $mail_subject;
        // Sending mail ///////////////////////////////////////////////////////
        if (function_exists('get_booking_title')) {
            $bk_title = get_booking_title($res->booking_type);
        } else {
            $bk_title = '';
        }
        if (get_bk_option('booking_date_view_type') == 'short') {
            $my_dates_4_send = get_dates_short_format(get_dates_str($res->booking_id));
        } else {
            $my_dates_4_send = change_date_format(get_dates_str($res->booking_id));
        }
        $my_dates4emeil_check_in_out = explode(',', get_dates_str($res->booking_id));
        $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
        $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
        $booking_form_show = get_form_content($res->form, $res->booking_type, '', array('booking_id' => $res->booking_id, 'id' => $res->booking_id, 'dates' => $my_dates_4_send, 'check_in_date' => $my_check_in_date, 'check_out_date' => $my_check_out_date, 'dates_count' => count($my_dates4emeil_check_in_out), 'cost' => isset($res->cost) ? $res->cost : '', 'siteurl' => htmlspecialchars_decode('<a href="' . home_url() . '">' . home_url() . '</a>'), 'resource_title' => $bk_title, 'bookingtype' => $bk_title, 'denyreason' => $denyreason));
        make_bk_action('booking_aproved', $res, $booking_form_show);
        $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send);
        $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $res->booking_id);
        $mail_subject_to_send = replace_bk_shortcodes_in_form($mail_subject_to_send, $booking_form_show['_all_fields_'], true);
        $mail_body_to_send = replace_bk_shortcodes_in_form($mail_body_to_send, $booking_form_show['_all_fields_'], true);
        //$mail_body_to_send = str_replace(array("\r\n", "\r", "\n"), "<br />", $mail_body_to_send);     // Fix issue of showing /n instead of the new line
        //$mail_body_to_send = nl2br($mail_body_to_send);
        //debuge( htmlspecialchars ($mail_body_to_send) );
        $mail_recipients = $booking_form_show['email'];
        $mail_headers = "From: {$mail_sender}\n";
        $mail_headers .= "Content-Type: text/html\n";
        if (strpos($mail_recipients, ',') !== false) {
            $mail_recipients = explode(';', $mail_recipients);
        } else {
            if (strpos($mail_recipients, ';') !== false) {
                $mail_recipients = explode(';', $mail_recipients);
            } else {
                $mail_recipients = array($mail_recipients);
            }
        }
        foreach ($mail_recipients as $mail_recipient) {
            if (get_bk_option('booking_is_email_approval_adress') != 'Off' && $is_send_emeils != 0) {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                    @wp_mail($mail_recipient, $mail_subject_to_send, $mail_body_to_send, $mail_headers);
                }
            }
            $mail_headers_for_admin = "From: {$mail_recipient}\nContent-Type: text/html\n";
            // Send to the Admin also
            $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
            $is_email_approval_send_copy_to_admin = get_bk_option('booking_is_email_approval_send_copy_to_admin');
            if ($is_email_approval_send_copy_to_admin == 'On') {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                    if ($is_send_emeils != 0) {
                        @wp_mail($mail_recipient, $mail_subject_to_send, $mail_body_to_send, $mail_headers_for_admin);
                    }
                }
            }
        }
    }
}
コード例 #7
0
    public function settings_show_content()
    {
        if (isset($_GET['tab']) && $_GET['tab'] == $this->term && $this->submit_form !== false) {
            ?>
            <div class="clear" style="height:0px;"></div>
            <div id="ajax_working"></div>
            <?php 
            if (isset($_POST['is_form_sbmitted_' . $this->submit_form])) {
                check_admin_referer('wpbc_settings_page_' . $this->submit_form);
                make_bk_action('wpbc_submit_of_settings_form_' . $this->submit_form);
            }
            ?>
    
            <div class="metabox-holder">
                <?php 
            make_bk_action('wpbc_before_content_of_settings_form_' . $this->submit_form);
            ?>
                <form  name="<?php 
            echo $this->submit_form;
            ?>
" id="<?php 
            echo $this->submit_form;
            ?>
"  action="" method="post" >
                    <input type="hidden" name="is_form_sbmitted_<?php 
            echo $this->submit_form;
            ?>
" id="is_form_sbmitted_<?php 
            echo $this->submit_form;
            ?>
" value="1" />
                        
                    <?php 
            wp_nonce_field('wpbc_settings_page_' . $this->submit_form);
            if (count($this->sub_menu) > 0) {
                // Several Tabs
                foreach ($this->sub_menu as $sub_section) {
                    ?>
<div  id="<?php 
                    echo $sub_section['visibility_container'];
                    ?>
" 
                                    style="<?php 
                    if ($sub_section['selected']) {
                        echo 'display:block;';
                    } else {
                        echo 'display:none;';
                    }
                    ?>
"
                                    class="visibility_container"                                     
                                    ><?php 
                    make_bk_action('wpbc_content_of_settings_form_' . $sub_section['visibility_container']);
                    ?>
</div><?php 
                }
            } else {
                // General One Content
                ?>
<div  id="visibility_container_<?php 
                echo $this->term;
                ?>
" class="visibility_container" ><?php 
                make_bk_action('wpbc_content_of_settings_form_' . $this->term);
                ?>
</div><?php 
            }
            ?>
                    <div class="clear" style="height:10px;"></div>
                    <input class="button-primary button" style="float:right;" type="submit" value="<?php 
            echo $this->submit_title;
            ?>
" name="submit_form" />
                    <div class="clear" style="height:10px;"></div>
                </form>
                <?php 
            make_bk_action('wpbc_after_content_of_settings_form_' . $this->submit_form);
            ?>
                
            </div><?php 
        }
    }
コード例 #8
0
function wpdev_bk_settings_legend_section()
{
    if (isset($_POST['booking_legend_text_for_item_available'])) {
        if (isset($_POST['booking_is_show_legend'])) {
            $booking_is_show_legend = 'On';
        } else {
            $booking_is_show_legend = 'Off';
        }
        update_bk_option('booking_is_show_legend', $booking_is_show_legend);
        if (isset($_POST['booking_legend_is_show_item_available'])) {
            $booking_legend_is_show_item_available = 'On';
        } else {
            $booking_legend_is_show_item_available = 'Off';
        }
        update_bk_option('booking_legend_is_show_item_available', $booking_legend_is_show_item_available);
        update_bk_option('booking_legend_text_for_item_available', $_POST['booking_legend_text_for_item_available']);
        if (isset($_POST['booking_legend_is_show_item_pending'])) {
            $booking_legend_is_show_item_pending = 'On';
        } else {
            $booking_legend_is_show_item_pending = 'Off';
        }
        update_bk_option('booking_legend_is_show_item_pending', $booking_legend_is_show_item_pending);
        update_bk_option('booking_legend_text_for_item_pending', $_POST['booking_legend_text_for_item_pending']);
        if (isset($_POST['booking_legend_is_show_item_approved'])) {
            $booking_legend_is_show_item_approved = 'On';
        } else {
            $booking_legend_is_show_item_approved = 'Off';
        }
        update_bk_option('booking_legend_is_show_item_approved', $booking_legend_is_show_item_approved);
        update_bk_option('booking_legend_text_for_item_approved', $_POST['booking_legend_text_for_item_approved']);
        if (class_exists('wpdev_bk_biz_s')) {
            if (isset($_POST['booking_legend_is_show_item_partially'])) {
                $booking_legend_is_show_item_partially = 'On';
            } else {
                $booking_legend_is_show_item_partially = 'Off';
            }
            update_bk_option('booking_legend_is_show_item_partially', $booking_legend_is_show_item_partially);
            update_bk_option('booking_legend_text_for_item_partially', $_POST['booking_legend_text_for_item_partially']);
        }
    }
    $booking_is_show_legend = get_bk_option('booking_is_show_legend');
    $booking_legend_is_show_item_available = get_bk_option('booking_legend_is_show_item_available');
    $booking_legend_text_for_item_available = get_bk_option('booking_legend_text_for_item_available');
    $booking_legend_is_show_item_pending = get_bk_option('booking_legend_is_show_item_pending');
    $booking_legend_text_for_item_pending = get_bk_option('booking_legend_text_for_item_pending');
    $booking_legend_is_show_item_approved = get_bk_option('booking_legend_is_show_item_approved');
    $booking_legend_text_for_item_approved = get_bk_option('booking_legend_text_for_item_approved');
    if (class_exists('wpdev_bk_biz_s')) {
        $booking_legend_is_show_item_partially = get_bk_option('booking_legend_is_show_item_partially');
        $booking_legend_text_for_item_partially = get_bk_option('booking_legend_text_for_item_partially');
    }
    ?>
               <tr valign="top" class="ver_premium_plus">
                    <th scope="row">
                        <?php 
    _e('Show legend below calendar', 'wpdev-booking');
    ?>
:
                    </th>
                    <td>
                        <fieldset>
                        <label for="booking_is_show_legend" >
                            <input <?php 
    if ($booking_is_show_legend == 'On') {
        echo "checked";
    }
    /**/
    ?>
  value="<?php 
    echo $booking_is_show_legend;
    ?>
" name="booking_is_show_legend" id="booking_is_show_legend" type="checkbox"
                                 onclick="javascript: if (this.checked) jQuery('#togle_settings_show_legend').slideDown('normal'); else  jQuery('#togle_settings_show_legend').slideUp('normal');"
                                                                                                          />
                            <?php 
    _e('Check this box to display a legend of dates below the booking calendar.', 'wpdev-booking');
    ?>
                        </label>
                        </fieldset>    
                    </td>
                </tr>

                <tr valign="top" class="ver_premium_plus"><td colspan="2"  style="padding:0px;">
                    <div style="margin: 0px 0 10px 50px;">
                    <table id="togle_settings_show_legend" style="<?php 
    if ($booking_is_show_legend != 'On') {
        echo "display:none;";
    }
    /**/
    ?>
" class="hided_settings_table">
                        <tr>
                            <th scope="row"><label for="booking_legend_is_show_item_available" ><?php 
    _e('Available item', 'wpdev-booking');
    ?>
:</label></th>
                            <td>
                                <input <?php 
    if ($booking_legend_is_show_item_available == 'On') {
        echo "checked";
    }
    ?>
  type="checkbox"
                                    value="<?php 
    echo $booking_legend_is_show_item_available;
    ?>
"
                                    name="booking_legend_is_show_item_available"  id="booking_legend_is_show_item_available"  />&nbsp;
                                <input value="<?php 
    echo $booking_legend_text_for_item_available;
    ?>
" name="booking_legend_text_for_item_available" id="booking_legend_text_for_item_available" type="text"    />
                                <span class="description"><?php 
    printf(__('Activate and type your %stitle of available%s item in legend', 'wpdev-booking'), '<b>', '</b>');
    ?>
</span>
                                <?php 
    //make_bk_action('show_additional_translation_shortcode_help');
    ?>
                            </td>
                        </tr>

                        <tr>
                            <th scope="row"><label for="booking_legend_is_show_item_pending" ><?php 
    _e('Pending item', 'wpdev-booking');
    ?>
:</label></th>
                            <td>
                                <input <?php 
    if ($booking_legend_is_show_item_pending == 'On') {
        echo "checked";
    }
    ?>
  type="checkbox"
                                    value="<?php 
    echo $booking_legend_is_show_item_pending;
    ?>
"
                                    name="booking_legend_is_show_item_pending"  id="booking_legend_is_show_item_pending"  />&nbsp;
                                <input value="<?php 
    echo $booking_legend_text_for_item_pending;
    ?>
" name="booking_legend_text_for_item_pending" id="booking_legend_text_for_item_pending" type="text"    />
                                <span class="description"><?php 
    printf(__('Activate and type your %stitle of pending%s item in legend', 'wpdev-booking'), '<b>', '</b>');
    ?>
</span>
                                <?php 
    //make_bk_action('show_additional_translation_shortcode_help');
    ?>
                            </td>
                        </tr>

                        <tr>
                            <th scope="row"><label for="booking_legend_is_show_item_approved" ><?php 
    _e('Approved item', 'wpdev-booking');
    ?>
:</label></th>
                            <td>
                                <input <?php 
    if ($booking_legend_is_show_item_approved == 'On') {
        echo "checked";
    }
    ?>
  type="checkbox"
                                    value="<?php 
    echo $booking_legend_is_show_item_approved;
    ?>
"
                                    name="booking_legend_is_show_item_approved"  id="booking_legend_is_show_item_approved"  />&nbsp;
                                <input value="<?php 
    echo $booking_legend_text_for_item_approved;
    ?>
" name="booking_legend_text_for_item_approved" id="booking_legend_text_for_item_approved" type="text"    />
                                <span class="description"><?php 
    printf(__('Activate and type your %stitle of approved%s item in legend', 'wpdev-booking'), '<b>', '</b>');
    ?>
</span>
                                <?php 
    //make_bk_action('show_additional_translation_shortcode_help');
    ?>
                            </td>
                        </tr>
                        <?php 
    if (class_exists('wpdev_bk_biz_s')) {
        ?>
                            <tr>
                                <th scope="row"><label for="booking_legend_is_show_item_partially" ><?php 
        _e('Partially booked item', 'wpdev-booking');
        ?>
:</label></th>
                                <td>
                                    <input <?php 
        if ($booking_legend_is_show_item_partially == 'On') {
            echo "checked";
        }
        ?>
  type="checkbox"
                                        value="<?php 
        echo $booking_legend_is_show_item_partially;
        ?>
"
                                        name="booking_legend_is_show_item_partially"  id="booking_legend_is_show_item_partially"  />&nbsp;
                                    <input value="<?php 
        echo $booking_legend_text_for_item_partially;
        ?>
" name="booking_legend_text_for_item_partially" id="booking_legend_text_for_item_partially" type="text"    />
                                    <span class="description"><?php 
        printf(__('Activate and type your %stitle of partially booked%s item in legend', 'wpdev-booking'), '<b>', '</b>');
        ?>
</span>
                                    <p class="description"><strong><?php 
        _e('Note', 'wpdev-booking');
        ?>
:</strong> <?php 
        printf(__('Partially booked item - day, which is booked for the specific time-slot(s).', 'wpdev-booking'), '<b>', '</b>');
        ?>
</p>
                                    <?php 
        //make_bk_action('show_additional_translation_shortcode_help');
        ?>
                                </td>
                            </tr>
                        <?php 
    }
    ?>
                        <tr><td colspan="2" style="padding:0px;"><div style="margin-top:-15px;"><?php 
    make_bk_action('show_additional_translation_shortcode_help');
    ?>
</div></td></tr>
                    </table>
                    </div>
                </td></tr>
                <tr valign="top"><td colspan="2" style="padding:10px"><div style="border-bottom:1px solid #cccccc;"></div></td></tr>
        <?php 
}
コード例 #9
0
function wpbc_ajax_WPBC_IMPORT_GCAL_EVENTS()
{
    wpdev_check_nonce_in_admin_panel();
    make_bk_action('check_multiuser_params_for_client_side_by_user_id', $_POST['user_id']);
    make_bk_action('wpbc_import_gcal_events');
}
コード例 #10
0
function wpbc_add_new_booking($params, $is_edit_booking = false)
{
    if ($is_edit_booking !== false) {
        // Edit booking
        $booking_id = $is_edit_booking['booking_id'];
        $bktype = $is_edit_booking['booking_type'];
    } else {
        // New booking
        if (!isset($params["bktype"])) {
            return false;
        } else {
            $bktype = intval($params["bktype"]);
        }
        if ($bktype == 0) {
            return false;
        }
        // Error: Unknown booking resources
    }
    make_bk_action('check_multiuser_params_for_client_side', $bktype);
    // Activate working with specific user in WP MU
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Define init variables
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    global $wpdb;
    $formdata = escape_any_xss($params["form"]);
    $my_modification_date = "'" . date_i18n('Y-m-d H:i:s') . "'";
    // Localize booking modification date
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Get Dates
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $dates_in_diff_formats = wpbc_get_dates_in_diff_formats($params["dates"], $bktype, $formdata);
    //debuge($dates_in_diff_formats);
    $str_dates__dd_mm_yyyy = $dates_in_diff_formats['string'];
    // $my_dates   = $dates_in_diff_formats['array'];
    $start_time = $dates_in_diff_formats['start_time'];
    $end_time = $dates_in_diff_formats['end_time'];
    //Here we need to check for double booking for the same sessions
    if (!$is_edit_booking && !wpbc_check_if_dates_free($bktype, $formdata, $dates_in_diff_formats, $start_time, $end_time)) {
        die;
    }
    $my_check_in_date = explode('-', $dates_in_diff_formats['array'][0]);
    $my_check_in_date_sql = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $my_check_in_date[0], $my_check_in_date[1], $my_check_in_date[2], $start_time[0], $start_time[1], $start_time[2]);
    if (empty($str_dates__dd_mm_yyyy)) {
        ?>
 <script type="text/javascript"> if ( jQuery('#submiting<?php 
        echo $bktype;
        ?>
' ).length ) { document.getElementById('submiting<?php 
        echo $bktype;
        ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
        bk_error('Error! No Dates', __FILE__, __LINE__);
        ?>
</div>'; } </script> <?php 
        die('Error! No Dates');
    }
    $auto_approve_new_bookings_is_active = trim(get_bk_option('booking_auto_approve_new_bookings_is_active'));
    $is_approved_dates = $auto_approve_new_bookings_is_active == 'On' ? '1' : '0';
    //    // Auto Approve booking from Booking > Add booking page for single booking resources
    //    $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
    //    if ( strpos( $_SERVER['HTTP_REFERER'], $admin_uri ) !== false )
    //        $is_approved_dates = '1';
    $additional_fields = $additional_fields_vlaues = '';
    if (isset($params["sync_gid"])) {
        $additional_fields = ", sync_gid";
        $additional_fields_vlaues = ", '" . wpbc_clean_parameter($params["sync_gid"]) . "'";
    }
    if ($is_edit_booking === false) {
        ////////////////////////////////////////////////////////////////////////////
        // Add new booking
        ////////////////////////////////////////////////////////////////////////////
        $sql_insertion = "INSERT INTO {$wpdb->prefix}booking (form, booking_type, modification_date, sort_date{$additional_fields}) VALUES ('{$formdata}', {$bktype}, {$my_modification_date}, '{$my_check_in_date_sql}' {$additional_fields_vlaues})";
        if (false === $wpdb->query($sql_insertion)) {
            ?>
 <script type="text/javascript"> if ( jQuery('#submiting<?php 
            echo $bktype;
            ?>
' ).length ) {  document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into DB', __FILE__, __LINE__);
            ?>
</div>'; }</script> <?php 
            die('Error during inserting into DB');
        }
        $booking_id = (int) $wpdb->insert_id;
        // Get ID of booking
    } else {
        ////////////////////////////////////////////////////////////////////////////
        // Edit booking
        ////////////////////////////////////////////////////////////////////////////
        $update_sql = "UPDATE {$wpdb->prefix}booking AS bk SET bk.form='{$formdata}', bk.booking_type={$bktype}, bk.modification_date={$my_modification_date}, sort_date='{$my_check_in_date_sql}' WHERE bk.booking_id={$booking_id};";
        if (false === $wpdb->query($update_sql)) {
            ?>
 <script type="text/javascript"> if ( jQuery('#submiting<?php 
            echo $bktype;
            ?>
' ).length ) {  document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking in DB', __FILE__, __LINE__);
            ?>
</div>'; }</script> <?php 
            die('Error during updating exist booking in DB');
        }
        // Check if dates already aproved or no
        $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id}) LIMIT 0,1";
        $slct_sql_results = $wpdb->get_results($slct_sql);
        if (count($slct_sql_results) > 0) {
            $is_approved_dates = $slct_sql_results[0]->approved;
        }
        $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id})";
        if (false === $wpdb->query($delete_sql)) {
            ?>
 <script type="text/javascript"> if ( jQuery('#submiting<?php 
            echo $bktype;
            ?>
' ).length ) {  document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during updating exist booking for deleting dates in DB', __FILE__, __LINE__);
            ?>
</div>'; }</script> <?php 
            die('Error during updating exist booking for deleting dates in DB');
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // Update the Hash and Cost  of the booking
    make_bk_action('wpbc_update_booking_hash', $booking_id, $bktype);
    make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $insert = wpbc_get_SQL_to_insert_dates($dates_in_diff_formats, $is_approved_dates, $booking_id);
    if (!empty($insert)) {
        if (false === $wpdb->query("INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert)) {
            ?>
 <script type="text/javascript"> if ( jQuery('#submiting<?php 
            echo $bktype;
            ?>
' ).length ) {  document.getElementById('submiting<?php 
            echo $bktype;
            ?>
').innerHTML = '<div style=&quot;height:20px;width:100%;text-align:center;margin:15px auto;&quot;><?php 
            bk_error('Error during inserting into BD - Dates', __FILE__, __LINE__);
            ?>
</div>'; }</script> <?php 
            die('Error during inserting into BD - Dates');
        }
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    if (isset($params["is_send_emeils"])) {
        $is_send_emeils = $params["is_send_emeils"];
    } else {
        $is_send_emeils = 1;
    }
    if ($is_edit_booking === false) {
        if ($is_send_emeils != 0) {
            sendNewBookingEmails($booking_id, $bktype, $formdata);
        }
        if (isset($params["is_show_payment_form"]) && $params["is_show_payment_form"] == 1) {
            do_action('wpdev_new_booking', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata);
        } else {
            do_action('wpbc_update_cost_of_new_booking', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata);
        }
        // wpbc_integrate_MailChimp($formdata, $bktype);
        if ($auto_approve_new_bookings_is_active == 'On' && $is_send_emeils != 0) {
            sendApproveEmails($booking_id, 1);
        }
    } else {
        if ($is_send_emeils != 0) {
            sendModificationEmails($booking_id, $bktype, $formdata);
        }
        $admin_uri = ltrim(str_replace(get_site_url(null, '', 'admin'), '', admin_url('admin.php?')), '/');
        if (strpos($_SERVER['HTTP_REFERER'], $admin_uri) === false) {
            if (isset($params["is_show_payment_form"]) && $params["is_show_payment_form"] == 1) {
                do_action('wpdev_new_booking', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata);
            } else {
                do_action('wpbc_update_cost_of_new_booking', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata);
            }
        }
    }
    // Re-Update booking resource TYPE if its needed here
    if (isset($params["skip_page_checking_for_updating"])) {
        $skip_page_checking_for_updating = (bool) $params["skip_page_checking_for_updating"];
    } else {
        $skip_page_checking_for_updating = true;
    }
    make_bk_action('wpdev_booking_reupdate_bk_type_to_childs', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time), $formdata, $skip_page_checking_for_updating);
    make_bk_action('finish_check_multiuser_params_for_client_side', $bktype);
    // Deactivate working with  specific user in WP MU
    return $booking_id;
}
function email_help_section($skip_shortcodes = array(), $email_example = '')
{
    ?>
            <div class="wpbc-help-message" style="margin-top:10px;">
                <?php 
    if (class_exists('wpdev_bk_personal')) {
        ?>
                <p class="description" style="font-weight:normal;"><?php 
        printf(__('You can use (in subject and content of email template) any shortcodes, which you used in the booking form. Use the shortcodes in the same way as you used them in the content form at Settings Fields page.', 'booking'));
        ?>
</p>
                <br/>
                <p class="description"><strong><?php 
        printf(__('You can use following shortcodes in content of this template', 'booking'));
        ?>
</strong>: </p>
                <?php 
    } else {
        ?>
                <p class="description"><strong><?php 
        printf(__('You can use following shortcodes in content of this template', 'booking'));
        ?>
</strong>: </p>
                <?php 
    }
    ?>
                <p class="description" style="font-weight:normal;"><?php 
    if (!class_exists('wpdev_bk_personal')) {
        printf(__('%s - inserting data info about the booking', 'booking'), '<code>[content]</code>');
    } else {
        printf(__('%s - inserting data info about the booking, which you configured in the content form at Settings Fields page', 'booking'), '<code>[content]</code>');
    }
    ?>
, </p>
                <p class="description"><?php 
    printf(__('%s - inserting ID of booking ', 'booking'), '<code>[id]</code>');
    ?>
, </p>
                <?php 
    if (!in_array('bookingtype', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s or %s - inserting the title of the booking resource ', 'booking'), '<code>[resource_title]</code>', '<code>[bookingtype]</code>');
        ?>
, </p>
                <?php 
    }
    if (!in_array('cost', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting the cost of  booking ', 'booking'), '<code>[cost]</code>');
        ?>
, </p>
                <?php 
    }
    ?>
                                                                 

                <p class="description"><?php 
    printf(__('%s - inserting the dates of booking', 'booking'), '<code>[dates]</code>');
    ?>
, </p>
                <?php 
    if (!in_array('check_in_date', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting check-in date (first day of reservation),', 'booking'), '<code>[check_in_date]</code>');
        ?>
, </p>
                <?php 
    }
    if (!in_array('check_out_date', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting check-out date (last day of reservation),', 'booking'), '<code>[check_out_date]</code>');
        ?>
, </p>
                <?php 
    }
    if (!in_array('dates_count', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting the number of booking dates ', 'booking'), '<code>[dates_count]</code>');
        ?>
, </p>
                <?php 
    }
    ?>
                <?php 
    if (class_exists('wpdev_bk_personal')) {
        ?>
                <hr />
                <p class="description"><?php 
        printf(__('%s - inserting your site URL ', 'booking'), '<code>[siteurl]</code>');
        ?>
, </p>                    
                <p class="description"><?php 
        printf(__('%s - inserting IP address of the user who made this action ', 'booking'), '<code>[remote_ip]</code>');
        ?>
, </p>                                    
                <p class="description"><?php 
        printf(__('%s - inserting contents of the User-Agent: header from the current request, if there is one ', 'booking'), '<code>[user_agent]</code>');
        ?>
, </p>                    
                <p class="description"><?php 
        printf(__('%s - inserting address of the page (if any), where visitor make this action ', 'booking'), '<code>[request_url]</code>');
        ?>
, </p>                    
                <p class="description"><?php 
        printf(__('%s - inserting date of this action ', 'booking'), '<code>[current_date]</code>');
        ?>
, </p>                    
                <p class="description"><?php 
        printf(__('%s - inserting time of this action ', 'booking'), '<code>[current_time]</code>');
        ?>
, </p>                    
                <hr />
                <?php 
    } else {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting your site URL ', 'booking'), '<code>[siteurl]</code>');
        ?>
, </p>                    
                <?php 
    }
    ?>

                <?php 
    if (!in_array('moderatelink', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - inserting moderate link of new booking ', 'booking'), '<code>[moderatelink]</code>');
        ?>
, </p>
                <?php 
    }
    ?>
                <?php 
    if (class_exists('wpdev_bk_personal')) {
        ?>
                    <?php 
        if (!in_array('visitorbookingediturl', $skip_shortcodes)) {
            ?>
                    <p class="description"><?php 
            printf(__('%s - inserting link to the page where visitor can edit the reservation,  (possible to use the %s parameter for setting different %s of this page. Example: %s )', 'booking'), '<code>[visitorbookingediturl]</code>', '"url"', 'URL', '<em>[visitorbookingediturl url="http://www.server.com/custom-page/"]</em>');
            ?>
, </p>
                    <?php 
        }
        if (!in_array('visitorbookingcancelurl', $skip_shortcodes)) {
            ?>
                    <p class="description"><?php 
            printf(__('%s - inserting link to the page where visitor can cancel the reservation, (possible to use the %s parameter for setting different %s of this page. Example: %s )', 'booking'), '<code>[visitorbookingcancelurl]</code>', '"url"', 'URL', '<em>[visitorbookingcancelurl url="http://www.server.com/custom-page/"]</em>');
            ?>
, </p>
                    <?php 
        }
        if (!in_array('visitorbookingpayurl', $skip_shortcodes)) {
            ?>
                    <p class="description"><?php 
            printf(__('%s - inserting link to payment page where visitor can pay for the reservation  (possible to use the %s parameter for setting different %s of this page. Example: %s )', 'booking'), '<code>[visitorbookingpayurl]</code>', '"url"', 'URL', '<em>[visitorbookingpayurl url="http://www.server.com/custom-page/"]</em>');
            ?>
, </p>
                    <?php 
        }
        ?>

                    <?php 
        if (!in_array('paymentreason', $skip_shortcodes)) {
            ?>
                    <p class="description"><?php 
            printf(__('%s - add the reason for booking payment, you can enter it before sending email, ', 'booking'), '<code>[paymentreason]</code>');
            ?>
, </p>
                    <?php 
        }
        ?>
 
                <?php 
    }
    ?>
                <?php 
    if (!in_array('denyreason', $skip_shortcodes)) {
        ?>
                <p class="description"><?php 
        printf(__('%s - add the reason booking was cancelled, you can enter it before sending email, ', 'booking'), '<code>[denyreason]</code>');
        ?>
, </p>
                <?php 
    }
    ?>
                <br/>
                <p class="description"><strong><?php 
    _e('HTML tags is accepted.', 'booking');
    ?>
</strong></p>
                <?php 
    make_bk_action('show_additional_translation_shortcode_help');
    ?>
                <?php 
    // echo ($email_example);
    ?>
            </div>
        <?php 
}
コード例 #12
0
function wpbc_gcal_settings_content()
{
    $booking_gcal_feed = get_bk_option('booking_gcal_feed');
    $booking_gcal_events_from = get_bk_option('booking_gcal_events_from');
    $booking_gcal_events_from_offset = get_bk_option('booking_gcal_events_from_offset');
    $booking_gcal_events_from_offset_type = get_bk_option('booking_gcal_events_from_offset_type');
    $booking_gcal_events_until = get_bk_option('booking_gcal_events_until');
    $booking_gcal_events_until_offset = get_bk_option('booking_gcal_events_until_offset');
    $booking_gcal_events_until_offset_type = get_bk_option('booking_gcal_events_until_offset_type');
    $booking_gcal_events_max = get_bk_option('booking_gcal_events_max');
    $booking_gcal_api_key = get_bk_option('booking_gcal_api_key');
    $booking_gcal_timezone = get_bk_option('booking_gcal_timezone');
    $booking_gcal_is_send_email = get_bk_option('booking_gcal_is_send_email');
    $booking_gcal_auto_import_is_active = get_bk_option('booking_gcal_auto_import_is_active');
    $booking_gcal_auto_import_time = get_bk_option('booking_gcal_auto_import_time');
    $booking_gcal_events_form_fields = get_bk_option('booking_gcal_events_form_fields');
    if (is_serialized($booking_gcal_events_form_fields)) {
        $booking_gcal_events_form_fields = unserialize($booking_gcal_events_form_fields);
    }
    ?>
       
     <div class='meta-box' style="">                
        <div <?php 
    $my_close_open_win_id = 'bk_settings_gcal_sync_form_fields';
    ?>
  id="<?php 
    echo $my_close_open_win_id;
    ?>
" class="postbox <?php 
    if ('1' == get_user_option('booking_win_' . $my_close_open_win_id)) {
        echo 'closed';
    }
    ?>
" > <div title="<?php 
    _e('Click to toggle', 'booking');
    ?>
" class="handlediv"  onclick="javascript:verify_window_opening(<?php 
    echo get_bk_current_user_id();
    ?>
, '<?php 
    echo $my_close_open_win_id;
    ?>
');"><br></div>
            <h3 class='hndle'><span><?php 
    _e('Assign events fields to specific booking form field', 'booking');
    ?>
</span></h3>          
       <div class="inside" style="margin:0px;">
        
           <table class="visibility_gcal_feeds_settings form-table settings-table">
            <tbody>
                <?php 
    wpbc_gcal_settings_content_form_fields($booking_gcal_events_form_fields);
    ?>
            </tbody>
        </table>
           
       </div>
      </div>
     </div> 
           
     <?php 
    $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin');
    if ($is_can) {
        ?>
  
       
     <div class='meta-box' style="">                
        <div <?php 
        $my_close_open_win_id = 'bk_settings_gcal_sync_auto_import';
        ?>
  id="<?php 
        echo $my_close_open_win_id;
        ?>
" class="postbox <?php 
        if ('1' == get_user_option('booking_win_' . $my_close_open_win_id)) {
            echo 'closed';
        }
        ?>
" > <div title="<?php 
        _e('Click to toggle', 'booking');
        ?>
" class="handlediv"  onclick="javascript:verify_window_opening(<?php 
        echo get_bk_current_user_id();
        ?>
, '<?php 
        echo $my_close_open_win_id;
        ?>
');"><br></div>
            <h3 class='hndle'><span><?php 
        _e('Auto import events', 'booking');
        ?>
</span></h3>          
       <div class="inside" style="margin:0px;">
        
           <table class="visibility_gcal_feeds_settings form-table settings-table">
            <tbody>
                <?php 
        wpbc_gcal_settings_content_field_auto_import($booking_gcal_auto_import_is_active, $booking_gcal_auto_import_time);
        ?>
            </tbody>
        </table>
           
       </div>
      </div>
     </div> 
     <?php 
    }
    ?>
       
       
     <div class='meta-box' style="">                
        <div <?php 
    $my_close_open_win_id = 'bk_settings_gcal_sync';
    ?>
  id="<?php 
    echo $my_close_open_win_id;
    ?>
" class="postbox <?php 
    if ('1' == get_user_option('booking_win_' . $my_close_open_win_id)) {
        echo 'closed';
    }
    ?>
" > <div title="<?php 
    _e('Click to toggle', 'booking');
    ?>
" class="handlediv"  onclick="javascript:verify_window_opening(<?php 
    echo get_bk_current_user_id();
    ?>
, '<?php 
    echo $my_close_open_win_id;
    ?>
');"><br></div>
            <h3 class='hndle'><span><?php 
    _e('Google Calendar - General Settings', 'booking');
    ?>
</span></h3>          
       <div class="inside" style="margin:0px;">
           
        <table class="visibility_gcal_feeds_settings form-table settings-table">
            <tbody>
                <?php 
    wpbc_gcal_settings_content_api_key($booking_gcal_api_key);
    wpbc_gcal_settings_content_field_timezone($booking_gcal_timezone);
    /*
                    ?>
                    <tr valign="top">
                        <th scope="row"><?php _e('Send emails' ,'booking'); ?>:</th>
                        <td>
                            <fieldset>
                                <label for="booking_gcal_is_send_email" >                                                                                                
                                    <input <?php if ($booking_gcal_is_send_email == 'On') echo "checked"; ?>  value="<?php echo $booking_gcal_is_send_email; ?>" name="booking_gcal_is_send_email" id="booking_gcal_is_send_email" type="checkbox"   />
                                    <?php printf(__('Check this box to %ssend emails about creation new bookings%s after events requesting.' ,'booking'),'<b>','</b>');?>
                                </label>
                            </fieldset>                                                                                                        
                        </td>
                    </tr>
                    <?php /**/
    ?>
                <tr valign="top">
                    <td colspan="2"><hr/>
                        <p class="description" style="text-align:right;"><strong><?php 
    _e('Default settings for retrieving events', 'booking');
    ?>
</strong></p>
                    </td>
                </tr>

                <?php 
    wpbc_gcal_settings_content_field_max_feeds($booking_gcal_events_max);
    wpbc_gcal_settings_content_field_from($booking_gcal_events_from, $booking_gcal_events_from_offset, $booking_gcal_events_from_offset_type);
    wpbc_gcal_settings_content_field_until($booking_gcal_events_until, $booking_gcal_events_until_offset, $booking_gcal_events_until_offset_type);
    ?>
                
                <tr valign="top"><td colspan="2" style=""><hr/></td></tr>
                
                <?php 
    if (!class_exists('wpdev_bk_personal')) {
        ?>
                <tr valign="top">
                    <th scope="row"><label for="booking_gcal_feed" ><?php 
        _e('Google Calendar ID', 'booking');
        ?>
:</label></th>
                    <td class="wpdevbk">
                        <div class="control-group">
                        <div class="inline controls">
<!--                            <div class="input-prepend">-->
<!--                                <span class="add-on" style="float:left!important;box-sizing: content-box;font-size: 14px;padding:9px 0;" >&nbsp;https://www.google.com&nbsp;</span>-->
                                <input style="box-sizing: content-box;font-size: 14px;width: 50%;" 
                                       id="booking_gcal_feed" name="booking_gcal_feed" 
                                       type="text" value="<?php 
        echo $booking_gcal_feed;
        ?>
"

                                       />
<!--                                       placeholder="calendar/feeds/your-email@group.calendar.google.com/public/basic"-->                                
<!--                            </div>-->
                        </div>                   
                        </div>
                        <p class="description"><?php 
        ?>
</p>
                    </td>
                </tr>  
                <?php 
    }
    ?>
               
                
            </tbody>
        </table>

       </div>
      </div>
     </div> 
       
       
     <div class='meta-box' style="">                
        <div <?php 
    $my_close_open_win_id = 'bk_settings_gcal_sync_help';
    ?>
  id="<?php 
    echo $my_close_open_win_id;
    ?>
" class="postbox <?php 
    if ('1' == get_user_option('booking_win_' . $my_close_open_win_id)) {
        echo 'closed';
    }
    ?>
" > <div title="<?php 
    _e('Click to toggle', 'booking');
    ?>
" class="handlediv"  onclick="javascript:verify_window_opening(<?php 
    echo get_bk_current_user_id();
    ?>
, '<?php 
    echo $my_close_open_win_id;
    ?>
');"><br></div>
            <h3 class='hndle'><span><?php 
    _e('Google Calendar - Help Info', 'booking');
    ?>
</span></h3>          
       <div class="inside" style="margin:0px;">
        
            <div class="wpbc-help-message" style="margin-top:10px;">                
                <table class="resource_table booking_table" style="border:none !important;background: none !important;box-shadow: 0 0 0 #fff !important;">
                    <tbody>
                    <tr>
                        <td style="vertical-align: top;border:none;">
                            
                <h4>01. <?php 
    _e('To get Google Calendar API key please follow this instruction', 'booking');
    ?>
:</h4>                                
                <ol style="list-style-type: decimal !important;margin-left: 20px;">
                    <li><?php 
    printf(__('Go to Google Developer Console: %s.', 'booking'), '<a href="https://console.developers.google.com" target="_blank">https://console.developers.google.com</a>');
    ?>
</li>
                    <li><?php 
    printf(__('Give your project a name and click "Create".', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('In the sidebar click on "APIs & auth".', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Click APIs and make sure "Calendar API" is set to ON.', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Now click on "Credentials" in the sidebar.', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Under the section "Public API access" click the button "Create new Key".', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('On the popup click the button "Server Key" and click "Create".', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('You will now see a table loaded with the top item being the API Key. Copy this and paste it into %sGoogle API Key%s field at this page.', 'booking'), '<strong>', '</strong>');
    ?>
</li>
                </ol>                    
                            
                        </td>
                        <td style="vertical-align: top;border:none;">
                            
                <h4>02. <?php 
    _e('Set Your Calendar to Public', 'booking');
    ?>
:</h4>                                
                <ol style="list-style-type: decimal !important;margin-left: 20px;">
                    <li><?php 
    printf(__('Navigate to your Google calendars.', 'booking'), '<a href="https://console.developers.google.com" target="_blank">https://console.developers.google.com</a>');
    ?>
</li>
                    <li><?php 
    printf(__('Open the settings for the calendar.', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Click the "Share this Calendar" link.', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Click the checkbox to make calendar public. Do not check the other option.', 'booking'));
    ?>
</li>
                </ol>                    

                <h4>03. <?php 
    _e('Find Your Calendar ID', 'booking');
    ?>
:</h4>                                
                <ol style="list-style-type: decimal !important;margin-left: 20px;">
                    <li><?php 
    printf(__('Navigate to your Google calendars.', 'booking'), '<a href="https://console.developers.google.com" target="_blank">https://console.developers.google.com</a>');
    ?>
</li>
                    <li><?php 
    printf(__('Open the settings for the calendar.', 'booking'));
    ?>
</li>
                    <li><?php 
    printf(__('Now copy the Calendar ID to use in the plugin settings in your WordPress admin. Make sure to %suse the Calendar ID only, not the entire XML feed URL%s.', 'booking'), '<strong>', '</strong>');
    ?>
</li>
                </ol>                    
                            
                        </td>
                    </tr>
                    </tbody>
                </table>


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

    <?php 
    if (wpdev_bk_is_this_demo()) {
        ?>
 <div class="wpbc-error-message" style="text-align:left;"> <span class="wpbc-demo-alert-not-allow"><strong>Warning!</strong> Demo test version does not allow changes to these items.</span></div> <?php 
    }
    ?>
   
    <?php 
    make_bk_action('wpbc_gcal_settings_content_show_booking_resources_table');
}
コード例 #13
0
function sendApproveEmails($approved_id_str, $is_send_emeils)
{
    //debuge($approved_id_str, $is_send_emeils);
    global $wpdb;
    $sql = "SELECT * FROM " . $wpdb->prefix . "booking as bk WHERE bk.booking_id IN ({$approved_id_str})";
    $result = $wpdb->get_results($wpdb->prepare($sql));
    //debuge($result);
    $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_approval_adress'));
    //'"'. 'Booking sender' . '" <' . $booking_form_show['email'].'>';
    $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_approval_subject'));
    $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_approval_content'));
    $mail_subject = apply_bk_filter('wpdev_check_for_active_language', $mail_subject);
    $mail_body = apply_bk_filter('wpdev_check_for_active_language', $mail_body);
    foreach ($result as $res) {
        //debuge($res)                    ;
        // Sending mail ///////////////////////////////////////////////////////
        if (function_exists('get_booking_title')) {
            $bk_title = get_booking_title($res->booking_type);
        } else {
            $bk_title = '';
        }
        //debuge($bk_title);
        $booking_form_show = get_form_content($res->form, $res->booking_type);
        //debuge($booking_form_show);
        make_bk_action('booking_aproved', $res, $booking_form_show);
        $mail_body_to_send = str_replace('[bookingtype]', $bk_title, $mail_body);
        if (get_bk_option('booking_date_view_type') == 'short') {
            $my_dates_4_send = get_dates_short_format(get_dates_str($res->booking_id));
        } else {
            $my_dates_4_send = change_date_format(get_dates_str($res->booking_id));
        }
        //debuge($my_dates_4_send);
        $my_dates4emeil_check_in_out = explode(',', get_dates_str($res->booking_id));
        $my_check_in_date = change_date_format($my_dates4emeil_check_in_out[0]);
        $my_check_out_date = change_date_format($my_dates4emeil_check_in_out[count($my_dates4emeil_check_in_out) - 1]);
        $mail_body_to_send = str_replace('[dates]', $my_dates_4_send, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_in_date]', $my_check_in_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[check_out_date]', $my_check_out_date, $mail_body_to_send);
        $mail_body_to_send = str_replace('[id]', $res->booking_id, $mail_body_to_send);
        $mail_body_to_send = str_replace('[content]', $booking_form_show['content'], $mail_body_to_send);
        $mail_body_to_send = str_replace('[name]', $booking_form_show['name'], $mail_body_to_send);
        if (isset($res->cost)) {
            $mail_body_to_send = str_replace('[cost]', $res->cost, $mail_body_to_send);
        }
        $mail_body_to_send = str_replace('[siteurl]', htmlspecialchars_decode('<a href="' . site_url() . '">' . site_url() . '</a>'), $mail_body_to_send);
        $mail_body_to_send = apply_bk_filter('wpdev_booking_set_booking_edit_link_at_email', $mail_body_to_send, $res->booking_id);
        if (isset($booking_form_show['secondname'])) {
            $mail_body_to_send = str_replace('[secondname]', $booking_form_show['secondname'], $mail_body_to_send);
        }
        $mail_subject1 = $mail_subject;
        $mail_subject1 = str_replace('[name]', $booking_form_show['name'], $mail_subject1);
        if (isset($booking_form_show['secondname'])) {
            $mail_subject1 = str_replace('[secondname]', $booking_form_show['secondname'], $mail_subject1);
        }
        $mail_recipient = $booking_form_show['email'];
        $mail_headers = "From: {$mail_sender}\n";
        $mail_headers .= "Content-Type: text/html\n";
        //debuge($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers);
        //debuge(get_bk_option( 'booking_is_email_approval_adress'  ));
        if (get_bk_option('booking_is_email_approval_adress') != 'Off') {
            if ($is_send_emeils != 0) {
                if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                    @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers);
                }
            }
        }
        // Send to the Admin also
        $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress'));
        $is_email_approval_send_copy_to_admin = get_bk_option('booking_is_email_approval_send_copy_to_admin');
        //debuge($mail_recipient, $is_email_approval_send_copy_to_admin)                    ;
        if ($is_email_approval_send_copy_to_admin == 'On') {
            if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) {
                if ($is_send_emeils != 0) {
                    @wp_mail($mail_recipient, $mail_subject1, $mail_body_to_send, $mail_headers);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////
        //debuge(';Fin')                            ;die;
    }
    //die;
}
function wpdev_bk_custom_button_dialog_CSS()
{
    global $user_ID;
    // Attempt to match the dialog box to the admin colors
    if ('classic' == get_user_option('admin_color', $user_ID)) {
        $color = '#fff';
        $background = '#777';
    } else {
        $color = '#fff';
        $background = '#777';
    }
    ?>
    <style type='text/css'>
        .ui-dialog-titlebar {
            color: <?php 
    echo $color;
    ?>
;
            background: <?php 
    echo $background;
    ?>
;
        }
        <?php 
    $custom_buttons_settings = wpdev_bk_get_custom_buttons_settings();
    foreach ($custom_buttons_settings as $type => $props) {
        echo '#content_' . WP_BK_PREFIX . '_' . $type . ' img.mceIcon{
                                                    width:16px;
                                                    height:16px;
                                                    margin:2px auto;0
                                               }';
    }
    ?>
        .ui-dialog-title img{
            margin:3px auto;
            width:16px;
            height:16px;
        }
        #wpdev_bk-dialog .field {
            margin:10px 0px;
            display:block;
            clear:both;
        }
        #wpdev_bk-dialog .field label {
            display: inline-block;
            font-weight: bold;
            padding-right: 10px;
            text-align: left;
            vertical-align: baseline;
            width: 170px;                
        }
        #wpdev_bk-dialog .wpdev_bk-dialog-inputs {float:left;}
        #wpdev_bk-dialog input[type="text"], 
        #wpdev_bk-dialog select {  
/*                width:120px;  */
        }
        #wpdev_bk-dialog .input_check {width:10px; margin:5px 10px;text-align:center;}
        #wpdev_bk-dialog .dialog-wraper {float:left;width:100%;}
        #wpdev_bk-dialog p.description {
            margin-left:180px;
        }
        #wpdev_bk-dialog .description {
            vertical-align: middle;
        }
        .ui-dialog-buttonset button { margin:0 5px !important}
        .bk_help_message{
            background-color: #FFFFE0;
            border: 1px solid #E6DB55;
            border-radius: 3px;
            margin:0 0 10px;
            padding: 5px;
            width: 98%;
            color:#777;
        }
        #wpdev_bk-dialog .wpbc_sub_options {
            background: none repeat scroll 0 0 #F3F3F3;
            border: 1px solid #DDDDDD;
            border-radius: 3px;
            box-shadow: 0 0 1px #FFFFFF;
            margin: 0;
            padding: 5px 10px;
            width: auto;
        }
        .booking_configuration_dialog {
            width:650px;
            height:110px;
            display:none;
        }
        <?php 
    make_bk_action('show_insertion_popup_css_for_tabs');
    ?>
    </style>
    <?php 
}
コード例 #15
0
 function run()
 {
     // Define some variables  //////////////////////////////////////////////
     $is_send_emeils = 0;
     // ( ( get_bk_option( 'booking_gcal_is_send_email') == 'On' ) ? 1 : 0 );
     $this->events = array();
     //        $url = $this->feed_url;
     //
     //        // Break the feed URL up into its parts (scheme, host, path, query)
     //        $url_parts = parse_url( $url );
     //
     //        if (! isset($url_parts['path']))                                        // Something wrong with  URL
     //            return  false;
     //
     //        $scheme_and_host = $url_parts['scheme'] . '://' . $url_parts['host'];
     //
     //        // Remove the exisitng projection from the path, and replace it with '/full-noattendees'
     //        $path = substr( $url_parts['path'], 0, strrpos( $url_parts['path'], '/' ) ) . '/full-noattendees';
     //
     //        // Add the default parameters to the querystring (retrieving JSON, not XML)
     //        $query = '?alt=json&singleevents=false&sortorder=ascending&orderby=starttime';
     $gmt_offset = get_option('gmt_offset') * 3600;
     //$this->feed_url = '*****@*****.**';
     $url = 'https://www.googleapis.com/calendar/v3/calendars/' . $this->feed_url . '/events';
     // Google API Key    -- public Google API key shared across all plugin users. Currently the shared key is limited to 500,000 requests per day and 5 requests per second.
     $api_key = get_bk_option('booking_gcal_api_key');
     // Set API key
     $url .= '?key=' . $api_key;
     $args['timeMin'] = urlencode(date('c', $this->booking_gcal_events_from - $gmt_offset));
     $args['timeMax'] = urlencode(date('c', $this->booking_gcal_events_until - $gmt_offset));
     $args['maxResults'] = $this->booking_gcal_events_max;
     $args['singleEvents'] = 'True';
     //'False';                              // Each  recurrent event will be showing as separate booking.  Google Description: Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
     if (!empty($this->booking_gcal_timezone)) {
         $args['timeZone'] = $this->booking_gcal_timezone;
     }
     $url = add_query_arg($args, $url);
     //        //Append the feed specific parameters to the querystring
     //        $query .= '&start-min=' . date( 'Y-m-d\TH:i:s', $this->booking_gcal_events_from - $gmt_offset );
     //        $query .= '&start-max=' . date( 'Y-m-d\TH:i:s', $this->booking_gcal_events_until - $gmt_offset );
     //        $query .= '&max-results=' . $this->booking_gcal_events_max;
     //
     //        if ( ! empty( $this->booking_gcal_timezone ) )
     //                $query .= '&ctz=' . $this->booking_gcal_timezone;
     //
     //        //If enabled, use experimental 'fields' parameter of Google Data API, so that only necessary data is retrieved. This *significantly* reduces amount of data to retrieve and process
     //        // $query .= '&fields=entry(title,link[@rel="alternate"],content,gd:where,gd:when,gCal:uid)';
     //
     //        $url =  $scheme_and_host . $path . $query;
     $this->show_message(__('Importing Feed', 'booking') . ': ' . $url, true);
     //debuge($url);
     //Retrieve the feed data
     $raw_data = wp_remote_get($url, array('sslverify' => false, 'timeout' => 10));
     //debuge($raw_data);
     //If $raw_data is a WP_Error, something went wrong
     if (!is_wp_error($raw_data)) {
         //If response code isn't 200, something went wrong
         if (200 == $raw_data['response']['code']) {
             $this->show_message(__('Data Parsing', 'booking'), true);
             //Attempt to convert the returned JSON into an array
             $raw_data = json_decode($raw_data['body'], true);
             //debuge($raw_data);
             //If decoding was successful
             if (!empty($raw_data)) {
                 //If there are some entries (events) to process
                 if (isset($raw_data['items'])) {
                     //Loop through each event, extracting the relevant information
                     foreach ($raw_data['items'] as $event) {
                         //debuge($event);
                         $id = esc_html($event['id']);
                         $title = isset($event['summary']) ? esc_html($event['summary']) : '';
                         $description = isset($event['description']) ? esc_html($event['description']) : '';
                         //$link        = esc_url( $event['link'][0]['href'] );
                         $location = isset($event['location']) ? esc_html($event['location']) : '';
                         if (isset($event['creator']) && isset($event['creator']['email'])) {
                             $event_author_email = esc_html($event['creator']['email']);
                         } else {
                             $event_author_email = '';
                         }
                         if (isset($event['start']) && isset($event['end'])) {
                             list($range_dates, $range_time) = $this->getCommaSeparatedDates($event['start'], $event['end']);
                         } else {
                             continue;
                         }
                         // Skip  if we gave no dates
                         //debuge($range_dates, $range_time);
                         $bktype = $this->getResource();
                         $previous_active_user = -1;
                         // MU
                         if (class_exists('wpdev_bk_multiuser')) {
                             // Get  the owner of this booking resource
                             $user_bk_id = apply_bk_filter('get_user_of_this_bk_resource', false, $bktype);
                             // Check if its different user
                             if ($user_bk_id !== false && $this->getUserID() != $user_bk_id) {
                                 // Get possible other active user settings
                                 $previous_active_user = apply_bk_filter('get_client_side_active_params_of_user');
                                 // Set active user of that specific booking resource
                                 make_bk_action('check_multiuser_params_for_client_side_by_user_id', $user_bk_id);
                             }
                         }
                         $booking_gcal_events_form_fields = get_bk_option('booking_gcal_events_form_fields');
                         if (is_serialized($booking_gcal_events_form_fields)) {
                             $booking_gcal_events_form_fields = unserialize($booking_gcal_events_form_fields);
                         }
                         // MU
                         if ($previous_active_user !== -1) {
                             // Reactivate the previous active user
                             make_bk_action('check_multiuser_params_for_client_side_by_user_id', $previous_active_user);
                         }
                         $booking_gcal_events_form_fields1 = explode('^', $booking_gcal_events_form_fields['title']);
                         $booking_gcal_events_form_fields1 = empty($booking_gcal_events_form_fields1[1]) ? false : true;
                         $booking_gcal_events_form_fields2 = explode('^', $booking_gcal_events_form_fields['description']);
                         $booking_gcal_events_form_fields2 = empty($booking_gcal_events_form_fields2[1]) ? false : true;
                         $booking_gcal_events_form_fields3 = explode('^', $booking_gcal_events_form_fields['where']);
                         $booking_gcal_events_form_fields3 = empty($booking_gcal_events_form_fields3[1]) ? false : true;
                         $submit_array = array('bktype' => $bktype, 'dates' => $range_dates, 'form' => $range_time . ($booking_gcal_events_form_fields1 ? trim($booking_gcal_events_form_fields['title']) . "{$bktype}^{$title}~" : '') . ($booking_gcal_events_form_fields2 ? trim($booking_gcal_events_form_fields['description']) . "{$bktype}^{$description}~" : '') . ($booking_gcal_events_form_fields3 ? trim($booking_gcal_events_form_fields['where']) . "{$bktype}^{$location}" : ''), 'is_send_emeils' => $is_send_emeils, 'sync_gid' => $id);
                         // Add imported data to the array of events
                         $this->events[] = array('sync_gid' => $id, 'title' => $title, 'description' => $description, 'location' => $location, 'dates' => $range_dates, 'times' => $range_time, 'booking_submit_data' => $submit_array);
                     }
                 }
             } else {
                 //json_decode failed
                 $this->error = __('Some data was retrieved, but could not be parsed successfully. Please ensure your feed URL is correct.', GCE_TEXT_DOMAIN);
             }
         } else {
             //The response code wasn't 200, so generate a helpful(ish) error message depending on error code
             switch ($raw_data['response']['code']) {
                 case 404:
                     $this->error = __('The feed could not be found (404). Please ensure your feed URL is correct.', 'booking');
                     break;
                 case 403:
                     $this->error = __('Access to this feed was denied (403). Please ensure you have public sharing enabled for your calendar.', 'booking');
                     break;
                 default:
                     $this->error = sprintf(__('The feed data could not be retrieved. Error code: %s. Please ensure your feed URL is correct.', 'booking'), $raw_data['response']['code']);
             }
         }
     } else {
         //Generate an error message from the returned WP_Error
         $this->error = $raw_data->get_error_message();
     }
     if (!empty($this->error)) {
         $is_spin = false;
         $is_error = true;
         $this->show_message($this->error, $is_spin, $is_error);
         return false;
     } else {
         $this->show_message(__('Done', 'booking'));
     }
     // Get Already  exist same bookings
     $exist_bookings_guid = $this->getExistBookings_gid($this->events);
     // Create New bookings
     if (!empty($this->events)) {
         $this->createNewBookingsFromEvents($exist_bookings_guid);
     }
     // Show imported Bookings Table
     if (!empty($this->events) && !$this->is_silent) {
         $this->showImportedEvents();
     }
     return true;
 }