Example #1
0
 /**
  * Remove entitlement
  *
  * @since 0.1
  *
  * @return json
  */
 public function remove_entitlement()
 {
     $this->verify_nonce('wp-erp-hr-nonce');
     $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
     $user_id = isset($_POST['user_id']) ? intval($_POST['user_id']) : 0;
     $policy_id = isset($_POST['policy_id']) ? intval($_POST['policy_id']) : 0;
     if ($id && $user_id && $policy_id) {
         erp_hr_delete_entitlement($id, $user_id, $policy_id);
         $this->send_success();
     } else {
         $this->send_error(__('Somthing wrong !', 'wp-erp'));
     }
 }
Example #2
0
 /**
  * Handle entitlement bulk actions
  *
  * @since 0.1
  *
  * @return void
  */
 public function entitlement_bulk_action()
 {
     if (!$this->verify_current_page_screen('erp-leave-assign', 'bulk-entitlements')) {
         return;
     }
     $employee_table = new \WeDevs\ERP\HRM\Entitlement_List_Table();
     $action = $employee_table->current_action();
     if ($action) {
         $redirect = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'filter_entitlement'), wp_unslash($_SERVER['REQUEST_URI']));
         if ($action == 'filter_entitlement') {
             wp_redirect($redirect);
             exit;
         }
         if ($action == 'entitlement_delete') {
             if (isset($_GET['entitlement_id']) && !empty($_GET['entitlement_id'])) {
                 foreach ($_GET['entitlement_id'] as $key => $ent_id) {
                     $entitlement_data = \WeDevs\ERP\HRM\Models\Leave_Entitlement::select('user_id', 'policy_id')->find($ent_id)->toArray();
                     erp_hr_delete_entitlement($ent_id, $entitlement_data['user_id'], $entitlement_data['policy_id']);
                 }
             }
             wp_redirect($redirect);
             exit;
         }
     }
 }