[add] Getting employee data
This commit is contained in:
parent
2d3f52372c
commit
30420975c4
@ -174,5 +174,32 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
return $results[0]['id'];
|
return $results[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEmployeeDataById($idEmployee){
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
p.id,
|
||||||
|
p.firstName,
|
||||||
|
p.middleName,
|
||||||
|
IFNULL(p.lastName, '') AS lastName,
|
||||||
|
p.email,
|
||||||
|
p.phone,
|
||||||
|
e.code,
|
||||||
|
e.contractType
|
||||||
|
FROM
|
||||||
|
employees e
|
||||||
|
INNER JOIN
|
||||||
|
persons p ON p.id = e.idPerson
|
||||||
|
WHERE
|
||||||
|
e.id = :idEmployee");
|
||||||
|
|
||||||
|
$stmt->execute(array(':idEmployee' => $idEmployee));
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -56,3 +56,11 @@ $app->get('/api/employee/type/{code}', function (Request $request, Response $res
|
|||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->getIdEmployeeTypeByCode($code)));
|
->write(json_encode($this->employeeApplication->getIdEmployeeTypeByCode($code)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) {
|
||||||
|
$idEmployee = $args['idEmployee'];
|
||||||
|
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->getEmployeeDataById($idEmployee)));
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user