mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-02 11:29:27 +00:00
SQL-Abfragen der Zeitaufzeichnung optimiert
This commit is contained in:
@@ -724,8 +724,6 @@ if($projekt->getProjekteMitarbeiter($user, true))
|
||||
echo '<SELECT style="width:200px;" name="oe_kurzbz_2">';
|
||||
echo '<option value="">-- '.$p->t("zeitaufzeichnung/keineAuswahl").' --</option>';
|
||||
|
||||
$oe = new organisationseinheit();
|
||||
$oe->getFrequent($user,'180','3',true);
|
||||
$trennlinie = true;
|
||||
|
||||
foreach ($oe->result as $row)
|
||||
|
||||
@@ -632,42 +632,29 @@ class organisationseinheit extends basis_db
|
||||
organisationseinheittyp_kurzbz,
|
||||
aktiv,
|
||||
lehre,
|
||||
sum(a.anzahl) AS anzahl FROM (
|
||||
SELECT
|
||||
tbl_organisationseinheit.oe_kurzbz,
|
||||
tbl_organisationseinheit.oe_parent_kurzbz,
|
||||
tbl_organisationseinheit.bezeichnung,
|
||||
tbl_organisationseinheit.organisationseinheittyp_kurzbz,
|
||||
tbl_organisationseinheit.aktiv,
|
||||
tbl_organisationseinheit.lehre,
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.*) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_organisationseinheit.oe_kurzbz IN (tbl_zeitaufzeichnung.oe_kurzbz_1,tbl_zeitaufzeichnung.oe_kurzbz_2) AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit) AS anzahl
|
||||
FROM public.tbl_organisationseinheit
|
||||
WHERE
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.*) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_organisationseinheit.oe_kurzbz IN (tbl_zeitaufzeichnung.oe_kurzbz_1,tbl_zeitaufzeichnung.oe_kurzbz_2) AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit) > $anzahl_ereignisse
|
||||
GROUP BY tbl_organisationseinheit.oe_kurzbz, tbl_organisationseinheit.oe_parent_kurzbz, tbl_organisationseinheit.bezeichnung, tbl_organisationseinheit.organisationseinheittyp_kurzbz, tbl_organisationseinheit.aktiv, tbl_organisationseinheit.lehre, anzahl
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
tbl_organisationseinheit.oe_kurzbz,
|
||||
tbl_organisationseinheit.oe_parent_kurzbz,
|
||||
tbl_organisationseinheit.bezeichnung,
|
||||
tbl_organisationseinheit.organisationseinheittyp_kurzbz,
|
||||
tbl_organisationseinheit.aktiv,
|
||||
tbl_organisationseinheit.lehre,
|
||||
'0' AS anzahl
|
||||
FROM public.tbl_organisationseinheit";
|
||||
count(tbl_zeitaufzeichnung.zeitaufzeichnung_id)
|
||||
FROM campus.tbl_zeitaufzeichnung
|
||||
JOIN public.tbl_organisationseinheit ON(oe_kurzbz IN (oe_kurzbz_1,oe_kurzbz_2))
|
||||
WHERE tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
GROUP BY tbl_organisationseinheit.oe_kurzbz HAVING COUNT(*) > $anzahl_ereignisse
|
||||
|
||||
UNION
|
||||
|
||||
SELECT
|
||||
oe_kurzbz,
|
||||
oe_parent_kurzbz,
|
||||
bezeichnung,
|
||||
organisationseinheittyp_kurzbz,
|
||||
aktiv,
|
||||
lehre,
|
||||
'0'
|
||||
FROM public.tbl_organisationseinheit";
|
||||
|
||||
if(!is_null($aktiv))
|
||||
$qry.=" WHERE aktiv=".$this->db_add_param($aktiv, FHC_BOOLEAN);
|
||||
|
||||
$qry .=" ) AS a
|
||||
GROUP BY oe_kurzbz,oe_parent_kurzbz,bezeichnung,organisationseinheittyp_kurzbz,aktiv,lehre
|
||||
ORDER BY anzahl DESC, bezeichnung";
|
||||
$qry .=" ORDER BY count DESC,bezeichnung,oe_kurzbz";
|
||||
|
||||
if($this->db_query($qry))
|
||||
{
|
||||
@@ -681,7 +668,7 @@ class organisationseinheit extends basis_db
|
||||
$obj->organisationseinheittyp_kurzbz = $row->organisationseinheittyp_kurzbz;
|
||||
$obj->aktiv = $this->db_parse_bool($row->aktiv);
|
||||
$obj->lehre = $this->db_parse_bool($row->lehre);
|
||||
$obj->anzahl = $row->anzahl;
|
||||
$obj->anzahl = $row->count;
|
||||
|
||||
$this->result[] = $obj;
|
||||
}
|
||||
|
||||
+13
-22
@@ -182,27 +182,18 @@ class service extends basis_db
|
||||
else
|
||||
$zeit = "";
|
||||
|
||||
$qry = " SELECT service_id,oe_kurzbz,bezeichnung,beschreibung,ext_id,content_id, sum(a.anzahl) AS anzahl FROM (
|
||||
SELECT
|
||||
tbl_service.*,
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.service_id) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
) AS anzahl
|
||||
FROM public.tbl_service
|
||||
WHERE
|
||||
(SELECT COUNT (tbl_zeitaufzeichnung.service_id) FROM campus.tbl_zeitaufzeichnung
|
||||
WHERE tbl_service.service_id=tbl_zeitaufzeichnung.service_id AND tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
) > $anzahl_ereignisse
|
||||
GROUP BY tbl_service.service_id,tbl_service.beschreibung,tbl_service.ext_id,tbl_service.oe_kurzbz,tbl_service.bezeichnung,tbl_service.content_id,anzahl
|
||||
|
||||
UNION
|
||||
SELECT tbl_service.*, '0' AS anzahl
|
||||
FROM public.tbl_service
|
||||
) AS a
|
||||
GROUP BY service_id,oe_kurzbz,bezeichnung,beschreibung,ext_id,content_id
|
||||
ORDER BY anzahl DESC,bezeichnung,oe_kurzbz";
|
||||
$qry = " SELECT tbl_service.*, count(tbl_zeitaufzeichnung.service_id)
|
||||
FROM campus.tbl_zeitaufzeichnung
|
||||
JOIN public.tbl_service USING (service_id)
|
||||
WHERE tbl_zeitaufzeichnung.uid=".$this->db_add_param($user)."
|
||||
$zeit
|
||||
GROUP BY tbl_service.service_id HAVING COUNT(*) > $anzahl_ereignisse
|
||||
|
||||
UNION
|
||||
SELECT tbl_service.*, '0' AS anzahl
|
||||
FROM public.tbl_service
|
||||
|
||||
ORDER BY count DESC,bezeichnung,oe_kurzbz";
|
||||
|
||||
if($result = $this->db_query($qry))
|
||||
{
|
||||
@@ -215,7 +206,7 @@ class service extends basis_db
|
||||
$obj->beschreibung = $row->beschreibung;
|
||||
$obj->ext_id = $row->ext_id;
|
||||
$obj->oe_kurzbz = $row->oe_kurzbz;
|
||||
$obj->anzahl = $row->anzahl;
|
||||
$obj->anzahl = $row->count;
|
||||
$obj->content_id = $row->content_id;
|
||||
|
||||
$this->result[] = $obj;
|
||||
|
||||
Reference in New Issue
Block a user