Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OHRM5X-2560: Fix admin - work shift employee autocomplete #1848

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing copyright header


namespace OrangeHRM\Tests\Admin\Api;

use OrangeHRM\Admin\Api\WorkShiftEmployeeAPI;
use OrangeHRM\Framework\Services;
use OrangeHRM\Tests\Util\EndpointIntegrationTestCase;
use OrangeHRM\Tests\Util\Integration\TestCaseParams;

/**
* @group Admin
* @group APIv2
*/
class WorkShiftEmployeeAPITest extends EndpointIntegrationTestCase
{
/**
* @dataProvider dataProviderForTestGetAll
*/
public function testGetAll(TestCaseParams $testCaseParams): void
{
$this->populateFixtures('WorkShiftEmployeeAPI.yaml');
$this->createKernelWithMockServices([Services::AUTH_USER => $this->getMockAuthUser($testCaseParams)]);
$this->registerServices($testCaseParams);
$api = $this->getApiEndpointMock(WorkShiftEmployeeAPI::class, $testCaseParams);
$this->assertValidTestCase($api, 'getAll', $testCaseParams);
}

public function dataProviderForTestGetAll(): array
{
return $this->getTestCases('WorkShiftEmployeeTestCases.yaml', 'GetAll');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Config:
- { name: 'authorize_user_role_manager_class', value: 'BasicUserRoleManager' }

Subunit:
- { id: 1, name: 'Organization', description: 'company description', lft: 1, rgt: 14, level: 0 }
- { id: 2, name: 'Open Source', description: 'department description', lft: 2, rgt: 5, level: 1 }
- { id: 3, name: 'Development', description: 'sub department description', lft: 6, rgt: 7, level: 1 }

JobTitle:
- { id: 1, job_title: 'Software Engineer - Intern', is_deleted: 0 }

JobCategory:
- { id: 1, name: "Officials and Managers" }

Nationality:
- { "id": 167, "name": "Sri Lanka" }

EmploymentStatus:
- { "id": 1, "name": "Intern" }

TerminationReason:
- { "id": "1","name": "Other" }
- { "id": "2","name": "Retired" }
- { "id": "3","name": "Contract Not Renewed" }
- { "id": "4","name": "Resigned - Company Requested" }
- { "id": "5","name": "Resigned - Self Proposed" }
- { "id": "6","name": "Resigned" }
- { "id": "7","name": "Deceased" }
- { "id": "8","name": "Physically Disabled/Compensated" }
- { "id": "9","name": "Laid-off" }
- { "id": "10","name": "Dismissed" }

EmployeeTerminationRecord:
- {"id":"1","reason_id":"3","termination_date":"2022-03-01","note":null}
- {"id":"2","reason_id":"3","termination_date":"2022-03-01","note":null}
- {"id":"3","reason_id":"2","termination_date":"2022-05-01","note":null}

Employee:
- {"emp_number":"1","employee_id":"0001","emp_lastname":"Admin","emp_firstname":"Devi"}
- {"emp_number":"2","employee_id":"0002","emp_lastname":"Kumara","emp_firstname":"Rajitha"}OHRm5
- {"emp_number":"3","employee_id":"0003","emp_lastname":"de Silva","emp_firstname":"Devishke","emp_status": 1,"job_title_code": 1,"work_station": 3}
- {"emp_number":"4","employee_id":"0004","emp_lastname":"Employee","emp_firstname":"Purged","termination_id":"1","purged_at":"2022-03-07 03:48:17"}
- {"emp_number":"5","employee_id":"0005","emp_lastname":"Perera","emp_firstname":"Sharuka"}
- {"emp_number":"6","employee_id":"0006","emp_lastname":"Gamage","emp_firstname":"Chenuka","termination_id":"2"}
- {"emp_number": "7","employee_id": "0007","emp_lastname": "Anderson","emp_firstname": "Linda","emp_middle_name": "Jane", "termination_id":"3"}

EmpPicture:
- { emp_number: 1, epic_picture: 'testblob', epic_filename: 'profile.jpeg', epic_type: 'image/jpeg', epic_file_size: '20692', epic_file_width: '200', epic_file_height: '200'}

UserRole:
- { id: 1, name: Admin, display_name: Admin, is_assignable: 1, is_predefined: 1 }
- { id: 2, name: ESS, display_name: ESS, is_assignable: 1, is_predefined: 1 }
- { id: 3, name: Supervisor, display_name: Supervisor, is_assignable: 0, is_predefined: 1 }

User:
- {"id":"1","user_role_id":"1","emp_number":"1","user_name":"admin"}
- {"id":"2","user_role_id":"2","emp_number":"2","user_name":"rajitha"}
- {"id":"3","user_role_id":"2","emp_number":"3","user_name":"devishke"}
- {"id":"4","user_role_id":"2","emp_number":"5","user_name":"sharuka"}

WorkShift:
- {"id":"1","name":"Shift 1","hours_per_day":"8.00","start_time":"09:00:00","end_time":"17:00:00"}

EmployeeWorkShift:
- {"work_shift_id":"1","emp_number":"1"}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
GetAll:
'get employee with nameOrId=Raj':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
query:
nameOrId: Raj
data: [
{
empNumber: 2,
lastName: Kumara,
firstName: Rajitha,
middleName: '',
employeeId: 0002,
terminationId: null
}
]
meta:
total: 1

'get purged employees':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
query:
nameOrId: Purged
data: [ ]
meta:
total: 0

'get terminated employees':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
query:
nameOrId: Linda
data: [ ]
meta:
total: 0

'get employee with nameOrId=Dev':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
query:
nameOrId: Dev
data: [
{
empNumber: 3,
lastName: de Silva,
firstName: Devishke,
middleName: '',
employeeId: 0003,
terminationId: null
}
]
meta:
total: 2 #employee count is not considering assigned employees

'get already assigned employee':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
query:
nameOrId: Devi Admin
data: [ ]
meta:
total: 1 #employee count is not considering assigned employees

'without query params':
userId: 1
services:
pim.employee_service: \OrangeHRM\Pim\Service\EmployeeService
data: [
{
empNumber: 3,
lastName: de Silva,
firstName: Devishke,
middleName: '',
employeeId: 0003,
terminationId: null,
},
{
empNumber: 2,
lastName: Kumara,
firstName: Rajitha,
middleName: '',
employeeId: 0002,
terminationId: null,
},
{
empNumber: 5,
lastName: Perera,
firstName: Sharuka,
middleName: '',
employeeId: 0005,
terminationId: null,
}
]
meta:
total: 4 #employee count is not considering assigned employees
2 changes: 1 addition & 1 deletion src/plugins/orangehrmPimPlugin/Dao/EmployeeDao.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public function getAvailableEmployeeListForWorkShift(EmployeeSearchFilterParams
$q = $this->getEmployeeListQueryBuilderWrapper($employeeSearchParamHolder)->getQueryBuilder();
$q->leftJoin('employee.employeeWorkShift', 'ew');
$q->andWhere($q->expr()->isNull('ew.employee'));
return $q->getQuery()->execute();
return array_column($q->getQuery()->execute(), 0);
}

/**
Expand Down