PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.3.13
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.3.13
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / modules / hrm / includes / admin / class-menu.php

class-menu.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.3.13, at modules/hrm/includes/admin/class-menu.php

301 lines 9.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WeDevs\ERP\HRM\Admin;
3 use WeDevs\ERP\HRM\Employee;
4
5 /**
6 * Admin Menu
7 */
8 class Admin_Menu {
9
10 /**
11 * Kick-in the class
12 */
13 public function __construct() {
14 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
15 }
16
17 /**
18 * Add menu items
19 *
20 * @return void
21 */
22 public function admin_menu() {
23
24 /** HR Management **/
25 add_menu_page( __( 'Human Resource', 'erp' ), 'HR Management', 'erp_list_employee', 'erp-hr', array( $this, 'dashboard_page' ), 'dashicons-groups', null );
26
27 $overview = add_submenu_page( 'erp-hr', __( 'Overview', 'erp' ), __( 'Overview', 'erp' ), 'erp_list_employee', 'erp-hr', array( $this, 'dashboard_page' ) );
28 add_submenu_page( 'erp-hr', __( 'Employees', 'erp' ), __( 'Employees', 'erp' ), 'erp_list_employee', 'erp-hr-employee', array( $this, 'employee_page' ) );
29
30 if ( current_user_can( 'employee' ) ) {
31 add_submenu_page( 'erp-hr', __( 'My Profile', 'erp' ), __( 'My Profile', 'erp' ), 'erp_list_employee', 'erp-hr-my-profile', array( $this, 'employee_my_profile_page' ) );
32 }
33
34 add_submenu_page( 'erp-hr', __( 'Departments', 'erp' ), __( 'Departments', 'erp' ), 'erp_manage_department', 'erp-hr-depts', array( $this, 'department_page' ) );
35 add_submenu_page( 'erp-hr', __( 'Designations', 'erp' ), __( 'Designations', 'erp' ), 'erp_manage_designation', 'erp-hr-designation', array( $this, 'designation_page' ) );
36 add_submenu_page( 'erp-hr', __( 'Announcement', 'erp' ), __( 'Announcement', 'erp' ), 'erp_manage_announcement', 'edit.php?post_type=erp_hr_announcement' );
37 add_submenu_page( 'erp-hr', __( 'Reporting', 'erp' ), __( 'Reporting', 'erp' ), 'erp_hr_manager', 'erp-hr-reporting', array( $this, 'reporting_page' ) );
38
39 //Help page
40 add_submenu_page( 'erp-hr', __( 'Help', 'erp' ), __( '<span style="color:#f18500">Help</span>', 'erp' ), 'erp_hr_manager', 'erp-hr-help', array( $this, 'help_page' ) );
41
42 /** Leave Management **/
43 add_menu_page( __( 'Leave Management', 'erp' ), 'Leave', 'erp_leave_manage', 'erp-leave', array( $this, 'empty_page' ), 'dashicons-arrow-right-alt', null );
44
45 $leave_request = add_submenu_page( 'erp-leave', __( 'Requests', 'erp' ), __( 'Requests', 'erp' ), 'erp_leave_manage', 'erp-leave', array( $this, 'leave_requests' ) );
46 add_submenu_page( 'erp-leave', __( 'Leave Entitlements', 'erp' ), __( 'Leave Entitlements', 'erp' ), 'erp_leave_manage', 'erp-leave-assign', array( $this, 'leave_entitilements' ) );
47 add_submenu_page( 'erp-leave', __( 'Holidays', 'erp' ), __( 'Holidays', 'erp' ), 'erp_leave_manage', 'erp-holiday-assign', array( $this, 'holiday_page' ) );
48 add_submenu_page( 'erp-leave', __( 'Policies', 'erp' ), __( 'Policies', 'erp' ), 'erp_leave_manage', 'erp-leave-policies', array( $this, 'leave_policy_page' ) );
49 $calendar = add_submenu_page( 'erp-leave', __( 'Calendar', 'erp' ), __( 'Calendar', 'erp' ), 'erp_leave_manage', 'erp-leave-calendar', array( $this, 'leave_calendar_page' ) );
50 // add_submenu_page( 'erp-leave', __( 'Leave Calendar', 'erp' ), __( 'Leave Calendar', 'erp' ), 'manage_options', 'erp-leave-calendar', array( $this, 'empty_page' ) );
51
52 add_action( 'admin_print_styles-' . $overview, array( $this, 'hr_calendar_script' ) );
53 add_action( 'admin_print_styles-' . $calendar, array( $this, 'hr_calendar_script' ) );
54 }
55
56 /**
57 * Handles HR calendar script
58 *
59 * @return void
60 */
61 function hr_calendar_script() {
62 wp_enqueue_script( 'erp-momentjs' );
63 wp_enqueue_script( 'erp-fullcalendar' );
64 enqueue_fullcalendar_locale();
65 wp_enqueue_style( 'erp-fullcalendar' );
66 }
67
68 /**
69 * Handles the dashboard page
70 *
71 * @return void
72 */
73 public function dashboard_page() {
74 include WPERP_HRM_VIEWS . '/dashboard.php';
75 }
76
77 /**
78 * Handles the dashboard page
79 *
80 * @return void
81 */
82 public function employee_page() {
83 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
84 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
85
86 switch ($action) {
87 case 'view':
88 $employee = new Employee( $id );
89 if ( ! $employee->get_user_id() ) {
90 wp_die( __( 'Employee not found!', 'erp' ) );
91 }
92
93 $template = WPERP_HRM_VIEWS . '/employee/single.php';
94 break;
95
96 default:
97 $template = WPERP_HRM_VIEWS . '/employee.php';
98 break;
99 }
100
101 $template = apply_filters( 'erp_hr_employee_templates', $template, $action, $id );
102
103 if ( file_exists( $template ) ) {
104 include $template;
105 }
106 }
107
108 /**
109 * Employee my profile page template
110 *
111 * @since 0.1
112 *
113 * @return void
114 */
115 public function employee_my_profile_page() {
116 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'view';
117 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : intval( get_current_user_id() );
118
119 switch ($action) {
120 case 'view':
121 $employee = new Employee( $id );
122 if ( ! $employee->ID ) {
123 wp_die( __( 'Employee not found!', 'erp' ) );
124 }
125
126 $template = WPERP_HRM_VIEWS . '/employee/single.php';
127 break;
128
129 default:
130 $template = WPERP_HRM_VIEWS . '/employee/single.php';
131 break;
132 }
133
134 $template = apply_filters( 'erp_hr_employee_my_profile_templates', $template, $action, $id );
135
136 if ( file_exists( $template ) ) {
137 $is_my_profile_page = false;
138 if( get_current_user_id() == $id ){
139 $is_my_profile_page = true;
140 }
141
142 include $template;
143 }
144 }
145
146 /**
147 * Handles the dashboard page
148 *
149 * @return void
150 */
151 public function department_page() {
152 $action = isset( $_GET['action'] ) ? $_GET['action'] : 'list';
153 $id = isset( $_GET['id'] ) ? intval( $_GET['id'] ) : 0;
154
155 switch ($action) {
156 case 'view':
157 $template = WPERP_HRM_VIEWS . '/departments/single.php';
158 break;
159
160 default:
161 $template = WPERP_HRM_VIEWS . '/departments.php';
162 break;
163 }
164
165 $template = apply_filters( 'erp_hr_department_templates', $template, $action, $id );
166
167 if ( file_exists( $template ) ) {
168 include $template;
169 }
170 }
171
172 /**
173 * Render the designation page
174 *
175 * @return void
176 */
177 public function designation_page() {
178 include WPERP_HRM_VIEWS . '/designation.php';
179 }
180
181 /**
182 * Renders ERP HR Reporting Page
183 *
184 * @return void
185 */
186 public function reporting_page() {
187
188 $action = isset( $_GET['type'] ) ? $_GET['type'] : 'main';
189
190 switch ( $action ) {
191 case 'age-profile':
192 $template = WPERP_HRM_VIEWS . '/reporting/age-profile.php';
193 break;
194
195 case 'gender-profile':
196 $template = WPERP_HRM_VIEWS . '/reporting/gender-profile.php';
197 break;
198
199 case 'headcount':
200 $template = WPERP_HRM_VIEWS . '/reporting/headcount.php';
201 break;
202
203 case 'salary-history':
204 $template = WPERP_HRM_VIEWS . '/reporting/salary-history.php';
205 break;
206
207 case 'years-of-service':
208 $template = WPERP_HRM_VIEWS . '/reporting/years-of-service.php';
209 break;
210
211 case 'leaves':
212 $template = WPERP_HRM_VIEWS . '/reporting/leave.php';
213 break;
214
215 default:
216 $template = WPERP_HRM_VIEWS . '/reporting.php';
217 break;
218 }
219
220 $template = apply_filters( 'erp_hr_reporting_pages', $template, $action );
221
222 if ( file_exists( $template ) ) {
223
224 include $template;
225 }
226 }
227
228 /**
229 * Render the leave policy page
230 *
231 * @return void
232 */
233 public function leave_policy_page() {
234 include WPERP_HRM_VIEWS . '/leave/leave-policies.php';
235 }
236
237 /**
238 * Render the holiday page
239 *
240 * @return void
241 */
242 public function holiday_page() {
243 include WPERP_HRM_VIEWS . '/leave/holiday.php';
244 }
245
246 /**
247 * Render the leave entitlements page
248 *
249 * @return void
250 */
251 public function leave_entitilements() {
252 include WPERP_HRM_VIEWS . '/leave/leave-entitlements.php';
253 }
254
255 /**
256 * Render the leave entitlements calendar
257 *
258 * @return void
259 */
260 public function leave_calendar_page() {
261 include WPERP_HRM_VIEWS . '/leave/calendar.php';
262 }
263
264 /**
265 * Render the leave requests page
266 *
267 * @return void
268 */
269 public function leave_requests() {
270 $view = isset( $_GET['view'] ) ? $_GET['view'] : 'list';
271
272 switch ($view) {
273 case 'new':
274 include WPERP_HRM_VIEWS . '/leave/new-request.php';
275 break;
276
277 default:
278 include WPERP_HRM_VIEWS . '/leave/requests.php';
279 break;
280 }
281 }
282
283 /**
284 * Show HRM Help Page
285 * @since 1.0.0
286 */
287 public function help_page(){
288 include WPERP_HRM_VIEWS . '/help.php';
289 }
290
291 /**
292 * An empty page for testing purposes
293 *
294 * @return void
295 */
296 public function empty_page() {
297
298 }
299
300 }
301