[add] List of all active employees
This commit is contained in:
parent
f4d1ce1ab7
commit
6c4e42e337
@ -404,5 +404,44 @@ class EmployeeApplication{
|
|||||||
$this->pdo->rollback();
|
$this->pdo->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intended for internal use
|
||||||
|
*
|
||||||
|
* This method will bring a list of ids of all the employees that are
|
||||||
|
* currently active in the system
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getIdEmployeeFromAllActiveEmployees(){
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
employees
|
||||||
|
WHERE
|
||||||
|
status = 'ACTIVE';");
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function listAllActiveEmployees(){
|
||||||
|
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach($ids as $row){
|
||||||
|
$result[] = $this->proxyGetEmployeeDataById($row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -41,6 +41,12 @@ $app->get('/api/employee/types', function (Request $request, Response $response,
|
|||||||
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/all', function (Request $request, Response $response, array $args) {
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->listAllActiveEmployees()));
|
||||||
|
});
|
||||||
|
|
||||||
$app->post('/api/employee', function ($request, $response) {
|
$app->post('/api/employee', function ($request, $response) {
|
||||||
$requestData = $request->getParsedBody();
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user