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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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); } }
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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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="height:20px;width:100%;text-align:center;margin:15px auto;"><?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); } }
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '') { $user = wp_get_current_user(); $user_bk_id = $user->ID; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Gathering data about the booking to show in the calendar !!! //////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get it from the option settings $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode'); // '<span style="font-size:07px;">[id]</span>:[name]'; if ($title != '') { $title .= ' / '; } // Other Booking in the same day $title .= $bk_id; if ($title_in_day != '') { $title_in_day .= ','; } // Other Booking in the same day //$title_in_day .= $bk_id ; if (function_exists('get_title_for_showing_in_day')) { $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template); } else { $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name']; } if ($title_hint != '') { $title_hint .= ' <hr style="margin:10px 5px;" /> '; } // Other Booking in the same day $title_hint .= '<div class=\'booking-listing-collumn\' >'; if (function_exists('get_booking_title')) { if (isset($booking_types[$bookings[$bk_id]->booking_type])) { $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title; } else { $bk_title = get_booking_title($bookings[$bk_id]->booking_type); } $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>'; } else { $bk_title = ''; } $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title; if (class_exists('wpdev_bk_biz_s')) { $title_hint .= '<div style=\'float:right;\'>'; if (function_exists('wpdev_bk_get_payment_status_simple')) { $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status); $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'wpdev-booking') . '</span> ' . $pay_status . '</span>'; } else { $pay_status = ''; } $title_hint .= ' ' . $pay_status; $currency = apply_bk_filter('get_currency_info'); $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost); $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>'; $title_hint .= '</div>'; } $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>'; //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ; //$title_hint .= ' '. $bookings[$bk_id]->remark; //BL $bk_dates_short_id = array(); if (count($bookings[$bk_id]->dates) > 0) { $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array(); } // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 ) $is_approved = 0; if (count($bookings[$bk_id]->dates) > 0) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types); $short_dates_content = str_replace('"', "'", $short_dates_content); $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>'; // $reload_time = 2000; // setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.'); /** $title_hint .= '<div style=\'text-align:right;\'>'; if ( class_exists('wpdev_bk_personal') ) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/'. WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation' ; $bk_hash = (isset($bookings[$bk_id]->hash))?$bookings[$bk_id]->hash:''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type='.$bk_booking_type.'&booking_hash='.$bk_hash.'&parent_res=1' ; $title_hint .= '<a style=\'margin:-60px 20px 0 2px;position:absolute;right:0px;\' href=\''.$edit_booking_url .'\' onclick=\'\' ><i class=\'icon-edit\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/edit_type.png\' style=\'width:12px; height:13px;\'--></a>'; } $title_hint .= '<a style=\'margin:-40px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-ok-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'--></a>'; $title_hint .= '<a style=\'margin:-22px 20px 0 0;position:absolute;right:0px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-ban-circle\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'--></a>'; $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );\' ><i class=\'icon-trash\'></i><!--img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'--></a>'; $title_hint .= '</div>'; /**/ $is_approved = 0; if (!empty($bookings[$bk_id]->dates)) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\' style=\'display: inline; line-height: 1em; padding: 10px; vertical-align: text-top;\'>'; if (class_exists('wpdev_bk_personal')) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation'; $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : ''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>'; } $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ok-circle\'></i></a>'; $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ban-circle\'></i></a>'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-trash\'></i></a>'; $title .= '</div>'; //cell_bk_id_10 time_section_in_day timeslots_in_this_day1 time_hour0 time_in_days_num_30 time_booked_in_day approved /** $title_hint .= '<div style=\'text-align:right;\'>'; $title_hint .= '<a style=\'margin:-40px 0 0 0;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif\' style=\'width:14px; height:14px;\'></a>'; // $title_hint .= ' <a href="javascript:void(0)" class="tooltip_bottom approve_bk_link '. ( ($is_approved)?' hidden_items ':'') .' " // onclick="javascript:approve_unapprove_booking('. $bk_id.',1, '. $user_bk_id. ', \''. getBookingLocale() .'\' , 1 );" // ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/accept-24x24.gif" style="width:14px; height:14px;"></a>'; // $title_hint .= '<a style=\'margin:-22px 0 0 -6px;position:absolute;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking('. $bk_id.',0, '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png\' style=\'margin:0px 5px;width:15px; height:15px;\'></a>'; // $title_hint .= '<a href="javascript:void(0)" class="tooltip_bottom pending_bk_link '. ( (! $is_approved)? ' hidden_items ':'' ) .' " // onclick="javascript:approve_unapprove_booking('. $bk_id .',0, '. $user_bk_id .', \''. getBookingLocale() .'\' , 1 );" // ><img src="' . WPDEV_BK_PLUGIN_URL .'/img/remove-16x16.png" style="width:15px; height:15px;"></a>'; // //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to set booking as pending ?', 'wpdev-booking')) .'\') ) $title_hint .= '<a href=\'javascript:;\' onclick=\'javascript:delete_booking('. $bk_id.', '. $user_bk_id .', "'. getBookingLocale() .'" , 1 );setTimeout(function ( ) {location.reload(true);} ,'.$reload_time.');\' ><img src=\'' . WPDEV_BK_PLUGIN_URL .'/img/delete_type.png\' style=\'width:13px; height:13px;\'></a>'; //if ( bk_are_you_sure(\''. esc_js(__('Do you really want to delete this booking ?', 'wpdev-booking')) .'\') ) $title_hint .= '</div>'; /**/ $title_hint .= '</div>'; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// return array($title_in_day, $title, $title_hint, $is_approved); }
function get_booking_info_4_tooltip($bk_id, $bookings, $booking_types, $title_in_day = '', $title = '', $title_hint = '') { $user = wp_get_current_user(); $user_bk_id = $user->ID; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Gathering data about the booking to show in the calendar !!! //////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Get it from the option settings $what_show_in_day_template = get_bk_option('booking_default_title_in_day_for_calendar_view_mode'); // '<span style="font-size:07px;">[id]</span>:[name]'; if ($title != '') { $title .= ' / '; } // Other Booking in the same day $title .= $bk_id; if ($title_in_day != '') { $title_in_day .= ','; } // Other Booking in the same day //$title_in_day .= $bk_id ; if (function_exists('get_title_for_showing_in_day')) { $title_in_day .= get_title_for_showing_in_day($bk_id, $bookings, $what_show_in_day_template); } else { $title_in_day .= $bk_id . ':' . $bookings[$bk_id]->form_data['_all_fields_']['name']; } if ($title_hint != '') { $title_hint .= ' <hr style="margin:10px 5px;" /> '; } // Other Booking in the same day $title_hint .= '<div class=\'booking-listing-collumn\' >'; if (function_exists('get_booking_title')) { if (isset($booking_types[$bookings[$bk_id]->booking_type])) { $bk_title = $booking_types[$bookings[$bk_id]->booking_type]->title; } else { $bk_title = get_booking_title($bookings[$bk_id]->booking_type); } $bk_title = '<span class=\'label label-resource label-info\'>' . $bk_title . '</span>'; } else { $bk_title = ''; } $title_hint .= '<span class=\'field-id\'>' . $bk_id . '</span>' . ' ' . $bk_title; if (class_exists('wpdev_bk_biz_s')) { $title_hint .= '<div style=\'float:right;\'>'; if (function_exists('wpdev_bk_get_payment_status_simple')) { $pay_status = wpdev_bk_get_payment_status_simple($bookings[$bk_id]->pay_status); $pay_status = '<span class=\'label label-payment-status payment-label-unknown\'><span style=\'font-size:07px;\'>' . __('Payment', 'booking') . '</span> ' . $pay_status . '</span>'; } else { $pay_status = ''; } $title_hint .= ' ' . $pay_status; $currency = apply_bk_filter('get_currency_info'); $show_cost_value = wpdev_bk_cost_number_format($bookings[$bk_id]->cost); $title_hint .= ' <div class="cost-fields-group" style=\'float:right; margin:2px;\'>' . $currency . ' ' . $show_cost_value . '</div>'; $title_hint .= '</div>'; } $title_hint .= '<div>' . $bookings[$bk_id]->form_show . '</div>'; //$bookings[$bk_id]->form_data['name'].' ' . $bookings[$bk_id]->form_data['secondname'] ; //$title_hint .= ' '. $bookings[$bk_id]->remark; //BL $bk_dates_short_id = array(); if (count($bookings[$bk_id]->dates) > 0) { $bk_dates_short_id = isset($bookings[$bk_id]->dates_short_id) ? $bookings[$bk_id]->dates_short_id : array(); } // Array ([0] => [1] => .... [4] => 6... [11] => [12] => 8 ) $is_approved = 0; if (count($bookings[$bk_id]->dates) > 0) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $short_dates_content = wpdevbk_get_str_from_dates_short($bookings[$bk_id]->dates_short, $is_approved, $bk_dates_short_id, $booking_types); $short_dates_content = str_replace('"', "'", $short_dates_content); $title_hint .= '<div style=\'margin-top:5px;\'>' . $short_dates_content . '</div>'; $is_approved = 0; if (!empty($bookings[$bk_id]->dates)) { $is_approved = $bookings[$bk_id]->dates[0]->approved; } $title .= '<div class=\'timeline_info_bk_actionsbar_' . $bk_id . '\' style=\'display: inline; line-height: 1em; padding: 10px; vertical-align: text-top;\'>'; $is_can = true; //current_user_can( 'edit_posts' ); if ($is_can) { if (class_exists('wpdev_bk_personal')) { $bk_url_add = 'admin.php?page=' . WPDEV_BK_PLUGIN_DIRNAME . '/' . WPDEV_BK_PLUGIN_FILENAME . 'wpdev-booking-reservation'; $bk_hash = isset($bookings[$bk_id]->hash) ? $bookings[$bk_id]->hash : ''; $bk_booking_type = $bookings[$bk_id]->booking_type; $edit_booking_url = $bk_url_add . '&booking_type=' . $bk_booking_type . '&booking_hash=' . $bk_hash . '&parent_res=1'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'' . $edit_booking_url . '\' onclick=\'\' ><i class=\'icon-edit\'></i></a>'; } $title .= '<a class=\'button button-secondary approve_bk_link ' . ($is_approved ? 'hidden_items' : '') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',1, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ok-circle\'></i></a>'; $title .= '<a class=\'button button-secondary pending_bk_link ' . ($is_approved ? '' : 'hidden_items') . '\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:approve_unapprove_booking(' . $bk_id . ',0, ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-ban-circle\'></i></a>'; $title .= '<a class=\'button button-secondary\' style=\'margin-right:5px;\' href=\'javascript:;\' onclick=\'javascript:delete_booking(' . $bk_id . ', ' . $user_bk_id . ', "' . getBookingLocale() . '" , 1 );\' ><i class=\'icon-trash\'></i></a>'; } $title .= '</div>'; $title_hint .= '</div>'; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// return array($title_in_day, $title, $title_hint, $is_approved); }
function sendPaymentRequestEmail($booking_id, $bktype, $formdata, $reason = '') { $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_payment_request_adress')); $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_payment_request_subject')); $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_payment_request_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_to_send = $mail_body; $mail_subject_to_send = $mail_subject; if (function_exists('get_booking_title')) { $bk_title = get_booking_title($bktype); } else { $bk_title = ''; } $my_dates4emeil = get_dates_str($booking_id); 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); } $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]); $my_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id); $booking_form_show = get_form_content($formdata, $bktype, '', array('booking_id' => $booking_id, 'id' => $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' => $my_cost, 'siteurl' => htmlspecialchars_decode('<a href="' . home_url() . '">' . home_url() . '</a>'), 'resource_title' => $bk_title, 'bookingtype' => $bk_title, 'paymentreason' => $reason)); $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, $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('\\n', '<br />', $mail_body_to_send); // Fix issue of showing /n instead of the new line $mail_recipients = $booking_form_show['email']; $mail_headers = "From: {$mail_sender}\nContent-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 (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 $is_email_payment_request_send_copy_to_admin = get_bk_option('booking_is_email_payment_request_send_copy_to_admin'); $mail_recipient = htmlspecialchars_decode(get_bk_option('booking_email_reservation_adress')); if ($is_email_payment_request_send_copy_to_admin == 'On') { 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_for_admin); } } } if (strpos($mail_recipient, '@blank.com') === false && strpos($mail_body_to_send, '*****@*****.**') === false) { return true; } else { return false; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }
function sendDeclineEmails($approved_id_str, $is_send_emeils, $denyreason = '') { //debuge($approved_id_str, $is_send_emeils); global $wpdb; $sql = "SELECT * FROM " . $wpdb->prefix . "booking as bk\n WHERE bk.booking_id IN ({$approved_id_str})"; $result = $wpdb->get_results($wpdb->prepare($sql)); $mail_sender = htmlspecialchars_decode(get_bk_option('booking_email_deny_adress')); $mail_subject = htmlspecialchars_decode(get_bk_option('booking_email_deny_subject')); $mail_body = htmlspecialchars_decode(get_bk_option('booking_email_deny_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) { // Sending mail /////////////////////////////////////////////////////// if (function_exists('get_booking_title')) { $bk_title = get_booking_title($res->booking_type); } else { $bk_title = ''; } $booking_form_show = get_form_content($res->form, $res->booking_type); $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)); } $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('[denyreason]', $denyreason, $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"; if (get_bk_option('booking_is_email_deny_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_deny_send_copy_to_admin = get_bk_option('booking_is_email_deny_send_copy_to_admin'); if ($is_email_deny_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); } } } ///////////////////////////////////////////////////////////////////////// } }
public function showImportedEvents() { //////////////////////////////////////////////////////////////////////// ?> <table style="width:100%;margin-top:45px;" id="gcal_imported_events<?php echo $this->getResource(); ?> " class="resource_table booking_table" cellpadding="0" cellspacing="0"> <?php if (function_exists('get_booking_title')) { echo '<tr><td colspan="6" style="padding:5px 10px;font-style:italic;"> <h4>', get_booking_title($this->getResource()), '</h4></td></tr>'; } ?> <?php // Headers ?> <tr> <th style="width:15px;"><input type="checkbox" onclick="javascript:jQuery('#gcal_imported_events<?php echo $this->getResource(); ?> .events_items').attr('checked', this.checked);" class="" id="events_items_all" name="events_items_all" /></th> <th style="width:10px;height:35px;border-left: 1px solid #BBBBBB;"> <?php _e('ID', 'booking'); ?> </th> <th style="height:35px;width:220px;" style="border-left: 1px solid #ccc;"> <?php _e('Title', 'booking'); ?> </th> <th style="text-align:center;"> <?php _e('Info', 'booking'); ?> </th> <th style="text-align:center;"> <?php _e('Dates', 'booking'); ?> </th> <th style="width:10px;height:35px;border-left: 1px solid #BBBBBB;"> <?php _e('GID', 'booking'); ?> </th> </tr> <?php $alternative_color = ''; if (!empty($this->events)) { foreach ($this->events as $bt) { if ($alternative_color == '') { $alternative_color = ' class="alternative_color" '; } else { $alternative_color = ''; } ?> <tr id="gcal_imported_events_id_<?php echo $bt['id']; ?> "> <td <?php echo $alternative_color; ?> ><span class="wpbc_mobile_legend"><?php _e('Selection', 'booking'); ?> :</span><input type="checkbox" class="events_items" id="events_items_<?php echo $bt['id']; ?> " value="<?php echo $bt['id']; ?> " name="events_items_<?php echo $bt['id']; ?> " /></td> <td style="border-left: 1px solid #ccc;text-align: center;" <?php echo $alternative_color; ?> ><span class="wpbc_mobile_legend"><?php _e('ID', 'booking'); ?> :</span><?php echo $bt['id']; ?> </td> <td <?php echo $alternative_color; ?> style="border-left: 1px solid #ccc;"> <span class="wpbc_mobile_legend"><?php _e('Title', 'booking'); ?> :</span> <span ><?php echo $bt['title']; ?> </span> </td> <td style="border-right: 0px;border-left: 1px solid #ccc;text-align: center;" <?php echo $alternative_color; ?> > <span class="wpbc_mobile_legend"><?php _e('Info', 'booking'); ?> :</span> <span ><?php echo $bt['description']; ?> </span><br/> <?php if (!empty($bt['location'])) { echo '<span >', __('Location:', 'booking'), ': ', $bt['location'], '</span>'; } ?> </td> <td style="border-right: 0px;border-left: 1px solid #ccc;text-align: center;" <?php echo $alternative_color; ?> > <span class="booking-listing-collumn booking-dates"> <span class="wpbc_mobile_legend"><?php _e('Dates', 'booking'); ?> :</span> <div class="booking_dates_full" style="font-size: 11px;padding:3px 5px;" ><?php $bt['dates'] = explode(', ', $bt['dates']); foreach ($bt['dates'] as $keyd => $valued) { $valued = explode('.', $valued); $valued = wpdevbk_get_date_in_correct_format(sprintf("%04d-%02d-%02d", $valued[2], $valued[1], $valued[0])); $bt['dates'][$keyd] = '<a href="javascript:void(0)" class="field-booking-date" style="font-weight: normal;">' . $valued[0] . '</a>'; } $bt['dates'] = implode('<span class="date_tire" style="font-size: 12px;">, </span>', $bt['dates']); echo $bt['dates']; //date_i18n('d.m.Y H:i',$bt['start_time'] ), ' - ', date_i18n('d.m.Y H:i',$bt['end_time']); ?> </div> </span> </td> <td style="border-left: 1px solid #ccc;text-align: center;" <?php echo $alternative_color; ?> ><span class="wpbc_mobile_legend"><?php _e('GID', 'booking'); ?> :</span><?php echo $bt['sync_gid']; ?> </td> </tr> <?php } } ?> <tr class="wpbc_table_footer"> <td colspan="6" style="text-align: center;"> <a href="javascript:void(0)" class="button button-primary" style="float:none;margin:10px;" onclick="javascript:location.reload();" ><?php _e('Reload page', 'booking'); ?> </a> <a href="javascript:void(0)" class="button" style="float:none;margin:10px;" onclick="javascript:jQuery('#gcal_imported_events<?php echo $this->getResource(); ?> ').remove();" ><?php _e('Hide', 'booking'); ?> </a> <a href="javascript:void(0)" class="button" style="float:none;margin:10px;" onclick="javascript: if ( bk_are_you_sure('<?php echo esc_js(__('Do you really want to delete selected booking(s) ?', 'booking')); ?> ') ) { delete_booking( get_selected_bookings_id_in_this_list('#gcal_imported_events<?php echo $this->getResource(); ?> .events_items', 13) , <?php echo $this->getUserID(); ?> , '<?php echo getBookingLocale(); ?> ' , 1 ); } " ><?php _e('Delete selected booking(s)', 'booking'); ?> </i></a> </td> </tr> </table> <script type="text/javascript"> jQuery("#gcal_imported_events<?php echo $this->getResource(); ?> ").insertAfter("#booking_listings_interface_header"); </script> <?php }