Changeset 3103274
- Timestamp:
- 06/16/2024 04:45:47 PM (22 months ago)
- Location:
- occupancy-plan/trunk
- Files:
-
- 12 edited
-
admin/class-occupancy-plan-admin.php (modified) (9 diffs)
-
admin/controller/class-occupancy-plan-blocks.php (modified) (1 diff)
-
admin/controller/class-occupancy-plan-plans.php (modified) (5 diffs)
-
admin/partials/occupancy-plan-plan.php (modified) (1 diff)
-
includes/class-occupancy-plan-plugin.php (modified) (3 diffs)
-
occupancy-plan.php (modified) (2 diffs)
-
public/class-occupancy-plan-public.php (modified) (2 diffs)
-
public/css/occupancy-plan-public.css (modified) (1 diff)
-
public/js/occupancy-plan-public.js (modified) (3 diffs)
-
public/partials/occupancy-plan-booking-dialog.php (modified) (1 diff)
-
public/partials/occupancy-plan-public-display.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
occupancy-plan/trunk/admin/class-occupancy-plan-admin.php
r3068888 r3103274 532 532 * 1.3.8 - Don't send mail for block update 533 533 * 1.3.16 - Replace of [email] tag 534 * 1.4.1 - Bugfix: User correct blocks controller 534 * 1.4.1 - Bugfix: Use correct blocks controller 535 * 1.4.3 - Use 'checkblockconflict' column 535 536 */ 536 537 public function add_block() … … 548 549 { 549 550 return $this->handleError(__('No permission.', 'occupancy-plan')); 551 } 552 553 // Check if block is already occupied 554 if (isset($plan->checkblockconflict) && ($plan->checkblockconflict == 1) && ($this->blocks->check_block() > 0)) 555 { 556 return $this->handleError(__('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan')); 550 557 } 551 558 … … 789 796 * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column 790 797 * 1.3.13 - Add 'undefinedname' column 798 * 1.4.3 - Add 'checkblockconflict' column 791 799 */ 792 800 private function generate_csv($planID) … … 815 823 'allowintervaledit', 'anonymized', 'placeholder', 816 824 'allowcourtedit','timeinterval', 'frontendtooltip', 817 'undefinedname' );825 'undefinedname'. 'checkblockconflict'); 818 826 fputcsv($file, $csv_header, $delimiter); 819 827 … … 830 838 allowintervaledit,anonymized, placeholder, 831 839 allowcourtedit, timeinterval, frontendtooltip 832 undefinedname 840 undefinedname, checkblockconflict 833 841 FROM $table_plan WHERE id = $planID"; 834 842 $schedule = $wpdb->get_row($sql, ARRAY_A); … … 914 922 * 1.3.8 - Support of import of block for selected schedule 915 923 * 1.3.17 - Import of field 'authorizedusers' 924 * 1.4.3 - Add 'checkblockconflict' column 916 925 */ 917 926 public function csv_import($planID, $importblocks) … … 1048 1057 'timeinterval' => ($datalen > 43)? intval($csvdata[43]) : 60, 1049 1058 'frontendtooltip' => ($datalen > 44)? sanitize_text_field($csvdata[44]) : '', 1050 'undefinedname' => ($datalen > 45)? sanitize_text_field($csvdata[45]) : __('Undefined', 'occupancy-plan') 1059 'undefinedname' => ($datalen > 45)? sanitize_text_field($csvdata[45]) : __('Undefined', 'occupancy-plan'), 1060 'checkblockconflict' => ($datalen > 46)? intval($csvdata[46]) : 0 1051 1061 ); 1052 1062 $format = array('%s','%s','%s','%s','%s','%s', … … 1413 1423 * @since 1.4 1414 1424 * 1425 * 1.4.3 - Fix: Error An active PHP session was detected 1415 1426 */ 1416 1427 public function start_session() … … 1418 1429 if (!session_id()) 1419 1430 { 1420 session_start(); 1431 session_start([ 1432 'read_and_close' => true, 1433 ]); 1421 1434 } 1422 1435 } -
occupancy-plan/trunk/admin/controller/class-occupancy-plan-blocks.php
r3076337 r3103274 700 700 } 701 701 } 702 703 /** 704 * Check block existence / conflict 705 * 706 * @since 1.4.3 707 * 708 */ 709 public function check_block() 710 { 711 $planid = intval($_POST['planid']); 712 713 $interval = isset($_POST['interval'])? intval($_POST['interval']) : 1; 714 if ($interval != 1) 715 { 716 return 0; 717 } 718 $singledate = sanitize_text_field($_POST['startdate']); 719 $date = DateTime::createFromFormat('Y-m-d', $singledate); 720 721 $starttime = sanitize_text_field($_POST['starttime']); 722 $endtime = sanitize_text_field($_POST['endtime']); 723 724 $courttext = sanitize_text_field($_POST['court']); 725 if (strpos($courttext, '|') > 0) 726 { 727 $courtids = explode("|", $courttext); 728 $courtid = intval($courtids[0]); 729 $childcourtid = intval($courtids[1]); 730 } 731 else 732 { 733 $courtid = intval($courttext); 734 if (isset($_POST['childcourt-' . $courtid])) 735 { 736 $childcourtid = intval($_POST['childcourt-' . $courtid]); 737 } 738 else 739 { 740 $childcourtid = isset($_POST['childcourt'])? intval($_POST['childcourt']) : 0; 741 } 742 } 743 744 $weekday = $date->format("N"); 745 $weekdayinmonth = (int) ceil($date->format("d") / 7); 746 $calendarweek = 2 - (int) ceil($date->format("W") % 2 ); 747 748 global $wpdb; 749 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 750 751 $sql = "SELECT * FROM $table_block WHERE planid = {$planid} 752 AND (weekday = {$weekday}) 753 AND ((court = 0) OR (court = {$courtid})) 754 AND ((childcourt = 0) OR (childcourt = {$childcourtid})) 755 AND ('{$singledate}' BETWEEN startdate AND enddate) 756 AND ((('$starttime' >= starttime) AND ('$starttime' < endtime)) OR 757 (('$endtime' > starttime) AND ('$endtime' <= endtime))) 758 AND ((`interval` <> 3) OR (intervalinfo = {$weekdayinmonth})) 759 AND ((`interval` <> 5) OR (intervalinfo = {$calendarweek})) 760 LIMIT 1"; 761 762 $results = $wpdb->get_results($sql, OBJECT); 763 return sizeof($results); 764 } 702 765 } -
occupancy-plan/trunk/admin/controller/class-occupancy-plan-plans.php
r3068435 r3103274 28 28 * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column 29 29 * 1.3.13 - Add 'undefinedname' column 30 * 1.4.3 - Add 'checkblockconflict' column 30 31 */ 31 32 public function new_plan() … … 136 137 $plan->frontendtooltip = ''; 137 138 $plan->undefinedname =__('Undefined', 'occupancy-plan'); 139 $plan->checkblockconflict = 0; 138 140 return $plan; 139 141 } … … 268 270 * 1.3.6 - Add 'timeinterval' column, Add 'frontendtooltip' column 269 271 * 1.3.13 - Add 'undefinedname' column 272 * 1.4.3 - Add 'checkblockconflict' column 270 273 */ 271 274 public function save_plan() … … 351 354 'placeholder' => sanitize_text_field($_POST['placeholder']), 352 355 'frontendtooltip' => sanitize_text_field($_POST['frontendtooltip']), 353 'undefinedname' => sanitize_text_field($_POST['undefinedname']) 356 'undefinedname' => sanitize_text_field($_POST['undefinedname']), 357 'checkblockconflict' => isset($_POST['checkblockconflict'])? 1:0 354 358 ); 355 359 … … 361 365 '%d','%d','%s','%s','%s','%s','%s','%s','%d','%d', 362 366 '%s','%s','%s','%s','%s','%s','%d','%s','%s', 363 '%d','%s','%s','%s' );367 '%d','%s','%s','%s','%d'); 364 368 365 369 if ((isset($_POST['id'])) && (intval($_POST['id']) > 0)) -
occupancy-plan/trunk/admin/partials/occupancy-plan-plan.php
r3076337 r3103274 419 419 <input class="op-admin-input-90" type="text" name="undefinedname" maxlength="128" value="<?php echo (isset($plan->undefinedname))? esc_attr($plan->undefinedname) : '' ?>" <?php echo (isset($mode))? '':'readonly'?> /> 420 420 <span class="op-help-tip" data-tooltip="<?php echo __('This default text is used for the name in bookings when the user is not logged in', 'occupancy-plan');?>">?</span> 421 </div> 422 <div class="op-admin-form-col-4"> 423 <label class="op-admin-label" for="checkblockconflict"><?php echo __('Check Block Conflict', 'occupancy-plan');?></label> 424 </div> 425 <div class="op-admin-form-col-8"> 426 <input class="op-admin-input-100" type="checkbox" name="checkblockconflict" value="1" <?php if ($plan->checkblockconflict== 1 ) echo 'checked'; ?> <?php echo (isset($mode))? '':'disabled'?> /> 427 <span class="op-help-tip" data-tooltip="<?php echo __('If this flag is set, when creating a booking from the frontend, it is checked whether there is a conflict with an existing booking', 'occupancy-plan');?>">?</span> 421 428 </div> 422 429 </div> -
occupancy-plan/trunk/includes/class-occupancy-plan-plugin.php
r3068435 r3103274 15 15 16 16 global $occupancy_plan_db_version; 17 $occupancy_plan_db_version = '1.4 ';17 $occupancy_plan_db_version = '1.4.3'; 18 18 19 19 class Occupancy_Plan_Plugin … … 48 48 * 1.3.21 - 'shortname' changed length to 16 characters 49 49 * 1.4 - Add block exceptions 50 * 1.4.3 - Add 'checkblockconflict' column 50 51 * 51 52 */ … … 157 158 frontendtooltip varchar(128) NULL, 158 159 undefinedname varchar(128) NULL, 160 checkblockconflict bit(1) NULL, 159 161 UNIQUE KEY id (id) 160 162 ) $charset_collate;"; -
occupancy-plan/trunk/occupancy-plan.php
r3076337 r3103274 16 16 * Plugin URI: https://www.software-kunze.de/plugins/occupancy-plan/ 17 17 * Description: Management of Occupancy Plans 18 * Version: 1.4. 218 * Version: 1.4.3 19 19 * Author: Alexander Kunze Software Consulting 20 20 * Author URI: https://www.software-kunze.de … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('Occupancy_Plan', '1.4. 2');38 define('Occupancy_Plan', '1.4.3'); 39 39 40 40 /** -
occupancy-plan/trunk/public/class-occupancy-plan-public.php
r3068435 r3103274 228 228 * 1.2.6 - Add approval process data to plan object 229 229 * 1.3.6 - Set new columm 'timeinterval' based on the plan configuration 230 * 1.4.3 - Fix: Check plan existencse 230 231 */ 231 232 private function get_plan($planID) … … 235 236 $plan = $wpdb->get_row("SELECT * FROM $table_plan WHERE id = $planID"); 236 237 237 if (!isset($plan->timeinterval)) 238 { 239 if ((isset($plan->oneandahalf)) && ($plan->oneandahalf == 1)) 240 { 241 if ((isset($plan->halfhour)) && ($plan->halfhour == 1)) 242 { 243 $plan->timeinterval = 45; 238 if (isset($plan)) 239 { 240 if (!isset($plan->timeinterval)) 241 { 242 if ((isset($plan->oneandahalf)) && ($plan->oneandahalf == 1)) 243 { 244 if ((isset($plan->halfhour)) && ($plan->halfhour == 1)) 245 { 246 $plan->timeinterval = 45; 247 } 248 else 249 { 250 $plan->timeinterval = 90; 251 } 244 252 } 245 253 else 246 254 { 247 $plan->timeinterval = 90; 248 } 249 } 250 else 251 { 252 if ((isset($plan->halfhour)) && ($plan->halfhour == 1)) 253 { 254 $plan->timeinterval = 30; 255 } 256 else 257 { 258 $plan->timeinterval = 60; 259 } 260 } 261 } 262 $table_approval_process = "{$wpdb->prefix}occupancy_plan_approval_process"; 263 $approval_process = $wpdb->get_row("SELECT * FROM $table_approval_process WHERE planid = $planID"); 264 265 if (isset($approval_process)) 266 { 267 if (isset($approval_process->informationlink)) 268 { 269 $parts = explode("|", $approval_process->informationlink); 270 if (sizeof($parts) > 1) 271 { 272 $plan->informationlinkhref = $parts[0]; 273 $plan->informationlinkname = $parts[1]; 274 } 275 } 276 277 return (object) array_merge((array) $plan, (array) $approval_process); 278 } 279 else 280 { 281 return $plan; 282 } 255 if ((isset($plan->halfhour)) && ($plan->halfhour == 1)) 256 { 257 $plan->timeinterval = 30; 258 } 259 else 260 { 261 $plan->timeinterval = 60; 262 } 263 } 264 } 265 $table_approval_process = "{$wpdb->prefix}occupancy_plan_approval_process"; 266 $approval_process = $wpdb->get_row("SELECT * FROM $table_approval_process WHERE planid = $planID"); 267 268 if (isset($approval_process)) 269 { 270 if (isset($approval_process->informationlink)) 271 { 272 $parts = explode("|", $approval_process->informationlink); 273 if (sizeof($parts) > 1) 274 { 275 $plan->informationlinkhref = $parts[0]; 276 $plan->informationlinkname = $parts[1]; 277 } 278 } 279 280 return (object) array_merge((array) $plan, (array) $approval_process); 281 } 282 } 283 284 return $plan; 283 285 } 284 286 -
occupancy-plan/trunk/public/css/occupancy-plan-public.css
r3016326 r3103274 328 328 } 329 329 330 .op-booking-conflict { 331 color: red; 332 } -
occupancy-plan/trunk/public/js/occupancy-plan-public.js
r3068435 r3103274 163 163 $('.wp-color-result-text').text(publicobject.selectcolor); 164 164 $('.wp-picker-clear').val(publicobject.clearcolor); 165 $($dialogid).find('.op-booking-conflict').hide(); 165 166 166 167 for (var $key in $data) … … 294 295 }, 295 296 error: function (err) { 297 $($dialogid).find('.op-booking-conflict').show(); 296 298 console.error(err.responseText); 297 299 } 298 300 }); 299 $(this).dialog("close");300 301 } 301 302 else { … … 329 330 }, 330 331 success: function(response) { 331 $($dialogid).dialog('close');332 332 document.location.reload(); 333 333 } -
occupancy-plan/trunk/public/partials/occupancy-plan-booking-dialog.php
r3068435 r3103274 425 425 </p> 426 426 <?php } ?> 427 <p class="op-booking-conflict"> 428 <?php echo __('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan');?> 429 </p> 427 430 </form> 428 431 </div> -
occupancy-plan/trunk/public/partials/occupancy-plan-public-display.php
r3059603 r3103274 592 592 </p> 593 593 <?php } ?> 594 <p class="op-booking-conflict"> 595 <?php echo __('Conflict: Selected time slot overlaps with existing booking', 'occupancy-plan');?> 596 </p> 594 597 </form> 595 598 </div> -
occupancy-plan/trunk/readme.txt
r3076337 r3103274 4 4 Tags: Occupancy Plan, Belegungsplan, Booking, Buchungen, Hallenbelegung, Reservierung 5 5 Requires at least: 4.9 6 Tested up to: 6.5. 27 Stable tag: 1.4. 26 Tested up to: 6.5.4 7 Stable tag: 1.4.3 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 50 50 == Changelog == 51 51 52 = 1.4.3 = 53 * Bugfix: Error An active PHP session was detected 54 * Bugfix: Handle wrong plan identifier in short code 55 * Support of checking block conflicts 56 52 57 = 1.4.2 = 53 58 * Bugfix: Use plans controller for CSV export
Note: See TracChangeset
for help on using the changeset viewer.