PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / new / controller / customtime.php

customtime.php in ShiftController Employee Shift Scheduling 4.9.66, at sh4/new/controller/customtime.php

79 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 #[AllowDynamicProperties]
3 class SH4_New_Controller_CustomTime
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7
8 HC3_Request $request,
9 HC3_Post $post,
10
11 HC3_Time $t
12 )
13 {
14 $this->t = $t;
15 $this->request = $request;
16 $this->post = $hooks->wrap( $post );
17
18 $this->self = $hooks->wrap($this);
19 }
20
21 public function execute( $calendarId )
22 {
23 $thisId = array();
24
25 $params = $this->request->getParams();
26
27 $time = $this->post->get('time');
28 list( $start, $end ) = explode('-', $time);
29 $thisId[] = $start;
30 $thisId[] = $end;
31
32 $startBreak = $endBreak = NULL;
33 $breakOn = $this->post->get('break_on');
34 if( $breakOn ){
35 $break = $this->post->get('break');
36 list( $startBreak, $endBreak ) = explode( '-', $break );
37 }
38
39 if( $breakOn ){
40 $errors = array();
41
42 if( ($end > 24*60*60) && ($startBreak < $start) ){
43 $startBreak = 24*60*60 + $startBreak;
44 $endBreak = 24*60*60 + $endBreak;
45 }
46
47 if( ($startBreak >= $end) OR ($startBreak < $start) ){
48 $msg = '__Lunch break should be within shift hours.__';
49 $errors['break'] = $msg;
50 }
51 if( ($endBreak > $end) OR ($endBreak <= $start) ){
52 $msg = '__Lunch break should be within shift hours.__';
53 $errors['break'] = $msg;
54 }
55
56 if( $errors ){
57 $return = array( '-referrer-', $errors, TRUE );
58 return $return;
59 }
60 }
61
62 if( $breakOn ){
63 $thisId[] = $startBreak;
64 $thisId[] = $endBreak;
65 }
66
67 $thisId = join('-', $thisId);
68
69 $to = 'new';
70 $toParams = $params;
71 $toParams['calendar'] = $calendarId;
72 $toParams['shifttype'] = $thisId;
73 $to = array( $to, $toParams );
74
75 $return = array( $to, NULL );
76 return $return;
77 }
78 }
79