PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / trunk
LatePoint – Calendar Booking Plugin for Appointments and Events vtrunk
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 / misc / work_period.php
latepoint / lib / misc Last commit date
blocked_period.php 3 months ago booked_period.php 3 months ago booking_request.php 3 months ago booking_resource.php 3 months ago booking_slot.php 3 months ago filter.php 3 months ago process_action.php 1 month ago process_event.php 1 month ago role.php 2 weeks ago router.php 3 months ago step.php 3 months ago stripe_connect_customer.php 3 months ago time_period.php 3 months ago user.php 3 months ago work_period.php 3 months ago
work_period.php
70 lines
1 <?php
2 /*
3 * Copyright (c) 2021 LatePoint LLC. All rights reserved.
4 */
5
6 namespace LatePoint\Misc;
7
8 class WorkPeriod {
9 public ?string $custom_date = null;
10 public int $week_day;
11 public int $start_time = 0;
12 public int $end_time = 0;
13 public int $service_id = 0;
14 public int $agent_id = 0;
15 public int $location_id = 0;
16 public int $weight = 0;
17
18 function calculate_weight(): int {
19 if ( $this->service_id ) {
20 $this->weight++;
21 }
22 if ( $this->agent_id ) {
23 $this->weight++;
24 }
25 if ( $this->location_id ) {
26 $this->weight++;
27 }
28 if ( $this->custom_date ) {
29 $this->weight = $this->weight + 3;
30 }
31 return $this->weight;
32 }
33
34 function __construct( $args = [] ) {
35 $allowed_props = self::allowed_props();
36 foreach ( $args as $key => $arg ) {
37 if ( in_array( $key, $allowed_props ) ) {
38 $this->$key = $arg;
39 }
40 }
41 $this->calculate_weight();
42 }
43
44 public static function create_from_work_period_model( \OsWorkPeriodModel $work_period ): WorkPeriod {
45 return new WorkPeriod(
46 [
47 'custom_date' => $work_period->custom_date,
48 'week_day' => $work_period->week_day,
49 'start_time' => $work_period->start_time,
50 'end_time' => $work_period->end_time,
51 'agent_id' => $work_period->agent_id,
52 'location_id' => $work_period->location_id,
53 'service_id' => $work_period->service_id,
54 ]
55 );
56 }
57
58 public static function allowed_props(): array {
59 return [
60 'custom_date',
61 'week_day',
62 'start_time',
63 'end_time',
64 'agent_id',
65 'location_id',
66 'service_id',
67 ];
68 }
69 }
70