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 / employees / html / admin / controller / index.php

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

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