PluginProbe
ShiftController Employee Shift Scheduling / 4.9.26
ShiftController Employee Shift Scheduling v4.9.26
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 / conflictscalendar / overlap.php

overlap.php in ShiftController Employee Shift Scheduling 4.9.26, at sh4/conflictscalendar/overlap.php

94 lines 1.9 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 class SH4_ConflictsCalendar_Overlap implements SH4_Shifts_Conflict_IConflict
3 {
4 private $_conflictingShifts = array();
5
6 public function __construct(
7 HC3_Hooks $hooks,
8 HC3_Ui $ui,
9
10 SH4_Shifts_Query $shiftsQuery,
11 SH4_Shifts_View_Widget $widget
12 )
13 {
14 $this->ui = $ui;
15 $this->widget = $widget;
16
17 $this->shiftsQuery = $hooks->wrap( $shiftsQuery );
18 }
19
20 // find overlapping shifts for the same calendar
21 public function check( SH4_Shifts_Model $shift )
22 {
23 $return = TRUE;
24
25 $this->_conflictingShifts = array();
26
27 // $isOpen = $shift->isOpen();
28 // if( $isOpen ){
29 // return $return;
30 // }
31
32 $calendar = $shift->getCalendar();
33 if( $calendar->isAvailability() ){
34 return $return;
35 }
36
37 $calendar = $shift->getCalendar();
38 if( ! $calendar ){
39 return $return;
40 }
41 $calendarId = $calendar->getId();
42 $id = $shift->getId();
43
44 $this->shiftsQuery
45 ->setStart( $shift->getStart() )
46 ->setEnd( $shift->getEnd() )
47 ;
48
49 $testShifts = $this->shiftsQuery->find();
50
51 foreach( $testShifts as $testShift ){
52 $testId = $testShift->getId();
53
54 if( $testId == $id ){
55 continue;
56 }
57
58 $testCalendar = $testShift->getCalendar();
59 if( $testCalendar->isAvailability() ){
60 continue;
61 }
62
63 $testCalendarId = $testCalendar->getId();
64 if( $testCalendarId != $calendarId ){
65 continue;
66 }
67
68 $this->_conflictingShifts[] = $testShift;
69 }
70
71 if( $this->_conflictingShifts ){
72 $return = FALSE;
73 }
74
75 return $return;
76 }
77
78 public function render()
79 {
80 $label = '__Calendar Overlap__';
81
82 $iknow = array('conflicts');
83 $hori = TRUE;
84
85 $viewShifts = array();
86 foreach( $this->_conflictingShifts as $shift ){
87 $viewShifts[] = $this->widget->render( $shift, $iknow, $hori );
88 }
89 $out = $this->ui->makeList( $viewShifts );
90
91 $out = $this->ui->makeLabelled( $label, $out );
92 return $out;
93 }
94 }