| 1 |
<?php |
| 2 |
namespace WeDevs\ERP\HRM; |
| 3 |
|
| 4 |
use WeDevs\ERP\Framework\ERP_Settings_Page; |
| 5 |
|
| 6 |
/** |
| 7 |
* Settings class |
| 8 |
*/ |
| 9 |
class Settings extends ERP_Settings_Page { |
| 10 |
|
| 11 |
/** |
| 12 |
* [__construct description] |
| 13 |
*/ |
| 14 |
public function __construct() { |
| 15 |
$this->id = 'erp-hr'; |
| 16 |
$this->label = __( 'HR', 'erp' ); |
| 17 |
$this->single_option = true; |
| 18 |
$this->sections = $this->get_sections(); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Get registered tabs |
| 23 |
* |
| 24 |
* @return array |
| 25 |
*/ |
| 26 |
public function get_sections() { |
| 27 |
$sections = array( |
| 28 |
'workdays' => __( 'Workdays', 'erp' ), |
| 29 |
'leave' => __( 'Leave', 'erp' ), |
| 30 |
'miscellaneous' => __( 'Miscellaneous', 'erp' ), |
| 31 |
); |
| 32 |
|
| 33 |
return apply_filters( 'erp_settings_hr_sections', $sections ); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Get sections fields |
| 38 |
* |
| 39 |
* @return array |
| 40 |
*/ |
| 41 |
public function get_section_fields( $section = '' ) { |
| 42 |
$options = array( |
| 43 |
'8' => __( 'Full Day', 'erp' ), |
| 44 |
'4' => __( 'Half Day', 'erp' ), |
| 45 |
'0' => __( 'Non-working Day', 'erp' ) |
| 46 |
); |
| 47 |
|
| 48 |
$week_days = array( |
| 49 |
'mon' => __( 'Monday', 'erp' ), |
| 50 |
'tue' => __( 'Tuesday', 'erp' ), |
| 51 |
'wed' => __( 'Wednesday', 'erp' ), |
| 52 |
'thu' => __( 'Thursday', 'erp' ), |
| 53 |
'fri' => __( 'Friday', 'erp' ), |
| 54 |
'sat' => __( 'Saturday', 'erp' ), |
| 55 |
'sun' => __( 'Sunday', 'erp' ) |
| 56 |
); |
| 57 |
|
| 58 |
$fields = []; |
| 59 |
|
| 60 |
$fields['workdays'][] = [ |
| 61 |
'title' => __( 'Work Days', 'erp' ), |
| 62 |
'type' => 'title', |
| 63 |
'desc' => __( 'Week day settings for this company.', 'erp' ), |
| 64 |
'id' => 'general_options' |
| 65 |
]; |
| 66 |
|
| 67 |
foreach ($week_days as $key => $day) { |
| 68 |
$fields['workdays'][] = [ |
| 69 |
'title' => $day, |
| 70 |
'id' => $key, |
| 71 |
'type' => 'select', |
| 72 |
'options' => $options, |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
$fields['workdays'][] = [ |
| 77 |
'type' => 'sectionend', |
| 78 |
'id' => 'script_styling_options' |
| 79 |
]; |
| 80 |
|
| 81 |
|
| 82 |
$fields['leave'][] = [ |
| 83 |
'title' => __( 'Leave', 'erp' ), |
| 84 |
'type' => 'title', |
| 85 |
'desc' => __( 'Leave settings for this company.', 'erp' ), |
| 86 |
'id' => 'general_options' |
| 87 |
]; |
| 88 |
$fields['leave'][] = [ |
| 89 |
'title' => __( 'Extra Leave', 'erp' ), |
| 90 |
'type' => 'checkbox', |
| 91 |
'id' => 'enable_extra_leave', |
| 92 |
'desc' => __( 'Employees can apply for leave, even when there is no entitlement left.', 'erp' ) |
| 93 |
]; |
| 94 |
$fields['leave'][] = [ |
| 95 |
'type' => 'sectionend', |
| 96 |
'id' => 'script_styling_options' |
| 97 |
]; |
| 98 |
|
| 99 |
$fields['miscellaneous'][] =[ |
| 100 |
'title' => __( 'Miscellaneous', 'erp' ), |
| 101 |
'type' => 'title', |
| 102 |
'desc' => __( 'HRM miscellaneous settings.', 'erp' ), |
| 103 |
'id' => 'hrm_miscellaneous' |
| 104 |
]; |
| 105 |
$fields['miscellaneous'][] = [ |
| 106 |
'title' => __( 'Remove WP User', 'erp' ), |
| 107 |
'type' => 'checkbox', |
| 108 |
'id' => 'erp_hrm_remove_wp_user', |
| 109 |
'desc' => __( 'Remove wp user on removing employee.', 'erp' ) |
| 110 |
]; |
| 111 |
$fields['miscellaneous'][] =[ |
| 112 |
'type' => 'sectionend', |
| 113 |
'id' => 'hrm_miscellaneous' |
| 114 |
]; |
| 115 |
$fields = apply_filters( 'erp_settings_hr_section_fields', $fields, $section ); |
| 116 |
|
| 117 |
$section = $section === false ? $fields['workdays'] : $fields[$section]; |
| 118 |
|
| 119 |
return $section; |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
return new Settings(); |
| 124 |
|