Changeset 3483637
- Timestamp:
- 03/16/2026 09:29:19 AM (12 days ago)
- Location:
- occupancy-plan/trunk
- Files:
-
- 6 edited
-
admin/partials/occupancy-plan-block.php (modified) (1 diff)
-
admin/table/class-occupancy-plan-blocks.php (modified) (3 diffs)
-
occupancy-plan.php (modified) (2 diffs)
-
public/js/occupancy-plan-public.js (modified) (2 diffs)
-
public/partials/occupancy-plan-booking-dialog.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
occupancy-plan/trunk/admin/partials/occupancy-plan-block.php
r3462665 r3483637 494 494 </p> 495 495 </div> 496 <?php 497 $exceptionsTable = new Occupancy_Plan_Block_Exceptions(); 498 $exceptionsTable->prepare_items(); 499 $exceptionsTable->search_box(__('search', 'occupancy-plan'), 'search_id'); 500 $exceptionsTable->display(); 501 ?> 496 <form method="GET"> 497 <input type="hidden" name="page" value="occupancy-plan-blocks" /> 498 <?php 499 $exceptionsTable = new Occupancy_Plan_Block_Exceptions(); 500 $exceptionsTable->prepare_items(); 501 $exceptionsTable->search_box(__('search', 'occupancy-plan'), 'search_id'); 502 $exceptionsTable->display(); 503 ?> 504 </form> 502 505 <div class="op-admin-action-panel-bottom-1"> 503 506 <div class="op-admin-form-group"> -
occupancy-plan/trunk/admin/table/class-occupancy-plan-blocks.php
r3398617 r3483637 152 152 * 153 153 * 1.1.1 - Add process_bulk_action() call 154 * 1.4.18 - Get blocks and count logic changed 154 155 */ 155 156 public function prepare_items() 156 157 { 157 $columns = $this->get_columns();158 $hidden = $this->get_hidden_columns();158 $columns = $this->get_columns(); 159 $hidden = $this->get_hidden_columns(); 159 160 $sortable = $this->get_sortable_columns(); 160 161 $this->_column_headers = array($columns, $hidden, $sortable); 162 161 163 $this->process_bulk_action(); 162 164 163 $per_page = 20;165 $per_page = 20; 164 166 $current_page = $this->get_pagenum(); 165 $total_items = $this->get_numberof_blocks(); 166 167 $pagination = array( 167 168 $total_items = $this->get_blocks_count(); 169 $this->items = $this->get_blocks($current_page, $per_page); 170 171 $this->set_pagination_args(array( 168 172 'total_items' => $total_items, // total number of items 169 173 'per_page' => $per_page, // items to show on a page 170 174 'total_pages' => ceil($total_items / $per_page) // calculate pages count 171 ); 172 $this->set_pagination_args($pagination); 175 )); 173 176 174 177 $this->court_names = $this->get_court_names(); 175 $this->items = $this->get_blocks($current_page, $per_page);176 178 } 177 179 … … 331 333 case 4: return __('Flexible', 'occupancy-plan'); 332 334 case 5: return __('Every second week', 'occupancy-plan'); 333 case 5: return __('Blocker', 'occupancy-plan');335 case 6: return __('Blocker', 'occupancy-plan'); 334 336 default: return $item['interval']; 335 337 } … … 385 387 386 388 /** 387 * Load the number of blocks from the wordpress database 388 * 389 * @since 1.0.0 390 * @access public 391 */ 392 public function get_numberof_blocks() 393 { 389 * Create blocks where clause 390 * 391 * @since 1.14.18 392 * @access private 393 */ 394 private function get_blocks_where_clause() 395 { 396 global $wpdb; 397 398 $where = array(); 399 $values = array(); 400 401 $planid = occupancy_plan_get_state_value('op_planid', 0); 402 if ($planid > 0) { 403 $where[] = 'plan.id = %d'; 404 $values[] = (int) $planid; 405 } 406 407 if ($this->is_provisional == true) { 408 $where[] = 'block.provisional = 1'; 409 } else { 410 $where[] = 'block.provisional <> 1'; 411 } 412 413 if (isset($_REQUEST['s']) && $_REQUEST['s'] !== '') { 414 $search = '%' . $wpdb->esc_like(wp_unslash($_REQUEST['s'])) . '%'; 415 416 $where[] = '(block.shortname LIKE %s OR block.name LIKE %s OR block.description LIKE %s OR block.contact LIKE %s)'; 417 $values[] = $search; 418 $values[] = $search; 419 $values[] = $search; 420 $values[] = $search; 421 } 422 423 $sql = ''; 424 if (!empty($where)) { 425 $sql = ' WHERE ' . implode(' AND ', $where); 426 } 427 428 return array($sql, $values); 429 } 430 431 /** 432 * Calculate number of selected blocks 433 * 434 * @since 1.14.18 435 * @access public 436 */ 437 public function get_blocks_count() 438 { 439 global $wpdb; 440 441 $table_plan = "{$wpdb->prefix}occupancy_plan"; 442 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 443 444 list($where_sql, $values) = $this->get_blocks_where_clause(); 445 446 $sql = "SELECT COUNT(*) 447 FROM $table_block AS block 448 JOIN $table_plan AS plan ON plan.id = block.planid 449 $where_sql"; 450 451 if (!empty($values)) { 452 $sql = $wpdb->prepare($sql, $values); 453 } 454 455 return (int) $wpdb->get_var($sql); 456 } 457 458 /** 459 * Load the blocks from the wordpress database 460 * 461 * @since 1.0.0 462 * @access public 463 * 464 * 1.4.18 - Logic changed form POST to GET 465 */ 466 public function get_blocks($current_page, $per_page) 467 { 468 global $wpdb; 469 470 $table_plan = "{$wpdb->prefix}occupancy_plan"; 471 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 472 473 list($where_sql, $values) = $this->get_blocks_where_clause(); 474 475 $allowed_orderby = array( 476 'shortname', 'name', 'description', 'weekday', 'court', 477 'startdate', 'enddate', 'interval', 'color', 'textcolor', 'contact' 478 ); 479 480 $orderby = 'name'; 481 if (!empty($_REQUEST['orderby']) && in_array($_REQUEST['orderby'], $allowed_orderby, true)) { 482 $orderby = $_REQUEST['orderby']; 483 } 484 485 $order = 'ASC'; 486 if (!empty($_REQUEST['order']) && strtoupper($_REQUEST['order']) === 'DESC') { 487 $order = 'DESC'; 488 } 489 490 $offset = ($current_page - 1) * $per_page; 491 492 $sql = "SELECT block.*, plan.name AS planname 493 FROM $table_block AS block 494 JOIN $table_plan AS plan ON plan.id = block.planid 495 $where_sql 496 ORDER BY $orderby $order 497 LIMIT %d OFFSET %d"; 498 499 $values[] = (int) $per_page; 500 $values[] = (int) $offset; 501 502 $sql = $wpdb->prepare($sql, $values); 503 504 return $wpdb->get_results($sql, ARRAY_A); 505 } 506 507 /** 508 * Load the court names from the wordpress database 509 * 510 * @since 1.0.9 511 * @access public 512 */ 513 public function get_court_names() 514 { 515 global $wpdb; 516 $table_court_name= "{$wpdb->prefix}occupancy_plan_court_name"; 517 518 $sql = "SELECT * FROM $table_court_name"; 519 $planid = occupancy_plan_get_state_value('op_planid', 0); 520 $sql .= " WHERE (planid = '" . esc_sql($planid) . "')"; 521 522 return $wpdb->get_results($sql); 523 } 524 525 /** 526 * Process the bulk action 527 * 528 * @since 1.1.1 529 * @access public 530 * 531 * 1.4.18 - Logic changed from POST to GET 532 */ 533 public function process_bulk_action() 534 { 535 if ($this->current_action() !== 'delete') { 536 return; 537 } 538 539 if (empty($_REQUEST['bulk-item-selection'])) { 540 return; 541 } 542 543 $selecteditems = array_map('intval', (array) $_REQUEST['bulk-item-selection']); 544 $selecteditems = array_filter($selecteditems); 545 546 if (empty($selecteditems)) { 547 return; 548 } 549 394 550 global $wpdb; 395 551 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 396 return $wpdb->get_var("SELECT COUNT(*) FROM $table_block"); 397 } 398 399 /** 400 * Load the blocks from the wordpress database 401 * 402 * @since 1.0.0 403 * @access public 404 */ 405 public function get_blocks($current_page, $per_page) 406 { 407 global $wpdb; 408 $table_plan = "{$wpdb->prefix}occupancy_plan"; 409 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 410 411 $sql = "SELECT block.*, plan.name AS planname FROM $table_block AS block 412 JOIN $table_plan AS plan ON plan.id = block.planid"; 413 414 $planid = occupancy_plan_get_state_value('op_planid', 0); 415 if ($planid > 0) 416 { 417 $sql .= " WHERE (plan.id = " . esc_sql($planid) . ")"; 418 } 419 420 if (strpos($sql, 'WHERE') == false) 421 { 422 $sql .= " WHERE "; 423 } 424 else 425 { 426 $sql .= " AND "; 427 } 428 if ($this->is_provisional == true) 429 { 430 $sql .= " (block.provisional = 1)"; 431 } 432 else 433 { 434 $sql .= " (block.provisional <> 1)"; 435 } 436 437 if (isset($_POST['s'])) 438 { 439 $searchstr = sanitize_text_field($_POST['s']); 440 if (strpos($sql, 'WHERE') == false) 441 { 442 $sql .= " WHERE ("; 443 } 444 else 445 { 446 $sql .= " AND ("; 447 } 448 449 $sql .= " (block.shortname LIKE '%" . esc_sql($searchstr) . "%')"; 450 $sql .= " OR (block.name LIKE '%" . esc_sql($searchstr) . "%')"; 451 $sql .= " OR (block.description LIKE '%" . esc_sql($searchstr) . "%')"; 452 $sql .= " OR (block.contact LIKE '%" . esc_sql($searchstr) . "%'))"; 453 } 454 455 if (!empty( $_REQUEST['orderby'])) 456 { 457 $sql .= ' ORDER BY ' . esc_sql( $_REQUEST['orderby'] ); 458 $sql .= !empty( $_REQUEST['order'])? ' ' . esc_sql( $_REQUEST['order'] ) : ' ASC'; 459 } 460 461 $sql .= " LIMIT $per_page"; 462 $sql .= ' OFFSET ' . ($current_page - 1) * $per_page; 463 464 return $wpdb->get_results($sql, ARRAY_A); 465 } 466 467 /** 468 * Load the court names from the wordpress database 469 * 470 * @since 1.0.9 471 * @access public 472 */ 473 public function get_court_names() 474 { 475 global $wpdb; 476 $table_court_name= "{$wpdb->prefix}occupancy_plan_court_name"; 477 478 $sql = "SELECT * FROM $table_court_name"; 479 480 if (isset($_POST['planID'])) 481 { 482 $sql .= " WHERE (planid = '" . esc_sql($_POST['planID']) . "')"; 483 } 484 else if (isset($_GET['planID'])) 485 { 486 $sql .= " WHERE (planid = '" . esc_sql($_GET['planID']) . "')"; 487 } 488 489 return $wpdb->get_results($sql); 490 } 491 492 /** 493 * Process the bulk action 494 * 495 * @since 1.1.1 496 * @access public 497 */ 498 public function process_bulk_action() 499 { 500 if (isset($_POST['bulk-item-selection'])) 501 { 502 if (is_array($_POST['bulk-item-selection'])) 503 { 504 $selecteditems = array_map('sanitize_text_field', $_POST['bulk-item-selection']); 505 $selecteditems = implode(',', $selecteditems); 506 occupancy_plan_set_state_value("op_delcount", count($_POST['bulk-item-selection'])); 507 } 508 else 509 { 510 $selecteditems = sanitize_text_field($_POST['bulk-item-selection']); 511 } 512 513 if (!empty($selecteditems)) 514 { 515 global $wpdb; 516 $table_block = "{$wpdb->prefix}occupancy_plan_block"; 517 $wpdb->query("DELETE FROM $table_block WHERE id IN ($selecteditems)"); 518 occupancy_plan_set_state_value("op_msgid", ($this->is_provisional)? 26 : 16); 519 } 520 } 552 553 $placeholders = implode(',', array_fill(0, count($selecteditems), '%d')); 554 $sql = "DELETE FROM $table_block WHERE id IN ($placeholders)"; 555 $sql = $wpdb->prepare($sql, $selecteditems); 556 557 $wpdb->query($sql); 558 559 occupancy_plan_set_state_value("op_delcount", count($selecteditems)); 560 occupancy_plan_set_state_value("op_msgid", ($this->is_provisional) ? 26 : 16); 521 561 522 562 return; -
occupancy-plan/trunk/occupancy-plan.php
r3462665 r3483637 16 16 * Plugin URI: https://www.software-kunze.de/plugins/occupancy-plan/ 17 17 * Description: Management of Occupancy Plans 18 * Version: 1.4.1 718 * Version: 1.4.18 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.1 7');38 define('Occupancy_Plan', '1.4.18'); 39 39 40 40 /** -
occupancy-plan/trunk/public/js/occupancy-plan-public.js
r3190680 r3483637 101 101 } 102 102 103 /* 104 $.ajax({ 105 method: "POST", 106 url: publicobject.ajax_url, 107 dataType : 'json', 108 data: { 109 action: 'op_get_details_dlg', 110 id: $data['blockid'], 111 planid: $data['planid'], 112 details: $data 113 }, 114 }) 115 .success(function( response ) { 116 $($dialogid).html(response); 117 }); 118 */ 119 103 if (e.shiftKey) 104 { 105 $.ajax({ 106 method: "POST", 107 url: publicobject.ajax_url, 108 dataType : 'json', 109 data: { 110 action: 'op_get_details_dlg', 111 id: $data['blockid'], 112 planid: $data['planid'], 113 details: $data 114 }, 115 }) 116 .success(function( response ) { 117 $($dialogid).html(response); 118 }); 119 } 120 120 121 $($dialogid).dialog( { 121 122 modal: true, … … 244 245 var $currentForm = $($dialogid + '-form'); 245 246 246 /* 247 $.ajax({ 248 method: "POST", 249 url: publicobject.ajax_url, 250 data: { 251 action: 'op_get_booking_dlg', 252 id: $data['blockid'], 253 planid: $data['planid'], 254 details: $data 255 }, 256 }) 257 .success(function( response ) { 258 $($dialogid).html(response); 259 }); 260 */ 247 if (e.shiftKey) 248 { 249 $.ajax({ 250 method: "POST", 251 url: publicobject.ajax_url, 252 data: { 253 action: 'op_get_booking_dlg', 254 id: $data['blockid'], 255 planid: $data['planid'], 256 details: $data 257 }, 258 }) 259 .success(function( response ) { 260 $($dialogid).html(response); 261 }); 262 } 261 263 262 264 $($dialogid).dialog( { -
occupancy-plan/trunk/public/partials/occupancy-plan-booking-dialog.php
r3103274 r3483637 37 37 else 38 38 { 39 $ block = $this->get_block($blockID);40 if ($context->block == null)39 $context->block = $this->get_block($blockID); 40 if (!isset($context->block)) 41 41 { 42 42 wp_die(__("Block not found.",'occupancy-plan')); … … 44 44 45 45 $context->plan = $this->get_plan($context->block->planid); 46 if ($context->plan == null)46 if (!isset($context->plan)) 47 47 { 48 48 wp_die(__("Plan not found.",'occupancy-plan')); 49 49 } 50 50 51 $co urt_names = $this->get_court_names($context->block->planid);52 foreach ($co urt_names as $single_court_name)51 $context->court_names = $this->get_court_names($context->block->planid); 52 foreach ($context->court_names as $single_court_name) 53 53 { 54 54 if ((!isset($context->block->courtID)) || ($single_court_name->id == $context->block->courtID)) … … 123 123 <tr> 124 124 <td><?php echo __('Plan', 'occupancy-plan');?></td> 125 <td><input type="text" name="planname" readonly /></td>125 <td><input type="text" name="planname" value="<?php echo esc_attr($context->plan->name)?>" readonly /></td> 126 126 </tr> 127 127 <?php if ($context->plan->daily != 1) { ?> … … 190 190 <td> 191 191 <?php if ($this->check_permission($context->plan, 'edit_time')) { ?> 192 <input type="date" name="enddate" value="<?php echo esc_attr($context->block->end ate)?>" />192 <input type="date" name="enddate" value="<?php echo esc_attr($context->block->enddate)?>" /> 193 193 <?php } else { ?> 194 194 <input type="text" name="enddatetext" readonly /> … … 285 285 <tr> 286 286 <td valign="top"><?php echo __('Contact', 'occupancy-plan');?></td> 287 <td colspan=4><textarea name="contacttext" maxlength="512"> value="<?php echo esc_textarea($context->block->contacttext)?>"</textarea></td>287 <td colspan=4><textarea name="contacttext" maxlength="512"><?php echo esc_textarea($context->block->contacttext)?></textarea></td> 288 288 </tr> 289 289 <tr> 290 290 <td valign="top"><?php echo __('Comment', 'occupancy-plan');?></td> 291 <td colspan=4><textarea name="commenttext" maxlength="512"> value="<?php echo esc_textarea($context->block->commenttext)?>"</textarea></td>291 <td colspan=4><textarea name="commenttext" maxlength="512"><?php echo esc_textarea($context->block->commenttext)?></textarea></td> 292 292 </tr> 293 293 <?php if ((isset($context->plan)) && ((!isset($context->plan->showcolorpicker)) || ($context->plan->showcolorpicker == 1))) { ?> 294 294 <tr> 295 295 <td><?php echo __('Color', 'occupancy-plan');?></td> 296 <td><input type="text" name="color" class="block-color-field" value=" value="<?php echo esc_attr($context->block->color)?>"" /></td>296 <td><input type="text" name="color" class="block-color-field" value="<?php echo esc_attr($context->block->color)?>" /></td> 297 297 </tr> 298 298 <tr> 299 299 <td><?php echo __('Text Color', 'occupancy-plan');?></td> 300 <td><input type="text" name="textcolor" class="block-color-field" value=" value="<?php echo esc_attr($context->block->textcolor)?>"" /></td>300 <td><input type="text" name="textcolor" class="block-color-field" value="<?php echo esc_attr($context->block->textcolor)?>" /></td> 301 301 </tr> 302 302 <?php } ?> -
occupancy-plan/trunk/readme.txt
r3462665 r3483637 4 4 Tags: Occupancy Plan, Belegungsplan, Booking, Buchungen, Hallenbelegung 5 5 Requires at least: 4.9 6 Tested up to: 6.9. 17 Stable tag: 1.4.1 76 Tested up to: 6.9.4 7 Stable tag: 1.4.18 8 8 Requires PHP: 5.2.4 9 9 License: GPLv2 or later … … 52 52 == Changelog == 53 53 54 = 1.4.18 = 55 * Fix: Delete of block exceptions 56 * Tested with WordPress version 6.9.4 57 * Improvements to the block table => Changed from POST to GET 58 54 59 = 1.4.17 = 55 60 * Fix: CSV Import of schedules and blocks
Note: See TracChangeset
for help on using the changeset viewer.