PluginProbe
ShiftController Employee Shift Scheduling / 4.9.68
ShiftController Employee Shift Scheduling v4.9.68
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 / employees / html / admin / controller / index.php

index.php in ShiftController Employee Shift Scheduling 4.9.68, at sh4/employees/html/admin/controller/index.php

109 lines 2.3 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_Employees_Html_Admin_Controller_Index
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7 HC3_Post $post,
8
9 SH4_Employees_Query $query,
10 SH4_Employees_Command $command
11 )
12 {
13 $this->post = $hooks->wrap($post);
14 $this->query = $hooks->wrap($query);
15 $this->command = $hooks->wrap($command);
16 $this->self = $hooks->wrap($this);
17 }
18
19 public function execute()
20 {
21 $action = $this->post->get('action');
22 $ids = $this->post->get('id');
23
24 if( ! is_array($ids) ){
25 $ids = explode( ':', $ids );
26 }
27
28 $filter = $this->post->get('filter');
29 if( $filter ){
30 $calendarId = $this->post->get('calendar');
31 return $this->self->executeFilter( $calendarId );
32 }
33
34 if( ('archive' == $action) && $ids ){
35 $this->self->executeArchive( $ids );
36
37 $msg = '__Employee Archived__';
38 if( count($ids) > 1 ){
39 $msg .= ' (' . count($ids) . ')';
40 }
41 }
42
43 if( ('restore' == $action) && $ids ){
44 $this->self->executeRestore( $ids );
45
46 $msg = '__Employee Restored__';
47 if( count($ids) > 1 ){
48 $msg .= ' (' . count($ids) . ')';
49 }
50 }
51
52 if( ('delete' == $action) && $ids ){
53 $this->self->executeDelete( $ids );
54
55 $msg = '__Employee Deleted__';
56 if( count($ids) > 1 ){
57 $msg .= ' (' . count($ids) . ')';
58 }
59 }
60
61 $return = array( 'admin/employees', $msg );
62 return $return;
63 }
64
65 public function executeFilter( $calendarId )
66 {
67 $params = array();
68 $params['calendar'] = $calendarId ? $calendarId : NULL;
69
70 $return = array( array('admin/employees', $params), NULL );
71 return $return;
72 }
73
74 public function executeArchive( $ids )
75 {
76 if( ! is_array($ids) ){
77 $ids = array($ids);
78 }
79
80 foreach( $ids as $id ){
81 $model = $this->query->findById( $id );
82 $this->command->archive( $model );
83 }
84 }
85
86 public function executeRestore( $ids )
87 {
88 if( ! is_array($ids) ){
89 $ids = array($ids);
90 }
91
92 foreach( $ids as $id ){
93 $model = $this->query->findById( $id );
94 $this->command->restore( $model );
95 }
96 }
97
98 public function executeDelete( $ids )
99 {
100 if( ! is_array($ids) ){
101 $ids = array($ids);
102 }
103
104 foreach( $ids as $id ){
105 $model = $this->query->findById( $id );
106 $this->command->delete( $model );
107 }
108 }
109 }