Booking Calendar - Version 6.2.1

Version Description

  • Features and issue fixings in All versions:
    • Fix Improve security checking during saving settings and searching in booking listing pages.
  • Personal / Business Small / Business Medium / Business Large / MultiUser versions features:
    • Fix showing of error message instead of stop working, during submitting new booking, if this booking possible only in different booking resources for different days, but system have not allow this. This issue exist in some situations for booking resources with specific capacity, when all payment options are deactivated. (fix:6.2.1.1) (Business Large, MultiUser)
    • Fix issue of incorrect working with required radio-button options. (fix:6.2.1.2) (Personal, Business Small/Medium/Large, MultiUser)
    • Fix issue of not calculating "LAST" option in "Valuation days" if previously used "Together" term. (fix:6.2.1.3) Description: the number of selected days in calendar
Download this release

Release Info

Developer wpdevelop
Plugin Icon 128x128 Booking Calendar
Version 6.2.1
Comparing to
See all releases

Code changes from version 6.2 to 6.2.1

js/client.js CHANGED
@@ -568,7 +568,8 @@ function mybooking_submit( submit_form , bk_type, wpdev_active_locale){
568
  if (element.checked)
569
  inp_value = element.value;
570
  else
571
- continue;
 
572
 
573
  } else {
574
  inp_value = element.value;
@@ -611,7 +612,7 @@ function mybooking_submit( submit_form , bk_type, wpdev_active_locale){
611
  return;
612
  }
613
  }
614
- if ((element.type !='checkbox') && ( inp_value === '')) {
615
  showErrorMessage( element , message_verif_requred);
616
  return;
617
  }
568
  if (element.checked)
569
  inp_value = element.value;
570
  else
571
+ inp_value = ''; //FixIn:6.2.1.2
572
+
573
 
574
  } else {
575
  inp_value = element.value;
612
  return;
613
  }
614
  }
615
+ if ((element.type !='checkbox') && (element.type !='radio') && ( inp_value === '')) { //FixIn:6.2.1.2
616
  showErrorMessage( element , message_verif_requred);
617
  return;
618
  }
lib/wpbc-booking-new.php CHANGED
@@ -1,690 +1,693 @@
1
- <?php
2
- /**
3
- * @version 1.0
4
- * @package Booking Calendar
5
- * @subpackage Create new bookings functions
6
- * @category Bookings
7
- *
8
- * @author wpdevelop
9
- * @link http://wpbookingcalendar.com/
10
- * @email info@wpbookingcalendar.com
11
- *
12
- * @modified 2014.04.23
13
- */
14
-
15
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
-
17
-
18
- // CAPTCHA CHECKING //////////////////////////////////////////////////////////////////////////////////////
19
- function wpbc_check_CAPTCHA( $the_answer_from_respondent, $prefix, $bktype ) {
20
-
21
- if (! ( ($the_answer_from_respondent == '') && ($prefix == '') ) ) {
22
- $captcha_instance = new wpdevReallySimpleCaptcha();
23
- $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
24
-
25
- if (! $correct) {
26
- $word = $captcha_instance->generate_random_word();
27
- $prefix = mt_rand();
28
- $captcha_instance->generate_image($prefix, $word);
29
-
30
- $filename = $prefix . '.png';
31
- $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' .$filename;
32
- $ref = substr($filename, 0, strrpos($filename, '.'));
33
- ?> <script type="text/javascript">
34
- document.getElementById('captcha_input<?php echo $bktype; ?>').value = '';
35
- document.getElementById('captcha_img<?php echo $bktype; ?>').src = '<?php echo $captcha_url; ?>';
36
- document.getElementById('wpdev_captcha_challenge_<?php echo $bktype; ?>').value = '<?php echo $ref; ?>';
37
- 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' ,'booking'); ?></span>';
38
- document.getElementById('submiting<?php echo $bktype; ?>').innerHTML ='';
39
- jQuery('#captcha_input<?php echo $bktype; ?>')
40
- .fadeOut( 350 ).fadeIn( 300 )
41
- .fadeOut( 350 ).fadeIn( 400 )
42
- .animate( {opacity: 1}, 4000 );
43
- jQuery("span.wpdev-help-message span.alert")
44
- .fadeIn( 1 )
45
- //.css( {'color' : 'red'} )
46
- .animate( {opacity: 1}, 10000 )
47
- .fadeOut( 2000 ); // hide message
48
- document.getElementById('captcha_input<?php echo $bktype; ?>').focus(); // make focus to elemnt
49
- jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false);
50
- </script> <?php
51
- return false;
52
- }
53
- }//////////////////////////////////////////////////////////////////////////////////////////////////////////
54
- return true;
55
- }
56
-
57
-
58
- // Customization for the integration of Mail Chimp Subscription.
59
- function wpbc_integrate_MailChimp($formdata , $bktype) {
60
- /*
61
- // Start Mail Chimp Customization
62
- $booking_form_show = get_form_content ($formdata , $bktype );
63
- if ( ( isset ($booking_form_show['subscribe_me'] )) && ( $booking_form_show['subscribe_me'] == 'yes') ) {
64
-
65
- 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/ )
66
- require_once(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.class.php' );
67
-
68
- $MailChimp = new MailChimp('key-my'); // You are need to specify here YOUR KEY !!!!
69
-
70
- $result = $MailChimp->call('lists/subscribe', array(
71
- 'id' => 'id' . $booking_id ,
72
- 'email' => array('email'=>$booking_form_show['email']),
73
- 'merge_vars' => array('FNAME'=>$booking_form_show['name'], 'LNAME'=>$booking_form_show['secondname']),
74
- 'double_optin' => false,
75
- 'update_existing' => true,
76
- 'replace_interests' => false,
77
- 'send_welcome' => false,
78
- ));
79
- // print_r($result);
80
- }
81
- } // End Mail Chimp Customization
82
- /**/
83
- }
84
-
85
-
86
- // Create new booking and make actions on HTML page
87
- function wpdev_bk_insert_new_booking() {
88
-
89
- $is_edit_booking = false;
90
-
91
- if ( isset($_POST['my_booking_hash']) && (! empty($_POST['my_booking_hash']) ) ) {
92
-
93
- $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id',false, $_POST['my_booking_hash'] );
94
- if ($my_booking_id_type !== false) {
95
- $is_edit_booking = array();
96
- $is_edit_booking['booking_id'] = $my_booking_id_type[0];
97
- $is_edit_booking['booking_type'] = $my_booking_id_type[1];
98
- $bktype = intval( $is_edit_booking['booking_type'] );
99
-
100
- // FixIn: 6.1.1.9
101
- // Check situation when we have editing "child booking resource", so need to reupdate calendar and form to have it for parent resource.
102
- if ( ( function_exists( 'wpbc_is_this_child_resource') ) && ( wpbc_is_this_child_resource( $bktype ) ) ){
103
- $bk_parent_br_id = wpbc_get_parent_resource( $bktype );
104
-
105
- $is_edit_booking['booking_type'] = $bk_parent_br_id;
106
- $bktype = $bk_parent_br_id;
107
- }
108
- // End: 6.1.1.9
109
- }
110
-
111
- } else {
112
- $bktype = intval( $_POST[ "bktype" ] );
113
- }
114
-
115
-
116
- if ( $bktype <= 0 ) {
117
- ?> <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 of saving data into DB. Unknown booking resource.',__FILE__,__LINE__); ?></div>'; }</script> <?php
118
- die('Error of saving data into DB. Unknown booking resource.');
119
- }
120
-
121
-
122
- // CAPTCHA CHECKING
123
- if ( isset($_POST['captcha_user_input']) && isset($_POST['captcha_chalange']) )
124
- if (! wpbc_check_CAPTCHA( $_POST['captcha_user_input'], $_POST['captcha_chalange'], $bktype ) )
125
- die;
126
-
127
- $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
128
- if ( $is_edit_booking !== false )
129
- if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) !==false ) {
130
- ?> <script type="text/javascript">
131
- if ( jQuery('#ajax_working' ).length ) {
132
- document.getElementById('ajax_working').innerHTML =
133
- '<div class="updated ajax_message" id="ajax_message">\n\
134
- <div style="float:left;"><?php echo __('Updating...' ,'booking'); ?></div> \n\
135
- <div class="wpbc_spin_loader">\n\
136
- <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
137
- </div>\n\
138
- </div>';
139
- }
140
- </script> <?php
141
- }
142
-
143
- $_POST["skip_page_checking_for_updating"] = 0;
144
- $_POST["is_show_payment_form"] = 1;
145
- $result_bk_id = wpbc_add_new_booking( $_POST , $is_edit_booking );
146
-
147
- if ( $result_bk_id !== false ) {
148
- ?> <script type="text/javascript"> <?php
149
-
150
- $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
151
- if ( $is_edit_booking !== false ) {
152
-
153
- if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) ===false ) {
154
-
155
- ?> setReservedSelectedDates('<?php echo $bktype; ?>'); <?php
156
-
157
- } else { ?>
158
- document.getElementById('ajax_message').innerHTML = '<?php echo __('Updated successfully' ,'booking'); ?>';
159
- jQuery('#ajax_message').fadeOut(1000);
160
- 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' ,'booking'); ?></div>';
161
- if ( jQuery('#wpdev_http_referer').length > 0 ) {
162
- location.href=jQuery('#wpdev_http_referer').val();
163
- } 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 $is_edit_booking['booking_id'] ; ?>';
164
- <?php
165
- }
166
-
167
- } else {
168
- ?> setReservedSelectedDates('<?php echo $bktype; ?>'); <?php
169
- }
170
-
171
- ?> </script> <?php
172
- }
173
-
174
- }
175
-
176
-
177
-
178
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
179
- // A D D N e w B o o k i n g
180
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
181
- //
182
- //$params = array(
183
- // ["bktype"] => 4
184
- // ["dates"] => 24.09.2014, 25.09.2014, 26.09.2014
185
- // ["form"] => select-one^rangetime4^14:00 - 16:00~text^name4^Costa~text^secondname4^Rika~email^email4^rika@cost.com~text^phone4^2423432~text^address4^Ferrari~text^city4^Rome~text^postcode4^2343~select-one^country4^IT~select-one^visitors4^1~select-one^children4^0~textarea^details4^dhfjksdhfkdhjs~checkbox^term_and_condition4[]^I Accept term and conditions
186
- // ["is_send_emeils"] => 1
187
- // ["booking_form_type"] =>
188
- // [wpdev_active_locale] => en_US
189
- //
190
- // // Paramters for adding booking in the HTML:
191
- // ["skip_page_checking_for_updating"] = 0;
192
- // ["is_show_payment_form"] = 1;
193
- // )
194
- //
195
- // Update Booking params:
196
- // $is_edit_booking = array(
197
- // 'booking_id' => 10
198
- // , 'booking_type' => 1
199
- // )
200
- //
201
- function wpbc_add_new_booking( $params , $is_edit_booking = false ){
202
-
203
- if ( $is_edit_booking !== false ) { // Edit booking
204
-
205
- $booking_id = $is_edit_booking['booking_id'];
206
- $bktype = $is_edit_booking['booking_type'];
207
-
208
- } else { // New booking
209
- if (! isset($params[ "bktype" ]))
210
- return false; // Error: Unknown booking resources
211
- else
212
- $bktype = intval( $params[ "bktype" ] );
213
- if ( $bktype == 0 )
214
- return false; // Error: Unknown booking resources
215
- }
216
-
217
- make_bk_action('check_multiuser_params_for_client_side', $bktype ); // Activate working with specific user in WP MU
218
-
219
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
220
- // Define init variables
221
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
222
- global $wpdb;
223
-
224
- $formdata = escape_any_xss( $params[ "form" ] );
225
-
226
- $my_modification_date = "'" . date_i18n( 'Y-m-d H:i:s' ) ."'" ; // Localize booking modification date
227
-
228
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
229
- // Get Dates
230
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
231
-
232
- $dates_in_diff_formats = wpbc_get_dates_in_diff_formats( $params[ "dates" ], $bktype, $formdata );
233
- //debuge($dates_in_diff_formats);
234
- $str_dates__dd_mm_yyyy = $dates_in_diff_formats['string'];
235
- // $my_dates = $dates_in_diff_formats['array'];
236
- $start_time = $dates_in_diff_formats['start_time'];
237
- $end_time = $dates_in_diff_formats['end_time'];
238
-
239
- //Here we need to check for double booking for the same sessions
240
- if ( ( ! $is_edit_booking ) &&
241
- (! wpbc_check_if_dates_free( $bktype, $formdata ,$dates_in_diff_formats, $start_time, $end_time ) )
242
- ) {
243
- die;
244
- }
245
-
246
-
247
- $my_check_in_date = explode( '-', $dates_in_diff_formats['array'][0] );
248
- $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] );
249
-
250
-
251
- if ( empty( $str_dates__dd_mm_yyyy ) ){
252
- ?> <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
253
- die('Error! No Dates');
254
- }
255
-
256
-
257
- $auto_approve_new_bookings_is_active = trim( get_bk_option( 'booking_auto_approve_new_bookings_is_active' ) );
258
- $is_approved_dates = ( $auto_approve_new_bookings_is_active == 'On' ) ? '1' : '0';
259
-
260
- // $booking_form_show = get_form_content( $formdata, $bktype, '', array());
261
- // if ( intval($booking_form_show['visitors'] ) > 4 )
262
- // $is_approved_dates = '1';
263
- // else $is_approved_dates = '0';
264
-
265
- // // Auto Approve booking from Booking > Add booking page for single booking resources
266
- // $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
267
- // if ( strpos( $_SERVER['HTTP_REFERER'], $admin_uri ) !== false )
268
- // $is_approved_dates = '1';
269
-
270
- $additional_fields = $additional_fields_vlaues = '';
271
- if ( isset( $params["sync_gid"] ) ) {
272
- $additional_fields = ", sync_gid" ;
273
- $additional_fields_vlaues = ", '" . wpbc_clean_parameter($params["sync_gid"]) . "'" ;
274
- }
275
-
276
- if ( $is_edit_booking === false ) {
277
-
278
- ////////////////////////////////////////////////////////////////////////////
279
- // Add new booking
280
- ////////////////////////////////////////////////////////////////////////////
281
- $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})" ;
282
-
283
- if ( false === $wpdb->query( $sql_insertion ) ){
284
- ?> <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
285
- die('Error during inserting into DB');
286
- }
287
- $booking_id = (int) $wpdb->insert_id; // Get ID of booking
288
-
289
- } else {
290
-
291
- ////////////////////////////////////////////////////////////////////////////
292
- // Edit booking
293
- ////////////////////////////////////////////////////////////////////////////
294
- $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};";
295
- if ( false === $wpdb->query( $update_sql ) ){
296
- ?> <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
297
- die('Error during updating exist booking in DB');
298
- }
299
-
300
- // Check if dates already aproved or no
301
- $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id}) LIMIT 0,1";
302
- $slct_sql_results = $wpdb->get_results( $slct_sql );
303
- if ( count($slct_sql_results) > 0 ) {
304
- $is_approved_dates = $slct_sql_results[0]->approved;
305
- }
306
-
307
- $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id})";
308
- if ( false === $wpdb->query( $delete_sql ) ){
309
- ?> <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
310
- die('Error during updating exist booking for deleting dates in DB');
311
- }
312
- }
313
-
314
-
315
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
316
- // Update the Hash and Cost of the booking
317
- make_bk_action('wpbc_update_booking_hash', $booking_id, $bktype );
318
- make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) , $formdata );
319
-
320
- // Auto approve booking if cost = 0.
321
- // $booking_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id ); // Auto approve booking if cost = 0.
322
- // $booking_cost = floatval( $booking_cost );
323
- // if ( empty( $booking_cost ) ) {
324
- // $is_approved_dates = '1';
325
- // }
326
-
327
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
328
-
329
- $insert = wpbc_get_SQL_to_insert_dates( $dates_in_diff_formats , $is_approved_dates, $booking_id );
330
-
331
- if ( !empty($insert) )
332
- if ( false === $wpdb->query( "INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert ) ){
333
- ?> <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
334
- die('Error during inserting into BD - Dates');
335
- }
336
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
337
-
338
- if ( isset( $params["is_send_emeils"] ) ) $is_send_emeils = $params["is_send_emeils"];
339
- else $is_send_emeils = 1;
340
-
341
-
342
- if ( $is_edit_booking === false ) {
343
-
344
- if ( $is_send_emeils != 0 )
345
- sendNewBookingEmails($booking_id, $bktype, $formdata) ;
346
-
347
- if ( ( isset( $params["is_show_payment_form"]) ) && ( $params["is_show_payment_form"] == 1 ) )
348
- do_action('wpdev_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
349
- else
350
- do_action('wpbc_update_cost_of_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
351
-
352
- // wpbc_integrate_MailChimp($formdata, $bktype);
353
-
354
- if (
355
- ( ( $auto_approve_new_bookings_is_active == 'On') && ($is_send_emeils != 0 ) )
356
- // || ($is_approved_dates == '1') // Auto approve and send email if cost = 0.
357
- ) {
358
- sendApproveEmails($booking_id, 1);
359
- }
360
-
361
- } else {
362
-
363
- if ($is_send_emeils != 0 )
364
- sendModificationEmails($booking_id, $bktype, $formdata );
365
-
366
- $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
367
-
368
- if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) === false ) {
369
-
370
- if ( ( isset( $params["is_show_payment_form"]) ) && ( $params["is_show_payment_form"] == 1 ) )
371
- do_action('wpdev_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
372
- else
373
- do_action('wpbc_update_cost_of_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
374
-
375
- }
376
-
377
- }
378
-
379
-
380
-
381
- // Re-Update booking resource TYPE if its needed here
382
- if ( isset( $params["skip_page_checking_for_updating"] ) ) $skip_page_checking_for_updating = (bool) $params["skip_page_checking_for_updating"];
383
- else $skip_page_checking_for_updating = true;
384
- 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 );
385
-
386
-
387
- make_bk_action('finish_check_multiuser_params_for_client_side', $bktype ); // Deactivate working with specific user in WP MU
388
-
389
- return $booking_id;
390
- }
391
- add_bk_filter('wpbc_add_new_booking_filter' , 'wpbc_add_new_booking' );
392
- add_bk_action('wpbc_add_new_booking' , 'wpbc_add_new_booking' );
393
- /*
394
- make_bk_action('wpbc_add_new_booking' , array(
395
- 'bktype' => 1
396
- , 'dates' => '27.08.2014, 28.08.2014, 29.08.2014'
397
- , 'form' => 'select-one^rangetime1^10:00 - 12:00~text^name1^Jo~text^secondname1^Smith~email^email1^smith@gmail.com~text^phone1^678676678~text^address1^Linkoln Street~text^city1^London~text^postcode1^78788~select-one^country1^GB~select-one^visitors1^1~select-one^children1^1~textarea^details1^Rooms with sea view~checkbox^term_and_condition1[]^I Accept term and conditions'
398
- , 'is_send_emeils' => 0
399
- // , 'booking_form_type' => ''
400
- // , 'wpdev_active_locale' => 'en_US'
401
- ) ); /**/
402
-
403
-
404
-
405
- /** Check if dates intersect with other dates array
406
- *
407
- * @param array $dates_for_check - Dates Array of specific booking, which we checking - date in SQL format: '2014-11-21 10:00:01'
408
- * @param array $dates_exist - Other dates from booking resource(s), that already exist - date in SQL format: '2014-11-21 15:00:02'
409
- * @return bool true - intersect, false - not intersect
410
- */
411
- function wpbc_check_dates_intersections( $dates_for_check, $dates_exist ) { // FixIn: 5.4.5
412
-
413
- $is_intersected = false;
414
-
415
- $booked_dates = array();
416
- $what_dates_to_check = array();
417
-
418
- //debuge($dates_for_check, $dates_exist);
419
-
420
- foreach ( $dates_exist as $value ) {
421
-
422
- if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
423
- $booking_date = $value->booking_date; // Its object with date value
424
- else
425
- $booking_date = $value; // Its array of string dates
426
-
427
-
428
- if ( intval( substr( $booking_date, -1 ) ) == 1 ) { // We require time shift for situation, when previous booking end in the same time, when new booking start
429
- $time_shift = 10; // Plus 10 seconds
430
- } elseif ( intval( substr( $booking_date, -1 ) ) == 2 ) {
431
- $time_shift = -10; // Minus 10 seconds
432
- } else
433
- $time_shift = 0;
434
-
435
- // Booked dates in destination resource, that can intersect
436
- $booked_dates[ $booking_date ] = strtotime( $booking_date ) + $time_shift;;
437
-
438
- // Get here only dates, without times: [2015-11-09] => 1447027200
439
- $what_dates_to_check[ substr($booking_date, 0, 10) ] = strtotime( substr($booking_date, 0, 10) );
440
- }
441
-
442
- asort( $booked_dates ); // Sort dates
443
-
444
-
445
- $keyi=0;
446
- $dates_to_add = array();
447
- foreach ( $booked_dates as $date_key => $date_value ) {
448
-
449
- if ( $keyi == 0 ) { // First element
450
- if ( intval( substr( $date_key, -1 ) ) == 2 ) {
451
- // We are having first date as ending date, its means that starting date exist somewhere before, and we need to set it at the begining
452
- $dates_to_add[ substr($date_key, 0, 10) . ' 00:00:11' ] = strtotime( substr($date_key, 0, 10) . ' 00:00:11' );
453
- }
454
- }
455
-
456
- if ( $keyi == ( count($booked_dates) - 1 ) ) { // last element
457
- if ( intval( substr( $date_key, -1 ) ) == 1 ) {
458
- // We are having last date as ending date, its means that ending date exist somewhere after, and we need to set it at the end of array
459
- $dates_to_add[ substr($date_key, 0, 10) . ' 23:59:42' ] = strtotime( substr($date_key, 0, 10) . ' 23:59:42' );
460
- }
461
- }
462
- $keyi++;
463
- }
464
- $booked_dates = array_merge($booked_dates, $dates_to_add);
465
- asort( $booked_dates ); // Sort dates
466
-
467
-
468
- // Skip dates (in original booking) that does not exist in destination resource at all
469
- $check_dates = array();
470
- foreach ( $dates_for_check as $value ) {
471
-
472
- if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
473
- $booking_date = $value->booking_date; // Its object with date value
474
- else
475
- $booking_date = $value; // Its array of string dates
476
-
477
- // Check dates only if these dates already exist in $what_dates_to_check array
478
- if ( ( isset( $what_dates_to_check[ substr($booking_date, 0, 10) ] ) ) ) //|| ( intval( substr( $booking_date, -1 ) ) != 0 ) )
479
- $check_dates[] = $value;
480
- }
481
-
482
- if ( count( $check_dates ) == 0 ) return $is_intersected; // No intersected dates at all in exist bookings. Return. //FixIn: 6.0.1.13
483
-
484
- foreach ( $check_dates as $value ) {
485
-
486
- if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
487
- $booking_date = $value->booking_date; // Its object with date value
488
- else
489
- $booking_date = $value; // Its array of string dates
490
-
491
- if ( isset( $booked_dates[ $booking_date ] ) ) { // Already have exactly this date as booked
492
- $is_intersected = true;
493
- break;
494
- }
495
-
496
- if ( intval( substr( $booking_date, -1 ) ) == 1 ) { // We require time shift for situation, when previous booking end in the same time, when new booking start
497
- $time_shift = 10; // Plus 10 seconds
498
- } elseif ( intval( substr( $booking_date, -1 ) ) == 2 ) {
499
- $time_shift = -10; // Minus 10 seconds
500
- } else
501
- $time_shift = 0;
502
-
503
- $booked_dates[ $booking_date ] = strtotime( $booking_date ) + $time_shift;
504
- }
505
-
506
-
507
- asort( $booked_dates ); // Sort dates
508
-
509
- //debuge('$booked_dates',$booked_dates);
510
- if ( ! $is_intersected ) {
511
-
512
- // check dates and times for intersections
513
- $previos_date_key = 0;
514
- foreach ( $booked_dates as $date_key => $value ) {
515
-
516
- $date_key = intval( substr( $date_key, -1 ) ); // Get last second
517
-
518
- // Check if the date fully booked (key = 0), or we are having 2 the same keys, like 1 and 1 or 2 and 2 one under other. Its means that we are having time intersection.
519
- if ( ( $date_key !== 0 ) && ( $date_key != $previos_date_key ) )
520
- $previos_date_key = $date_key;
521
- else {
522
- $is_intersected = true;
523
- break;
524
- }
525
- }
526
- }
527
-
528
- return $is_intersected ;
529
- }
530
-
531
-
532
- /**
533
- * Checking for bookings in the same session and prevention of the double booking
534
- *
535
- * @param type $bktype
536
- * @param type $formdata
537
- * @param type $str_dates__dd_mm_yyyy
538
- * @param type $start_time
539
- * @param type $end_time
540
- * @return true|false - free or unavailable
541
- */
542
- function wpbc_check_if_dates_free($bktype, $formdata ,$dates_in_diff_formats, $start_time, $end_time) {
543
-
544
- if ( ( get_bk_option( 'booking_check_on_server_if_dates_free' ) == 'Off') // Check if this feature active or not
545
- || ( get_bk_option( 'booking_is_days_always_available' ) == 'On') // Check if any days available feature is active
546
- ) return true;
547
-
548
- //TODO: Finish checking for parent booking resources
549
- // We need to get availabaility for the specific dates
550
- // We need to rewrite
551
- // function show_availability_at_calendar
552
- // for getting availability only for the specific dates
553
- // and then based on the availability approve or decline this current booking.
554
- if ( class_exists('wpdev_bk_biz_l')) {
555
- $number_of_child_resources = apply_bk_filter('wpbc_get_number_of_child_resources', $bktype );
556
- if ( $number_of_child_resources > 1 ) // if this booking resources - parent, then do not chekc it, yet!
557
- return true;
558
- }
559
-
560
- // $is_days_free = true;
561
-
562
- ////////////////////////////////////////////////////////////////////////////
563
- // Get Selected Dates Array in full format - all possible dates and times //
564
- ////////////////////////////////////////////////////////////////////////////
565
- //Example:
566
- // [0] => 2014-11-21 10:00:01
567
- // [1] => 2014-11-21 12:00:02
568
- // [2] => 2014-11-22 10:00:01
569
- // [3] => 2014-11-22 12:00:02
570
- $selected_dates_array = array();
571
- $i=0;
572
- //debuge('$dates_in_diff_formats["array]',$dates_in_diff_formats['array']) ;
573
-
574
- // if we selected only 1 day, system retur in this array 2 same dates. But in situation with recurenttime we need only one day
575
- if ( get_bk_option( 'booking_recurrent_time' ) == 'On')
576
- $dates_in_diff_formats['array'] = array_unique( $dates_in_diff_formats['array'] );
577
-
578
- foreach ($dates_in_diff_formats['array'] as $my_date) {
579
- $i++;
580
- $my_date = explode('-', $my_date);
581
-
582
-
583
- // For start and end times we cut 10 seconds, so we can check for sure if this times inside of the booked times or not
584
- if ( get_bk_option( 'booking_recurrent_time' ) !== 'On') {
585
-
586
- if ($i == 1) {
587
- $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] );
588
- $date = date('Y-m-d H:i:s', strtotime( '+20 second', strtotime( $date ) ) );
589
- }elseif ($i == count( $dates_in_diff_formats['array'] )) {
590
- $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] );
591
- $date = date('Y-m-d H:i:s', strtotime( '-20 second', strtotime( $date ) ) );
592
- }else {
593
- $date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00' );
594
- }
595
- $selected_dates_array[] = $date;
596
- } else {
597
- $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] );
598
- $date = date('Y-m-d H:i:s', strtotime( '+20 second', strtotime( $date ) ) );
599
- $selected_dates_array[] = $date;
600
- $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] );
601
- $date = date('Y-m-d H:i:s', strtotime( '-20 second', strtotime( $date ) ) );
602
- $selected_dates_array[] = $date;
603
- }
604
- }
605
- ////////////////////////////////////////////////////////////////////////////
606
-
607
-
608
-
609
- // SQL condition for getting any booked dates, which inside of selected dates intervals
610
- $dates_sql_where = '';
611
- foreach ($dates_in_diff_formats['array'] as $selected_date) {
612
- $selected_date = explode( '-', $selected_date );
613
- $my_check_in_date_sql = sprintf( "%04d-%02d-%02d 00:00:00", $selected_date[0], $selected_date[1], $selected_date[2] );
614
- $my_check_out_date_sql = sprintf( "%04d-%02d-%02d 23:59:59", $selected_date[0], $selected_date[1], $selected_date[2] );
615
-
616
- if ( ! empty( $dates_sql_where ) )
617
- $dates_sql_where .= " OR ";
618
- $dates_sql_where .= " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) ";
619
- }
620
- if ( ! empty( $dates_sql_where ) )
621
- $dates_sql_where = " ({$dates_sql_where}) ";
622
- ////////////////////////////////////////////////////////////////////////////
623
-
624
- /*
625
- // WE can not use this type of days condition for check in and check out dates, because user can select several not consecutive days
626
- $my_check_in_date = explode( '-', $dates_in_diff_formats['array'][0] );
627
- $my_check_in_date_sql = sprintf( "%04d-%02d-%02d 00:00:00", $my_check_in_date[0], $my_check_in_date[1], $my_check_in_date[2] );
628
-
629
- $my_check_out_date = explode( '-', $dates_in_diff_formats['array'][ ( count($dates_in_diff_formats['array']) - 1 ) ] );
630
- $my_check_out_date_sql = sprintf( "%04d-%02d-%02d 23:59:59", $my_check_out_date[0], $my_check_out_date[1], $my_check_out_date[2] );
631
-
632
- $dates_sql_where = " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) ";
633
- /**/
634
-
635
- global $wpdb;
636
-
637
- // Checking only for approved bookings, if pending days available is active
638
- if ( get_bk_option( 'booking_is_show_pending_days_as_available') == 'On' )
639
- $approved_only = ' dt.approved = 1 AND ';
640
- else
641
- $approved_only = '';
642
-
643
- $trash_bookings = ' AND bk.trash != 1 '; //FixIn: 6.1.1.10 - check also below usage of {$trash_bookings}
644
-
645
- // Get all booked dates ////////////////////////////////////////////////////
646
- $sql_req = "SELECT DISTINCT dt.booking_date
647
-
648
- FROM {$wpdb->prefix}bookingdates as dt
649
-
650
- INNER JOIN {$wpdb->prefix}booking as bk
651
-
652
- ON bk.booking_id = dt.booking_id
653
-
654
- WHERE {$approved_only} {$dates_sql_where} {$trash_bookings} AND bk.booking_type IN ({$bktype})
655
-
656
- ORDER BY dt.booking_date" ;
657
-
658
- $exist_dates_results = $wpdb->get_results( $sql_req );
659
- ////////////////////////////////////////////////////////////////////////////
660
-
661
- if ( count($exist_dates_results) == 0 ) // We do not have here booked dates at all, so - TRUE
662
- return true;
663
-
664
-
665
- //FixIn: 5.4.5
666
- $is_dates_intersections = wpbc_check_dates_intersections( $selected_dates_array, $exist_dates_results );
667
-
668
- if ( $is_dates_intersections ) {
669
- // Show Warning message and return FALSE ///////////////////////////////
670
- ?> <script type="text/javascript">
671
- if ( jQuery('#submiting<?php echo $bktype; ?>' ).length ) {
672
- // Disable spinning
673
- document.getElementById('submiting<?php echo $bktype; ?>').innerHTML = '';
674
- // Show Error message under the calendar
675
- showMessageUnderElement( '#date_booking<?php echo $bktype; ?>',
676
- '<?php echo html_entity_decode( '<strong>' . esc_js( __('Error!' ,'booking') ) . '</strong> '
677
- . esc_js( __('Probably these date(s) just was booking by other visitor. Please reload this page and make booking again.' ,'booking') ) ,ENT_QUOTES); ?>' ,
678
- 'alert-error');
679
- // Scroll to the calendar
680
- makeScroll('#calendar_booking<?php echo $bktype; ?>');
681
- // Enable Submit button
682
- jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false);
683
- }
684
- </script> <?php
685
-
686
- return false;
687
- }
688
-
689
- return true;
690
- }
 
 
 
1
+ <?php
2
+ /**
3
+ * @version 1.0
4
+ * @package Booking Calendar
5
+ * @subpackage Create new bookings functions
6
+ * @category Bookings
7
+ *
8
+ * @author wpdevelop
9
+ * @link http://wpbookingcalendar.com/
10
+ * @email info@wpbookingcalendar.com
11
+ *
12
+ * @modified 2014.04.23
13
+ */
14
+
15
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
16
+
17
+
18
+ // CAPTCHA CHECKING //////////////////////////////////////////////////////////////////////////////////////
19
+ function wpbc_check_CAPTCHA( $the_answer_from_respondent, $prefix, $bktype ) {
20
+
21
+ if (! ( ($the_answer_from_respondent == '') && ($prefix == '') ) ) {
22
+ $captcha_instance = new wpdevReallySimpleCaptcha();
23
+ $correct = $captcha_instance->check($prefix, $the_answer_from_respondent);
24
+
25
+ if (! $correct) {
26
+ $word = $captcha_instance->generate_random_word();
27
+ $prefix = mt_rand();
28
+ $captcha_instance->generate_image($prefix, $word);
29
+
30
+ $filename = $prefix . '.png';
31
+ $captcha_url = WPDEV_BK_PLUGIN_URL . '/js/captcha/tmp/' .$filename;
32
+ $ref = substr($filename, 0, strrpos($filename, '.'));
33
+ ?> <script type="text/javascript">
34
+ document.getElementById('captcha_input<?php echo $bktype; ?>').value = '';
35
+ document.getElementById('captcha_img<?php echo $bktype; ?>').src = '<?php echo $captcha_url; ?>';
36
+ document.getElementById('wpdev_captcha_challenge_<?php echo $bktype; ?>').value = '<?php echo $ref; ?>';
37
+ 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' ,'booking'); ?></span>';
38
+ document.getElementById('submiting<?php echo $bktype; ?>').innerHTML ='';
39
+ jQuery('#captcha_input<?php echo $bktype; ?>')
40
+ .fadeOut( 350 ).fadeIn( 300 )
41
+ .fadeOut( 350 ).fadeIn( 400 )
42
+ .animate( {opacity: 1}, 4000 );
43
+ jQuery("span.wpdev-help-message span.alert")
44
+ .fadeIn( 1 )
45
+ //.css( {'color' : 'red'} )
46
+ .animate( {opacity: 1}, 10000 )
47
+ .fadeOut( 2000 ); // hide message
48
+ document.getElementById('captcha_input<?php echo $bktype; ?>').focus(); // make focus to elemnt
49
+ jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false);
50
+ </script> <?php
51
+ return false;
52
+ }
53
+ }//////////////////////////////////////////////////////////////////////////////////////////////////////////
54
+ return true;
55
+ }
56
+
57
+
58
+ // Customization for the integration of Mail Chimp Subscription.
59
+ function wpbc_integrate_MailChimp($formdata , $bktype) {
60
+
61
+ return false; // Exit
62
+
63
+ // Start Mail Chimp Customization
64
+ $booking_form_show = get_form_content ($formdata , $bktype );
65
+
66
+ if ( ( isset ($booking_form_show['subscribe_me'] )) && ( $booking_form_show['subscribe_me'] == 'yes') ) { // In booking form at the Booking > Settings > Fields page you need to have this: <p>[checkbox subscribe_me ""] Subscribe Me</p>
67
+
68
+ if (file_exists(WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.php')) { // Include MailChimp class (You can download (API v2) !!! from here https://github.com/drewm/mailchimp-api/tree/api-v2
69
+ require_once( WPDEV_BK_PLUGIN_DIR. '/lib/MailChimp.php' );
70
+
71
+ $MailChimp = new MailChimp('key-my'); // You are need to specify here YOUR KEY !!!!
72
+ $list_id = '3344044af8'; // Specify List ID here
73
+
74
+ $result = $MailChimp->call('lists/subscribe', array(
75
+ 'id' => $list_id, //'id' . $booking_id ,
76
+ 'email' => array('email'=>$booking_form_show['email']),
77
+ 'merge_vars' => array('FNAME'=>$booking_form_show['name'], 'LNAME'=>$booking_form_show['secondname']),
78
+ 'double_optin' => false,
79
+ 'update_existing' => true,
80
+ 'replace_interests' => false,
81
+ 'send_welcome' => false,
82
+ ));
83
+ //debuge($result);
84
+ }
85
+ } // End Mail Chimp Customization
86
+ }
87
+
88
+
89
+ // Create new booking and make actions on HTML page
90
+ function wpdev_bk_insert_new_booking() {
91
+
92
+ $is_edit_booking = false;
93
+
94
+ if ( isset($_POST['my_booking_hash']) && (! empty($_POST['my_booking_hash']) ) ) {
95
+
96
+ $my_booking_id_type = apply_bk_filter('wpdev_booking_get_hash_to_id',false, $_POST['my_booking_hash'] );
97
+ if ($my_booking_id_type !== false) {
98
+ $is_edit_booking = array();
99
+ $is_edit_booking['booking_id'] = $my_booking_id_type[0];
100
+ $is_edit_booking['booking_type'] = $my_booking_id_type[1];
101
+ $bktype = intval( $is_edit_booking['booking_type'] );
102
+
103
+ // FixIn: 6.1.1.9
104
+ // Check situation when we have editing "child booking resource", so need to reupdate calendar and form to have it for parent resource.
105
+ if ( ( function_exists( 'wpbc_is_this_child_resource') ) && ( wpbc_is_this_child_resource( $bktype ) ) ){
106
+ $bk_parent_br_id = wpbc_get_parent_resource( $bktype );
107
+
108
+ $is_edit_booking['booking_type'] = $bk_parent_br_id;
109
+ $bktype = $bk_parent_br_id;
110
+ }
111
+ // End: 6.1.1.9
112
+ }
113
+
114
+ } else {
115
+ $bktype = intval( $_POST[ "bktype" ] );
116
+ }
117
+
118
+
119
+ if ( $bktype <= 0 ) {
120
+ ?> <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 of saving data into DB. Unknown booking resource.',__FILE__,__LINE__); ?></div>'; }</script> <?php
121
+ die('Error of saving data into DB. Unknown booking resource.');
122
+ }
123
+
124
+
125
+ // CAPTCHA CHECKING
126
+ if ( isset($_POST['captcha_user_input']) && isset($_POST['captcha_chalange']) )
127
+ if (! wpbc_check_CAPTCHA( $_POST['captcha_user_input'], $_POST['captcha_chalange'], $bktype ) )
128
+ die;
129
+
130
+ $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
131
+ if ( $is_edit_booking !== false )
132
+ if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) !==false ) {
133
+ ?> <script type="text/javascript">
134
+ if ( jQuery('#ajax_working' ).length ) {
135
+ document.getElementById('ajax_working').innerHTML =
136
+ '<div class="updated ajax_message" id="ajax_message">\n\
137
+ <div style="float:left;"><?php echo __('Updating...' ,'booking'); ?></div> \n\
138
+ <div class="wpbc_spin_loader">\n\
139
+ <img src="'+wpdev_bk_plugin_url+'/img/ajax-loader.gif">\n\
140
+ </div>\n\
141
+ </div>';
142
+ }
143
+ </script> <?php
144
+ }
145
+
146
+ $_POST["skip_page_checking_for_updating"] = 0;
147
+ $_POST["is_show_payment_form"] = 1;
148
+ $result_bk_id = wpbc_add_new_booking( $_POST , $is_edit_booking );
149
+
150
+ if ( $result_bk_id !== false ) {
151
+ ?> <script type="text/javascript"> <?php
152
+
153
+ $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
154
+ if ( $is_edit_booking !== false ) {
155
+
156
+ if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) ===false ) {
157
+
158
+ ?> setReservedSelectedDates('<?php echo $bktype; ?>'); <?php
159
+
160
+ } else { ?>
161
+ document.getElementById('ajax_message').innerHTML = '<?php echo __('Updated successfully' ,'booking'); ?>';
162
+ jQuery('#ajax_message').fadeOut(1000);
163
+ 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' ,'booking'); ?></div>';
164
+ if ( jQuery('#wpdev_http_referer').length > 0 ) {
165
+ location.href=jQuery('#wpdev_http_referer').val();
166
+ } 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 $is_edit_booking['booking_id'] ; ?>';
167
+ <?php
168
+ }
169
+
170
+ } else {
171
+ ?> setReservedSelectedDates('<?php echo $bktype; ?>'); <?php
172
+ }
173
+
174
+ ?> </script> <?php
175
+ }
176
+
177
+ }
178
+
179
+
180
+
181
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
182
+ // A D D N e w B o o k i n g
183
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
184
+ //
185
+ //$params = array(
186
+ // ["bktype"] => 4
187
+ // ["dates"] => 24.09.2014, 25.09.2014, 26.09.2014
188
+ // ["form"] => select-one^rangetime4^14:00 - 16:00~text^name4^Costa~text^secondname4^Rika~email^email4^rika@cost.com~text^phone4^2423432~text^address4^Ferrari~text^city4^Rome~text^postcode4^2343~select-one^country4^IT~select-one^visitors4^1~select-one^children4^0~textarea^details4^dhfjksdhfkdhjs~checkbox^term_and_condition4[]^I Accept term and conditions
189
+ // ["is_send_emeils"] => 1
190
+ // ["booking_form_type"] =>
191
+ // [wpdev_active_locale] => en_US
192
+ //
193
+ // // Paramters for adding booking in the HTML:
194
+ // ["skip_page_checking_for_updating"] = 0;
195
+ // ["is_show_payment_form"] = 1;
196
+ // )
197
+ //
198
+ // Update Booking params:
199
+ // $is_edit_booking = array(
200
+ // 'booking_id' => 10
201
+ // , 'booking_type' => 1
202
+ // )
203
+ //
204
+ function wpbc_add_new_booking( $params , $is_edit_booking = false ){
205
+
206
+ if ( $is_edit_booking !== false ) { // Edit booking
207
+
208
+ $booking_id = $is_edit_booking['booking_id'];
209
+ $bktype = $is_edit_booking['booking_type'];
210
+
211
+ } else { // New booking
212
+ if (! isset($params[ "bktype" ]))
213
+ return false; // Error: Unknown booking resources
214
+ else
215
+ $bktype = intval( $params[ "bktype" ] );
216
+ if ( $bktype == 0 )
217
+ return false; // Error: Unknown booking resources
218
+ }
219
+
220
+ make_bk_action('check_multiuser_params_for_client_side', $bktype ); // Activate working with specific user in WP MU
221
+
222
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
223
+ // Define init variables
224
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
225
+ global $wpdb;
226
+
227
+ $formdata = escape_any_xss( $params[ "form" ] );
228
+
229
+ $my_modification_date = "'" . date_i18n( 'Y-m-d H:i:s' ) ."'" ; // Localize booking modification date
230
+
231
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
232
+ // Get Dates
233
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
234
+
235
+ $dates_in_diff_formats = wpbc_get_dates_in_diff_formats( $params[ "dates" ], $bktype, $formdata );
236
+ //debuge($dates_in_diff_formats);
237
+ $str_dates__dd_mm_yyyy = $dates_in_diff_formats['string'];
238
+ // $my_dates = $dates_in_diff_formats['array'];
239
+ $start_time = $dates_in_diff_formats['start_time'];
240
+ $end_time = $dates_in_diff_formats['end_time'];
241
+
242
+ //Here we need to check for double booking for the same sessions
243
+ if ( ( ! $is_edit_booking ) &&
244
+ (! wpbc_check_if_dates_free( $bktype, $formdata ,$dates_in_diff_formats, $start_time, $end_time ) )
245
+ ) {
246
+ die;
247
+ }
248
+
249
+
250
+ $my_check_in_date = explode( '-', $dates_in_diff_formats['array'][0] );
251
+ $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] );
252
+
253
+
254
+ if ( empty( $str_dates__dd_mm_yyyy ) ){
255
+ ?> <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
256
+ die('Error! No Dates');
257
+ }
258
+
259
+
260
+ $auto_approve_new_bookings_is_active = trim( get_bk_option( 'booking_auto_approve_new_bookings_is_active' ) );
261
+ $is_approved_dates = ( $auto_approve_new_bookings_is_active == 'On' ) ? '1' : '0';
262
+
263
+ // $booking_form_show = get_form_content( $formdata, $bktype, '', array());
264
+ // if ( intval($booking_form_show['visitors'] ) > 4 )
265
+ // $is_approved_dates = '1';
266
+ // else $is_approved_dates = '0';
267
+
268
+ // // Auto Approve booking from Booking > Add booking page for single booking resources
269
+ // $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
270
+ // if ( strpos( $_SERVER['HTTP_REFERER'], $admin_uri ) !== false )
271
+ // $is_approved_dates = '1';
272
+
273
+ $additional_fields = $additional_fields_vlaues = '';
274
+ if ( isset( $params["sync_gid"] ) ) {
275
+ $additional_fields = ", sync_gid" ;
276
+ $additional_fields_vlaues = ", '" . wpbc_clean_parameter($params["sync_gid"]) . "'" ;
277
+ }
278
+
279
+ if ( $is_edit_booking === false ) {
280
+
281
+ ////////////////////////////////////////////////////////////////////////////
282
+ // Add new booking
283
+ ////////////////////////////////////////////////////////////////////////////
284
+ $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})" ;
285
+
286
+ if ( false === $wpdb->query( $sql_insertion ) ){
287
+ ?> <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
288
+ die('Error during inserting into DB');
289
+ }
290
+ $booking_id = (int) $wpdb->insert_id; // Get ID of booking
291
+
292
+ } else {
293
+
294
+ ////////////////////////////////////////////////////////////////////////////
295
+ // Edit booking
296
+ ////////////////////////////////////////////////////////////////////////////
297
+ $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};";
298
+ if ( false === $wpdb->query( $update_sql ) ){
299
+ ?> <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
300
+ die('Error during updating exist booking in DB');
301
+ }
302
+
303
+ // Check if dates already aproved or no
304
+ $slct_sql = "SELECT approved FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id}) LIMIT 0,1";
305
+ $slct_sql_results = $wpdb->get_results( $slct_sql );
306
+ if ( count($slct_sql_results) > 0 ) {
307
+ $is_approved_dates = $slct_sql_results[0]->approved;
308
+ }
309
+
310
+ $delete_sql = "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$booking_id})";
311
+ if ( false === $wpdb->query( $delete_sql ) ){
312
+ ?> <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
313
+ die('Error during updating exist booking for deleting dates in DB');
314
+ }
315
+ }
316
+
317
+
318
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
319
+ // Update the Hash and Cost of the booking
320
+ make_bk_action('wpbc_update_booking_hash', $booking_id, $bktype );
321
+ make_bk_action('wpdev_booking_post_inserted', $booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) , $formdata );
322
+
323
+ // Auto approve booking if cost = 0.
324
+ // $booking_cost = apply_bk_filter('get_booking_cost_from_db', '', $booking_id ); // Auto approve booking if cost = 0.
325
+ // $booking_cost = floatval( $booking_cost );
326
+ // if ( empty( $booking_cost ) ) {
327
+ // $is_approved_dates = '1';
328
+ // }
329
+
330
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
331
+
332
+ $insert = wpbc_get_SQL_to_insert_dates( $dates_in_diff_formats , $is_approved_dates, $booking_id );
333
+
334
+ if ( !empty($insert) )
335
+ if ( false === $wpdb->query( "INSERT INTO {$wpdb->prefix}bookingdates (booking_id, booking_date, approved) VALUES " . $insert ) ){
336
+ ?> <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
337
+ die('Error during inserting into BD - Dates');
338
+ }
339
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
340
+
341
+ if ( isset( $params["is_send_emeils"] ) ) $is_send_emeils = $params["is_send_emeils"];
342
+ else $is_send_emeils = 1;
343
+
344
+
345
+ if ( $is_edit_booking === false ) {
346
+
347
+ if ( $is_send_emeils != 0 )
348
+ sendNewBookingEmails($booking_id, $bktype, $formdata) ;
349
+
350
+ if ( ( isset( $params["is_show_payment_form"]) ) && ( $params["is_show_payment_form"] == 1 ) )
351
+ do_action('wpdev_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
352
+ else
353
+ do_action('wpbc_update_cost_of_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
354
+
355
+ wpbc_integrate_MailChimp( $formdata, $bktype );
356
+
357
+ if (
358
+ ( ( $auto_approve_new_bookings_is_active == 'On') && ($is_send_emeils != 0 ) )
359
+ // || ($is_approved_dates == '1') // Auto approve and send email if cost = 0.
360
+ ) {
361
+ sendApproveEmails($booking_id, 1);
362
+ }
363
+
364
+ } else {
365
+
366
+ if ($is_send_emeils != 0 )
367
+ sendModificationEmails($booking_id, $bktype, $formdata );
368
+
369
+ $admin_uri = ltrim( str_replace( get_site_url( null, '', 'admin' ), '', admin_url('admin.php?') ), '/' ) ;
370
+
371
+ if ( strpos($_SERVER['HTTP_REFERER'], $admin_uri ) === false ) {
372
+
373
+ if ( ( isset( $params["is_show_payment_form"]) ) && ( $params["is_show_payment_form"] == 1 ) )
374
+ do_action('wpdev_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
375
+ else
376
+ do_action('wpbc_update_cost_of_new_booking',$booking_id, $bktype, $str_dates__dd_mm_yyyy, array($start_time, $end_time ) ,$formdata );
377
+
378
+ }
379
+
380
+ }
381
+
382
+
383
+
384
+ // Re-Update booking resource TYPE if its needed here
385
+ if ( isset( $params["skip_page_checking_for_updating"] ) ) $skip_page_checking_for_updating = (bool) $params["skip_page_checking_for_updating"];
386
+ else $skip_page_checking_for_updating = true;
387
+ 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 );
388
+
389
+
390
+ make_bk_action('finish_check_multiuser_params_for_client_side', $bktype ); // Deactivate working with specific user in WP MU
391
+
392
+ return $booking_id;
393
+ }
394
+ add_bk_filter('wpbc_add_new_booking_filter' , 'wpbc_add_new_booking' );
395
+ add_bk_action('wpbc_add_new_booking' , 'wpbc_add_new_booking' );
396
+ /*
397
+ make_bk_action('wpbc_add_new_booking' , array(
398
+ 'bktype' => 1
399
+ , 'dates' => '27.08.2014, 28.08.2014, 29.08.2014'
400
+ , 'form' => 'select-one^rangetime1^10:00 - 12:00~text^name1^Jo~text^secondname1^Smith~email^email1^smith@gmail.com~text^phone1^678676678~text^address1^Linkoln Street~text^city1^London~text^postcode1^78788~select-one^country1^GB~select-one^visitors1^1~select-one^children1^1~textarea^details1^Rooms with sea view~checkbox^term_and_condition1[]^I Accept term and conditions'
401
+ , 'is_send_emeils' => 0
402
+ // , 'booking_form_type' => ''
403
+ // , 'wpdev_active_locale' => 'en_US'
404
+ ) ); /**/
405
+
406
+
407
+
408
+ /** Check if dates intersect with other dates array
409
+ *
410
+ * @param array $dates_for_check - Dates Array of specific booking, which we checking - date in SQL format: '2014-11-21 10:00:01'
411
+ * @param array $dates_exist - Other dates from booking resource(s), that already exist - date in SQL format: '2014-11-21 15:00:02'
412
+ * @return bool true - intersect, false - not intersect
413
+ */
414
+ function wpbc_check_dates_intersections( $dates_for_check, $dates_exist ) { // FixIn: 5.4.5
415
+
416
+ $is_intersected = false;
417
+
418
+ $booked_dates = array();
419
+ $what_dates_to_check = array();
420
+
421
+ //debuge($dates_for_check, $dates_exist);
422
+
423
+ foreach ( $dates_exist as $value ) {
424
+
425
+ if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
426
+ $booking_date = $value->booking_date; // Its object with date value
427
+ else
428
+ $booking_date = $value; // Its array of string dates
429
+
430
+
431
+ if ( intval( substr( $booking_date, -1 ) ) == 1 ) { // We require time shift for situation, when previous booking end in the same time, when new booking start
432
+ $time_shift = 10; // Plus 10 seconds
433
+ } elseif ( intval( substr( $booking_date, -1 ) ) == 2 ) {
434
+ $time_shift = -10; // Minus 10 seconds
435
+ } else
436
+ $time_shift = 0;
437
+
438
+ // Booked dates in destination resource, that can intersect
439
+ $booked_dates[ $booking_date ] = strtotime( $booking_date ) + $time_shift;;
440
+
441
+ // Get here only dates, without times: [2015-11-09] => 1447027200
442
+ $what_dates_to_check[ substr($booking_date, 0, 10) ] = strtotime( substr($booking_date, 0, 10) );
443
+ }
444
+
445
+ asort( $booked_dates ); // Sort dates
446
+
447
+
448
+ $keyi=0;
449
+ $dates_to_add = array();
450
+ foreach ( $booked_dates as $date_key => $date_value ) {
451
+
452
+ if ( $keyi == 0 ) { // First element
453
+ if ( intval( substr( $date_key, -1 ) ) == 2 ) {
454
+ // We are having first date as ending date, its means that starting date exist somewhere before, and we need to set it at the begining
455
+ $dates_to_add[ substr($date_key, 0, 10) . ' 00:00:11' ] = strtotime( substr($date_key, 0, 10) . ' 00:00:11' );
456
+ }
457
+ }
458
+
459
+ if ( $keyi == ( count($booked_dates) - 1 ) ) { // last element
460
+ if ( intval( substr( $date_key, -1 ) ) == 1 ) {
461
+ // We are having last date as ending date, its means that ending date exist somewhere after, and we need to set it at the end of array
462
+ $dates_to_add[ substr($date_key, 0, 10) . ' 23:59:42' ] = strtotime( substr($date_key, 0, 10) . ' 23:59:42' );
463
+ }
464
+ }
465
+ $keyi++;
466
+ }
467
+ $booked_dates = array_merge($booked_dates, $dates_to_add);
468
+ asort( $booked_dates ); // Sort dates
469
+
470
+
471
+ // Skip dates (in original booking) that does not exist in destination resource at all
472
+ $check_dates = array();
473
+ foreach ( $dates_for_check as $value ) {
474
+
475
+ if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
476
+ $booking_date = $value->booking_date; // Its object with date value
477
+ else
478
+ $booking_date = $value; // Its array of string dates
479
+
480
+ // Check dates only if these dates already exist in $what_dates_to_check array
481
+ if ( ( isset( $what_dates_to_check[ substr($booking_date, 0, 10) ] ) ) ) //|| ( intval( substr( $booking_date, -1 ) ) != 0 ) )
482
+ $check_dates[] = $value;
483
+ }
484
+
485
+ if ( count( $check_dates ) == 0 ) return $is_intersected; // No intersected dates at all in exist bookings. Return. //FixIn: 6.0.1.13
486
+
487
+ foreach ( $check_dates as $value ) {
488
+
489
+ if ( ( is_object( $value ) ) && ( isset( $value->booking_date ) ) )
490
+ $booking_date = $value->booking_date; // Its object with date value
491
+ else
492
+ $booking_date = $value; // Its array of string dates
493
+
494
+ if ( isset( $booked_dates[ $booking_date ] ) ) { // Already have exactly this date as booked
495
+ $is_intersected = true;
496
+ break;
497
+ }
498
+
499
+ if ( intval( substr( $booking_date, -1 ) ) == 1 ) { // We require time shift for situation, when previous booking end in the same time, when new booking start
500
+ $time_shift = 10; // Plus 10 seconds
501
+ } elseif ( intval( substr( $booking_date, -1 ) ) == 2 ) {
502
+ $time_shift = -10; // Minus 10 seconds
503
+ } else
504
+ $time_shift = 0;
505
+
506
+ $booked_dates[ $booking_date ] = strtotime( $booking_date ) + $time_shift;
507
+ }
508
+
509
+
510
+ asort( $booked_dates ); // Sort dates
511
+
512
+ //debuge('$booked_dates',$booked_dates);
513
+ if ( ! $is_intersected ) {
514
+
515
+ // check dates and times for intersections
516
+ $previos_date_key = 0;
517
+ foreach ( $booked_dates as $date_key => $value ) {
518
+
519
+ $date_key = intval( substr( $date_key, -1 ) ); // Get last second
520
+
521
+ // Check if the date fully booked (key = 0), or we are having 2 the same keys, like 1 and 1 or 2 and 2 one under other. Its means that we are having time intersection.
522
+ if ( ( $date_key !== 0 ) && ( $date_key != $previos_date_key ) )
523
+ $previos_date_key = $date_key;
524
+ else {
525
+ $is_intersected = true;
526
+ break;
527
+ }
528
+ }
529
+ }
530
+
531
+ return $is_intersected ;
532
+ }
533
+
534
+
535
+ /**
536
+ * Checking for bookings in the same session and prevention of the double booking
537
+ *
538
+ * @param type $bktype
539
+ * @param type $formdata
540
+ * @param type $str_dates__dd_mm_yyyy
541
+ * @param type $start_time
542
+ * @param type $end_time
543
+ * @return true|false - free or unavailable
544
+ */
545
+ function wpbc_check_if_dates_free($bktype, $formdata ,$dates_in_diff_formats, $start_time, $end_time) {
546
+
547
+ if ( ( get_bk_option( 'booking_check_on_server_if_dates_free' ) == 'Off') // Check if this feature active or not
548
+ || ( get_bk_option( 'booking_is_days_always_available' ) == 'On') // Check if any days available feature is active
549
+ ) return true;
550
+
551
+ //TODO: Finish checking for parent booking resources
552
+ // We need to get availabaility for the specific dates
553
+ // We need to rewrite
554
+ // function show_availability_at_calendar
555
+ // for getting availability only for the specific dates
556
+ // and then based on the availability approve or decline this current booking.
557
+ if ( class_exists('wpdev_bk_biz_l')) {
558
+ $number_of_child_resources = apply_bk_filter('wpbc_get_number_of_child_resources', $bktype );
559
+ if ( $number_of_child_resources > 1 ) // if this booking resources - parent, then do not chekc it, yet!
560
+ return true;
561
+ }
562
+
563
+ // $is_days_free = true;
564
+
565
+ ////////////////////////////////////////////////////////////////////////////
566
+ // Get Selected Dates Array in full format - all possible dates and times //
567
+ ////////////////////////////////////////////////////////////////////////////
568
+ //Example:
569
+ // [0] => 2014-11-21 10:00:01
570
+ // [1] => 2014-11-21 12:00:02
571
+ // [2] => 2014-11-22 10:00:01
572
+ // [3] => 2014-11-22 12:00:02
573
+ $selected_dates_array = array();
574
+ $i=0;
575
+ //debuge('$dates_in_diff_formats["array]',$dates_in_diff_formats['array']) ;
576
+
577
+ // if we selected only 1 day, system retur in this array 2 same dates. But in situation with recurenttime we need only one day
578
+ if ( get_bk_option( 'booking_recurrent_time' ) == 'On')
579
+ $dates_in_diff_formats['array'] = array_unique( $dates_in_diff_formats['array'] );
580
+
581
+ foreach ($dates_in_diff_formats['array'] as $my_date) {
582
+ $i++;
583
+ $my_date = explode('-', $my_date);
584
+
585
+
586
+ // For start and end times we cut 10 seconds, so we can check for sure if this times inside of the booked times or not
587
+ if ( get_bk_option( 'booking_recurrent_time' ) !== 'On') {
588
+
589
+ if ($i == 1) {
590
+ $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] );
591
+ $date = date('Y-m-d H:i:s', strtotime( '+20 second', strtotime( $date ) ) );
592
+ }elseif ($i == count( $dates_in_diff_formats['array'] )) {
593
+ $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] );
594
+ $date = date('Y-m-d H:i:s', strtotime( '-20 second', strtotime( $date ) ) );
595
+ }else {
596
+ $date = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $my_date[0], $my_date[1], $my_date[2], '00', '00', '00' );
597
+ }
598
+ $selected_dates_array[] = $date;
599
+ } else {
600
+ $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] );
601
+ $date = date('Y-m-d H:i:s', strtotime( '+20 second', strtotime( $date ) ) );
602
+ $selected_dates_array[] = $date;
603
+ $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] );
604
+ $date = date('Y-m-d H:i:s', strtotime( '-20 second', strtotime( $date ) ) );
605
+ $selected_dates_array[] = $date;
606
+ }
607
+ }
608
+ ////////////////////////////////////////////////////////////////////////////
609
+
610
+
611
+
612
+ // SQL condition for getting any booked dates, which inside of selected dates intervals
613
+ $dates_sql_where = '';
614
+ foreach ($dates_in_diff_formats['array'] as $selected_date) {
615
+ $selected_date = explode( '-', $selected_date );
616
+ $my_check_in_date_sql = sprintf( "%04d-%02d-%02d 00:00:00", $selected_date[0], $selected_date[1], $selected_date[2] );
617
+ $my_check_out_date_sql = sprintf( "%04d-%02d-%02d 23:59:59", $selected_date[0], $selected_date[1], $selected_date[2] );
618
+
619
+ if ( ! empty( $dates_sql_where ) )
620
+ $dates_sql_where .= " OR ";
621
+ $dates_sql_where .= " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) ";
622
+ }
623
+ if ( ! empty( $dates_sql_where ) )
624
+ $dates_sql_where = " ({$dates_sql_where}) ";
625
+ ////////////////////////////////////////////////////////////////////////////
626
+
627
+ /*
628
+ // WE can not use this type of days condition for check in and check out dates, because user can select several not consecutive days
629
+ $my_check_in_date = explode( '-', $dates_in_diff_formats['array'][0] );
630
+ $my_check_in_date_sql = sprintf( "%04d-%02d-%02d 00:00:00", $my_check_in_date[0], $my_check_in_date[1], $my_check_in_date[2] );
631
+
632
+ $my_check_out_date = explode( '-', $dates_in_diff_formats['array'][ ( count($dates_in_diff_formats['array']) - 1 ) ] );
633
+ $my_check_out_date_sql = sprintf( "%04d-%02d-%02d 23:59:59", $my_check_out_date[0], $my_check_out_date[1], $my_check_out_date[2] );
634
+
635
+ $dates_sql_where = " ( dt.booking_date >= '{$my_check_in_date_sql}' AND dt.booking_date <= '{$my_check_out_date_sql}' ) ";
636
+ /**/
637
+
638
+ global $wpdb;
639
+
640
+ // Checking only for approved bookings, if pending days available is active
641
+ if ( get_bk_option( 'booking_is_show_pending_days_as_available') == 'On' )
642
+ $approved_only = ' dt.approved = 1 AND ';
643
+ else
644
+ $approved_only = '';
645
+
646
+ $trash_bookings = ' AND bk.trash != 1 '; //FixIn: 6.1.1.10 - check also below usage of {$trash_bookings}
647
+
648
+ // Get all booked dates ////////////////////////////////////////////////////
649
+ $sql_req = "SELECT DISTINCT dt.booking_date
650
+
651
+ FROM {$wpdb->prefix}bookingdates as dt
652
+
653
+ INNER JOIN {$wpdb->prefix}booking as bk
654
+
655
+ ON bk.booking_id = dt.booking_id
656
+
657
+ WHERE {$approved_only} {$dates_sql_where} {$trash_bookings} AND bk.booking_type IN ({$bktype})
658
+
659
+ ORDER BY dt.booking_date" ;
660
+
661
+ $exist_dates_results = $wpdb->get_results( $sql_req );
662
+ ////////////////////////////////////////////////////////////////////////////
663
+
664
+ if ( count($exist_dates_results) == 0 ) // We do not have here booked dates at all, so - TRUE
665
+ return true;
666
+
667
+
668
+ //FixIn: 5.4.5
669
+ $is_dates_intersections = wpbc_check_dates_intersections( $selected_dates_array, $exist_dates_results );
670
+
671
+ if ( $is_dates_intersections ) {
672
+ // Show Warning message and return FALSE ///////////////////////////////
673
+ ?> <script type="text/javascript">
674
+ if ( jQuery('#submiting<?php echo $bktype; ?>' ).length ) {
675
+ // Disable spinning
676
+ document.getElementById('submiting<?php echo $bktype; ?>').innerHTML = '';
677
+ // Show Error message under the calendar
678
+ showMessageUnderElement( '#date_booking<?php echo $bktype; ?>',
679
+ '<?php echo html_entity_decode( '<strong>' . esc_js( __('Error!' ,'booking') ) . '</strong> '
680
+ . esc_js( __('Probably these date(s) just was booking by other visitor. Please reload this page and make booking again.' ,'booking') ) ,ENT_QUOTES); ?>' ,
681
+ 'alert-error');
682
+ // Scroll to the calendar
683
+ makeScroll('#calendar_booking<?php echo $bktype; ?>');
684
+ // Enable Submit button
685
+ jQuery('#booking_form_div<?php echo $bktype; ?> input[type=button]').prop("disabled", false);
686
+ }
687
+ </script> <?php
688
+
689
+ return false;
690
+ }
691
+
692
+ return true;
693
+ }
lib/wpbc-constants.php CHANGED
@@ -26,10 +26,9 @@ if (!defined('WP_BK_IS_SEND_EMAILS_ON_COST_CHANGE')) define('WP_BK_IS_SEND_EM
26
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27
  // SYSTEM CONSTANTS //////////////////////////////////////////////////////////////////////////////////////////////////
28
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29
- if (!defined('WP_BK_VERSION_NUM')) define('WP_BK_VERSION_NUM', '6.2' );
30
- if (!defined('WP_BK_MINOR_UPDATE')) define('WP_BK_MINOR_UPDATE', ! true );
31
  if (!defined('IS_USE_WPDEV_BK_CACHE')) define('IS_USE_WPDEV_BK_CACHE', true );
32
  if (!defined('WP_BK_DEBUG_MODE')) define('WP_BK_DEBUG_MODE', false );
33
  if (!defined('WP_BK_MIN')) define('WP_BK_MIN', false );//TODO: Finish with this contstant, right now its not working correctly with TRUE status
34
  if (!defined('WP_BK_RESPONSE')) define('WP_BK_RESPONSE', false );
35
- ?>
26
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27
  // SYSTEM CONSTANTS //////////////////////////////////////////////////////////////////////////////////////////////////
28
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29
+ if (!defined('WP_BK_VERSION_NUM')) define('WP_BK_VERSION_NUM', '6.2.1' );
30
+ if (!defined('WP_BK_MINOR_UPDATE')) define('WP_BK_MINOR_UPDATE', true );
31
  if (!defined('IS_USE_WPDEV_BK_CACHE')) define('IS_USE_WPDEV_BK_CACHE', true );
32
  if (!defined('WP_BK_DEBUG_MODE')) define('WP_BK_DEBUG_MODE', false );
33
  if (!defined('WP_BK_MIN')) define('WP_BK_MIN', false );//TODO: Finish with this contstant, right now its not working correctly with TRUE status
34
  if (!defined('WP_BK_RESPONSE')) define('WP_BK_RESPONSE', false );
 
lib/wpbc-scripts.php CHANGED
@@ -273,6 +273,8 @@ function wpbc_remove_conflict_scripts(){
273
  if (function_exists('wp_dequeue_style')) {
274
  wp_dequeue_style( 'toolset-font-awesome-css' ); // Remove this script sitepress-multilingual-cms/res/css/font-awesome.min.css?ver=3.1.6, which is load by the "sitepress-multilingual-cms"
275
  wp_dequeue_style( 'toolset-font-awesome' ); //FixIn: 5.4.5.8
 
 
276
  }
277
  }
278
 
273
  if (function_exists('wp_dequeue_style')) {
274
  wp_dequeue_style( 'toolset-font-awesome-css' ); // Remove this script sitepress-multilingual-cms/res/css/font-awesome.min.css?ver=3.1.6, which is load by the "sitepress-multilingual-cms"
275
  wp_dequeue_style( 'toolset-font-awesome' ); //FixIn: 5.4.5.8
276
+ wp_dequeue_style( 'the7-fontello' ); //FixIn: 6.1.1.21
277
+
278
  }
279
  }
280
 
lib/wpdev-bk-lib.php CHANGED
@@ -704,15 +704,93 @@ if ( ! defined( 'ABSPATH' ) ) exit;
704
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
705
  // Bookings listing E N G I N E ///////////////////////////////////////////////////////////////////////////////////////////////////
706
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
 
 
 
 
 
 
 
 
 
 
 
 
 
 
708
  // Get Default params or from Request
709
  function wpdev_get_args_from_request_in_bk_listing(){
710
  //debuge($_REQUEST);
 
711
  $num_per_page_check = get_bk_option( 'bookings_num_per_page');
712
  if (empty( $num_per_page_check)) {
713
  $num_per_page_check = '10';
714
  update_bk_option( 'bookings_num_per_page', $num_per_page_check );
715
  }
 
716
  $args = array(
717
  'wh_booking_type' => (isset($_REQUEST['wh_booking_type'])) ? wpbc_clean_parameter( $_REQUEST['wh_booking_type'] ):'',
718
  'wh_approved' => (isset($_REQUEST['wh_approved'])) ? wpbc_clean_parameter( $_REQUEST['wh_approved'] ):'',
@@ -731,7 +809,13 @@ if ( ! defined( 'ABSPATH' ) ) exit;
731
  'wh_trash' => (isset($_REQUEST['wh_trash'])) ? wpbc_clean_parameter( $_REQUEST['wh_trash'] ):'', //FixIn:6.1.1.10
732
  'page_items_count' => (isset($_REQUEST['page_items_count'])) ? wpbc_clean_parameter( $_REQUEST['page_items_count'] ):$num_per_page_check,
733
  );
734
- //debuge($args, $_REQUEST['wh_booking_type'] );
 
 
 
 
 
 
735
  return $args;
736
  }
737
 
@@ -1153,7 +1237,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
1153
 
1154
  // Get Number of booking for the pages
1155
  $bookings_count = $wpdb->get_results( $sql_start_count . $sql . $sql_where );
1156
-
1157
  // Get NUMBER of Bookings
1158
  if (count($bookings_count)>0) $bookings_count = $bookings_count[0]->count ;
1159
  else $bookings_count = 0;
@@ -1329,6 +1413,9 @@ if ( ! defined( 'ABSPATH' ) ) exit;
1329
  // B o o k i n g P A G E s ////////////////////////////////////////////////////////////////////////////////////////////////
1330
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1331
  function wpdevbk_show_booking_page(){
 
 
 
1332
  wpbc_welcome_panel();
1333
  ////////////////////////////////////////////////////////////////////////////////////////////////////////
1334
  // Get from SETTINGS (if its not set in request yet) the "tab" & "view_mode" and set to $_REQUEST
704
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
705
  // Bookings listing E N G I N E ///////////////////////////////////////////////////////////////////////////////////////////////////
706
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
707
+
708
+ //FixIn:6.2.1.4
709
+ /** Clean Request Parameters
710
+ *
711
+ */
712
+ function wpbc_check_request_paramters() {
713
+
714
+ //debuge($_REQUEST);
715
+ $clean_params = array();
716
+
717
+ $clean_params['wh_booking_id'] = 'digit_or_csd';
718
+ $clean_params['wh_booking_type'] = 'digit_or_csd';
719
+ $clean_params['wh_approved'] = 'digit_or_csd'; // '0' | '1' | ''
720
+
721
+ $clean_params['wh_booking_date'] = 'digit_or_date'; // number | date 2016-07-20
722
+ $clean_params['wh_booking_date2'] = 'digit_or_date'; // number | date 2016-07-20
723
+ $clean_params['wh_booking_datenext'] = 'd'; // '1' | '2' ....
724
+ $clean_params['wh_booking_dateprior'] = 'd'; // '1' | '2' ....
725
+ $clean_params['wh_booking_datefixeddates'] = 'digit_or_date'; // number | date 2016-07-20
726
+ $clean_params['wh_booking_date2fixeddates'] = 'digit_or_date'; // number | date 2016-07-20
727
+
728
+ $clean_params['wh_is_new'] = 'd'; // '1' | ''
729
+
730
+ $clean_params['wh_modification_date'] = 'digit_or_date'; // number | date 2016-07-20
731
+ $clean_params['wh_modification_date2'] = 'digit_or_date'; // number | date 2016-07-20
732
+ $clean_params['wh_modification_dateprior'] = 'd'; // '1' | '2' ....
733
+ $clean_params['wh_modification_datefixeddates'] = 'digit_or_date'; // number | date 2016-07-20
734
+ $clean_params['wh_modification_date2fixeddates']= 'digit_or_date'; // number | date 2016-07-20
735
+
736
+ $clean_params['wh_keyword'] = 's'; //string
737
+
738
+ $clean_params['wh_pay_statuscustom'] = 's'; //string
739
+ $clean_params['wh_pay_status'] = 's'; //string
740
+ $clean_params['wh_cost'] = 'd'; // '1' | ''
741
+ $clean_params['wh_cost2'] = 'd'; // '1' | ''
742
+ $clean_params['or_sort'] = 's'; //string
743
+ $clean_params['wh_trash'] = 's'; //string
744
+
745
+ foreach ( $clean_params as $request_key => $clean_type ) {
746
+ switch ( $clean_type ) {
747
+
748
+ case 'digit_or_date': // digit or comma separated digit
749
+ if ( isset( $_REQUEST[ $request_key ] ) )
750
+ $_REQUEST[ $request_key ] = wpbc_clean_digit_or_date( $_REQUEST[ $request_key ] ); // nums
751
+
752
+ break;
753
+
754
+ case 'digit_or_csd': // digit or comma separated digit
755
+ if ( isset( $_REQUEST[ $request_key ] ) )
756
+ $_REQUEST[ $request_key ] = wpbc_clean_digit_or_csd( $_REQUEST[ $request_key ] ); // nums
757
+
758
+ break;
759
+
760
+ case 's': // string
761
+ if ( isset( $_REQUEST[ $request_key ] ) )
762
+ $_REQUEST[ $request_key ] = wpbc_clean_string_for_db( $_REQUEST[ $request_key ] );
763
+
764
+ break;
765
+
766
+ case 'd': // digit
767
+ if ( isset( $_REQUEST[ $request_key ] ) )
768
+ if ( $_REQUEST[ $request_key ] !== '' )
769
+ $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] );
770
 
771
+ break;
772
+
773
+ default:
774
+ if ( isset( $_REQUEST[ $request_key ] ) ) {
775
+ $_REQUEST[ $request_key ] = intval( $_REQUEST[ $request_key ] );
776
+ }
777
+ break;
778
+ }
779
+ }
780
+
781
+ //debuge($_REQUEST);
782
+ }
783
+
784
  // Get Default params or from Request
785
  function wpdev_get_args_from_request_in_bk_listing(){
786
  //debuge($_REQUEST);
787
+
788
  $num_per_page_check = get_bk_option( 'bookings_num_per_page');
789
  if (empty( $num_per_page_check)) {
790
  $num_per_page_check = '10';
791
  update_bk_option( 'bookings_num_per_page', $num_per_page_check );
792
  }
793
+
794
  $args = array(
795
  'wh_booking_type' => (isset($_REQUEST['wh_booking_type'])) ? wpbc_clean_parameter( $_REQUEST['wh_booking_type'] ):'',
796
  'wh_approved' => (isset($_REQUEST['wh_approved'])) ? wpbc_clean_parameter( $_REQUEST['wh_approved'] ):'',
809
  'wh_trash' => (isset($_REQUEST['wh_trash'])) ? wpbc_clean_parameter( $_REQUEST['wh_trash'] ):'', //FixIn:6.1.1.10
810
  'page_items_count' => (isset($_REQUEST['page_items_count'])) ? wpbc_clean_parameter( $_REQUEST['page_items_count'] ):$num_per_page_check,
811
  );
812
+
813
+
814
+ //debuge($args);
815
+ //$args['wh_booking_id'] = wpbc_clean_digit_or_csd( $args['wh_booking_id'] );
816
+ //$args['wh_keyword'] = wpbc_clean_string_for_db( $args['wh_keyword'] );
817
+ //debuge($args);
818
+
819
  return $args;
820
  }
821
 
1237
 
1238
  // Get Number of booking for the pages
1239
  $bookings_count = $wpdb->get_results( $sql_start_count . $sql . $sql_where );
1240
+ //debuge( $bookings_count );
1241
  // Get NUMBER of Bookings
1242
  if (count($bookings_count)>0) $bookings_count = $bookings_count[0]->count ;
1243
  else $bookings_count = 0;
1413
  // B o o k i n g P A G E s ////////////////////////////////////////////////////////////////////////////////////////////////
1414
  ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1415
  function wpdevbk_show_booking_page(){
1416
+
1417
+ wpbc_check_request_paramters(); //FixIn:6.2.1.4
1418
+
1419
  wpbc_welcome_panel();
1420
  ////////////////////////////////////////////////////////////////////////////////////////////////////////
1421
  // Get from SETTINGS (if its not set in request yet) the "tab" & "view_mode" and set to $_REQUEST
lib/wpdev-booking-functions.php CHANGED
@@ -2375,6 +2375,61 @@ if ( ! defined( 'ABSPATH' ) ) exit;
2375
  return $clean_formdata;
2376
  }
2377
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2378
  // check $value for injection here
2379
  function wpbc_clean_parameter( $value ) {
2380
  $value = preg_replace( '/<[^>]*>/', '', $value ); // clean any tags
2375
  return $clean_formdata;
2376
  }
2377
 
2378
+
2379
+
2380
+ /** Check paramter if it number or comma separated list of numbers
2381
+ *
2382
+ * @global type $wpdb
2383
+ * @param string $value
2384
+ * @return string
2385
+ */
2386
+ function wpbc_clean_digit_or_csd( $value ) { //FixIn:6.2.1.4
2387
+
2388
+ if ( $value === '' ) return $value;
2389
+
2390
+
2391
+ if ( is_array( $value ) ) {
2392
+ foreach ( $value as $key => $check_value ) {
2393
+ $value[ $key ] = wpbc_clean_digit_or_csd( $check_value );
2394
+ }
2395
+ return $value;
2396
+ }
2397
+
2398
+
2399
+ global $wpdb;
2400
+
2401
+ $value = str_replace( ';', ',', $value );
2402
+
2403
+ $array_of_nums = explode(',', $value);
2404
+
2405
+ $result = array();
2406
+ foreach ($array_of_nums as $check_element) {
2407
+ $result[] = $wpdb->prepare( "%d", $check_element );
2408
+ }
2409
+ $result = implode(',', $result );
2410
+ return $result;
2411
+ }
2412
+
2413
+
2414
+ /** Cehck about Valid date, like 2016-07-20 or digit
2415
+ *
2416
+ * @param string $value
2417
+ * @return string or int
2418
+ */
2419
+ function wpbc_clean_digit_or_date( $value ) { //FixIn:6.2.1.4
2420
+
2421
+ if ( $value === '' ) return $value;
2422
+
2423
+ if ( preg_match("/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/", $value ) ) {
2424
+
2425
+ return $value; // Date is valid in format: 2016-07-20
2426
+ } else {
2427
+ return intval( $value );
2428
+ }
2429
+
2430
+ }
2431
+
2432
+
2433
  // check $value for injection here
2434
  function wpbc_clean_parameter( $value ) {
2435
  $value = preg_replace( '/<[^>]*>/', '', $value ); // clean any tags
lib/wpdev-settings-general.php CHANGED
@@ -95,7 +95,14 @@ function wpdev_bk_settings_general() {
95
  $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin');
96
  if ($is_can===false) return;
97
 
 
 
 
 
 
 
98
 
 
99
  if ( isset( $_POST['start_day_weeek'] ) ) {
100
  $booking_skin = $_POST['booking_skin'];
101
 
@@ -368,6 +375,13 @@ function wpdev_bk_settings_general() {
368
  <div class="clear" style="height:10px;"></div>
369
  <div class="wpdevbk-not-now">
370
  <form name="post_option" action="" method="post" id="post_option" class="form-horizontal">
 
 
 
 
 
 
 
371
 
372
  <div class="booking_settings_row" style="width:64%; float:left;margin-right:1%;">
373
  <?php /** ?>
@@ -1490,11 +1504,26 @@ function wpdev_bk_settings_legend_section(){
1490
 
1491
 
1492
  function wpdev_bk_settings_form_labels(){
 
 
 
 
 
 
 
 
1493
  ?>
1494
  <div class="clear" style="height:0px;"></div>
1495
  <div id="ajax_working"></div>
1496
  <div id="poststuff0" class="metabox-holder">
1497
  <form name="post_settings_form_fields" action="" method="post" id="post_settings_form_fields" class="form-horizontal">
 
 
 
 
 
 
 
1498
 
1499
  <div id="visibility_container_form_fields" class="visibility_container wpdevbk wpbc_settings_form_fields_free" style="display:block;">
1500
  <div class='meta-box'>
@@ -1808,6 +1837,13 @@ function wpdev_bk_settings_form_labels(){
1808
  // Emails Settings
1809
  function wpbc_settings_emails(){
1810
 
 
 
 
 
 
 
 
1811
  if ( isset( $_POST['email_reservation_adress'] ) ) {
1812
 
1813
  $email_reservation_adress = htmlspecialchars( str_replace('\"','"',$_POST['email_reservation_adress']));
@@ -1979,7 +2015,13 @@ function wpbc_settings_emails(){
1979
  <div id="ajax_working"></div>
1980
  <div id="poststuff0" class="metabox-holder">
1981
  <form name="post_settings_email_templates" action="" method="post" id="post_settings_email_templates" >
1982
-
 
 
 
 
 
 
1983
  <div id="visibility_container_email_new_to_admin" class="visibility_container" style="display:block;">
1984
 
1985
  <div class='meta-box'> <div <?php $my_close_open_win_id = 'bk_settings_emails_to_admin'; ?> 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>
95
  $is_can = apply_bk_filter('multiuser_is_user_can_be_here', true, 'only_super_admin');
96
  if ($is_can===false) return;
97
 
98
+ //FixIn:6.2.1.4
99
+ $submit_form = 'post_settings_general';
100
+ if ( isset( $_POST['is_form_sbmitted_'. $submit_form ] ) ) {
101
+ check_admin_referer( 'wpbc_settings_page_'.$submit_form );
102
+ }
103
+ //FixIn:6.2.1.4 - end
104
 
105
+
106
  if ( isset( $_POST['start_day_weeek'] ) ) {
107
  $booking_skin = $_POST['booking_skin'];
108
 
375
  <div class="clear" style="height:10px;"></div>
376
  <div class="wpdevbk-not-now">
377
  <form name="post_option" action="" method="post" id="post_option" class="form-horizontal">
378
+ <?php
379
+ //FixIn:6.2.1.4
380
+ $submit_form = 'post_settings_general';
381
+ ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form; ?>" id="is_form_sbmitted_<?php echo $submit_form; ?>" value="1" /><?php
382
+ wp_nonce_field( 'wpbc_settings_page_' . $submit_form );
383
+ //FixIn:6.2.1.4 - end
384
+ ?>
385
 
386
  <div class="booking_settings_row" style="width:64%; float:left;margin-right:1%;">
387
  <?php /** ?>
1504
 
1505
 
1506
  function wpdev_bk_settings_form_labels(){
1507
+
1508
+ //FixIn:6.2.1.4
1509
+ $submit_form = 'post_settings_fields';
1510
+ if ( isset( $_POST['is_form_sbmitted_'. $submit_form ] ) ) {
1511
+ check_admin_referer( 'wpbc_settings_page_'.$submit_form );
1512
+ }
1513
+ //FixIn:6.2.1.4 - end
1514
+
1515
  ?>
1516
  <div class="clear" style="height:0px;"></div>
1517
  <div id="ajax_working"></div>
1518
  <div id="poststuff0" class="metabox-holder">
1519
  <form name="post_settings_form_fields" action="" method="post" id="post_settings_form_fields" class="form-horizontal">
1520
+ <?php
1521
+ //FixIn:6.2.1.4
1522
+ $submit_form = 'post_settings_fields';
1523
+ ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form; ?>" id="is_form_sbmitted_<?php echo $submit_form; ?>" value="1" /><?php
1524
+ wp_nonce_field( 'wpbc_settings_page_' . $submit_form );
1525
+ //FixIn:6.2.1.4 - end
1526
+ ?>
1527
 
1528
  <div id="visibility_container_form_fields" class="visibility_container wpdevbk wpbc_settings_form_fields_free" style="display:block;">
1529
  <div class='meta-box'>
1837
  // Emails Settings
1838
  function wpbc_settings_emails(){
1839
 
1840
+ //FixIn:6.2.1.4
1841
+ $submit_form = 'post_settings_email_templates';
1842
+ if ( isset( $_POST['is_form_sbmitted_'. $submit_form ] ) ) {
1843
+ check_admin_referer( 'wpbc_settings_page_'.$submit_form );
1844
+ }
1845
+ //FixIn:6.2.1.4 - end
1846
+
1847
  if ( isset( $_POST['email_reservation_adress'] ) ) {
1848
 
1849
  $email_reservation_adress = htmlspecialchars( str_replace('\"','"',$_POST['email_reservation_adress']));
2015
  <div id="ajax_working"></div>
2016
  <div id="poststuff0" class="metabox-holder">
2017
  <form name="post_settings_email_templates" action="" method="post" id="post_settings_email_templates" >
2018
+ <?php
2019
+ //FixIn:6.2.1.4
2020
+ $submit_form = 'post_settings_email_templates';
2021
+ ?><input type="hidden" name="is_form_sbmitted_<?php echo $submit_form; ?>" id="is_form_sbmitted_<?php echo $submit_form; ?>" value="1" /><?php
2022
+ wp_nonce_field( 'wpbc_settings_page_' . $submit_form );
2023
+ //FixIn:6.2.1.4 - end
2024
+ ?>
2025
  <div id="visibility_container_email_new_to_admin" class="visibility_container" style="display:block;">
2026
 
2027
  <div class='meta-box'> <div <?php $my_close_open_win_id = 'bk_settings_emails_to_admin'; ?> 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>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://wpbookingcalendar.com/buy/
4
  Tags: booking calendar, availability calendar, event calendar, booking system, booking form, reservation, events, appointment, availability, schedule, calendar, contact form
5
  Requires at least: 3.3
6
  Tested up to: 4.5
7
- Stable tag: 6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -152,6 +152,14 @@ If you have any further questions, please fill free to <a href="mailto:support@w
152
  11. **Calendar Skins**. Select calendar skin for better fitting to your web-site design.
153
 
154
  == Changelog ==
 
 
 
 
 
 
 
 
155
  = 6.2 =
156
  - Features and issue fixings in All versions:
157
  * **New** Moving bookings to trash instead of complete deleting.
@@ -239,7 +247,7 @@ If you have any further questions, please fill free to <a href="mailto:support@w
239
  * **New** filer at Booking Listing page. Showing bookings that **"check in" or "check out" during today**.
240
  * **Improvement** Replaced "wpdev-booking" language locale to "booking". Prepare for ability to use Language Packs functionality.
241
  * **Translation** New Portugal translation [100% Completed] by Pedro Morgado
242
- * **Translation** New Ukrainian translation [100% Completed] by Ivanka from [Coupofy](http://www.coupofy.com/)
243
  * **Translation** Updated French translation [100% Completed] by Charles Petitfour.
244
  * Fix email format issue during sending emails. From this format '"\"John Smith\"" <email@some-server.com>' to this: 'John Smith <email@some-server.com>'
245
  * Fix language file locale for the Finnish language. Renamed suffix of translation file from fi_Fl to fi.
4
  Tags: booking calendar, availability calendar, event calendar, booking system, booking form, reservation, events, appointment, availability, schedule, calendar, contact form
5
  Requires at least: 3.3
6
  Tested up to: 4.5
7
+ Stable tag: 6.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
152
  11. **Calendar Skins**. Select calendar skin for better fitting to your web-site design.
153
 
154
  == Changelog ==
155
+ = 6.2.1 =
156
+ - Features and issue fixings in All versions:
157
+ * **Fix** Improve security checking during saving settings and searching in booking listing pages.
158
+ - Personal / Business Small / Business Medium / Business Large / MultiUser versions features:
159
+ * **Fix** showing of error message instead of stop working, during submitting new booking, if this booking possible only in different booking resources for different days, but system have not allow this. This issue exist in some situations for booking resources with specific capacity, when all payment options are deactivated. (fix:6.2.1.1) *(Business Large, MultiUser)*
160
+ * **Fix** issue of incorrect working with required radio-button options. (fix:6.2.1.2) *(Personal, Business Small/Medium/Large, MultiUser)*
161
+ * **Fix** issue of not calculating "LAST" option in "Valuation days" if previously used "Together" term. (fix:6.2.1.3) Description: the number of selected days in calendar = to the number of days in settings "Together", then Booking Calendar stop any other interaction of checking cost and just return cost depend from settings in this "Together" term. Thats why the "LAST" row cost settings was ignored. *(Business Medium/Large, MultiUser)*
162
+
163
  = 6.2 =
164
  - Features and issue fixings in All versions:
165
  * **New** Moving bookings to trash instead of complete deleting.
247
  * **New** filer at Booking Listing page. Showing bookings that **"check in" or "check out" during today**.
248
  * **Improvement** Replaced "wpdev-booking" language locale to "booking". Prepare for ability to use Language Packs functionality.
249
  * **Translation** New Portugal translation [100% Completed] by Pedro Morgado
250
+ * **Translation** New Ukrainian translation [100% Completed] by Ivanka
251
  * **Translation** Updated French translation [100% Completed] by Charles Petitfour.
252
  * Fix email format issue during sending emails. From this format '"\"John Smith\"" <email@some-server.com>' to this: 'John Smith <email@some-server.com>'
253
  * Fix language file locale for the Finnish language. Renamed suffix of translation file from fi_Fl to fi.
wpdev-booking.php CHANGED
@@ -7,7 +7,7 @@ Author: wpdevelop
7
  Author URI: http://wpbookingcalendar.com/
8
  Text Domain: booking
9
  Domain Path: /languages/
10
- Version: 6.2
11
  */
12
 
13
  /* Copyright 2009 - 2015 www.wpbookingcalendar.com (email: info@wpbookingcalendar.com),
7
  Author URI: http://wpbookingcalendar.com/
8
  Text Domain: booking
9
  Domain Path: /languages/
10
+ Version: 6.2.1
11
  */
12
 
13
  /* Copyright 2009 - 2015 www.wpbookingcalendar.com (email: info@wpbookingcalendar.com),