diff --git a/config/vilesci.config-default.inc.php b/config/vilesci.config-default.inc.php index cd45e6979..bc6995182 100644 --- a/config/vilesci.config-default.inc.php +++ b/config/vilesci.config-default.inc.php @@ -254,4 +254,10 @@ define('BIS_STANDORTCODE_LEHRGAENGE', '0'); // bPk Abfrage define('BPK_FUER_ALLE_BENUTZER_ABFRAGEN', false); + +// Bei folgenden Buchungstypen wird ein Anlegen geprüft ob bereits ein Eintrag für diesen Typ vorhanden ist im selben +// Semester und ggf ein Hinweis ausgegeben +define('FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK', serialize( + array('StudiengebuehrAnzahlung', 'Studiengebuehr', 'StudiengebuehrRestzahlung', 'OEH') +)); ?> diff --git a/content/student/studentDBDML.php b/content/student/studentDBDML.php index a2c6eca51..4a4b64201 100644 --- a/content/student/studentDBDML.php +++ b/content/student/studentDBDML.php @@ -2272,6 +2272,21 @@ if(!$error) $errormsg = 'Fehlerhafte Parameteruebergabe'; } } + elseif(isset($_POST['type']) && $_POST['type']=='checkbuchung') + { + $person_ids = explode(';',$_POST['person_ids']); + $exists = false; + if (defined('FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK') && (in_array($_POST['buchungstyp_kurzbz'], unserialize(FAS_DOPPELTE_BUCHUNGSTYPEN_CHECK)))) + { + $konto = new konto(); + $exists = $konto->checkDoppelteBuchung($person_ids, $_POST['studiensemester_kurzbz'], $_POST['buchungstyp_kurzbz']); + } + + if($exists) + $return = true; + else + $return = false; + } elseif(isset($_POST['type']) && $_POST['type']=='neuebuchung') { //Speichert eine neue Buchung diff --git a/content/student/studentoverlay.js.php b/content/student/studentoverlay.js.php index c41c60be1..5444504b1 100644 --- a/content/student/studentoverlay.js.php +++ b/content/student/studentoverlay.js.php @@ -3085,6 +3085,20 @@ function StudentKontoNeuSpeichern(dialog, person_ids, studiengang_kz) return false; } + var tocheck = ; + + var exists = false; + + if (tocheck) + { + exists = StudentCheckBuchung(person_ids, studiensemester_kurzbz, buchungstyp_kurzbz, studiengang_kz); + } + if (exists) + { + if(!confirm('Die Buchung ist bereits vorhanden. Trotzdem fortfahren?')) + return false; + } + req.add('type', 'neuebuchung'); req.add('person_ids', person_ids); @@ -3116,6 +3130,28 @@ function StudentKontoNeuSpeichern(dialog, person_ids, studiengang_kz) return true; } } +// **** +// * Prüft ob die Buchung bereits vorhanden ist +// **** +function StudentCheckBuchung(person_ids, studiensemester_kurzbz, buchungstyp_kurzbz, studiengang_kz) +{ + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + var url = 'content/student/studentDBDML.php'; + var req = new phpRequest(url,'',''); + req.add('type', 'checkbuchung'); + + req.add('person_ids', person_ids); + req.add('studiensemester_kurzbz', studiensemester_kurzbz); + req.add('buchungstyp_kurzbz', buchungstyp_kurzbz); + req.add('studiengang_kz', studiengang_kz); + + var response = req.executePOST(); + + var val = new ParseReturnValue(response); + + return(val.dbdml_return); +} // ***** // * Druckt eine Zahlungsbestaetigung aus diff --git a/include/konto.class.php b/include/konto.class.php index 09afa5303..6c4891674 100644 --- a/include/konto.class.php +++ b/include/konto.class.php @@ -957,6 +957,30 @@ class konto extends basis_db return false; } } + + public function checkDoppelteBuchung($person_ids, $stsem, $typ) + { + $qry = "SELECT betrag + FROM public.tbl_konto + JOIN public.tbl_benutzer benutzer USING(person_id) + WHERE person_id IN (".$this->implode4SQL(array_filter($person_ids)).") + AND studiensemester_kurzbz = ".$this->db_add_param($stsem)." + AND buchungstyp_kurzbz = ".$this->db_add_param($typ)." + GROUP BY buchungsnr"; + + if ($result = $this->db_query($qry)) + { + if ($this->db_num_rows($result) > 0) + return true; + else + return false; + } + else + { + $this->errormsg = 'Fehler bei der Abfrage aufgetreten'; + return false; + } + } } ?>