Exemplo n.º 1
0
 /**
  * Department handle bulk action
  *
  * @since 0.1
  *
  * @return void [redirection]
  */
 public function department_bulk_action()
 {
     if (!$this->verify_current_page_screen('erp-hr-depts', 'bulk-departments')) {
         return;
     }
     $employee_table = new \WeDevs\ERP\HRM\Department_List_Table();
     $action = $employee_table->current_action();
     if ($action) {
         $redirect = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2'), wp_unslash($_SERVER['REQUEST_URI']));
         $resp = [];
         switch ($action) {
             case 'delete_department':
                 if (isset($_GET['department_id']) && $_GET['department_id']) {
                     foreach ($_GET['department_id'] as $key => $dept_id) {
                         $resp[] = erp_hr_delete_department($dept_id);
                     }
                 }
                 if (in_array(false, $resp)) {
                     $redirect = add_query_arg(array('department_delete' => 'item_deleted'), $redirect);
                 }
                 wp_redirect($redirect);
                 exit;
         }
     }
 }