mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 00:24:35 +00:00
Added method getLastStatuses to Prestudent model and controller
This commit is contained in:
@@ -11,4 +11,51 @@ class Prestudent_model extends DB_Model
|
||||
$this->dbTable = 'public.tbl_prestudent';
|
||||
$this->pk = 'prestudent_id';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getLastStatuses($person_id, $studiensemester_kurzbz = null, $studiengang_kz = null, $status_kurzbz = null)
|
||||
{
|
||||
// Checks if the operation is permitted by the API caller
|
||||
if (($isEntitled = $this->isEntitled('public.tbl_prestudent', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $isEntitled;
|
||||
if (($isEntitled = $this->isEntitled('public.tbl_prestudentstatus', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $isEntitled;
|
||||
if (($isEntitled = $this->isEntitled('public.tbl_status', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
||||
return $isEntitled;
|
||||
|
||||
$query = 'SELECT *
|
||||
FROM public.tbl_prestudent p
|
||||
JOIN (
|
||||
SELECT DISTINCT ON(prestudent_id) *
|
||||
FROM public.tbl_prestudentstatus
|
||||
WHERE prestudent_id IN (SELECT prestudent_id FROM public.tbl_prestudent WHERE person_id = ?)
|
||||
ORDER BY prestudent_id, datum desc, insertamum desc
|
||||
) ps USING(prestudent_id)
|
||||
JOIN public.tbl_status USING(status_kurzbz)
|
||||
WHERE ps.ausbildungssemester = 1';
|
||||
|
||||
$parametersArray = array($person_id);
|
||||
|
||||
if ($studiensemester_kurzbz != '')
|
||||
{
|
||||
array_push($parametersArray, $studiensemester_kurzbz);
|
||||
$query .= ' AND ps.studiensemester_kurzbz = ?';
|
||||
}
|
||||
|
||||
if (isset($studiengang_kz))
|
||||
{
|
||||
array_push($parametersArray, $studiengang_kz);
|
||||
$query .= ' AND p.studiengang_kz = ?';
|
||||
}
|
||||
|
||||
if ($status_kurzbz != '')
|
||||
{
|
||||
array_push($parametersArray, $status_kurzbz);
|
||||
$query .= ' AND ps.status_kurzbz = ?';
|
||||
}
|
||||
|
||||
return $this->execQuery($query, $parametersArray);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user