PluginProbe ʕ •ᴥ•ʔ
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress / 5.6.10
Appointment Booking Plugin – LatePoint | Calendar & Scheduling for WordPress v5.6.10
5.6.10 5.6.9 5.6.8 5.6.7 5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / abilities / bookings / get-bookings-per-day.php
latepoint / lib / abilities / bookings Last commit date
abstract-booking-ability.php 1 month ago approve-booking.php 5 months ago cancel-booking.php 5 months ago change-booking-status.php 1 month ago create-booking.php 5 months ago delete-booking.php 1 month ago get-booking-stats.php 1 month ago get-booking-statuses.php 5 months ago get-booking.php 1 month ago get-bookings-for-date.php 5 months ago get-bookings-per-day.php 1 month ago get-upcoming-bookings.php 5 months ago list-bookings.php 5 months ago reschedule-booking.php 1 month ago update-booking.php 1 month ago
get-bookings-per-day.php
83 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; }
4
5 class LatePointAbilityGetBookingsPerDay extends LatePointAbstractBookingAbility {
6
7 protected function configure(): void {
8 $this->id = 'latepoint/get-bookings-per-day';
9 $this->label = __( 'Get bookings per day', 'latepoint' );
10 $this->description = __( 'Returns daily booking counts for a date range (histogram data).', 'latepoint' );
11 $this->permission = 'booking__view';
12 $this->read_only = true;
13 }
14
15 public function get_input_schema(): array {
16 return [
17 'type' => 'object',
18 'properties' => [
19 'date_from' => [
20 'type' => 'string',
21 'format' => 'date',
22 'description' => __( 'Period start (Y-m-d).', 'latepoint' ),
23 ],
24 'date_to' => [
25 'type' => 'string',
26 'format' => 'date',
27 'description' => __( 'Period end (Y-m-d).', 'latepoint' ),
28 ],
29 'agent_id' => [ 'type' => 'integer' ],
30 'service_id' => [ 'type' => 'integer' ],
31 'location_id' => [ 'type' => 'integer' ],
32 ],
33 'required' => [ 'date_from', 'date_to' ],
34 ];
35 }
36
37 public function get_output_schema(): array {
38 return [
39 'type' => 'object',
40 'properties' => [
41 'days' => [
42 'type' => 'array',
43 'items' => [
44 'type' => 'object',
45 'properties' => [
46 'date' => [
47 'type' => 'string',
48 'format' => 'date',
49 ],
50 'count' => [ 'type' => 'integer' ],
51 ],
52 ],
53 ],
54 ],
55 ];
56 }
57
58 public function execute( array $args ) {
59 $filter = new \LatePoint\Misc\Filter();
60 $filter->agent_id = ! empty( $args['agent_id'] ) ? (int) $args['agent_id'] : 0;
61 $filter->service_id = ! empty( $args['service_id'] ) ? (int) $args['service_id'] : 0;
62 $filter->location_id = ! empty( $args['location_id'] ) ? (int) $args['location_id'] : 0;
63 // Scope daily counts to the agents/services/locations the current user is allowed to access.
64 $filter = OsRolesHelper::filter_allowed_records_from_arguments_or_filter( $filter );
65
66 $rows = OsBookingHelper::get_total_bookings_per_day_for_period(
67 sanitize_text_field( $args['date_from'] ),
68 sanitize_text_field( $args['date_to'] ),
69 $filter
70 );
71
72 $days = array_map(
73 fn( $row ) => [
74 'date' => is_array( $row ) ? $row['start_date'] : $row->start_date,
75 'count' => (int) ( is_array( $row ) ? $row['bookings_per_day'] : $row->bookings_per_day ),
76 ],
77 $rows
78 );
79
80 return [ 'days' => $days ];
81 }
82 }
83