예제 #1
0
 function new_leave()
 {
     check_ajax_referer('hrm_nonce');
     $postdata = $_POST;
     $update = hrm_Leave::getInstance()->new_leave($postdata);
     if ($update) {
         $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' => __('Updated successfully', 'hrm')));
     } else {
         wp_send_json_error(array('error_msg' => __('Update Failed', 'hrm')));
     }
 }
$users = get_users();
foreach ($users as $key => $user) {
    $user_info[$user->ID] = $user->display_name;
}
$work_in_week = get_option('hrm_work_week');
$holidays = Hrm_Settings::getInstance()->hrm_query('hrm_holiday');
unset($holidays['total_row']);
$holiday_index = array();
foreach ($holidays as $key => $holiday) {
    $holiday_index = array_merge($holiday_index, maybe_unserialize($holiday->index_holiday));
}
foreach ($results as $key => $value) {
    if (!isset($leave_cat[$value->leave_type_id])) {
        continue;
    }
    $leave_action_dropdown = array('class' => 'hrm-leave-action', 'extra' => array('data-leave_id' => $value->id), 'option' => hrm_Leave::getInstance()->leave_employer_status(), 'selected' => $value->leave_status);
    $body[] = array('<input name="hrm_check[' . $value->id . ']" value="" type="checkbox">', '<a href="#" class="hrm-editable" data-user_id=' . $employer_id . ' data-table_option="hrm_leave" data-id=' . $value->id . '>' . $leave_cat[$value->leave_type_id] . '<a>', '<a href="#">' . $user_info[$value->emp_id] . '</a>', hrm_get_date2mysql($value->start_time), hrm_get_date2mysql($value->end_time), Hrm_Leave::getInstance()->leave_status($value->leave_status), $value->leave_comments, Hrm_Leave::getInstance()->total_leave($value->start_time, $value->end_time, $work_in_week, $holiday_index), Hrm_Leave::getInstance()->leave_take($value->start_time, $value->end_time, $work_in_week, $holiday_index), Hrm_Leave::getInstance()->leave_remain($value->start_time, $value->end_time, $work_in_week, $holiday_index));
    $td_attr[] = array('class="check-column"');
}
$table = array();
$table['head'] = array('<input type="checkbox">', 'Leave Type', 'Employee Name', 'Start Date', 'End Date', 'Leave Status', 'Comments', 'Total Leave(day)', 'Leave Take(day)', 'Leave Remain(day)');
$table['body'] = isset($body) ? $body : array();
$table['td_attr'] = isset($td_attr) ? $td_attr : array();
$table['th_attr'] = array('class="check-column"');
$table['table_attr'] = array('class' => 'widefat');
$table['table'] = 'hrm_leave';
$table['action'] = 'hrm_delete';
$table['tab'] = $tab;
$table['subtab'] = $subtab;
echo Hrm_Settings::getInstance()->table($table);
//table
        $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 {
        $del_checkbox = '';
    }
    if ($action) {
        $leave_action_dropdown = array('class' => 'hrm-leave-action', 'extra' => array('data-leave_id' => $value->id), 'option' => hrm_Leave::getInstance()->leave_status(), 'selected' => $value->leave_status);
        $leave_action = Hrm_Settings::getInstance()->select_field('leave_action', $leave_action_dropdown, $holiday_index);
    } else {
        $leave_action = __('Permission denied', 'hrm');
    }
    $body[] = array($del_checkbox, $name_id, '<a href="#">' . $user_info[$value->emp_id] . '</a>', hrm_get_date2mysql($value->start_time), hrm_get_date2mysql($value->end_time), hrm_Leave::getInstance()->leave_status($value->leave_status), $value->leave_comments, hrm_Leave::getInstance()->total_leave($value->start_time, $value->end_time, $work_in_week, $holiday_index), hrm_Leave::getInstance()->leave_take($value->start_time, $value->end_time, $work_in_week, $holiday_index), hrm_Leave::getInstance()->leave_remain($value->start_time, $value->end_time, $work_in_week, $holiday_index), $leave_action);
    $td_attr[] = array('class="check-column"');
}
$table = array();
$del_checkbox = $delete_permission ? '<input type="checkbox">' : '';
$table['head'] = array($del_checkbox, __('Leave Type', 'erhm'), __('Employee Name', 'erhm'), __('Start Date', 'erhm'), __('End Date', 'erhm'), __('Leave Status', 'erhm'), __('Comments', 'erhm'), __('Total Leave(day)', 'erhm'), __('Leave Take(day)', 'erhm'), __('Leave Remain(day)', 'erhm'), __('Action', 'hrm'));
$table['body'] = isset($body) ? $body : '';
$table['td_attr'] = isset($td_attr) ? $td_attr : '';
$table['th_attr'] = array('class="check-column"');
$table['table_attr'] = array('class' => 'widefat');
$table['table'] = 'hrm_leave';
$table['action'] = 'hrm_delete';
$table['tab'] = $tab;
$table['subtab'] = $subtab;
echo Hrm_Settings::getInstance()->table($table);
//table