Datenverbund Schnittstelle

- Fehler behoben bei der Vergabemeldung von Matrikelnummern für Incoming
- Neuen Job für autmatisierte Ermittlung der BPKs hinzugefügt
This commit is contained in:
Andreas Österreicher
2018-11-05 08:36:36 +01:00
parent 2959e60df0
commit 2674376e11
3 changed files with 139 additions and 13 deletions
+1 -1
View File
@@ -170,7 +170,7 @@ class dvb extends basis_db
WHERE
tbl_prestudent.person_id=".$this->db_add_param($person->person_id)."
AND tbl_benutzer.aktiv
AND tbl_prestudentstatus.status_kurzbz='Student'
AND tbl_prestudentstatus.status_kurzbz in('Student','Incoming')
AND tbl_prestudent.bismelden
ORDER BY tbl_prestudentstatus.datum desc LIMIT 1
";
+126
View File
@@ -0,0 +1,126 @@
<?php
/* Copyright (C) 2018 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: Andreas Oesterreicher < andreas.oesterreicher@technikum-wien.at >
*/
/**
* Erfragt die BPKs von Personen beim Datenverbund und speichert diese wenn gefunden
* Dieses Script sollte nach dem Matrikelnummer Job aufgerufen werden da dieser bereits bpks ermittelt
* Dieser Job versucht die BPKs zu holen die nicht automatisch über den Matrikelnummer Job gefunden wurden.
*/
require_once(dirname(__FILE__).'/../../config/vilesci.config.inc.php');
require_once(dirname(__FILE__).'/../../include/basis_db.class.php');
require_once(dirname(__FILE__).'/../../include/dvb.class.php');
require_once(dirname(__FILE__).'/../../include/benutzerberechtigung.class.php');
require_once(dirname(__FILE__).'/../../include/datum.class.php');
require_once(dirname(__FILE__).'/../../include/errorhandler.class.php');
if (!$db = new basis_db())
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
$limit = '';
$debug = false;
// Wenn das Script nicht ueber Commandline gestartet wird, muss eine
// Authentifizierung stattfinden
if (php_sapi_name() != 'cli')
{
$nl = '<br>';
// Benutzerdefinierte Variablen laden
$user = get_uid();
loadVariables($user);
// Berechtigungen pruefen
$rechte = new benutzerberechtigung();
$rechte->getBerechtigungen($user);
if (!$rechte->isBerechtigt('admin', null, 'suid'))
die('Sie haben keine Berechtigung für diese Seite');
if (isset($_GET['debug']))
$debug = ($_GET['debug'] == 'true'?true:false);
if (isset($_GET['limit']) && is_numeric($_GET['limit']))
$limit = $_GET['limit'];
}
else
{
$nl = "\n";
// Commandline Paramter parsen bei Aufruf ueber Cronjob
// zb php matrikelnummer.php --limit 100 --debug true
$longopt = array(
"limit:",
"debug:"
);
$commandlineparams = getopt('', $longopt);
if (isset($commandlineparams['limit']) && is_numeric($commandlineparams['limit']))
$limit = $commandlineparams['limit'];
if (isset($commandlineparams['debug']))
$debug = ($commandlineparams['debug'] == 'true'?true:false);
}
$webservice = new dvb(DVB_USERNAME, DVB_PASSWORD, $debug);
$qry = "
SELECT
distinct person_id, vorname, nachname
FROM
public.tbl_person
JOIN public.tbl_benutzer USING(person_id)
JOIN public.tbl_student ON(tbl_student.student_uid=tbl_benutzer.uid)
WHERE
public.tbl_benutzer.aktiv = true
AND tbl_person.matr_nr is not null
AND studiengang_kz<10000
AND EXISTS(SELECT 1 FROM public.tbl_prestudent WHERE person_id=tbl_person.person_id AND bismelden=true)
AND gebdatum is not null";
if ($limit != '')
$qry .= " LIMIT ".$limit;
$db = new basis_db();
if ($result = $db->db_query($qry))
{
while ($row = $db->db_fetch_object($result))
{
echo $nl."Pruefe $row->person_id $row->vorname $row->nachname";
$data = $webservice->getBPK($row->person_id);
if (ErrorHandler::isSuccess($data))
{
if (ErrorHandler::hasData($data) && isset($data->retval->bpk) && $data->retval->bpk != '')
{
$person = new person();
if ($person->load($row->person_id))
{
$person->bpk = $data->retval->bpk;
if ($person->save())
echo ' OK';
else
echo ' Failed: '.$person->errormsg;
}
}
else
{
echo 'Failed: BPK Empty';
}
}
else
echo ' Failed:'.$webservice->errormsg;
}
}
if ($debug)
echo $webservice->debug_output;
+12 -12
View File
@@ -51,14 +51,14 @@ if (php_sapi_name() != 'cli')
if (!$rechte->isBerechtigt('admin', null, 'suid'))
die('Sie haben keine Berechtigung für diese Seite');
if(isset($_GET['debug']))
$debug = ($_GET['debug']=='true'?true:false);
if (isset($_GET['debug']))
$debug = ($_GET['debug'] == 'true'?true:false);
if(isset($_GET['limit']) && is_numeric($_GET['limit']))
if (isset($_GET['limit']) && is_numeric($_GET['limit']))
$limit = $_GET['limit'];
if(isset($_GET['softrun']))
$debug = ($_GET['softrun']=='true'?true:false);
if (isset($_GET['softrun']))
$debug = ($_GET['softrun'] == 'true'?true:false);
}
else
{
@@ -74,9 +74,9 @@ else
if (isset($commandlineparams['limit']) && is_numeric($commandlineparams['limit']))
$limit = $commandlineparams['limit'];
if (isset($commandlineparams['debug']))
$debug = ($commandlineparams['debug']=='true'?true:false);
$debug = ($commandlineparams['debug'] == 'true'?true:false);
if (isset($commandlineparams['softrun']))
$softrun = ($commandlineparams['softrun']=='true'?true:false);
$softrun = ($commandlineparams['softrun'] == 'true'?true:false);
}
$matrikelnummer_added = 0;
@@ -97,19 +97,19 @@ $qry = "
AND (svnr is not null OR ersatzkennzeichen is not null)";
if ($limit != '')
$qry.=" LIMIT ".$limit;
$qry .= " LIMIT ".$limit;
$db = new basis_db();
if ($result = $db->db_query($qry))
{
while($row = $db->db_fetch_object($result))
while ($row = $db->db_fetch_object($result))
{
echo $nl."Pruefe $row->person_id $row->vorname $row->nachname";
$data = $webservice->assignMatrikelnummer($row->person_id, $softrun);
if(ErrorHandler::isSuccess($data))
echo $nl.$row->person_id.' OK';
if (ErrorHandler::isSuccess($data))
echo ' OK';
else
echo $nl.$row->person_id.' Failed:'.$webservice->errormsg;
echo ' Failed:'.$webservice->errormsg;
}
}
if($debug)