Пример #1
0
/**
 * Employee Delete
 *
 * @param  array|int $employee_ids
 *
 * @return void
 */
function erp_employee_delete($employee_ids, $hard = false)
{
    if (empty($employee_ids)) {
        return;
    }
    do_action('erp_hr_delete_employee', $employee_ids);
    if (is_array($employee_ids)) {
        foreach ($employee_ids as $key => $user_id) {
            if ($hard) {
                \WeDevs\ERP\HRM\Models\Employee::where('user_id', $user_id)->withTrashed()->forceDelete();
                wp_delete_user($user_id);
            } else {
                \WeDevs\ERP\HRM\Models\Employee::where('user_id', $user_id)->delete();
            }
        }
    }
    if (is_int($employee_ids)) {
        if ($hard) {
            \WeDevs\ERP\HRM\Models\Employee::where('user_id', $employee_ids)->withTrashed()->forceDelete();
            wp_delete_user($employee_ids);
        } else {
            \WeDevs\ERP\HRM\Models\Employee::where('user_id', $employee_ids)->delete();
        }
    }
}
Пример #2
0
 /**
  * Employee Status Update
  *
  * @since 0.1
  *
  * @return void
  */
 public function handle_employee_status_update()
 {
     if (!isset($_POST['employee_update_status'])) {
         return;
     }
     if (!wp_verify_nonce($_POST['_wpnonce'], 'wp-erp-hr-employee-update-nonce')) {
         return;
     }
     \WeDevs\ERP\HRM\Models\Employee::where('user_id', '=', $_POST['user_id'])->update(['status' => $_POST['employee_status']]);
     wp_redirect($_POST['_wp_http_referer']);
     exit;
 }
Пример #3
0
 /**
  * Reactive terminate employees
  *
  * @since 0.1
  *
  * @return json
  */
 public function employee_termination_reactive()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
     if (!$id) {
         $this->send_error(__('Something wrong', 'wp-erp'));
     }
     \WeDevs\ERP\HRM\Models\Employee::where('user_id', $id)->update(['status' => 'active']);
     delete_user_meta($id, '_erp_hr_termination');
     $this->send_success();
 }
Пример #4
0
 /**
  * Get number of employee belongs to this department
  *
  * @return int
  */
 public function num_of_employees()
 {
     return \WeDevs\ERP\HRM\Models\Employee::where(array('status' => 'active', 'designation' => $this->id))->count();
 }