/
dobooking.class.php
executable file
·7560 lines (6594 loc) · 305 KB
/
dobooking.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Core file.
*
* @author Vince Wooll <sales@jomres.net>
*
* @version Jomres 10.7.2
*
* @copyright 2005-2023 Vince Wooll
* Jomres (tm) PHP, CSS & Javascript files are released under both MIT and GPL2 licenses. This means that you can choose the license that best suits your project, and use it accordingly
**/
// ################################################################
defined('_JOMRES_INITCHECK') or die('');
// ################################################################
/**
* This file is the main code block that manages the booking engine.
#
* @package Jomres\Core\Classes
#
* It is not designed to be implemented or called directly. Instead it is called by the j05000bookingobject.class.php file which inherits from this file.
*/
#[AllowDynamicProperties]
class dobooking
{
/**
* Constructor for the jomres_booking object, sets a bunch of variables, finds configuration settings & gets the current state of the booking from the tmpbooking table.
*/
public function __construct()
{
$siteConfig = jomres_getSingleton('jomres_config_site_singleton');
$jrConfig = $siteConfig->get();
$this->jrConfig = $jrConfig; // Importing the site config settings
jr_import('jomres_encryption');
$this->jomres_encryption = new jomres_encryption();
$this->suppress_output = true;
if (get_showtime('task') == 'handlereq' || get_showtime('task') == 'dobooking') {
$this->suppress_output = false;
}
$this->requestedRoom = array();
$this->rate_pernight = 0.00;
$this->rate_pernight_nodiscount = 0.00;
$this->room_total_nodiscount = 0.00;
$this->discounts = array();
$this->total_in_party = 0;
$this->variancetypes = array();
$this->varianceuids = array();
$this->varianceqty = array();
$this->variancevals = array();
$this->variancevals_nodiscount = array();
$this->lastminute_id = '';
$this->arrivalDate = '';
$this->departureDate = '';
$this->stayDays = 1;
$this->dateRangeString = '';
$this->guests_uid = '';
$this->property_uid = '';
$this->rates_uid = '';
$this->tag = '';
$this->resource = '';
$this->rate_rules = 0.00;
$this->single_person_suppliment = 0.00;
$this->deposit_required = 0.00;
$this->contract_total = 0.00;
$this->extrasvalue = 0.00;
$this->tax = 0.00;
$this->extras = '';
$this->third_party_extras = array();
$this->third_party_extras_private_data = array();
$this->total_discount = 0.00;
$this->depositpaidsuccessfully = false;
$this->booker_class = '000';
$this->ok_to_book = false;
$this->referrer = '';
$this->error_log = '';
$this->total_in_party = 0;
$this->mininterval = 1;
$this->unixArrivalDate = null;
$this->unixDepartureDate = null;
$this->beds_available = 0;
$this->monitoringMessages = array();
$this->room_feature_filter = array();
$this->vt = '';
$this->vu = '';
$this->vq = '';
$this->vv = '';
$this->rr = '';
$this->standard_guest_numbers = 0;
$this->extra_guest_numbers = 0;
$this->child_numbers = array();
$this->child_prices = array();
$this->city_tax = 0;
$this->cleaning_fee = 0;
$this->extra_guest_price = 0.00;
$this->existing_id = '';
$this->mos_userid = 0;
$this->firstname = '';
$this->surname = '';
$this->house = '';
$this->street = '';
$this->town = '';
$this->region = '';
$this->postcode = '';
$this->tel_landline = '';
$this->tel_mobile = '';
$this->email = '';
$this->guest_specific_discount = 0;
$this->additional_line_items = array();
// Should be better at detecting today's date subject DST
$this->today = date('Y/m/d', mktime(0, 0, 0, date('m'), date('d'), date('Y')));
$this->error = '';
$this->error_code = '';
$this->billing_roomtotal = 0.00;
$this->resetPricingOutput = false;
$this->roomImageHTML = '';
$this->allPropertyRooms = array();
$this->allPropertyRoomUids = array();
$this->allPropertyTariffs = array();
$this->allFeatureDetails = array();
$this->allFeatureIds = array();
$this->allRoomClasses = array();
$this->allRoomClassIds = array();
$this->allBookings = array();
$this->rebuildIgnoreList = array();
$this->currentField = '';
$this->singlePersonSupplimentCalculated = false;
$this->email_address_can_be_used = true;
$bookingDeets = $this->getTmpBookingData();
$this->setErrorLog('Queried session data for existing booking');
if (!empty($bookingDeets)) {
if (!isset($bookingDeets[ 'email_address_can_be_used' ])) {
$bookingDeets[ 'email_address_can_be_used' ] = true;
}
$this->email_address_can_be_used = $bookingDeets[ 'email_address_can_be_used' ];
$this->rr = $bookingDeets[ 'requestedRoom' ];
$this->rate_pernight = $bookingDeets[ 'rate_pernight' ];
$this->vt = $bookingDeets[ 'variancetypes' ];
$this->vu = $bookingDeets[ 'varianceuids' ];
$this->vq = $bookingDeets[ 'varianceqty' ];
$this->vv = $bookingDeets[ 'variancevals' ];
$this->vv_nodiscount = $bookingDeets[ 'variancevals_nodiscount' ];
//$this->coupon_id = $bookingDeets['coupon_id'];
//$this->coupon = $bookingDeets['coupon'];
$this->lastminute_id = $bookingDeets[ 'lastminute_id' ];
if (!isset($bookingDeets[ 'arrivalDate' ])) {
$bookingDeets[ 'arrivalDate' ] = '';
$bookingDeets[ 'departureDate' ] = '';
}
$this->arrivalDate = $bookingDeets[ 'arrivalDate' ];
$this->departureDate = $bookingDeets[ 'departureDate' ];
$this->stayDays = $bookingDeets[ 'stayDays' ];
$this->dateRangeString = $bookingDeets[ 'dateRangeString' ];
$this->guests_uid = $bookingDeets[ 'guests_uid' ];
$this->property_uid = (int) $bookingDeets[ 'property_uid' ];
if ($this->property_uid==0 && isset($_GET['property_uid_check'])) {
$this->property_uid = (int)$_GET['property_uid_check'];
}
$this->rates_uid = $bookingDeets[ 'rates_uid' ];
$this->resource = $bookingDeets[ 'resource' ];
$this->single_person_suppliment = $bookingDeets[ 'single_person_suppliment' ];
$this->deposit_required = $bookingDeets[ 'deposit_required' ];
$this->contract_total = $bookingDeets[ 'contract_total' ];
$this->extrasvalue = $bookingDeets[ 'extrasvalue' ];
if (isset($bookingDeets[ 'standard_guest_numbers' ])) {
$this->standard_guest_numbers = $bookingDeets[ 'standard_guest_numbers' ];
}
if (isset($bookingDeets[ 'extra_guest_numbers' ])) {
$this->extra_guest_numbers = $bookingDeets[ 'extra_guest_numbers' ];
}
if (isset($bookingDeets[ 'child_numbers' ])) {
$this->child_numbers = $bookingDeets[ 'child_numbers' ];
}
if (isset($bookingDeets[ 'child_prices' ])) {
$this->child_prices = $bookingDeets[ 'child_prices' ];
}
$this->extra_guest_price = 0;
if (isset($bookingDeets[ 'extra_guest_price' ])) {
$this->extra_guest_price = $bookingDeets[ 'extra_guest_price' ];
}
$this->city_tax = 0;
if (isset($bookingDeets[ 'city_tax' ])) {
$this->city_tax = $bookingDeets['city_tax'];
}
$this->cleaning_fee = 0;
if (isset($bookingDeets[ 'cleaning_fee' ])) {
$this->cleaning_fee = $bookingDeets[ 'cleaning_fee' ];
}
if ($jrConfig['session_handler'] == 'database') {
if (is_array($bookingDeets[ 'extrasvalues_items' ])) {
$this->extrasvalues_items = $bookingDeets[ 'extrasvalues_items' ];
} else {
$this->extrasvalues_items = array();
}
if (is_array($bookingDeets[ 'third_party_extras' ])) {
$this->third_party_extras = $bookingDeets[ 'third_party_extras' ];
} else {
$this->third_party_extras = array();
}
if (is_array($bookingDeets[ 'third_party_extras_private_data' ])) {
$this->third_party_extras_private_data = $bookingDeets[ 'third_party_extras_private_data' ];
} else {
$this->third_party_extras_private_data = array();
}
if (is_array($bookingDeets[ 'room_allocations' ])) {
$this->room_allocations = $bookingDeets[ 'room_allocations' ];
} else {
$this->room_allocations = array();
}
if (is_array($bookingDeets[ 'additional_line_items' ])) {
$this->additional_line_items = $bookingDeets[ 'additional_line_items' ];
} else {
$this->additional_line_items = array();
}
if (is_array($bookingDeets[ 'room_feature_filter' ])) {
$this->room_feature_filter = $bookingDeets[ 'room_feature_filter' ];
} else {
$this->room_feature_filter = array();
}
} else {
$this->extrasvalues_items = unserialize($bookingDeets[ 'extrasvalues_items' ]);
$this->third_party_extras = unserialize($bookingDeets[ 'third_party_extras' ]);
$this->third_party_extras_private_data = unserialize($bookingDeets[ 'third_party_extras_private_data' ]);
$this->room_allocations = unserialize($bookingDeets[ 'room_allocations' ]);
$this->additional_line_items = unserialize($bookingDeets[ 'additional_line_items' ]);
$this->room_feature_filter = unserialize($bookingDeets[ 'room_feature_filter' ]);
}
$this->room_allocations_note = $bookingDeets[ 'room_allocations_note' ];
$this->property_currencycode = $bookingDeets[ 'property_currencycode' ];
$this->tax = $bookingDeets[ 'tax' ];
$this->extras = $bookingDeets[ 'extras' ];
$this->extrasquantities = $bookingDeets[ 'extrasquantities' ];
$this->total_discount = $bookingDeets[ 'total_discount' ];
$this->depositpaidsuccessfully = $bookingDeets[ 'depositpaidsuccessfully' ];
$this->booker_class = $bookingDeets[ 'booker_class' ];
$this->ok_to_book = $bookingDeets[ 'ok_to_book' ];
$this->beds_available = $bookingDeets[ 'beds_available' ];
$this->referrer = $bookingDeets[ 'referrer' ];
$this->error = $bookingDeets[ 'error_log' ];
$this->room_total = $bookingDeets[ 'room_total' ];
$this->room_total_nodiscount = $bookingDeets[ 'room_total_nodiscount' ];
//$this->discounts = $bookingDeets[ 'discounts' ];
$this->total_in_party = $bookingDeets[ 'total_in_party' ];
$this->amend_contract = false;
if (isset($bookingDeets[ 'amend_contract' ])) {
$this->amend_contract = $bookingDeets[ 'amend_contract' ];
}
$this->coupon_id = $bookingDeets[ 'coupon_id' ];
$this->coupon_code = $bookingDeets[ 'coupon_code' ];
$this->coupon_details = $bookingDeets[ 'coupon_details' ];
$this->coupon_discount_value = $bookingDeets[ 'coupon_discount_value' ];
$this->booking_notes = $bookingDeets[ 'booking_notes' ];
$this->override_room_total = $bookingDeets[ 'override_room_total' ];
$this->override_deposit = $bookingDeets[ 'override_deposit' ];
if (isset($bookingDeets[ 'thirdparty_vars' ])) {
$this->thirdparty_vars = $bookingDeets[ 'thirdparty_vars' ];
}
$MiniComponents = jomres_getSingleton('mcHandler');
$this->wiseprice_installed = false;
if (isset($MiniComponents->registeredClasses['00501']['xwiseprice'])) { // A check to see if the wiseprice config tab plugin is installed. If it is not, we will not use the setting elsewhere in the engine
$this->wiseprice_installed = true;
}
}
$dbdata = serialize($bookingDeets);
$dbdata = str_replace(';', ' ', $dbdata);
$this->setErrorLog("<font color='grey'>Constructor::Data pulled from Session variables ".$dbdata.'</font>');
if (!empty($this->rr)) {
$this->requestedRoom = explode(',', $this->rr);
}
$this->variancetypes = explode(',', $this->vt);
$this->varianceuids = explode(',', $this->vu);
$this->varianceqty = explode(',', $this->vq);
$this->variancevals = explode(',', $this->vv);
$this->variancevals_nodiscount = explode(',', $this->vv_nodiscount);
foreach ($this->varianceuids as $key => $variance_uid) {
if ((int) $variance_uid == 0 || !$this->checkGuestVariantIdAndQty($variance_uid, 1)) {
$this->setErrorLog('init::Unsetting variances with key '.$key);
unset($this->variancetypes[ $key ]);
unset($this->varianceuids[ $key ]);
unset($this->varianceqty[ $key ]);
unset($this->variancevals[ $key ]);
unset($this->variancevals_nodiscount[ $key ]);
}
}
$userDeets = $this->getTmpGuestData();
//$this->errorLog( "Set booking variables " );
$this->mos_userid = $userDeets[ 'mos_userid' ];
$this->existing_id = $userDeets[ 'existing_id' ];
$this->firstname = $userDeets[ 'firstname' ];
$this->surname = $userDeets[ 'surname' ];
$this->house = $userDeets[ 'house' ];
$this->street = $userDeets[ 'street' ];
$this->town = $userDeets[ 'town' ];
$this->region = $userDeets[ 'region' ];
$this->country = $userDeets[ 'country' ];
$this->postcode = $userDeets[ 'postcode' ];
$this->tel_landline = $userDeets[ 'tel_landline' ];
$this->tel_mobile = $userDeets[ 'tel_mobile' ];
$this->email = $userDeets[ 'email' ];
$this->guest_specific_discount = 0;
if (isset($userDeets[ 'discount' ])) {
$this->guest_specific_discount = $userDeets[ 'discount' ];
}
$mrConfig = getPropertySpecificSettings($this->property_uid);
$this->ignore_guest_number_checks = false;
if ($mrConfig['item_hire_property']) {
$this->ignore_guest_number_checks = true;
}
jr_import('jomres_occupancy_levels');
$this->jomres_occupancy_levels = new jomres_occupancy_levels($this->property_uid);
$this->mrConfig = $mrConfig;
if (isset($mrConfig[ 'margin' ]) && !empty($mrConfig[ 'margin' ])) {
$this->margin = $mrConfig[ 'margin' ];
} else {
$this->margin = '0.00';
}
$this->tariffModel = $mrConfig[ 'newTariffModels' ];
if ($this->tariffModel != '1' && $this->tariffModel != '2') {
$this->tariffModel = '1';
}
if (!isset($mrConfig[ 'cal_input' ])) {
echo "Error: Configuration settings don't appear to be set. There are ".count($mrConfig).' elements in the mrConfig var and '.count($jrConfig).' in the jrConfig var. If you have just installed Jomres you should log into the frontend as a property manager. This will set up sufficient data so that you can proceed.';
exit;
}
$this->cfg_tariffmode = $mrConfig[ 'tariffmode' ];
$this->cfg_errorChecking = $mrConfig[ 'errorChecking' ];
$this->cfg_singlePersonSuppliment = $mrConfig[ 'singlePersonSuppliment' ];
$this->cfg_supplimentChargeIsPercentage = $mrConfig[ 'supplimentChargeIsPercentage' ];
$this->cfg_singlePersonSupplimentCost = $mrConfig[ 'singlePersonSupplimentCost' ];
$this->cfg_perPersonPerNight = $mrConfig[ 'perPersonPerNight' ];
$this->cfg_depositIsPercentage = $mrConfig[ 'depositIsPercentage' ];
$this->cfg_depositValue = $mrConfig[ 'depositValue' ];
$this->cfg_visitorscanbookonline = $mrConfig[ 'visitorscanbookonline' ];
$this->cfg_fixedPeriodBookings = $mrConfig[ 'fixedPeriodBookings' ];
$this->cfg_fixedPeriodBookingsNumberOfDays = $mrConfig[ 'fixedPeriodBookingsNumberOfDays' ];
$this->cfg_numberofFixedPeriods = $mrConfig[ 'numberofFixedPeriods' ];
$this->cfg_fixedArrivalDateYesNo = $mrConfig[ 'fixedArrivalDateYesNo' ];
$this->cfg_fixedArrivalDay = $mrConfig[ 'fixedArrivalDay' ];
$this->cfg_fixedPeriodBookingsShortYesNo = $mrConfig[ 'fixedPeriodBookingsShortYesNo' ];
$this->cfg_fixedPeriodBookingsShortNumberOfDays = $mrConfig[ 'fixedPeriodBookingsShortNumberOfDays' ];
$this->cfg_singleRoomProperty = $mrConfig[ 'singleRoomProperty' ];
$this->cfg_cal_output = $mrConfig[ 'cal_output' ];
$this->cfg_cal_input = $jrConfig[ 'cal_input' ];
$this->cfg_templatePack = 'basic';
$this->cfg_limitAdvanceBookingsYesNo = $mrConfig[ 'limitAdvanceBookingsYesNo' ];
$this->cfg_advanceBookingsLimit = $mrConfig[ 'advanceBookingsLimit' ];
$this->cfg_roomTaxYesNo = $mrConfig[ 'roomTaxYesNo' ];
$this->cfg_roomTaxFixed = $mrConfig[ 'roomTaxFixed' ];
$this->cfg_roomTaxPercentage = $mrConfig[ 'roomTaxPercentage' ];
$this->cfg_euroTaxYesNo = $mrConfig[ 'euroTaxYesNo' ];
$this->cfg_euroTaxPercentage = $mrConfig[ 'euroTaxPercentage' ];
$this->cfg_depAmount = $mrConfig[ 'depAmount' ];
$this->cfg_showdepartureinput = $mrConfig[ 'showdepartureinput' ];
$this->cfg_ratemultiplier = $mrConfig[ 'ratemultiplier' ];
$this->cfg_dateFormatStyle = $mrConfig[ 'dateFormatStyle' ];
$this->cfg_inputBoxErrorBackground = $mrConfig[ 'inputBoxErrorBackground' ];
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
if (!isset($mrConfig[ 'auto_detect_country_for_booking_form' ])) {
$mrConfig[ 'auto_detect_country_for_booking_form' ] = '1';
}
if ($mrConfig[ 'auto_detect_country_for_booking_form' ] == '1' && isset($tmpBookingHandler->user_settings[ 'geolocated_country' ])) {
$this->cfg_defaultcountry = $tmpBookingHandler->user_settings[ 'geolocated_country' ];
} else {
$this->cfg_defaultcountry = $mrConfig[ 'defaultcountry' ];
}
//if ($this->booker_class == "100")
// $this->cfg_minimuminterval = 1;
//else
$this->cfg_minimuminterval = $mrConfig[ 'minimuminterval' ];
$this->cfg_showDeposit = $mrConfig[ 'chargeDepositYesNo' ];
$this->cfg_showRoomImageInBookingFormOverlib = $mrConfig[ 'showRoomImageInBookingFormOverlib' ];
if ($this->booker_class == '100') {
$this->cfg_mindaysbeforearrival = 0;
} else {
$this->cfg_mindaysbeforearrival = $mrConfig[ 'mindaysbeforearrival' ];
}
$this->cfg_defaultNumberOfFirstGuesttype = $mrConfig[ 'defaultNumberOfFirstGuesttype' ];
$this->cfg_roundupDepositYesNo = $mrConfig[ 'roundupDepositYesNo' ];
$this->cfg_chargeDepositYesNo = $mrConfig[ 'chargeDepositYesNo' ];
$this->cfg_tariffChargesStoredWeeklyYesNo = $mrConfig[ 'tariffChargesStoredWeeklyYesNo' ];
$this->cfg_fixedArrivalDatesRecurring = $mrConfig[ 'fixedArrivalDatesRecurring' ];
$this->cfg_returnRoomsLimit = $mrConfig[ 'returnRoomsLimit' ];
if (!isset($mrConfig[ 'cfg_weekenddays' ])) {
$mrConfig[ 'cfg_weekenddays' ] = '5,6';
}
$this->cfg_weekenddays = explode(',', $mrConfig[ 'weekenddays' ]);
$this->cfg_bookingform_roomlist_showroomno = $mrConfig[ 'bookingform_roomlist_showroomno' ];
$this->cfg_bookingform_roomlist_showroomname = $mrConfig[ 'bookingform_roomlist_showroomname' ];
$this->cfg_bookingform_roomlist_showdisabled = $mrConfig[ 'bookingform_roomlist_showdisabled' ];
$this->cfg_bookingform_roomlist_showmaxpeople = $mrConfig[ 'bookingform_roomlist_showmaxpeople' ];
$this->cfg_bookingform_requiredfields_name = $mrConfig[ 'bookingform_requiredfields_name' ];
$this->cfg_bookingform_requiredfields_surname = $mrConfig[ 'bookingform_requiredfields_surname' ];
$this->cfg_bookingform_requiredfields_houseno = $mrConfig[ 'bookingform_requiredfields_houseno' ];
$this->cfg_bookingform_requiredfields_street = $mrConfig[ 'bookingform_requiredfields_street' ];
$this->cfg_bookingform_requiredfields_town = $mrConfig[ 'bookingform_requiredfields_town' ];
$this->cfg_bookingform_requiredfields_postcode = $mrConfig[ 'bookingform_requiredfields_postcode' ];
$this->cfg_bookingform_requiredfields_region = $mrConfig[ 'bookingform_requiredfields_region' ];
$this->cfg_bookingform_requiredfields_country = $mrConfig[ 'bookingform_requiredfields_country' ];
$this->cfg_bookingform_requiredfields_tel = $mrConfig[ 'bookingform_requiredfields_tel' ];
$this->cfg_bookingform_requiredfields_mobile = $mrConfig[ 'bookingform_requiredfields_mobile' ];
$mrConfig[ 'bookingform_requiredfields_email' ] = "1"; // For GDPR compliance, bookings will always require an email address and the property manager will not be allowed to change this setting
$this->cfg_bookingform_requiredfields_email = $mrConfig[ 'bookingform_requiredfields_email' ];
$this->property_currencycode = $mrConfig[ 'property_currencycode' ];
if (!isset($mrConfig[ 'booking_form_rooms_list_style' ])) {
$mrConfig[ 'booking_form_rooms_list_style' ] = '1';
}
if (!isset($mrConfig[ 'booking_form_daily_weekly_monthly' ])) {
$mrConfig[ 'booking_form_daily_weekly_monthly' ] = 'D';
}
$this->cfg_booking_form_daily_weekly_monthly = $mrConfig[ 'booking_form_daily_weekly_monthly' ];
$amend_contract = $tmpBookingHandler->getBookingFieldVal('amend_contract');
if ($amend_contract) {
$mrConfig[ 'booking_form_rooms_list_style' ] = '1';
}
$this->cfg_booking_form_rooms_list_style = $mrConfig[ 'booking_form_rooms_list_style' ];
$mrConfig = $this->mrConfig;
$this->accommodation_tax_rate = 0.0;
if (isset($mrConfig[ 'accommodation_tax_code' ]) && (int) $mrConfig[ 'accommodation_tax_code' ] > 0) {
$jrportal_taxrate = jomres_singleton_abstract::getInstance('jrportal_taxrate');
$cfgcode = $mrConfig[ 'accommodation_tax_code' ];
$this->accommodation_tax_rate = (float) $jrportal_taxrate->taxrates[ $cfgcode ][ 'rate' ];
}
// Let's get the room, tariff, room type (class) and room feature information for this property
if (get_showtime('include_room_booking_functionality')) {
$this->getAllRoomsData();
$this->getAllTariffsData();
$this->getAllRoomFeatureDetails();
$this->getAllRoomClasses();
$this->getAllRoomFeatures();
$this->getAllBookings();
$this->getAllTaxRates();
$this->get_all_tariff_types();
$this->checkAllGuestsAllocatedToRooms();
}
$this->checkAllGuestsAllocatedToRooms();
return true;
}
/**
*Queries the database for the temporary booking data.
*/
public function getTmpBookingData()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$bookingDeets = $tmpBookingHandler->getBookingData();
if (!isset($bookingDeets[ 'show_extras' ])) {
$bookingDeets[ 'show_extras' ] = '1';
}
$this->cfg_showExtras = $bookingDeets[ 'show_extras' ];
return $bookingDeets;
}
/**
*Queries the database for the temporary booking data.
*/
public function getTmpGuestData()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$userDeets = $tmpBookingHandler->getGuestData();
return $userDeets;
}
/**
* Save the details of the booking object.
*/
public function storeBookingDetails()
{
$siteConfig = jomres_singleton_abstract::getInstance('jomres_config_site_singleton');
$jrConfig = $siteConfig->get();
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$this->writeToLogfile("<font color='grey'>".serialize($tmpBookingHandler->tmpguest).'</font>');
$tmpBookingHandler->tmpguest[ 'mos_userid' ] = $this->mos_userid;
$tmpBookingHandler->tmpguest[ 'existing_id' ] = (int)$this->existing_id;
$tmpBookingHandler->tmpguest[ 'firstname' ] = $this->firstname;
$tmpBookingHandler->tmpguest[ 'surname' ] = $this->surname;
$tmpBookingHandler->tmpguest[ 'house' ] = $this->house;
$tmpBookingHandler->tmpguest[ 'street' ] = $this->street;
$tmpBookingHandler->tmpguest[ 'town' ] = $this->town;
$tmpBookingHandler->tmpguest[ 'region' ] = $this->region;
$tmpBookingHandler->tmpguest[ 'country' ] = $this->country;
$tmpBookingHandler->tmpguest[ 'postcode' ] = $this->postcode;
$tmpBookingHandler->tmpguest[ 'tel_landline' ] = $this->tel_landline;
$tmpBookingHandler->tmpguest[ 'tel_mobile' ] = $this->tel_mobile;
$tmpBookingHandler->tmpguest[ 'email' ] = $this->email;
$tmpBookingHandler->tmpguest[ 'discount' ] = getEscaped($this->guest_specific_discount);
$rr = implode(',', $this->requestedRoom);
$this->implodeVariances();
$this->writeToLogfile($this->error);
$this->error = '';
$tmpBookingHandler->tmpbooking[ 'requestedRoom' ] = $rr;
$tmpBookingHandler->tmpbooking[ 'rate_pernight' ] = $this->rate_pernight;
$tmpBookingHandler->tmpbooking[ 'variancetypes' ] = $this->vt;
$tmpBookingHandler->tmpbooking[ 'varianceuids' ] = $this->vu;
$tmpBookingHandler->tmpbooking[ 'varianceqty' ] = $this->vq;
$tmpBookingHandler->tmpbooking[ 'variancevals' ] = $this->vv;
$tmpBookingHandler->tmpbooking[ 'variancevals_nodiscount' ] = $this->vv_nodiscount;
//$tmpBookingHandler->tmpbooking["coupon_id"] = $this->coupon_id;
//$tmpBookingHandler->tmpbooking["coupon"] = $this->coupon;
$tmpBookingHandler->tmpbooking[ 'lastminute_id' ] = $this->lastminute_id;
$tmpBookingHandler->tmpbooking[ 'arrivalDate' ] = $this->arrivalDate;
$tmpBookingHandler->tmpbooking[ 'departureDate' ] = $this->departureDate;
$tmpBookingHandler->tmpbooking[ 'stayDays' ] = $this->stayDays;
$tmpBookingHandler->tmpbooking[ 'dateRangeString' ] = $this->dateRangeString;
$tmpBookingHandler->tmpbooking[ 'guests_uid' ] = $this->guests_uid;
$tmpBookingHandler->tmpbooking[ 'property_uid' ] = $this->property_uid;
$tmpBookingHandler->tmpbooking[ 'rates_uid' ] = $this->rates_uid;
$tmpBookingHandler->tmpbooking[ 'resource' ] = $this->resource;
$tmpBookingHandler->tmpbooking[ 'single_person_suppliment' ] = $this->single_person_suppliment;
$tmpBookingHandler->tmpbooking[ 'deposit_required' ] = $this->deposit_required;
$tmpBookingHandler->tmpbooking[ 'contract_total' ] = $this->contract_total;
$tmpBookingHandler->tmpbooking[ 'extrasvalue' ] = $this->extrasvalue;
$tmpBookingHandler->tmpbooking[ 'extras' ] = $this->extras;
$tmpBookingHandler->tmpbooking[ 'extrasquantities' ] = $this->extrasquantities;
$tmpBookingHandler->tmpbooking[ 'standard_guest_numbers' ] = $this->standard_guest_numbers;
$tmpBookingHandler->tmpbooking[ 'extra_guest_numbers' ] = $this->extra_guest_numbers;
$tmpBookingHandler->tmpbooking[ 'child_numbers' ] = $this->child_numbers;
$tmpBookingHandler->tmpbooking[ 'child_prices' ] = $this->child_prices;
$tmpBookingHandler->tmpbooking[ 'extra_guest_price' ] = $this->extra_guest_price;
$tmpBookingHandler->tmpbooking[ 'city_tax' ] = $this->city_tax;
$tmpBookingHandler->tmpbooking[ 'cleaning_fee' ] = $this->cleaning_fee;
if ($jrConfig['session_handler'] == 'database') {
$tmpBookingHandler->tmpbooking[ 'extrasvalues_items' ] = $this->extrasvalues_items;
$tmpBookingHandler->tmpbooking[ 'third_party_extras' ] = $this->third_party_extras;
$tmpBookingHandler->tmpbooking[ 'third_party_extras_private_data' ] = $this->third_party_extras_private_data;
$tmpBookingHandler->tmpbooking[ 'room_allocations' ] = $this->room_allocations;
$tmpBookingHandler->tmpbooking[ 'room_allocations_note' ] = $this->room_allocations_note;
$tmpBookingHandler->tmpbooking[ 'additional_line_items' ] = $this->additional_line_items;
$tmpBookingHandler->tmpbooking[ 'room_feature_filter' ] = $this->room_feature_filter;
} else {
$tmpBookingHandler->tmpbooking[ 'extrasvalues_items' ] = serialize($this->extrasvalues_items);
$tmpBookingHandler->tmpbooking[ 'third_party_extras' ] = serialize($this->third_party_extras);
$tmpBookingHandler->tmpbooking[ 'third_party_extras_private_data' ] = serialize($this->third_party_extras_private_data);
$tmpBookingHandler->tmpbooking[ 'room_allocations' ] = serialize($this->room_allocations);
$tmpBookingHandler->tmpbooking[ 'room_allocations_note' ] = serialize($this->room_allocations_note);
$tmpBookingHandler->tmpbooking[ 'additional_line_items' ] = serialize($this->additional_line_items);
$tmpBookingHandler->tmpbooking[ 'room_feature_filter' ] = serialize($this->room_feature_filter);
}
$tmpBookingHandler->tmpbooking[ 'total_discount' ] = $this->total_discount;
$tmpBookingHandler->tmpbooking[ 'depositpaidsuccessfully' ] = $this->depositpaidsuccessfully;
$tmpBookingHandler->tmpbooking[ 'tax' ] = $this->tax;
$tmpBookingHandler->tmpbooking[ 'booker_class' ] = $this->booker_class;
$tmpBookingHandler->tmpbooking[ 'ok_to_book' ] = $this->ok_to_book;
$tmpBookingHandler->tmpbooking[ 'beds_available' ] = $this->beds_available;
$tmpBookingHandler->tmpbooking[ 'referrer' ] = $this->referrer;
$tmpBookingHandler->tmpbooking[ 'error_log' ] = $this->error;
$tmpBookingHandler->tmpbooking[ 'total_in_party' ] = $this->total_in_party;
$tmpBookingHandler->tmpbooking[ 'room_total' ] = $this->room_total;
$tmpBookingHandler->tmpbooking[ 'room_total_nodiscount' ] = $this->room_total_nodiscount;
$tmpBookingHandler->tmpbooking[ 'discounts' ] = $this->discounts;
$tmpBookingHandler->tmpbooking[ 'timestamp' ] = date('Y-m-d H:i:s');
$tmpBookingHandler->tmpbooking[ 'mininterval' ] = $this->mininterval;
$tmpBookingHandler->tmpbooking[ 'coupon_id' ] = $this->coupon_id;
$tmpBookingHandler->tmpbooking[ 'coupon_code' ] = $this->coupon_code;
$tmpBookingHandler->tmpbooking[ 'coupon_details' ] = $this->coupon_details;
$tmpBookingHandler->tmpbooking[ 'coupon_discount_value' ] = $this->coupon_discount_value;
$tmpBookingHandler->tmpbooking[ 'booking_notes' ] = $this->booking_notes;
$tmpBookingHandler->tmpbooking[ 'override_room_total' ] = $this->override_room_total;
$tmpBookingHandler->tmpbooking[ 'override_deposit' ] = $this->override_deposit;
$tmpBookingHandler->tmpbooking[ 'show_extras' ] = $this->cfg_showExtras;
$tmpBookingHandler->tmpbooking[ 'property_currencycode' ] = $this->property_currencycode;
$tmpBookingHandler->tmpbooking[ 'email_address_can_be_used' ] = $this->email_address_can_be_used;
if (isset($this->thirdparty_vars)) {
$tmpBookingHandler->tmpbooking[ 'thirdparty_vars' ] = $this->thirdparty_vars;
}
}
/**
*
*
*
*/
public function getAllRoomsData()
{
$room_type_filter = (int)jomresGetParam($_REQUEST, 'room_type_filter', 0);
$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);
jr_import('jomres_markdown');
$jomres_markdown = new jomres_markdown();
$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$images = $jomres_media_centre_images->get_images($this->property_uid, array('rooms')); // Gets the rooms images
$room_images = $images [ 'rooms' ];
foreach ($basic_room_details->rooms as $r) {
if ($room_type_filter == 0 || $r['room_classes_uid'] == $room_type_filter) {
$this->allPropertyRooms[ $r['room_uid'] ] = array(
'room_uid' => $r['room_uid'],
'room_classes_uid' => $r['room_classes_uid'],
'propertys_uid' => $r['propertys_uid'],
'room_features_uid' => $r['room_features_uid'],
'room_name' => $r['room_name'],
'room_number' => $r['room_number'],
'room_floor' => $r['room_floor'],
'max_people' => $r['max_people'],
'singleperson_suppliment' => $r['singleperson_suppliment'],
'tagline' => $r['tagline'],
'description' => $jomres_markdown->get_markdown($r['description']),
'surcharge' => $r['surcharge'],
'small_room_image' => $room_images [ $r['room_uid'] ] [0] ['small'],
'medium_room_image' => $room_images [ $r['room_uid'] ] [0] ['medium'],
'large_room_image' => $room_images [ $r['room_uid'] ] [0] ['large'],
);
$this->allPropertyRoomUids[ ] = $r['room_uid'];
if (!in_array($r['room_classes_uid'], $this->allRoomClassIds)) {
$this->allRoomClassIds[ ] = $r['room_classes_uid'];
}
}
}
if (!empty($basic_room_details->all_room_features)) {
$this->allFeatureIds = array_keys($basic_room_details->all_room_features);
}
}
/**
*
*
*
*/
public function getAllTariffsData()
{
$query = "SELECT `rates_uid`,`rate_title`,`rate_description`,`validfrom`,`validto`,
`roomrateperday`, `extra_guests_price`, `modifiers`, `mindays`,`maxdays`,`minpeople`,`maxpeople`,`roomclass_uid`,
`ignore_pppn`,`allow_ph`,`allow_we`,`weekendonly`,`dayofweek`,`minrooms_alreadyselected`,`maxrooms_alreadyselected`
FROM #__jomres_rates WHERE property_uid = '$this->property_uid'
AND DATE_FORMAT(`validto`, '%Y/%m/%d') >= DATE_FORMAT('".$this->today."', '%Y/%m/%d')
";
$this->absolute_max_guests_by_tariffs = 0;
$tariffs = doSelectSql($query);
//$this->setErrorLog("getAllTariffsData:: ".$query );
//$this->setErrorLog("Finding tariffs");
//$this->setErrorLog($query);
//$this->setErrorLog(serialize($tariffs) );
$interval = new DateInterval('P1D');
foreach ($tariffs as $t) {
if (is_null($t->modifiers)) {
$t->modifiers = '';
}
if ( $t->maxpeople > $this->absolute_max_guests_by_tariffs ) {
$this->absolute_max_guests_by_tariffs = $t->maxpeople;
}
$roomrate = $this->get_nett_price($t->roomrateperday, $this->accommodation_tax_rate);
$dates = $this->get_periods($t->validfrom, $t->validto.' 23:59:59', $interval);
$this->allPropertyTariffs[ $t->rates_uid ] = array(
'rates_uid' => $t->rates_uid,
'rate_title' => $t->rate_title,
'rate_description' => $t->rate_description,
'validfrom' => $t->validfrom,
'validto' => $t->validto,
'roomrateperday' => $roomrate,
'extra_guests_price' => $t->extra_guests_price ,
'modifiers' => json_decode(base64_decode($t->modifiers)) ,
'mindays' => $t->mindays,
'maxdays' => $t->maxdays,
'minpeople' => $t->minpeople,
'maxpeople' => $t->maxpeople,
'roomclass_uid' => $t->roomclass_uid,
'ignore_pppn' => $t->ignore_pppn,
'allow_ph' => $t->allow_ph,
'allow_we' => $t->allow_we,
'weekendonly' => $t->weekendonly,
'dayofweek' => $t->dayofweek,
'minrooms_alreadyselected' => $t->minrooms_alreadyselected,
'maxrooms_alreadyselected' => $t->maxrooms_alreadyselected,
'tariff_dates' => $dates,
);
if (!empty($this->allPropertyTariffs)) {
$mindays_array = array();
foreach ($this->allPropertyTariffs as $tariff) {
$mindays = $tariff['mindays'];
if (!isset($mindays_array[$mindays] )) {
$mindays_array[] = $mindays;
}
}
if (count($mindays_array) == 1) {
$this->mininterval = (int) $mindays;
} else {
$this->mininterval = min($mindays_array);
}
}
}
}
/**
*
*
*
*/
public function getAllRoomFeatureDetails()
{
$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$jomres_media_centre_images->get_images($this->property_uid, array('room_features'));
$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);
foreach ($basic_room_details->all_room_features as $f) {
$this->allFeatureDetails[ $f['room_features_uid'] ] = array('room_features_uid' => $f['room_features_uid'], 'feature_description' => $f['feature_description'], 'image' => $f['image'], 'tooltip' => $f['tooltip']);
}
}
/**
*
*
*
*/
public function getAllRoomClasses()
{
$jomres_media_centre_images = jomres_singleton_abstract::getInstance('jomres_media_centre_images');
$jomres_media_centre_images->get_images($this->property_uid);
$jomres_media_centre_images->get_site_images('rmtypes'); // These are administrator created room type images. If the property manager doesn't upload images for a room type (which is quite possible if they aren't given the option) then we'll "fallback" to admin created images instead
$basic_property_details = jomres_singleton_abstract::getInstance('basic_property_details');
$resource_type = 'room_types';
$query = 'SELECT room_classes_uid,room_class_abbv,room_class_full_desc,image FROM #__jomres_room_classes WHERE room_classes_uid IN ('.jomres_implode($this->allRoomClassIds).') ';
$roomClasses = doSelectSql($query);
foreach ($roomClasses as $c) {
$roomtype_abbv = jr_gettext('_JOMRES_CUSTOMTEXT_ROOMTYPES_ABBV'.(int) $c->room_classes_uid, stripslashes($c->room_class_abbv), false, false);
$roomtype_desc = jr_gettext('_JOMRES_CUSTOMTEXT_ROOMTYPES_DESC'.(int) $c->room_classes_uid, stripslashes($c->room_class_full_desc), false, false);
$resource_id = $c->room_classes_uid;
if (isset($jomres_media_centre_images->images [$resource_type] [$resource_id])) {
$images = $jomres_media_centre_images->images [$resource_type] [$resource_id];
} else {
if (isset($basic_property_details->this_property_room_classes[$resource_id]['image']) && file_exists(JOMRES_IMAGELOCATION_ABSPATH.'rmtypes/'.$basic_property_details->this_property_room_classes[$resource_id]['image'])) {
$images = array( array ( "large" => JOMRES_IMAGELOCATION_RELPATH.'rmtypes/'.$basic_property_details->this_property_room_classes[$resource_id]['image']) );
} else {
$images = array ( array(
"large" => $jomres_media_centre_images->multi_query_images['noimage-large'],
"medium" => $jomres_media_centre_images->multi_query_images['noimage-medium'],
"small" => $jomres_media_centre_images->multi_query_images['noimage-small']
) );
}
}
$this->allRoomClasses[ $c->room_classes_uid ] = array('room_class_abbv' => $roomtype_abbv, 'room_class_full_desc' => $roomtype_desc, 'image' => $c->image , 'images' => $images);
}
}
/**
*
*
*
*/
public function getAllRoomFeatures()
{
$basic_room_details = jomres_singleton_abstract::getInstance('basic_room_details');
$basic_room_details->get_all_rooms($this->property_uid);
if (!empty($basic_room_details->all_room_features)) {
foreach ($basic_room_details->all_room_features as $f) {
$this->allRoomFeatures[ $f['room_features_uid'] ] = $f['feature_description'];
}
}
}
/**
*
*
*
*/
public function getAllBookings()
{
$tmpBookingHandler = jomres_getSingleton('jomres_temp_booking_handler');
$amend_contract = $tmpBookingHandler->getBookingFieldVal('amend_contract');
$amend_contractuid = $tmpBookingHandler->getBookingFieldVal('amend_contractuid');
if (!$amend_contract) {
$query = "SELECT room_uid,date FROM #__jomres_room_bookings WHERE property_uid = '$this->property_uid' AND room_uid IN (".jomres_implode($this->allPropertyRoomUids).') ';
} else {
$query = "SELECT room_uid,date FROM #__jomres_room_bookings WHERE property_uid = '$this->property_uid' AND contract_uid != '$amend_contractuid' AND room_uid IN (".jomres_implode($this->allPropertyRoomUids).') ';
}
$bookings = doSelectSql($query);
foreach ($bookings as $c) {
//$date=str_replace("/","",$c->date);
$this->allBookings[ $c->date ][ $c->room_uid ] = array('room_uid' => $c->room_uid);
}
if (!empty($this->allBookings)) {
ksort($this->allBookings);
}
}
/**
*
*
*
*/
public function get_all_tariff_types()
{
$mrConfig = $this->mrConfig;
$this->all_tariff_types_to_tariff_id_xref = array();
$this->all_tariff_id_to_tariff_type_xref = array();
if ($mrConfig[ 'tariffmode' ] == '2' || $mrConfig[ 'tariffmode' ] == '5') {
$query = "SELECT tarifftype_id,tariff_id FROM #__jomcomp_tarifftype_rate_xref WHERE property_uid = '$this->property_uid'";
$tariff_type_list = doSelectSql($query);
if (!empty($tariff_type_list)) {
foreach ($tariff_type_list as $type) {
$this->all_tariff_types_to_tariff_id_xref[ $type->tarifftype_id ][ ] = $type->tariff_id;
$this->all_tariff_id_to_tariff_type_xref[ $type->tariff_id ][ ] = $type->tarifftype_id;
}
}
}
}
/**
*
*
*
*/
public function getAllTaxRates()
{
$jrportal_taxrate = jomres_singleton_abstract::getInstance('jrportal_taxrate');
$this->taxrates = $jrportal_taxrate->taxrates;
//$this->setErrorLog( "Init found tax rates " . serialize( $this->taxrates ) );
}
/**
*
*
*
*/
public function sanitise_for_eval($string)
{
$string = str_replace('"', '\"', $string);
$string = str_replace("'", "\'", $string);
$string = trim(preg_replace('/\s+/', ' ', $string)); // strips carriage returns from strings generated through templates
return $string;
}
/**
*
*
*
*/
public function get_fullybooked_dates()
{
$fully_booked_dates = array();
$MiniComponents = jomres_getSingleton('mcHandler');
if ($MiniComponents->eventFileExistsCheck('05060')) {
$result = $MiniComponents->triggerEvent('05060', $this);
if (isset($result[ 'plugin_manages_fully_booked_dates' ]) && $result[ 'plugin_manages_fully_booked_dates' ]) {
$booked_dates = $result[ 'fully_booked_dates' ];
foreach ($booked_dates as $date) {
$tmpdate = date('Y-n-j', strtotime($date));
$fully_booked_dates[ ] = $tmpdate;
}
}
}
if (!isset($result[ 'plugin_manages_fully_booked_dates' ])) {
$total_number_of_rooms = count($this->allPropertyRooms);
foreach ($this->allBookings as $date => $bookings) {
$number_of_bookings_this_date = count($bookings);
if ($number_of_bookings_this_date == $total_number_of_rooms) {
$tmpdate = date('Y-n-j', strtotime($date));
$fully_booked_dates[ ] = $tmpdate;
}
}
$all_tariffs_are_specific_days_of_week = true;
foreach ($this->allPropertyTariffs as $tariff) {
if ($tariff[ 'dayofweek' ] == 7) {
$all_tariffs_are_specific_days_of_week = false;
}
}
if ($all_tariffs_are_specific_days_of_week) {
$days_of_week_allowed = array();
foreach ($this->allPropertyTariffs as $tariff) {
$days_of_week_allowed[ ] = $tariff[ 'dayofweek' ];
}
$days_of_week_allowed = array_unique($days_of_week_allowed);
$start = date('Y/m/d');
$end = date('Y/m/d', strtotime('+4 years'));
$dates = $this->findDateRangeForDates($start, $end);
$count = count($dates);
for ($i = 0; $i <= $count; ++$i) {
$date = $dates[ $i ];
$day_of_week_of_date = $this->getDayOfWeek($date);
if (in_array($day_of_week_of_date, $days_of_week_allowed)) {
unset($dates[ $i ]);
}
}
foreach ($dates as $d) {
$tmpdate = date('Y-n-j', strtotime($d));
$fully_booked_dates[ ] = $tmpdate;
}
}
}
return $fully_booked_dates;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Generic variant handling