generieren einer Zahlungsreferenz beim anlegen einer neuen Buchung

This commit is contained in:
Stefan Puraner
2014-01-24 14:09:17 +00:00
parent 489ff601df
commit f112c48f70
4 changed files with 86 additions and 5 deletions
+35 -2
View File
@@ -24,6 +24,7 @@
* @create 2007-05-14
*/
require_once(dirname(__FILE__).'/basis_db.class.php');
require_once(dirname(__FILE__).'/'.EXT_FKT_PATH.'/generateZahlungsreferenz.inc.php');
class konto extends basis_db
{
@@ -185,11 +186,15 @@ class konto extends basis_db
if($new==null)
$new = $this->new;
if($new)
{
//Zahlungsreferenz generieren
//TODO Buchungscode
//$this->zahlungsreferenz = generateZahlungsreferenz($this->person_id, $this->studiengang_kz, "CODE");
//$this->zahlungsreferenz = "WTF";
//Neuen Datensatz einfuegen
$qry='BEGIN;INSERT INTO public.tbl_konto (person_id, studiengang_kz, studiensemester_kurzbz, buchungsnr_verweis, betrag, buchungsdatum, buchungstext, mahnspanne, buchungstyp_kurzbz, updateamum, updatevon, insertamum, insertvon, ext_id, credit_points) VALUES('.
$this->addslashes($this->person_id).', '.
$this->addslashes($this->studiengang_kz).', '.
@@ -240,6 +245,14 @@ class konto extends basis_db
if($row = $this->db_fetch_object())
{
$this->buchungsnr = $row->id;
if(strlen($this->buchungsnr_verweis) == 0)
{
if(!$this->addZahlungsreferenz($this->buchungsnr))
{
$this->db_query("ROLLBACK;");
return false;
}
}
$this->db_query('COMMIT;');
}
else
@@ -609,5 +622,25 @@ class konto extends basis_db
return false;
}
}
private function addZahlungsreferenz($buchungsnr)
{
$this->zahlungsreferenz = generateZahlungsreferenz($this->studiengang_kz, $buchungsnr);
$qry = "UPDATE public.tbl_konto "
. "SET zahlungsreferenz='".$this->zahlungsreferenz."' "
. "WHERE buchungsnr='".$buchungsnr."';";
if($this->db_query($qry))
{
return true;
}
else
{
$this->errormsg = 'Fehler beim speichern der Zahlungsreferenz aufgetreten';
return false;
}
}
}
?>
+39
View File
@@ -0,0 +1,39 @@
<?php
/* Copyright (C) 2014 fhcomplete.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Stefan Puraner <[email protected]>,
*
*/
require_once(dirname(__FILE__).'/../../config/cis.config.inc.php');
require_once(dirname(__FILE__).'/../../include/functions.inc.php');
require_once(dirname(__FILE__).'/../../include/studiengang.class.php');
function generateZahlungsreferenz($studiengang_kz, $buchungsNr)
{
//TODO Aufbau Zahlungsreferenz
$studiengang = new studiengang($studiengang_kz);
$zahlRefPrefix = strtoupper($studiengang->oe_kurzbz);
$zahlungsreferenz = $zahlRefPrefix.$buchungsNr;
//echo $zahlungsreferenz;
return $zahlungsreferenz;
}
//generateZahlungsreferenz(33403, 257);
?>