From c94f185308864352534642913dce69680a870f1d Mon Sep 17 00:00:00 2001 From: ma0048 Date: Wed, 10 Jul 2024 15:13:46 +0200 Subject: [PATCH 01/31] =?UTF-8?q?-=20faktor=20f=C3=BCr=20lvs=20hinzugefueg?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/lehrveranstaltung_faktor.class.php | 258 ++++++++++++++++ soap/lehrveranstaltung_faktor.json.php | 123 ++++++++ system/dbupdate_3.4.php | 2 + system/dbupdate_3.4/40717_lv_faktor.php | 65 ++++ vilesci/lehre/lehrveranstaltung.php | 19 +- vilesci/lehre/lehrveranstaltung_details.php | 27 ++ vilesci/lehre/lehrveranstaltung_faktor.php | 309 ++++++++++++++++++++ 7 files changed, 801 insertions(+), 2 deletions(-) create mode 100644 include/lehrveranstaltung_faktor.class.php create mode 100644 soap/lehrveranstaltung_faktor.json.php create mode 100644 system/dbupdate_3.4/40717_lv_faktor.php create mode 100644 vilesci/lehre/lehrveranstaltung_faktor.php diff --git a/include/lehrveranstaltung_faktor.class.php b/include/lehrveranstaltung_faktor.class.php new file mode 100644 index 000000000..49459321b --- /dev/null +++ b/include/lehrveranstaltung_faktor.class.php @@ -0,0 +1,258 @@ +load($lehrveranstaltung_faktor_id); + } + + + public function load($lehrveranstaltung_faktor_id) + { + if (!is_numeric($lehrveranstaltung_faktor_id)) + { + $this->errormsg = 'Lehrveranstaltung_faktor_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * FROM lehre.tbl_lehrveranstaltung_faktor + WHERE lehrveranstaltung_faktor_id=".$this->db_add_param($lehrveranstaltung_faktor_id, FHC_INTEGER); + + if (!$this->db_query($qry)) { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if ($row = $this->db_fetch_object()) + { + $this->lehrveranstaltung_faktor_id = $row->lehrveranstaltung_faktor_id; + $this->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $this->faktor = $row->faktor; + $this->studiensemester_kurzbz_von = $row->studiensemester_kurzbz_von; + $this->studiensemester_kurzbz_bis = $row->studiensemester_kurzbz_bis; + } + + return true; + } + + public function loadByLV($lv_id, $von = null, $bis = null, $id = null) + { + + if (!is_numeric($lv_id)) + { + $this->errormsg = 'Lehrveranstaltung_faktor_id muss eine gueltige Zahl sein'; + return false; + } + $qry = "SELECT * + FROM lehre.tbl_lehrveranstaltung_faktor + LEFT JOIN public.tbl_studiensemester vonstsem + ON tbl_lehrveranstaltung_faktor.studiensemester_kurzbz_von = vonstsem.studiensemester_kurzbz + LEFT JOIN public.tbl_studiensemester bisstem + ON tbl_lehrveranstaltung_faktor.studiensemester_kurzbz_bis = bisstem.studiensemester_kurzbz + WHERE lehrveranstaltung_id = ".$this->db_add_param($lv_id, FHC_INTEGER); + + if(!empty($von)) + { + $qry .= " + AND (bisstem.ende >= ( + SELECT start + FROM public.tbl_studiensemester + WHERE studiensemester_kurzbz = " . $this->db_add_param($von, FHC_STRING) . " + ) + OR bisstem.ende IS NULL + )"; + } + + if(!empty($bis) && $bis !== "") + { + $qry .= " + AND + (vonstsem.start <= ( + SELECT ende + FROM public.tbl_studiensemester + WHERE studiensemester_kurzbz = " . $this->db_add_param($bis, FHC_STRING) . " + )) + "; + } + + if (!empty($id) && $id !== "") + { + $qry .= " + AND + lehrveranstaltung_faktor_id != ". $this->db_add_param($id, FHC_INTEGER); + } + + if (!$result = $this->db_query($qry)) { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + while ($row = $this->db_fetch_object($result)) + { + $lv_faktor_objekt = new lehrveranstaltung_faktor(); + + $lv_faktor_objekt->lehrveranstaltung_faktor_id = $row->lehrveranstaltung_faktor_id; + $lv_faktor_objekt->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $lv_faktor_objekt->faktor = $row->faktor; + $lv_faktor_objekt->studiensemester_kurzbz_von = $row->studiensemester_kurzbz_von; + $lv_faktor_objekt->studiensemester_kurzbz_bis = $row->studiensemester_kurzbz_bis; + + $this->lv_faktoren[] = $lv_faktor_objekt; + } + + return true; + } + + public function addFaktor($lv_id, $faktor, $von, $bis = NULL) + { + $qry = 'INSERT INTO lehre.tbl_lehrveranstaltung_faktor (lehrveranstaltung_id, faktor, studiensemester_kurzbz_von, studiensemester_kurzbz_bis) + VALUES ('. $this->db_add_param($lv_id, FHC_INTEGER) . ', '. + $this->db_add_param($faktor, FHC_INTEGER) . ', '. + $this->db_add_param($von, FHC_STRING) . ', '. + $this->db_add_param($bis, FHC_STRING) . ');'; + + if ($this->db_query($qry)) + { + $qry_id = "SELECT currval('lehre.lehrveranstaltung_faktor_id_seq') as id;"; + if($this->db_query($qry_id)) + { + if($row = $this->db_fetch_object()) + { + $this->db_query('COMMIT'); + return [ + 'id' => $row->id, + 'lv_id' => $lv_id, + 'faktor' => $faktor, + 'von' => $von, + 'bis' => $bis + ]; + } + else + { + $this->db_query('ROLLBACK'); + return [ + 'status' => 'error', + 'message' => 'Fehler beim Einfügen in die Datenbank:' + ]; + } + } + else + { + $this->db_query('ROLLBACK'); + return [ + 'status' => 'error', + 'message' => 'Fehler beim Einfügen in die Datenbank:' + ]; + } + } + else + { + return [ + 'status' => 'error', + 'message' => 'Fehler beim Einfügen in die Datenbank:' + ]; + } + } + + public function updateFaktor($id, $faktor, $von, $bis) + { + $qry = "UPDATE lehre.tbl_lehrveranstaltung_faktor + SET faktor = ". $this->db_add_param($faktor) ." , + studiensemester_kurzbz_von = ". $this->db_add_param($von) .", + studiensemester_kurzbz_bis = ". $this->db_add_param($bis) ." + WHERE lehrveranstaltung_faktor_id = ". $this->db_add_param($id, FHC_INTEGER); + + if ($this->db_query($qry)) + { + return true; + } + else + { + return [ + 'status' => 'error', + 'message' => 'Fehler beim Einfügen in die Datenbank:' + ]; + } + } + + public function getAkt($lv_id) + { + if (!is_numeric($lv_id)) + { + $this->errormsg = 'Lehrveranstaltung_id muss eine gueltige Zahl sein'; + return false; + } + + $qry = "SELECT * + FROM lehre.tbl_lehrveranstaltung_faktor + LEFT JOIN public.tbl_studiensemester vonstsem + ON tbl_lehrveranstaltung_faktor.studiensemester_kurzbz_von = vonstsem.studiensemester_kurzbz + LEFT JOIN public.tbl_studiensemester bisstem + ON tbl_lehrveranstaltung_faktor.studiensemester_kurzbz_bis = bisstem.studiensemester_kurzbz + WHERE lehrveranstaltung_id = ".$this->db_add_param($lv_id, FHC_INTEGER) . " + AND (vonstsem.start <= now() OR vonstsem.start IS NULL) + AND (bisstem.ende >= now() OR bisstem.ende IS NULL) + ORDER BY vonstsem.start DESC LIMIT 1 + "; + + + if (!$this->db_query($qry)) { + $this->errormsg = 'Datensatz konnte nicht geladen werden'; + return false; + } + + if ($row = $this->db_fetch_object()) + { + $this->lehrveranstaltung_faktor_id = $row->lehrveranstaltung_faktor_id; + $this->lehrveranstaltung_id = $row->lehrveranstaltung_id; + $this->faktor = $row->faktor; + $this->studiensemester_kurzbz_von = $row->studiensemester_kurzbz_von; + $this->studiensemester_kurzbz_bis = $row->studiensemester_kurzbz_bis; + } + + return true; + } + + + public function deleteFaktor($id) + { + $qry = "DELETE FROM lehre.tbl_lehrveranstaltung_faktor + WHERE lehrveranstaltung_faktor_id = ". $this->db_add_param($id, FHC_INTEGER); + + if ($this->db_query($qry)) + { + return true; + } + else + { + return [ + 'status' => 'error', + 'message' => 'Fehler beim Löschen aus der Datenbank:' + ]; + } + } +} +?> diff --git a/soap/lehrveranstaltung_faktor.json.php b/soap/lehrveranstaltung_faktor.json.php new file mode 100644 index 000000000..49f13ac47 --- /dev/null +++ b/soap/lehrveranstaltung_faktor.json.php @@ -0,0 +1,123 @@ +getBerechtigungen($uid); + +if(!$rechte->isBerechtigt('basis/person', null, 'suid')) +{ + exit('Sie haben keine Berechtigung für die Seite'); +} + +$method = isset($_REQUEST['method']) ? $_REQUEST['method']: '' ; +$lv_faktor = new lehrveranstaltung_faktor(); + +switch($method) +{ + case 'addFaktor': + $faktor = isset($_REQUEST['faktor']) ? $_REQUEST['faktor']: '' ; + if ($faktor !== '') + { + if (!isRightType($faktor['lv_id'])) + { + echo json_encode([ + 'status' => 'error', + 'message' => 'Nur LVs und Templates möglich' + ]); + break; + } + if (vonHigherThanBis($faktor['von'], $faktor['bis'])) + { + echo json_encode([ + 'status' => 'error', + 'message' => 'Von nach Bis' + ]); + break; + } + if (exists($faktor['lv_id'], $faktor['von'], $faktor['bis'])) + { + echo json_encode([ + 'status' => 'error', + 'message' => 'Für den Zeitraum bereits vorhanden' + ]); + break; + } + + $result = $lv_faktor->addFaktor($faktor['lv_id'], $faktor['faktor'], $faktor['von'], $faktor['bis']); + echo json_encode($result); + } + break; + case 'updateFaktor': + $faktor = isset($_REQUEST['faktor']) ? $_REQUEST['faktor']: '' ; + if ($faktor !== '') + { + if (vonHigherThanBis($faktor['von'], $faktor['bis'])) + { + echo json_encode([ + 'status' => 'error', + 'message' => 'Von nach Bis' + ]); + break; + } + if (exists($faktor['lv_id'], $faktor['von'], $faktor['bis'], $faktor['id'])) + { + echo json_encode([ + 'status' => 'error', + 'message' => 'Für den Zeitraum bereits vorhanden' + ]); + break; + } + + $result = $lv_faktor->updateFaktor($faktor['id'], $faktor['faktor'], $faktor['von'], $faktor['bis']); + echo json_encode($result); + } + break; + case 'deleteFaktor': + $faktor = isset($_REQUEST['faktor']) ? $_REQUEST['faktor']: '' ; + if ($faktor !== '') + { + $result = $lv_faktor->deleteFaktor($faktor['id']); + echo json_encode($result); + } + break; + default: + break; +} + +function isRightType($lv_id) +{ + $lv = new lehrveranstaltung($lv_id); + if (in_array($lv->lehrtyp_kurzbz, array('lv', 'tpl'))) + return true; + + return false; +} + +function exists($lv_id, $von, $bis, $id = null) +{ + $lv_faktor = new lehrveranstaltung_faktor(); + $lv_faktor->loadByLV($lv_id, $von, $bis, $id); + return !empty($lv_faktor->lv_faktoren); +} + +function vonHigherThanBis($von, $bis) +{ + $vonStsem = new studiensemester($von); + $bisStsem = new studiensemester($bis); + + if (is_null($bis) || $bis === "") + return false; + if ($vonStsem->start > $bisStsem->start) + return true; + else + return false; + +} + +?> diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 9fb7f0ee9..06b1e0cb4 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -56,6 +56,7 @@ require_once('dbupdate_3.4/36530_bis_internationsalisierung_codextabelle_neuerun require_once('dbupdate_3.4/34543_ux_template.php'); require_once('dbupdate_3.4/17513_Entwicklungsteam.php'); require_once('dbupdate_3.4/28575_softwarebereitstellung.php'); +require_once('dbupdate_3.4/40717_lv_faktor.php'); // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; @@ -246,6 +247,7 @@ $tabellen=array( "lehre.tbl_zeitfenster" => array("wochentag","stunde","ort_kurzbz","studiengang_kz","gewicht"), "lehre.tbl_zeugnis" => array("zeugnis_id","student_uid","zeugnis","erstelltam","gedruckt","titel","bezeichnung","updateamum","updatevon","insertamum","insertvon","ext_id"), "lehre.tbl_zeugnisnote" => array("lehrveranstaltung_id","student_uid","studiensemester_kurzbz","note","uebernahmedatum","benotungsdatum","bemerkung","updateamum","updatevon","insertamum","insertvon","ext_id","punkte"), + "lehre.tbl_lehrveranstaltung_faktor" => array("lehrveranstaltung_faktor_id", "lehrveranstaltung_id","faktor","studiensemester_kurzbz_von","studiensemester_kurzbz_bis","insertamum","insertvon","updateamum","updatevon"), "public.ci_apikey" => array("apikey_id","key","level","ignore_limits","date_created"), "public.tbl_adresse" => array("adresse_id","person_id","name","strasse","plz","ort","gemeinde","nation","typ","heimatadresse","zustelladresse","firma_id","updateamum","updatevon","insertamum","insertvon","ext_id","rechnungsadresse","anmerkung", "co_name"), "public.tbl_adressentyp" => array("adressentyp_kurzbz", "bezeichnung", "bezeichnung_mehrsprachig", "sort"), diff --git a/system/dbupdate_3.4/40717_lv_faktor.php b/system/dbupdate_3.4/40717_lv_faktor.php new file mode 100644 index 000000000..932d6fd40 --- /dev/null +++ b/system/dbupdate_3.4/40717_lv_faktor.php @@ -0,0 +1,65 @@ +db_query("SELECT 1 FROM lehre.tbl_lehrveranstaltung_faktor LIMIT 1")) +{ + $qry = " + + CREATE TABLE lehre.tbl_lehrveranstaltung_faktor + ( + lehrveranstaltung_faktor_id integer NOT NULL, + lehrveranstaltung_id integer NOT NULL, + faktor numeric NOT NULL, + studiensemester_kurzbz_von varchar(16) NOT NULL, + studiensemester_kurzbz_bis varchar(16), + insertamum timestamp DEFAULT NOW(), + insertvon varchar(32), + updateamum timestamp, + updatevon varchar(32), + CONSTRAINT tbl_lehrveranstaltung_faktor_pk PRIMARY KEY (lehrveranstaltung_faktor_id) + ); + + CREATE SEQUENCE lehre.lehrveranstaltung_faktor_id_seq + START WITH 1 + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; + + ALTER TABLE lehre.tbl_lehrveranstaltung_faktor ALTER COLUMN lehrveranstaltung_faktor_id SET DEFAULT nextval('lehre.lehrveranstaltung_faktor_id_seq'); + ALTER TABLE lehre.tbl_lehrveranstaltung_faktor ADD CONSTRAINT fk_lehrveranstaltung_faktor_lehrveranstaltung_id FOREIGN KEY (lehrveranstaltung_id) REFERENCES lehre.tbl_lehrveranstaltung (lehrveranstaltung_id) ON DELETE RESTRICT ON UPDATE CASCADE; + ALTER TABLE lehre.tbl_lehrveranstaltung_faktor ADD CONSTRAINT fk_lehrveranstaltung_faktor_studiensemester_von FOREIGN KEY (studiensemester_kurzbz_von) REFERENCES public.tbl_studiensemester(studiensemester_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT; + ALTER TABLE lehre.tbl_lehrveranstaltung_faktor ADD CONSTRAINT fk_lehrveranstaltung_faktor_studiensemester_bis FOREIGN KEY (studiensemester_kurzbz_bis) REFERENCES public.tbl_studiensemester(studiensemester_kurzbz) ON UPDATE CASCADE ON DELETE RESTRICT; + + GRANT SELECT ON lehre.tbl_lehrveranstaltung_faktor TO web; + GRANT SELECT, UPDATE, INSERT, DELETE ON lehre.tbl_lehrveranstaltung_faktor TO vilesci; + GRANT SELECT ON lehre.lehrveranstaltung_faktor_id_seq TO web; + GRANT SELECT, UPDATE, INSERT, DELETE ON lehre.lehrveranstaltung_faktor_id_seq TO vilesci; + "; + + if (!$db->db_query($qry)) + echo 'lehre.tbl_lehrveranstaltung_faktor: ' . $db->db_last_error() . '
'; + else + echo 'Tabelle: lehre.tbl_lehrveranstaltung_faktor erstellt!'; + + //TODO ggf default wert in eine config + $qry = " + INSERT INTO lehre.tbl_lehrveranstaltung_faktor + (lehrveranstaltung_id, faktor, studiensemester_kurzbz_von, insertvon) + ( + SELECT lehrveranstaltung_id, + 2, + ( + SELECT public.tbl_studiensemester.studiensemester_kurzbz + FROM public.tbl_studiensemester + ORDER BY start LIMIT 1 + ), + 'checksystem' + FROM lehre.tbl_lehrveranstaltung + WHERE lehrtyp_kurzbz IN ('lv', 'tpl') + ); + "; + if (!$db->db_query($qry)) + echo 'lehre.tbl_lehrveranstaltung_faktor: ' . $db->db_last_error() . '
'; + else + echo 'Tabelle: lehre.tbl_lehrveranstaltung_faktor befüllt!'; +} diff --git a/vilesci/lehre/lehrveranstaltung.php b/vilesci/lehre/lehrveranstaltung.php index ab7abd9cd..2b3346d02 100644 --- a/vilesci/lehre/lehrveranstaltung.php +++ b/vilesci/lehre/lehrveranstaltung.php @@ -32,6 +32,7 @@ require_once('../../include/organisationsform.class.php'); require_once('../../include/addon.class.php'); require_once('../../include/sprache.class.php'); require_once('../../include/lehrmodus.class.php'); +require_once('../../include/lehrveranstaltung_faktor.class.php'); if (!$db = new basis_db()) die('Es konnte keine Verbindung zum Server aufgebaut werden.'); @@ -1108,7 +1109,8 @@ if ($result_lv!=0) { echo "LV-Angebot kompatible LV - Aktion"; + Aktion + Faktor"; } echo ""; @@ -1326,7 +1328,20 @@ if ($result_lv!=0) '; echo 'Kompatible LV'; - echo 'löschen'; + echo ' + löschen + '; + + if (in_array($row->lehrtyp_kurzbz, array("tpl", "lv"))) + echo '
Faktor'; + echo ''; + echo ' + '; + + $lv_faktor = new lehrveranstaltung_faktor(); + $lv_faktor->getAkt($row->lehrveranstaltung_id); + + echo $lv_faktor->faktor.''; echo "\n"; } } diff --git a/vilesci/lehre/lehrveranstaltung_details.php b/vilesci/lehre/lehrveranstaltung_details.php index bad2a7d93..60f2fc3c9 100644 --- a/vilesci/lehre/lehrveranstaltung_details.php +++ b/vilesci/lehre/lehrveranstaltung_details.php @@ -30,6 +30,8 @@ require_once('../../include/lehrmodus.class.php'); require_once('../../include/benutzerberechtigung.class.php'); require_once('../../include/studienplan.class.php'); + require_once('../../include/lehrveranstaltung_faktor.class.php'); + require_once('../../include/studiensemester.class.php'); if (!$db = new basis_db()) die('Es konnte keine Verbindung zum Server aufgebaut werden.'); @@ -139,6 +141,31 @@ $reloadstr .= " window.location.href='".$_SERVER['PHP_SELF']."?stg_kz=$lv->studiengang_kz&semester=$lv->semester&neu=true';"; } $reloadstr .= "\n"; + + if (in_array($lv->lehrtyp_kurzbz, array('tpl', 'lv')) && $lv->new === true) + { + $lv_faktor = new lehrveranstaltung_faktor(); + $studiensemester = new studiensemester(); + $studiensemester_von = $studiensemester->getLastOrAktSemester(); + if ($lv->lehrtyp_kurzbz === 'lv' && $_POST['lehrveranstaltung_template_id'] !== '') + { + + $lv_faktor->getAkt($_POST['lehrveranstaltung_template_id']); + //TODO Faktor in eine Config + if (is_null($lv_faktor->faktor)) + $lv_faktor->addFaktor($lv->lehrveranstaltung_id, 2, $studiensemester_von); + else + $lv_faktor->addFaktor($lv->lehrveranstaltung_id, $lv_faktor->faktor, $studiensemester_von); + } + else + { + $lv_faktor->loadByLV($lv->lehrveranstaltung_id); + if (empty($lv_faktor->lv_faktoren)) + { + $lv_faktor->addFaktor($lv->lehrveranstaltung_id, 2, $studiensemester_von); + } + } + } } } diff --git a/vilesci/lehre/lehrveranstaltung_faktor.php b/vilesci/lehre/lehrveranstaltung_faktor.php new file mode 100644 index 000000000..d2b39427f --- /dev/null +++ b/vilesci/lehre/lehrveranstaltung_faktor.php @@ -0,0 +1,309 @@ +getBerechtigungen($uid); + +$sprache = getSprache(); +$p = new phrasen($sprache); + +if(!$rechte->isBerechtigt('basis/person', 'suid')) + die('Sie haben keine Berechtigung für diese Seite'); + +echo ' + + + + + + + + + + + +'; +?> + +load($lehrveranstaltung_id); + +$faktor = new lehrveranstaltung_faktor(); +$faktor->loadByLV($lv->lehrveranstaltung_id); + +$studiensemester = new studiensemester(); +$studiensemester->getAll('desc'); + + +echo ' + + +

Faktor - '. $lv->bezeichnung . ' - ' . $lv->lehrveranstaltung_id . '

'; + +echo ' +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + +'; + +if(count($faktor->lv_faktoren) > 0) +{ + foreach($faktor->lv_faktoren as $lv_faktor) + { + echo " + + + + + + " + ; + } +} + + ' +
'.$p->t('lv/faktor').''.$p->t('global/von').''.$p->t('global/bis').''.$p->t('global/bearbeiten').''.$p->t('global/loeschen').'
".$lv_faktor->faktor."".$lv_faktor->studiensemester_kurzbz_von."".$lv_faktor->studiensemester_kurzbz_bis."
+'; + +?> + + From 0f708f4934d85b4353bd4c1aa38192634666d400 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Fri, 27 Sep 2024 11:23:54 +0200 Subject: [PATCH 02/31] - added app pep - phrases - added error - added model --- .../LehrveranstaltungFaktor_model.php | 14 +++++++ system/phrasesupdate.php | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 application/models/education/LehrveranstaltungFaktor_model.php diff --git a/application/models/education/LehrveranstaltungFaktor_model.php b/application/models/education/LehrveranstaltungFaktor_model.php new file mode 100644 index 000000000..c8a0c8aa8 --- /dev/null +++ b/application/models/education/LehrveranstaltungFaktor_model.php @@ -0,0 +1,14 @@ +dbTable = 'lehre.tbl_lehrveranstaltung_faktor'; + $this->pk = 'lehrveranstaltung_faktor_id'; + } +} diff --git a/system/phrasesupdate.php b/system/phrasesupdate.php index b7bd66e1d..afda422d7 100644 --- a/system/phrasesupdate.php +++ b/system/phrasesupdate.php @@ -26500,6 +26500,46 @@ array( ) ) ), + array( + 'app' => 'pep', + 'category' => 'ui', + 'phrase' => 'maprojohneoe', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Mitarbeiter und Projekt sind der Organisationseinheit nicht zugeordnet.', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Employee and project are not assigned to the organizational unit.', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), + array( + 'app' => 'pep', + 'category' => 'ui', + 'phrase' => 'infoandepl/kfl', + 'insertvon' => 'system', + 'phrases' => array( + array( + 'sprache' => 'German', + 'text' => 'Mitarbeiter und Projekt sind der Organisationseinheit nicht zugeordnet.', + 'description' => '', + 'insertvon' => 'system' + ), + array( + 'sprache' => 'English', + 'text' => 'Employee and project are not assigned to the organizational unit.', + 'description' => '', + 'insertvon' => 'system' + ) + ) + ), ); From 9c637b8575c4df645dca140b6eaeae12a8655a38 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Mon, 4 Nov 2024 12:20:52 +0100 Subject: [PATCH 03/31] - added model --- .../project/Projects_employees_model.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 application/models/project/Projects_employees_model.php diff --git a/application/models/project/Projects_employees_model.php b/application/models/project/Projects_employees_model.php new file mode 100644 index 000000000..a12e3961c --- /dev/null +++ b/application/models/project/Projects_employees_model.php @@ -0,0 +1,22 @@ +dbTable = 'sync.tbl_projects_employees'; + $this->pk = 'projects_employees_id'; + } + + public function deleteByProjectTaskId($ids) + { + $qry = "DELETE FROM " . $this->dbTable . " + WHERE project_task_id IN ?"; + + return $this->execQuery($qry, array($ids)); + } +} From 45bc65d32a783ef5002d7b3d1e0b5c9d52dd5026 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Mon, 11 Nov 2024 07:33:49 +0100 Subject: [PATCH 04/31] - Tags testversion - header tooltips - lehre spalte markieren wenn altes semester - legende-tab hinzugefuegt --- application/core/Tag_Controller.php | 176 ++++++++++++++ application/models/system/Notiztyp_model.php | 14 ++ application/views/templates/FHC-Common.php | 1 + application/views/templates/FHC-Header.php | 3 + public/css/tags.css | 66 ++++++ public/js/components/Tag/Tag.js | 233 +++++++++++++++++++ system/dbupdate_3.4.php | 2 + 7 files changed, 495 insertions(+) create mode 100644 application/core/Tag_Controller.php create mode 100644 application/models/system/Notiztyp_model.php create mode 100644 public/css/tags.css create mode 100644 public/js/components/Tag/Tag.js diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php new file mode 100644 index 000000000..740f3b09d --- /dev/null +++ b/application/core/Tag_Controller.php @@ -0,0 +1,176 @@ + self::BERECHTIGUNG_KURZBZ, + 'getTags' => self::BERECHTIGUNG_KURZBZ, + 'addTag' => self::BERECHTIGUNG_KURZBZ, + + 'updateTag' => self::BERECHTIGUNG_KURZBZ, + 'doneTag' => self::BERECHTIGUNG_KURZBZ, + 'deleteTag' => self::BERECHTIGUNG_KURZBZ, + ]; + + $merged_permissions = array_merge($default_permissions, $permissions); + + parent::__construct($merged_permissions); + + $this->_setAuthUID(); + $this->load->model('person/Notiz_model', 'NotizModel'); + $this->load->model('system/Notiztyp_model', 'NotiztypModel'); + $this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel'); + } + + public function getTag() + { + $id = $this->input->get('id'); + + $this->NotizModel->addSelect( + 'tbl_notiz.titel, + tbl_notiz.text, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung, + tbl_notiz.notiz_id, + tbl_notiz_typ.style, + tbl_notiz.erledigt as done, + tbl_notiz.insertamum, + tbl_notiz.updateamum, + tbl_notiz.insertvon, + tbl_notiz.updatevon + ' + ); + $this->NotizModel->addJoin('public.tbl_notiz_typ', 'public.tbl_notiz.typ = public.tbl_notiz_typ.typ_kurzbz'); + $notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id)); + + $this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array()); + } + + public function getTags() + { + $this->NotiztypModel->addSelect( + 'typ_kurzbz as tag_typ_kurzbz, + array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung, + style, + beschreibung, + tag + ' + ); + $notiztypen = $this->NotiztypModel->loadWhere(array('aktiv' => true)); + $this->terminateWithSuccess(hasData($notiztypen) ? getData($notiztypen) : array()); + } + + public function addTag($withZuordnung = true) + { + $postData = $this->getPostJson(); + + $checkTyp = $this->NotiztypModel->loadWhere(array('typ_kurzbz' => $postData->tag_typ_kurzbz)); + + if (!hasData($checkTyp)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $return = ""; + + if ($withZuordnung) + { + $checkZuordnungType = $this->NotizzuordnungModel->isValidType($postData->zuordnung_typ); + if (!isSuccess($checkZuordnungType)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $values = array_unique($postData->values); + + foreach ($values as $value) + { + $insertResult = $this->addNotiz($postData); + + if (isError($insertResult)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $insertZuordnung = $this->NotizzuordnungModel->insert(array( + 'notiz_id' => $insertResult->retval, + $postData->zuordnung_typ => $value + )); + + if (isError($insertZuordnung)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $return[] = [$postData->zuordnung_typ => $value, 'id' => $insertResult->retval]; + } + } + else + { + $insertResult = $this->addNotiz($postData); + if (isError($insertResult)) + $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); + + $return = $insertResult->retval; + } + + $this->terminateWithSuccess($return); + } + + private function addNotiz($postData) + { + return $this->NotizModel->insert(array( + 'titel' => 'TAG', //TODO klären + 'text' => $postData->notiz, + 'verfasser_uid' => $this->_uid, + 'erledigt' => false, + 'insertamum' => date('Y-m-d H:i:s'), + 'insertvon' => $this->_uid, + 'typ' => $postData->tag_typ_kurzbz + )); + + } + public function updateTag() + { + $postData = $this->getPostJson(); + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), + array('text' => $postData->notiz) + ); + $this->terminateWithSuccess($updateData); + } + public function doneTag() + { + $postData = $this->getPostJson(); + $updateData = $this->NotizModel->update(array('notiz_id' => $postData->id), + array('erledigt' => !$postData->done) + ); + + $this->terminateWithSuccess($updateData); + } + + public function deleteTag() + { + $postData = $this->getPostJson(); + $deleteZuordnung = $this->NotizzuordnungModel->delete(array( + 'notiz_id' => $postData->id + )); + + if (isSuccess($deleteZuordnung)) + { + $deleteNotiz = $this->NotizModel->delete(array( + 'notiz_id' => $postData->id + )); + } + $this->terminateWithSuccess(true); + } + + private function _setAuthUID() + { + $this->_uid = getAuthUID(); + + if (!$this->_uid) + show_error('User authentification failed'); + } + + +} \ No newline at end of file diff --git a/application/models/system/Notiztyp_model.php b/application/models/system/Notiztyp_model.php new file mode 100644 index 000000000..b173377e6 --- /dev/null +++ b/application/models/system/Notiztyp_model.php @@ -0,0 +1,14 @@ +dbTable = 'public.tbl_notiz_typ'; + $this->pk = 'typ_kurzbz'; + } +} diff --git a/application/views/templates/FHC-Common.php b/application/views/templates/FHC-Common.php index 072ff1d7f..f8194d194 100644 --- a/application/views/templates/FHC-Common.php +++ b/application/views/templates/FHC-Common.php @@ -44,3 +44,4 @@ $tablewidget = isset($tablewidget) ? $tablewidget : false; $udfs = isset($udfs) ? $udfs : false; $widgets = isset($widgets) ? $widgets : false; + $tags = isset($tags) ? $tags : false; diff --git a/application/views/templates/FHC-Header.php b/application/views/templates/FHC-Header.php index ed9fa97b9..39cc881d1 100644 --- a/application/views/templates/FHC-Header.php +++ b/application/views/templates/FHC-Header.php @@ -118,6 +118,9 @@ // CIS if ($cis === true) generateCSSsInclude('public/css/cis_bs5.css'); + //Tags + if ($tags === true) generateCSSsInclude('public/css/tags.css'); + // Eventually required CSS generateCSSsInclude($customCSSs); // Eventually required CSS ?> diff --git a/public/css/tags.css b/public/css/tags.css new file mode 100644 index 000000000..b1ee7d4c9 --- /dev/null +++ b/public/css/tags.css @@ -0,0 +1,66 @@ +:is(.tag_notice, .tag_inwork, .tag_planning) { + display: inline-block; + padding: 5px 10px; + margin-right: 5px; + border-radius: 3px; + color: white; + cursor: default; + font-size: .75em; + font-weight: 700; + line-height: 1; + text-align: center; + white-space: nowrap; + vertical-align: baseline; +} + +.tag_notice { + background-color: red !important; +} +.tag_inwork { + background-color: violet !important; +} +.tag_planning { + background-color: lightblue !important; +} + +.dropdown-list { + list-style: none; + background-color: white; + border: 1px solid #ccc; + border-radius: 5px; + box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); + z-index: 1000; + position: absolute; + padding: 10px 10px 10px; + max-width: 200px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; +} + +.plus-button-container.disabled { + pointer-events: none; + opacity: 0.5; +} + +.plus-more-tags { + font-weight: bold; + color: #007bff; + cursor: pointer; +} + +.all-tags-modal-content { + display: flex; + flex-direction: column; + gap: 0.5rem; +} + +.tag-done { + text-decoration: line-through; +} + +.modificationdate { + font-style: italic; + font-size: 0.7em; + text-align: left; +} diff --git a/public/js/components/Tag/Tag.js b/public/js/components/Tag/Tag.js new file mode 100644 index 000000000..be37659ae --- /dev/null +++ b/public/js/components/Tag/Tag.js @@ -0,0 +1,233 @@ +import CoreForm from '../Form/Form.js'; +import FormInput from "../Form/Input.js"; +import BsModal from '../Bootstrap/Modal.js'; + +export default { + components: { + CoreForm, + FormInput, + BsModal, + }, + emits: [ + 'added', + 'updated', + 'deleted', + ], + props: { + endpoint: { + type: Object, + required: true + }, + zuordnung_typ: String, + savepoint: {}, + values: { + type: Array, + required: true + } + }, + data() { + return { + showList: false, + selectedTagId: null, + tagData: { + beschreibung: "", + tag_typ_kurzbz: "", + notiz: "", + style: "", + zuordnung_typ: "", + id: "", + insertamum: "", + insertvon: "", + updateamum: "", + updatevon: "", + response: "" + }, + mode: "create" + }; + }, + created() { + this.init(); + }, + mounted() {}, + methods: { + init() { + if (!this.endpoint) + return; + this.endpoint.getTags() + .then(response => response.data) + .then(response => { + this.tags = response + }) + }, + hideList() { + this.showList = false; + }, + async editTag(tag_id) { + let getData = { + 'id': tag_id + }; + + this.endpoint.getTag(getData) + .then(result => result.data) + .then(result => this.openModal(result)) + }, + openModal(item = null) + { + this.tagData.beschreibung = item.bezeichnung; + this.tagData.tag_typ_kurzbz = item.tag_typ_kurzbz; + this.tagData.style = item.style; + this.tagData.zuordnung_typ = this.zuordnung_typ; + this.tagData.done = item.done; + this.tagData.insertamum = item.insertamum; + this.tagData.updateamum = item.updateamum; + this.tagData.updatevon = item.updatevon; + this.tagData.insertvon = item.insertvon; + + if (item && item.notiz_id) + { + this.selectedTagId = item.notiz_id; + this.tagData.notiz = item.text; + this.mode = "edit"; + } + else + { + this.selectedTagId = null; + this.tagData.notiz = ""; + this.mode = "create"; + } + this.$refs.tagModal.show(); + }, + async saveTag() + { + let postData = { + tag_typ_kurzbz: this.tagData.tag_typ_kurzbz, + notiz: this.tagData.notiz, + zuordnung_typ: this.tagData.zuordnung_typ, + values: this.values + } + + if (this.mode === "edit") + { + postData.id = this.selectedTagId; + this.tagData.id = this.selectedTagId; + this.endpoint.updateTag(postData); + this.$emit("updated", this.tagData); + this.$refs.tagModal.hide(); + } + else + { + this.endpoint.addTag(postData) + .then(response => response.data) + .then(response => { + if (typeof response === 'number') { + console.log(response); + this.tagData.id = response; + } else { + this.tagData.response = response; + } + }) + .then(() => { + this.$emit("added", this.tagData); + }) + .then(() => { + this.$refs.tagModal.hide(); + }); + } + + + }, + async doneTag() + { + this.tagData.id = this.selectedTagId; + this.tagData.done = !this.tagData.done; + + let postData = { + id: this.selectedTagId, + done: !this.tagData.done + } + this.endpoint.doneTag(postData) + this.$emit("updated", this.tagData); + this.$refs.tagModal.hide(); + }, + async deleteTag() + { + let postData = { + id: this.selectedTagId + } + this.endpoint.deleteTag(postData) + this.$emit("deleted", this.selectedTagId) + this.$refs.tagModal.hide(); + }, + reset() { + this.tagData = { + beschreibung: "", + tag_typ_kurzbz: "", + notiz: "", + style: "", + zuordnung_typ: "", + id: "", + done: false, + insertamum: "", + insertvon: "", + updateamum: "", + updatevon: "", + response: "" + }; + this.selectedTagId = null; + this.mode = "create"; + } + }, + template: ` +
+ + +
+ + + + + + `, +} \ No newline at end of file diff --git a/system/dbupdate_3.4.php b/system/dbupdate_3.4.php index 06b1e0cb4..42908ccbc 100644 --- a/system/dbupdate_3.4.php +++ b/system/dbupdate_3.4.php @@ -57,6 +57,8 @@ require_once('dbupdate_3.4/34543_ux_template.php'); require_once('dbupdate_3.4/17513_Entwicklungsteam.php'); require_once('dbupdate_3.4/28575_softwarebereitstellung.php'); require_once('dbupdate_3.4/40717_lv_faktor.php'); +require_once('dbupdate_3.4/48526_pep_tagging.php'); + // *** Pruefung und hinzufuegen der neuen Attribute und Tabellen echo '

Pruefe Tabellen und Attribute!

'; From 355652cdb1a41ab990cc31b4bbcd9d5be7740464 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Mon, 11 Nov 2024 07:51:52 +0100 Subject: [PATCH 05/31] - added sql for tags --- system/dbupdate_3.4/48526_pep_tagging.php | 50 +++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 system/dbupdate_3.4/48526_pep_tagging.php diff --git a/system/dbupdate_3.4/48526_pep_tagging.php b/system/dbupdate_3.4/48526_pep_tagging.php new file mode 100644 index 000000000..d935d9e92 --- /dev/null +++ b/system/dbupdate_3.4/48526_pep_tagging.php @@ -0,0 +1,50 @@ +db_query('SELECT 0 FROM public.tbl_notiz_typ WHERE 0 = 1')) +{ + //TODO zuordnung typ definieren + $qry = 'CREATE TABLE public.tbl_notiz_typ ( + typ_kurzbz varchar(32) NOT NULL, + bezeichnung_mehrsprachig character varying(256)[] NOT NULL, + beschreibung text, + automatisiert boolean NOT NULL, + aktiv boolean NOT NULL, + zuordnung text, + tag boolean NOT NULL, + style text, + vorrueckung boolean NOT NULL, + prioritaet smallint + ); + + ALTER TABLE public.tbl_notiz_typ ADD CONSTRAINT pk_tbl_tbl_notiz_typ PRIMARY KEY (typ_kurzbz)'; + + if (!$db->db_query($qry)) + echo 'public.tbl_notiz_typ: '.$db->db_last_error().'
'; + else + echo '
public.tbl_notiz_typ table created'; + + $qry = 'GRANT SELECT ON TABLE public.tbl_notiz_typ TO web;'; + if (!$db->db_query($qry)) + echo 'public.tbl_notiz_typ: '.$db->db_last_error().'
'; + else + echo '
Granted privileges to web on public.tbl_notiz_typ'; + + $qry = 'GRANT SELECT, UPDATE, INSERT, DELETE ON TABLE public.tbl_notiz_typ TO vilesci;'; + if (!$db->db_query($qry)) + echo 'public.tbl_notiz_typ: '.$db->db_last_error().'
'; + else + echo '
Granted privileges to vilesci on public.tbl_notiz_typ'; +} + +if(!@$db->db_query("SELECT typ FROM public.tbl_notiz LIMIT 1")) +{ + $qry = 'ALTER TABLE public.tbl_notiz ADD COLUMN typ varchar(32); + ALTER TABLE public.tbl_notiz ADD CONSTRAINT tbl_notiz_typ_fkey FOREIGN KEY (typ) REFERENCES public.tbl_notiz_typ (typ_kurzbz) ON DELETE RESTRICT ON UPDATE CASCADE;'; + + if(!$db->db_query($qry)) + echo ' public.tbl_notiz '.$db->db_last_error().'
'; + else + echo '
public.tbl_notiz: Neue Spalte typ hinzugefügt'; +} From 6b04dff4a3178557e2697bc2e16d73d13fb829da Mon Sep 17 00:00:00 2001 From: ma0048 Date: Tue, 12 Nov 2024 11:47:16 +0100 Subject: [PATCH 06/31] - start tab tags hinzugefuegt --- application/core/Tag_Controller.php | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/application/core/Tag_Controller.php b/application/core/Tag_Controller.php index 740f3b09d..5c0a580ef 100644 --- a/application/core/Tag_Controller.php +++ b/application/core/Tag_Controller.php @@ -77,10 +77,10 @@ class Tag_Controller extends FHCAPI_Controller if (!hasData($checkTyp)) $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); - $return = ""; if ($withZuordnung) { + $return = array(); $checkZuordnungType = $this->NotizzuordnungModel->isValidType($postData->zuordnung_typ); if (!isSuccess($checkZuordnungType)) $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); @@ -104,6 +104,7 @@ class Tag_Controller extends FHCAPI_Controller $return[] = [$postData->zuordnung_typ => $value, 'id' => $insertResult->retval]; } + $this->terminateWithSuccess($return); } else { @@ -111,10 +112,8 @@ class Tag_Controller extends FHCAPI_Controller if (isError($insertResult)) $this->terminateWithError('Error occurred', self::ERROR_TYPE_GENERAL); - $return = $insertResult->retval; + return $insertResult->retval; } - - $this->terminateWithSuccess($return); } private function addNotiz($postData) @@ -148,20 +147,31 @@ class Tag_Controller extends FHCAPI_Controller $this->terminateWithSuccess($updateData); } - public function deleteTag() + public function deleteTag($withZuordnung = true) { $postData = $this->getPostJson(); - $deleteZuordnung = $this->NotizzuordnungModel->delete(array( - 'notiz_id' => $postData->id - )); - if (isSuccess($deleteZuordnung)) + $deleteNotiz = ""; + if ($withZuordnung) + { + $deleteZuordnung = $this->NotizzuordnungModel->delete(array( + 'notiz_id' => $postData->id + )); + + if (isSuccess($deleteZuordnung)) + { + $deleteNotiz = $this->NotizModel->delete(array( + 'notiz_id' => $postData->id + )); + } + } + else { $deleteNotiz = $this->NotizModel->delete(array( 'notiz_id' => $postData->id )); } - $this->terminateWithSuccess(true); + $this->terminateWithSuccess($deleteNotiz); } private function _setAuthUID() From 1a1ed49f8b439d1052c01ee4f89f6da931c2bfcf Mon Sep 17 00:00:00 2001 From: ma0048 Date: Mon, 2 Dec 2024 13:09:38 +0100 Subject: [PATCH 07/31] =?UTF-8?q?-=20styling=20f=C3=BCr=20neuen=20tag=20-?= =?UTF-8?q?=20hover=20effekt=20-=20tagicon=20statt=20plus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/css/tags.css | 28 ++++++++++++++++++++++++---- public/js/components/Tag/Tag.js | 5 ++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/public/css/tags.css b/public/css/tags.css index b1ee7d4c9..fb0c33a29 100644 --- a/public/css/tags.css +++ b/public/css/tags.css @@ -1,10 +1,9 @@ -:is(.tag_notice, .tag_inwork, .tag_planning) { +:is(.tag_notice, .tag_inwork, .tag_planning, .tag_prio_one, .tag_prio_two, .tag_finished) { display: inline-block; padding: 5px 10px; margin-right: 5px; border-radius: 3px; color: white; - cursor: default; font-size: .75em; font-weight: 700; line-height: 1; @@ -13,16 +12,37 @@ vertical-align: baseline; } +:is(.tag_notice, .tag_inwork, .tag_planning, .tag_prio_one, .tag_prio_two, .tag_finished):hover { + transform: scale(1.05); +} + .tag_notice { background-color: red !important; } -.tag_inwork { + + +.tag_finished { + background-color: green !important; +} + +.tag_inwork { background-color: violet !important; } -.tag_planning { + +.tag_planning { background-color: lightblue !important; } +.tag_prio_one { + background-color: red !important; +} + +.tag_prio_two { + background-color: yellow !important; + color: black; +} + + .dropdown-list { list-style: none; background-color: white; diff --git a/public/js/components/Tag/Tag.js b/public/js/components/Tag/Tag.js index be37659ae..52d919a68 100644 --- a/public/js/components/Tag/Tag.js +++ b/public/js/components/Tag/Tag.js @@ -181,8 +181,8 @@ export default {