mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-23 09:52:22 +00:00
SYNC FAS Person mit Update-Überprüfung
SYNC FAS Nation
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Technikum-Wien
|
||||
*
|
||||
* 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: Christian Paminger <christian.paminger@technikum-wien.at>,
|
||||
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
|
||||
* Rudolf Hangl <rudolf.hangl@technikum-wien.at>.
|
||||
*/
|
||||
|
||||
//*
|
||||
//* Synchronisiert Nationendatensaetze von Vilesci DB in PORTAL DB
|
||||
//*
|
||||
//*
|
||||
|
||||
include('../../../vilesci/config.inc.php');
|
||||
include('../../../include/nation.class.php');
|
||||
|
||||
$conn=pg_connect(CONN_STRING) or die("Connection zur Portal Datenbank fehlgeschlagen");
|
||||
$conn_fas=pg_connect(CONN_STRING_FAS) or die("Connection zur FAS Datenbank fehlgeschlagen");
|
||||
|
||||
$adress='ruhan@technikum-wien.at';
|
||||
//$adress='fas_sync@technikum-wien.at';
|
||||
|
||||
$error_log='';
|
||||
$text = '';
|
||||
$anzahl_quelle=0;
|
||||
$anzahl_eingefuegt=0;
|
||||
$anzahl_fehler=0;
|
||||
|
||||
function validate($row)
|
||||
{
|
||||
}
|
||||
|
||||
/*************************
|
||||
* FAS-PORTAL - Synchronisation
|
||||
*/
|
||||
|
||||
//nation
|
||||
$qry = "SELECT * FROM nation";
|
||||
|
||||
if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
echo nl2br("Nation Sync\n--------------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
$error=false;
|
||||
$nation =new nation($conn);
|
||||
$nation->code =$row->code;
|
||||
$nation->entwicklungsstand =$row->entwland;
|
||||
$nation->eu =$row->euflag=='U'?true:false;
|
||||
$nation->ewr =$row->ewrflag=='W'?true:false;
|
||||
$nation->kontinent =$row->kontinent;
|
||||
$nation->kurztext =$row->kurztext;
|
||||
$nation->langtext =$row->langtext;
|
||||
$nation->engltext =$row->engltext;
|
||||
$nation->sperre =$row->sperre=='J'?true:false;
|
||||
|
||||
if(!$nation->save())
|
||||
{
|
||||
$error_log.=$nation->errormsg."\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - Vilesci -> Portal - Nation</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
//echo nl2br($text);
|
||||
echo nl2br($error_log);
|
||||
echo nl2br("\nGesamt: $anzahl_quelle / Eingefügt: $anzahl_eingefuegt / Fehler: $anzahl_fehler");
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -53,6 +53,9 @@ $anzahl_fehler=0;
|
||||
<body>
|
||||
<?php
|
||||
//person
|
||||
flush();
|
||||
?>
|
||||
<?php
|
||||
$qry = "SELECT * FROM person";
|
||||
if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
@@ -61,6 +64,7 @@ if($result = pg_query($conn_fas, $qry))
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
$person=new person($conn);
|
||||
|
||||
$person->geburtsnation=$row->gebnation;
|
||||
$person->anrede=$row->anrede;
|
||||
$person->titelpost=$row->postnomentitel;
|
||||
@@ -99,39 +103,106 @@ if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
$person->familienstand=='w';
|
||||
}
|
||||
|
||||
$error=false;
|
||||
$qry="SELECT ext_id FROM public.tbl_person WHERE ext_id='$row->person_pk'";
|
||||
if($result1 = pg_query($conn, $qry))
|
||||
$qry="SELECT person_id FROM public.tbl_benutzer WHERE uid='$row->uid'";
|
||||
if($resultu = pg_query($conn, $qry))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //wenn dieser eintrag schon vorhanden ist
|
||||
if(pg_num_rows($resultu)>0) //wenn dieser eintrag schon vorhanden ist
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
if($rowu=pg_fetch_object($resultu))
|
||||
{
|
||||
//update
|
||||
$person->new=false;
|
||||
$person->person_id=$rowu->person_id;
|
||||
$person->new=false;
|
||||
//echo nl2br("update1 von ".$row->uid.", ".$row->familienname."\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="person von $row->person_pk konnte nicht ermittelt werden\n";
|
||||
$error_log.="benutzer von $row->uid konnte nicht ermittelt werden\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//insert
|
||||
$person->new=true;
|
||||
|
||||
}
|
||||
$qry="SELECT person_fas, person_portal FROM public.tbl_syncperson WHERE person_fas='$row->person_pk'";
|
||||
if($result1 = pg_query($conn, $qry))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //wenn dieser eintrag schon vorhanden ist
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
//update
|
||||
$person->person_id=$row1->person_portal;
|
||||
$person->new=false;
|
||||
//echo nl2br("update2 von ".$row->uid.", ".$row->familienname."\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="person von $row->person_pk konnte nicht ermittelt werden\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//vergleich svnr und ersatzkennzeichen
|
||||
$qry="SELECT person_id FROM public.tbl_person
|
||||
WHERE ('$row->svnr' is not null AND svnr = '$row->svnr')
|
||||
OR ('$row->ersatzkennzeichen' is not null AND ersatzkennzeichen = '$row->ersatzkennzeichen')";
|
||||
if($resultz = pg_query($conn, $qry))
|
||||
{
|
||||
if(pg_num_rows($resultz)>0) //wenn dieser eintrag schon vorhanden ist
|
||||
{
|
||||
if($rowz=pg_fetch_object($resultz))
|
||||
{
|
||||
$person->new=false;
|
||||
$person->person_id=$rowz->person_id;
|
||||
//echo nl2br("update3 von ".$row->uid.", ".$row->familienname."\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="person mit svnr: $row->svnr bzw. ersatzkennzeichen: $row->ersatzkennzeichen konnte nicht ermittelt werden (".pg_num_rows($resultz).")\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//insert
|
||||
$person->new=true;
|
||||
//echo nl2br("insert von ".$row->uid.", ".$row->familienname."\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$error)
|
||||
{
|
||||
if(!$person->save())
|
||||
{
|
||||
$error_log.=$person->errormsg."\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//überprüfen, ob eintrag schon vorhanden
|
||||
$qry="SELECT person_fas FROM tbl_syncperson WHERE person_fas='$row->person_pk' AND person_portal='$person->person_id'";
|
||||
if($resultz = pg_query($conn, $qry))
|
||||
{
|
||||
if(pg_num_rows($resultz)==0) //wenn dieser eintrag noch nicht vorhanden ist
|
||||
{
|
||||
$qry='INSERT INTO tbl_syncperson (person_fas, person_portal)'.
|
||||
'VALUES ('.$row->person_pk.', '.$person->person_id.');';
|
||||
$resulti = pg_query($conn, $qry);
|
||||
}
|
||||
}
|
||||
$anzahl_eingefuegt++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo nl2br("abgeschlossen\n\n");
|
||||
|
||||
@@ -62,7 +62,8 @@ if($result = pg_query($conn_vilesci, $qry))
|
||||
$ort->bezeichnung =$row->bezeichnung;
|
||||
$ort->planbezeichnung =$row->planbezeichnung;
|
||||
$ort->max_person =$row->max_person;
|
||||
$ort->aktiv =($row->aktiv=='t'?true:false);
|
||||
$ort->aktiv =($row->aktiv=='t'?true:false);
|
||||
$ort->lehre =($row->lehre=='t'?true:false);
|
||||
$ort->lageplan =$row->lageplan;
|
||||
$ort->dislozierung =$row->dislozierung;
|
||||
$ort->kosten =$row->kosten;
|
||||
|
||||
Reference in New Issue
Block a user