예제 #1
0
 /**
  * Delete a department
  *
  * @return void
  */
 public function designation_delete()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
     if ($id) {
         // @TODO: check permission
         $deleted = erp_hr_delete_designation($id);
         if (is_wp_error($deleted)) {
             $this->send_error($deleted->get_error_message());
         }
         $this->send_success(__('Designation has been deleted', 'wp-erp'));
     }
     $this->send_error(__('Something went wrong!', 'wp-erp'));
 }
예제 #2
0
 /**
  * Handle designation bulk action
  *
  * @since 0.1
  *
  * @return void [redirection]
  */
 public function designation_bulk_action()
 {
     if (!$this->verify_current_page_screen('erp-hr-designation', 'bulk-designations')) {
         return;
     }
     $employee_table = new \WeDevs\ERP\HRM\Designation_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']));
         switch ($action) {
             case 'designation_delete':
                 if (isset($_GET['desig']) && !empty($_GET['desig'])) {
                     $not_deleted_item = erp_hr_delete_designation($_GET['desig']);
                 }
                 if (!empty($not_deleted_item)) {
                     $redirect = add_query_arg(array('desig_delete' => implode(',', $not_deleted_item)), $redirect);
                 }
                 wp_redirect($redirect);
                 exit;
         }
     }
 }