Status: Max Semester

This commit is contained in:
cgfhtw
2024-08-01 12:57:06 +02:00
parent f2180257c5
commit 6f0e46ac57
5 changed files with 113 additions and 9 deletions
@@ -53,4 +53,34 @@ class Lehrverband_model extends DB_Model
return success("1","Lehrverband vorhanden!");
}
}
/**
* Gets the maximum possible semester for one or more Studiengaenge.
* If there are more than one Studiengang each maximum is calculated and
* the smallest result is returned.
*
* @param array $studiengang_kzs
*
* @return stdClass
*/
public function getMaxSemester($studiengang_kzs)
{
$sqls = [];
foreach ($studiengang_kzs as $studiengang_kz) {
$this->addSelect('MAX(semester) AS maxsem');
$this->db->where('studiengang_kz', $studiengang_kz);
$sqls[] = $this->db->get_compiled_select($this->dbTable);
}
$this->addSelect('MIN(a.maxsem) AS maxsem');
$dbTable = $this->dbTable;
$this->dbTable = '(' . implode(' UNION ', $sqls) . ') AS a';
$result = $this->load();
$this->dbTable = $dbTable;
return $result;
}
}