<?php $pagenum = hrm_pagenum(); $limit = hrm_result_limit(); if (isset($_POST['type']) && $_POST['type'] == '_search') { $post = $_POST; $results = Hrm_Settings::getInstance()->search_query($post, $limit, $pagenum); $search_satus = true; } else { $results = Hrm_Settings::getInstance()->hrm_query('hrm_language', $limit, $pagenum); $search_satus = false; } $total = $results['total_row']; unset($results['total_row']); $add_permission = hrm_user_can_access($tab, $subtab, 'add') ? true : false; $delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false; foreach ($results as $key => $value) { if ($delete_permission) { $del_checkbox = '<input name="hrm_check[' . $value->id . ']" value="" type="checkbox">'; } else { $del_checkbox = ''; } if ($add_permission) { $name_id = '<a href="#" class="hrm-editable" data-table_option="hrm_language" data-id=' . $value->id . '>' . $value->name . '</a>'; } else { $name_id = $value->name; } $body[] = array($del_checkbox, $name_id); $td_attr[] = array('class="check-column"'); } $del_checkbox = $delete_permission ? '<input type="checkbox">' : '';
printf('<a href="%1$s" class="nav-tab %4$s" id="%2$s-tab">%3$s</a>', $url, $tab_event['id'], $tab_event['title'], $active); } ?> </h2> <?php if (!$subtab) { if (!isset($menu[$page][$tab]['submenu'])) { return; } if (!count($menu[$page][$tab]['submenu'])) { return; } $subtab = key($menu[$page][$tab]['submenu']); } ?> <h3 class="hrm-sub-nav"> <ul class="hrm-subsubsub"> <?php foreach ($menu[$page][$tab]['submenu'] as $sub_key => $sub_event) { if (!hrm_user_can_access($page, $tab, $sub_key, 'view')) { continue; } $sub_active = $sub_key == $subtab ? 'hrm-sub-current' : ''; $sub_event['id'] = isset($sub_event['id']) ? $sub_event['id'] : ''; $sub_url = hrm_subtab_menu_url($tab, $sub_key, $page); printf('<li><a class="%4$s" href="%1$s" id="%2$s-tab">%3$s</a></li> | ', $sub_url, $sub_event['id'], $sub_event['title'], $sub_active); } ?> </ul> </h3>
} else { $search_satus = false; $query = Hrm_Time::getInstance()->get_individulat_punch($_POST, $limit, $pagenum); } $posts = $query->posts; $total_pagination = $query->found_posts; ?> <div id="hrm-attendance"></div> <?php $add_permission = hrm_user_can_access($tab, $subtab, 'add') ? true : false; $delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false; // $puch_status = get_user_meta( $user_id, '_puch_in_status', true ); $total_duration = 0; foreach ($posts as $key => $post) { if ($add_permission && hrm_user_can_access($tab, $subtab, 'punch_edit', true)) { $name_id = '<a href="#" class="hrm-time-editable" data-post_id=' . $post->ID . '>' . hrm_get_punch_in_time($post->post_date) . '<a>'; } else { $name_id = hrm_get_punch_in_time($post->post_date); } if ($delete_permission) { $del_checkbox = '<input name="hrm_check[' . $post->ID . ']"$post="" type="checkbox">'; } else { $del_checkbox = ''; } $punch_out_time = get_post_meta($post->ID, '_puch_out_time', true); $puch_out_note = get_post_meta($post->ID, '_puch_out_note', true); if (!empty($punch_out_time)) { $total_duration = $total_duration + ($punch_out_time - strtotime($post->post_date)); $punch_out = date("Y-m-d H:i:s", $punch_out_time); $punch_out = new DateTime($punch_out);
function table($table) { if (!isset($table['head']) || !is_array($table['head']) || !count($table['head'])) { return; } $table = $this->data_formating($table); $count_head = count($table['head']); $table['action'] = isset($table['action']) ? $table['action'] : ''; $table['table'] = isset($table['table']) ? $table['table'] : ''; $tab = isset($table['tab']) ? $table['tab'] : null; $subtab = isset($table['subtab']) ? $table['subtab'] : null; $count = 1; $delet_button = isset($table['delete_button']) ? $table['delete_button'] : true; $pagination = isset($table['view_btn']) ? $table['view_btn'] : true; $add_btn_name = isset($table['add_btn_name']) ? $table['add_btn_name'] : __('Add', 'hrm'); $add_btn_class = isset($table['add_btn_class']) ? $table['add_btn_class'] : 'hrm-add-button'; $body = isset($table['body']) && is_array($table['body']) ? $table['body'] : array(); ob_start(); ?> <form id="hrm-list-form" action="" method="post"> <input type="hidden" name="action" value="<?php echo esc_attr($table['action']); ?> "> <input type="hidden" name="table_option" value="<?php echo esc_attr($table['table']); ?> "> <div class="hrm-table-action-wrap"> <?php if (hrm_user_can_access($tab, $subtab, 'add') && $add_btn_name) { ?> <a href="#" class="button button-primary <?php echo $add_btn_class; ?> "><?php echo $add_btn_name; ?> </a> <?php } ?> <?php if (hrm_user_can_access($tab, $subtab, 'delete') && $delet_button) { ?> <a href="#" class="button hrm-delete-button"><?php _e('Delete', 'hrm'); ?> </a> <?php } ?> </div> <?php if ($pagination) { ?> <div class="hrm-pagination-wrap"> <?php $this->pagination_select(); ?> <!-- <input type="submit" class="button-primary hrm-view-action" value="<?php _e('View', 'hrm'); ?> " name="hrm_pagination"> --> </div> <?php } ?> <span class="hrm-clear"></span> <?php wp_nonce_field('hrm_nonce', '_wpnonce'); ?> <table <?php echo $table['table_attr']; ?> > <thead> <tr> <?php foreach ($table['head'] as $key => $val) { ?> <?php $th_attr = isset($table['th_attr'][$key]) ? $table['th_attr'][$key] : ''; ?> <th <?php echo $th_attr; ?> ><?php echo $val; ?> </th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($body as $key => $val) { ?> <?php $odd_even = $count % 2 == 0 ? 'hrm-even' : 'hrm-odd'; ?> <tr class="<?php echo $odd_even; ?> "> <?php for ($i = 0; $i < $count_head; $i++) { $td_attr = isset($table['td_attr'][$key][$i]) ? $table['td_attr'][$key][$i] : ''; ?> <td <?php echo $td_attr; ?> ><?php echo isset($val[$i]) ? $val[$i] : ''; ?> </td> <?php } ?> </tr> <?php $count++; ?> <?php } ?> </tbody> </table> <?php if (!count($body)) { ?> <center><?php _e('No result found!', 'hrm'); ?> </center> <?php } ?> </form><?php return ob_get_clean(); }
function table($table) { $table = apply_filters('hrm_table_data', $table); if (!isset($table['head']) || !is_array($table['head']) || !count($table['head'])) { return; } $table = $this->data_formating($table); $count_head = count($table['head']); $table['action'] = isset($table['action']) ? $table['action'] : ''; $table['table'] = isset($table['table']) ? $table['table'] : ''; $tab = isset($table['tab']) ? $table['tab'] : null; $subtab = isset($table['subtab']) ? $table['subtab'] : null; $count = 1; $delet_button = isset($table['delete_button']) ? $table['delete_button'] : true; $pagination = isset($table['pagination']) ? $table['pagination'] : true; $add_btn_name = isset($table['add_btn_name']) ? $table['add_btn_name'] : __('Add', 'hrm'); $add_btn_class = isset($table['add_btn_class']) ? $table['add_btn_class'] : 'hrm-add-button'; $searc_mode = isset($table['search_mode']) ? $table['search_mode'] : false; $search = isset($table['search']) && $table['search'] ? $table['search'] : false; $page = isset($table['page']) ? $table['page'] : null; if (isset($table['data_table']) && $table['data_table']) { $datatable = 'hrm-data-table'; } else { if (isset($table['data_table']) && !$table['data_table']) { $datatable = ''; } else { $datatable = 'hrm-data-table'; } } $insert_new = hrm_user_can_access($page, $tab, $subtab, 'add') && $add_btn_name ? true : false; $event_delete = hrm_user_can_access($page, $tab, $subtab, 'delete') && $delet_button ? true : false; ob_start(); ?> <form id="hrm-list-form" class="" action="" method="post"> <input type="hidden" name="action" value="<?php echo esc_attr($table['action']); ?> "> <input type="hidden" name="table_option" value="<?php echo esc_attr($table['table']); ?> "> <?php if ($insert_new || $event_delete) { ?> <div class="hrm-table-action-wrap"> <?php if ($insert_new) { ?> <a href="#" class="button button-primary <?php echo $add_btn_class; ?> "><?php echo $add_btn_name; ?> </a> <?php } ?> <?php if ($event_delete) { ?> <a href="#" class="button hrm-delete-button"><?php _e('Delete', 'hrm'); ?> </a> <?php } ?> </div> <?php } if ($searc_mode) { ?> <div class="hrm-pagi-src"> <?php if ($pagination) { ?> <?php $this->pagination_select(); ?> <?php } ?> <?php if ($search) { ?> <a class="button button-primary hrm-search-button" href="#"><?php echo $search; ?> </a> <?php } ?> </div> <?php } ?> <span class="hrm-clear"></span> <?php wp_nonce_field('hrm_nonce', '_wpnonce'); ?> <?php echo isset($table['before']) ? '<div class="hrm-before-table">' . $table['before'] . '</div>' : ''; ?> <?php $this->table_generate($table); ?> </form><?php return ob_get_clean(); }
continue; } $flag = get_user_meta($user_obj->ID, '_status', true); $status = $flag == 'yes' ? 'Enable' : 'Disable'; $role = isset($user_obj->roles[0]) ? $user_obj->roles[0] : ''; if ($add_permission) { $name_id = '<a href="#" class="hrm-editable" data-action="user-role-edit-form-appear" data-id=' . $user_obj->ID . '>' . $user_obj->user_login . '<a>'; } else { $name_id = $user_obj->user_login; } if ($delete_permission) { $del_checkbox = '<input name="hrm_check[' . $user_obj->ID . ']" value="" type="checkbox">'; } else { $del_checkbox = ''; } $employer_status = hrm_user_can_access($tab, $subtab, 'admin_list_employer_status', true); if ($employer_status) { $admin_status_dropdown = array('class' => 'hrm-admin-status', 'extra' => array('data-user_id' => $user_obj->ID), 'option' => array('yes' => __('Enable', 'hrm'), 'no' => __('Disable', 'hrm')), 'selected' => $flag); $admin_status_dropdown = Hrm_settings::getInstance()->select_field('admin_staus', $admin_status_dropdown); } else { $admin_status_dropdown = __('Permission denied', 'hrm'); } $body[] = array($del_checkbox, $name_id, $role, $user_obj->display_name, $admin_status_dropdown); $td_attr[] = array('class="check-column"'); } $del_checkbox = $delete_permission ? '<input type="checkbox">' : ''; $table = array(); $table['head'] = array($del_checkbox, 'Admin Name', 'Role', 'Display Name', 'Status'); $table['body'] = isset($body) ? $body : ''; $table['td_attr'] = isset($td_attr) ? $td_attr : ''; $table['th_attr'] = array('class="check-column"');
function delete_employee() { check_ajax_referer('hrm_nonce'); $postdata = $_POST; if (!isset($postdata['hrm_check']) || !is_array($postdata['hrm_check'])) { wp_send_json_error(array('success_msg' => __('Failed to deletet employee', 'hrm'))); } $delete_user = false; if (hrm_user_can_access($postdata['tab'], null, 'delete')) { $delete_user = hrm_Employee::getInstance()->delete_employee($postdata['hrm_check']); } else { wp_send_json_error(array('error_msg' => __('You do not have permission deletet employee', 'hrm'))); } if ($delete_user) { $page = $_POST['page']; $tab = $_POST['tab']; $subtab = $_POST['subtab']; $req_frm = urldecode($_POST['req_frm']); ob_start(); require_once $req_frm; wp_send_json_success(array('content' => ob_get_clean(), 'success_msg' => __('Successfully deletet employee', 'hrm'))); } else { wp_send_json_error(array('error_msg' => __('Failed to deletet employee', 'hrm'))); } }
$leave_cat = isset($leave_cat) ? $leave_cat : array(); $users = get_users(array('role' => 'hrm_employee')); foreach ($users as $key => $user) { $user_info[$user->ID] = $user->display_name; } $user_info = isset($user_info) ? $user_info : array(); $work_in_week = get_option('hrm_work_week'); $holidays = Hrm_Settings::getInstance()->hrm_query('hrm_holiday'); unset($holidays['total_row']); $add_permission = hrm_user_can_access($tab, $subtab, 'add') ? true : false; $delete_permission = hrm_user_can_access($tab, $subtab, 'delete') ? true : false; $holiday_index = array(); foreach ($holidays as $key => $holiday) { $holiday_index = array_merge($holiday_index, maybe_unserialize($holiday->index_holiday)); } $leave_action_acess = hrm_user_can_access($tab, $subtab, 'leave_summary_action', true); if ($leave_action_acess === 'leave_summary_action' || $leave_action_acess) { $action = true; } else { $action = false; } foreach ($results as $key => $value) { $leave_type = isset($leave_cat[$value->leave_type_id]) ? $leave_cat[$value->leave_type_id] : ''; if ($add_permission) { $name_id = '<a href="#" class="hrm-editable" data-user_id=' . $value->emp_id . ' data-table_option="hrm_leave" data-id=' . $value->id . '>' . $leave_type . '<a>'; } else { $name_id = $leave_type; } if ($delete_permission) { $del_checkbox = '<input name="hrm_check[' . $value->id . ']" value="" type="checkbox">'; } else {
<div class="hrm-update-notification"></div> <?php if (!hrm_user_can_access($tab, $subtab, 'view')) { printf('<h1>%s</h1>', __('You do no have permission to access this page', 'cpm')); return; } ?> <?php $country = hrm_Settings::getInstance()->country_list(); //default $this for class hrm_Admin, $tab, $subtab; $field_value = Hrm_Admin::getInstance()->get_general_info(); $field['organization_name'] = array('label' => __('Organization Name', 'hrm'), 'class' => 'required', 'type' => 'text', 'value' => isset($field_value['data']['organization_name']) ? $field_value['data']['organization_name'] : '', 'extra' => array('data-hrm_validation' => true, 'data-hrm_required' => true, 'data-hrm_required_error_msg' => __('This field is required', 'hrm'))); $field['tax_id'] = array('label' => __('Tax ID', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['tax_id']) ? $field_value['data']['tax_id'] : ''); $field['registration_number'] = array('label' => __('Registration Number', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['registration_number']) ? $field_value['data']['registration_number'] : ''); $field['phone'] = array('label' => __('Phone', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['phone']) ? $field_value['data']['phone'] : ''); $field['fax'] = array('label' => __('Fax', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['fax']) ? $field_value['data']['fax'] : ''); $field['email'] = array('label' => __('email', 'hrm'), 'type' => 'email', 'value' => isset($field_value['data']['email']) ? $field_value['data']['email'] : ''); $field['addres_street_1'] = array('label' => __('Address Street 1', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['addres_street_1']) ? $field_value['data']['addres_street_1'] : ''); $field['address_street_2'] = array('label' => __('Address Street 2', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['address_street_2']) ? $field_value['data']['address_street_2'] : ''); $field['city'] = array('label' => __('City', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['city']) ? $field_value['data']['city'] : ''); $field['state_province'] = array('label' => __('State/Province', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['state_province']) ? $field_value['data']['state_province'] : ''); $field['zip'] = array('label' => __('Zip/Postal Code', 'hrm'), 'type' => 'text', 'value' => isset($field_value['data']['zip']) ? $field_value['data']['zip'] : ''); $field['country'] = array('label' => __('Country', 'hrm'), 'type' => 'select', 'option' => $country, 'selected' => isset($field_value['data']['country']) ? $field_value['data']['country'] : '', 'desc' => 'Chose your country'); $field['note'] = array('label' => __('Note', 'hrm'), 'type' => 'textarea', 'value' => isset($field_value['data']['note']) ? $field_value['data']['note'] : ''); $field['header'] = 'General Information'; $field['action'] = 'single_form'; $field['table_option'] = 'hrm_general_info'; $field['tab'] = $tab; $field['subtab'] = $subtab; echo Hrm_Settings::getInstance()->visible_form_generator($field);
function show_sub_tab_page($tab) { $subtab = isset($_GET['sub_tab']) ? $_GET['sub_tab'] : ''; $menu = hrm_page(); if (empty($subtab) && count($menu['admin'][$tab]['submenu'])) { $subtab = key($menu['admin'][$tab]['submenu']); if (!hrm_user_can_access($tab, $subtab, 'view')) { printf('<h1>%s</h1>', __('You do no have permission to access this page', 'cpm')); return false; } $path = isset($menu['admin'][$tab]['submenu'][$subtab]['file_path']) ? $menu['admin'][$tab]['submenu'][$subtab]['file_path'] : ''; if (file_exists($path)) { require_once $path; } else { echo 'Page not found'; } } else { if (!hrm_user_can_access($tab, $subtab, 'view')) { printf('<h1>%s</h1>', __('You do no have permission to access this page', 'cpm')); return; } $path = isset($menu['admin'][$tab]['submenu'][$subtab]['file_path']) ? $menu['admin'][$tab]['submenu'][$subtab]['file_path'] : ''; if (file_exists($path)) { require_once $path; } else { echo 'Page not found'; } } }