/** * Delete Note * * @return json */ public function employee_delete_note() { check_admin_referer('wp-erp-hr-nonce'); $note_id = isset($_POST['note_id']) ? intval($_POST['note_id']) : 0; $employee = new Employee(); if ($employee->delete_note($note_id)) { $this->send_success(); } else { $this->send_error(); } }
/** * Load admin scripts and styles * * @param string * * @return void */ public function admin_scripts($hook) { // var_dump( $hook ); $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_media(); wp_enqueue_script('wp-erp-hr', WPERP_HRM_ASSETS . "/js/hrm{$suffix}.js", array('wp-erp-script'), date('Ymd'), true); wp_enqueue_script('wp-erp-hr-leave', WPERP_HRM_ASSETS . "/js/leave{$suffix}.js", array('wp-erp-script', 'wp-color-picker'), date('Ymd'), true); $localize_script = apply_filters('erp_hr_localize_script', array('nonce' => wp_create_nonce('wp-erp-hr-nonce'), 'popup' => array('dept_title' => __('New Department', 'wp-erp'), 'dept_submit' => __('Create Department', 'wp-erp'), 'dept_update' => __('Update Department', 'wp-erp'), 'desig_title' => __('New Designation', 'wp-erp'), 'desig_submit' => __('Create Designation', 'wp-erp'), 'desig_update' => __('Update Designation', 'wp-erp'), 'employee_title' => __('New Employee', 'wp-erp'), 'employee_create' => __('Create Employee', 'wp-erp'), 'employee_update' => __('Update Employee', 'wp-erp'), 'employment_status' => __('Employment Status', 'wp-erp'), 'update_status' => __('Update', 'wp-erp'), 'policy' => __('Leave Policy', 'wp-erp'), 'policy_create' => __('Create Policy', 'wp-erp')), 'emp_upload_photo' => __('Upload Employee Photo', 'wp-erp'), 'emp_set_photo' => __('Set Photo', 'wp-erp'), 'confirm' => __('Are you sure?', 'wp-erp'), 'delConfirmDept' => __('Are you sure to delete this department?', 'wp-erp'), 'delConfirmEmployee' => __('Are you sure to delete this employee?', 'wp-erp'))); // if its an employee page if ('hr-management_page_erp-hr-employee' == $hook) { wp_enqueue_script('post'); $employee = new Employee(); $localize_script['employee_empty'] = $employee->to_array(); } wp_localize_script('wp-erp-hr', 'wpErpHr', $localize_script); wp_enqueue_style('wp-color-picker'); }
/** * Add a new note * * @return void */ public function employee_add_note() { $this->verify_nonce('wp-erp-hr-employee-nonce'); $employee_id = isset($_POST['user_id']) ? intval($_POST['user_id']) : 0; $note = isset($_POST['note']) ? strip_tags($_POST['note']) : 0; $note_by = get_current_user_id(); $employee = new Employee($employee_id); if ($employee->id) { $employee->add_note($note, $note_by); } $this->send_success(); }