Skip to content

Commit

Permalink
OHRM5X-1959: Soring from employee name added
Browse files Browse the repository at this point in the history
  • Loading branch information
DulsaraNethmin committed Mar 29, 2023
1 parent 8300436 commit 23c0f29
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
25 changes: 15 additions & 10 deletions src/plugins/orangehrmClaimPlugin/Api/EmployeeClaimRequestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected function setClaimRequest(ClaimRequest $claimRequest, int $empNumber):
* name="sortField",
* in="query",
* required=false,
* @OA\Schema(type="string", enum=ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
* @OA\Schema(type="string", enum=EmployeeClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
* ),
* @OA\Parameter(
* name="referenceId",
Expand Down Expand Up @@ -355,36 +355,36 @@ protected function setEmpNumbers(ClaimRequestSearchFilterParams $claimRequestSea
}

/**
* @param ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams
* @param ClaimRequestSearchFilterParams $claimRequestSearchFilterParams
* @return void
*/
private function getCommonFilterParams(ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams): void
private function getCommonFilterParams(ClaimRequestSearchFilterParams $claimRequestSearchFilterParams): void
{
$myClaimRequestSearchFilterParams->setReferenceId(
$claimRequestSearchFilterParams->setReferenceId(
$this->getRequestParams()->getStringOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_REFERENCE_ID
)
);
$myClaimRequestSearchFilterParams->setEventId(
$claimRequestSearchFilterParams->setEventId(
$this->getRequestParams()->getIntOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_EVENT_ID
)
);
$myClaimRequestSearchFilterParams->setStatus(
$claimRequestSearchFilterParams->setStatus(
$this->getRequestParams()->getStringOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_STATUS
)
);
$myClaimRequestSearchFilterParams->setFromDate(
$claimRequestSearchFilterParams->setFromDate(
$this->getRequestParams()->getDateTimeOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_FROM_DATE
)
);
$myClaimRequestSearchFilterParams->setToDate(
$claimRequestSearchFilterParams->setToDate(
$this->getRequestParams()->getDateTimeOrNull(
RequestParams::PARAM_TYPE_QUERY,
self::PARAMETER_TO_DATE
Expand Down Expand Up @@ -427,8 +427,7 @@ protected function getCommonParamRuleCollectionGetAll(): ParamRuleCollection
self::PARAMETER_TO_DATE,
new Rule(Rules::DATE_TIME)
)
),
...$this->getSortingAndPaginationParamsRules(ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS)
)
);
}

Expand All @@ -446,6 +445,12 @@ public function getValidationRuleForGetAll(): ParamRuleCollection
)
)
);
$sortFieldParamRules = $this->getSortingAndPaginationParamsRules(
EmployeeClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS
);
foreach ($sortFieldParamRules as $sortFieldParamRule) {
$paramRuleCollection->addParamValidation($sortFieldParamRule);
}

return $paramRuleCollection;
}
Expand Down
10 changes: 9 additions & 1 deletion src/plugins/orangehrmClaimPlugin/Api/MyClaimRequestAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,14 @@ protected function setEmpNumbers(ClaimRequestSearchFilterParams $claimRequestSea
*/
public function getValidationRuleForGetAll(): ParamRuleCollection
{
return $this->getCommonParamRuleCollectionGetAll();
$paramRuleCollection = $this->getCommonParamRuleCollectionGetAll();
$sortFieldParamRules = $this->getSortingAndPaginationParamsRules(
ClaimRequestSearchFilterParams::ALLOWED_SORT_FIELDS
);
foreach ($sortFieldParamRules as $sortFieldParamRule) {
$paramRuleCollection->addParamValidation($sortFieldParamRule);
}

return $paramRuleCollection;
}
}
2 changes: 2 additions & 0 deletions src/plugins/orangehrmClaimPlugin/Dao/ClaimDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ public function getClaimRequestList(ClaimRequestSearchFilterParams $myClaimReque
protected function getClaimRequestPaginator(ClaimRequestSearchFilterParams $myClaimRequestSearchFilterParams): Paginator
{
$q = $this->createQueryBuilder(ClaimRequest::class, 'claimRequest');
$q->leftJoin('claimRequest.claimEvent', 'claimEvent');
$q->leftJoin('claimRequest.employee', 'employee');
$this->setSortingAndPaginationParams($q, $myClaimRequestSearchFilterParams);

if (!is_null($myClaimRequestSearchFilterParams->getEmpNumbers())) {
Expand Down

0 comments on commit 23c0f29

Please sign in to comment.