PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.1.3
LatePoint – Calendar Booking Plugin for Appointments and Events v5.1.3
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 1 year ago booked_period.php 1 year ago booking_request.php 1 year ago booking_resource.php 1 year ago booking_slot.php 1 year ago filter.php 1 year ago process_action.php 1 year ago process_event.php 1 year ago role.php 1 year ago router.php 1 year ago step.php 1 year ago stripe_connect_customer.php 1 year ago time_period.php 1 year ago user.php 1 year ago work_period.php 1 year ago
work_period.php
53 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) $this->weight++;
20 if($this->agent_id) $this->weight++;
21 if($this->location_id) $this->weight++;
22 if($this->custom_date) $this->weight = $this->weight + 3;
23 return $this->weight;
24 }
25
26 function __construct($args = []){
27 $allowed_props = self::allowed_props();
28 foreach($args as $key => $arg){
29 if(in_array($key, $allowed_props)) $this->$key = $arg;
30 }
31 $this->calculate_weight();
32 }
33
34 public static function create_from_work_period_model(\OsWorkPeriodModel $work_period): WorkPeriod{
35 return new WorkPeriod([ 'custom_date' => $work_period->custom_date,
36 'week_day' => $work_period->week_day,
37 'start_time' => $work_period->start_time,
38 'end_time' => $work_period->end_time,
39 'agent_id' => $work_period->agent_id,
40 'location_id' => $work_period->location_id,
41 'service_id' => $work_period->service_id]);
42 }
43
44 public static function allowed_props(): array{
45 return ['custom_date',
46 'week_day',
47 'start_time',
48 'end_time',
49 'agent_id',
50 'location_id',
51 'service_id'];
52 }
53 }