mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 17:02:19 +00:00
SYNC FAS EMail und Telefon
This commit is contained in:
@@ -51,9 +51,17 @@ function validate($row)
|
||||
/*************************
|
||||
* FAS-PORTAL - Synchronisation
|
||||
*/
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - Vilesci -> Portal - Adresse</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
//nation
|
||||
$qry = "SELECT * FROM adresse";
|
||||
$qry = "SELECT * FROM adresse ORDER BY person_fk;";
|
||||
|
||||
if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
@@ -79,8 +87,9 @@ if($result = pg_query($conn_fas, $qry))
|
||||
$adresse->insertvon ="SYNC";
|
||||
$adresse->ext_id =$row->adresse_pk;
|
||||
|
||||
//echo nl2br ($adresse->ext_id."\n");
|
||||
//person_id herausfinden
|
||||
$qry1="SELECT person_portal FROM public.tbl_syncperson WHERE person_fas=".$row->adresse_pk.";";
|
||||
$qry1="SELECT person_portal FROM public.tbl_syncperson WHERE person_fas=".$row->person_fk.";";
|
||||
if($result1 = pg_query($conn, $qry1))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //eintrag gefunden
|
||||
@@ -88,49 +97,67 @@ if($result = pg_query($conn_fas, $qry))
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
$adresse->person_id=$row1->person_portal;
|
||||
$adresse->new=true;
|
||||
|
||||
//firma eintragen
|
||||
if ($row->typ==1)
|
||||
|
||||
$qry2="SELECT adresse_id, ext_id FROM tbl_adresse WHERE ext_id=".$row->adresse_pk.";";
|
||||
if($result2 = pg_query($conn, $qry2))
|
||||
{
|
||||
$anzahl_quelle2++;
|
||||
$firma=new firma($conn);
|
||||
$firma->name=$row->bezeichnung;
|
||||
$firma->anmerkung=null;
|
||||
$firma->ext_id=$row->adresse_pk;
|
||||
$qry2="SELECT firma_id, ext_id FROM tbl_firma WHERE ext_id=".$row->adresse_pk.";";
|
||||
if($result2 = pg_query($conn, $qry2))
|
||||
if(pg_num_rows($result2)>0) //eintrag gefunden
|
||||
{
|
||||
if(pg_num_rows($result2)>0) //eintrag gefunden
|
||||
{
|
||||
if($row2=pg_fetch_object($result2))
|
||||
{
|
||||
$firma->new=false;
|
||||
$firma->firma_id=$row2->firma_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="firma mit adresse_pk: $row->adresse_pk konnte nicht ermittelt werden!\n";
|
||||
}
|
||||
if($row2=pg_fetch_object($result2))
|
||||
{
|
||||
// update adresse, wenn datensatz bereits vorhanden
|
||||
$adresse->new=false;
|
||||
$adresse->adresse_id=$row2->adresse_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$firma->new=true;
|
||||
}
|
||||
}
|
||||
if(!$error)
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$firma->save())
|
||||
// insert, wenn datensatz noch nicht vorhanden
|
||||
$adresse->new=true;
|
||||
|
||||
//firma eintragen, wenn firmenadresse
|
||||
if ($row->typ==1)
|
||||
{
|
||||
$error_log.=$firma->errormsg."\n";
|
||||
$anzahl_fehler2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt2++;
|
||||
}
|
||||
$adresse->firma_id=$firma->firma_id;
|
||||
$anzahl_quelle2++;
|
||||
$firma=new firma($conn);
|
||||
$firma->name=$row->bezeichnung;
|
||||
$firma->anmerkung=null;
|
||||
$firma->ext_id=$row->adresse_pk;
|
||||
$qry3="SELECT firma_id, ext_id FROM tbl_firma WHERE ext_id=".$row->adresse_pk.";";
|
||||
if($result3 = pg_query($conn, $qry3))
|
||||
{
|
||||
if(pg_num_rows($result3)>0) //eintrag gefunden
|
||||
{
|
||||
if($row3=pg_fetch_object($result3))
|
||||
{
|
||||
$firma->new=false;
|
||||
$firma->firma_id=$row3->firma_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="firma mit adresse_pk: $row->adresse_pk konnte nicht ermittelt werden!\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$firma->new=true;
|
||||
}
|
||||
}
|
||||
if(!$error)
|
||||
{
|
||||
if(!$firma->save())
|
||||
{
|
||||
$error_log.=$firma->errormsg."\n";
|
||||
$anzahl_fehler2++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt2++;
|
||||
}
|
||||
$adresse->firma_id=$firma->firma_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +171,7 @@ if($result = pg_query($conn_fas, $qry))
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="adresse mit adresse_pk: $row->adresse_pk konnte nicht gefunden werden! (".pg_num_rows($result1).")\n";
|
||||
$error_log.="adresse mit adresse_pk: $row->adresse_pk ($row->person_fk) konnte in tbl_syncperson nicht gefunden werden! (".pg_num_rows($result1).")\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
@@ -159,20 +186,15 @@ if($result = pg_query($conn_fas, $qry))
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt++;
|
||||
echo "- ";
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - Vilesci -> Portal - Adresse</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
|
||||
//echo nl2br($text);
|
||||
echo nl2br($error_log);
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
<?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 EMaildatensaetze von FAS DB in PORTAL DB
|
||||
//*
|
||||
//*
|
||||
|
||||
include('../../../vilesci/config.inc.php');
|
||||
include('../../../include/kontakt.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)
|
||||
{
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - FAS -> Portal - EMail</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
/*************************
|
||||
* FAS-PORTAL - Synchronisation
|
||||
*/
|
||||
|
||||
//nation
|
||||
$qry = "SELECT * FROM email ORDER BY person_fk;";
|
||||
|
||||
if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
echo nl2br("E-Mail Sync\n--------------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
echo "- ";
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
$error=false;
|
||||
$kontakt =new kontakt($conn);
|
||||
$kontakt->firma_id ='';
|
||||
$kontakt->kontakttyp ='email';
|
||||
$kontakt->anmerkung =$row->name;
|
||||
$kontakt->kontakt =$row->email;
|
||||
$kontakt->zustellung =$row->zustelladresse=='J'?true:false;
|
||||
$kontakt->updatevon ="SYNC";
|
||||
$kontakt->insertvon ="SYNC";
|
||||
$kontakt->ext_id =$row->email_pk;
|
||||
|
||||
//Person_id feststellen
|
||||
$qry1="SELECT person_portal FROM public.tbl_syncperson WHERE person_fas=".$row->person_fk.";";
|
||||
if($result1 = pg_query($conn, $qry1))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //eintrag gefunden
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
$qry2="SELECT kontakt_id, ext_id FROM tbl_kontakt WHERE ext_id=".$row->email_pk." AND kontakttyp='email';";
|
||||
if($result2 = pg_query($conn, $qry2))
|
||||
{
|
||||
if(pg_num_rows($result2)>0) //eintrag gefunden
|
||||
{
|
||||
if($row2=pg_fetch_object($result2))
|
||||
{
|
||||
// update , wenn datensatz bereits vorhanden
|
||||
$kontakt->person_id=$row1->person_portal;
|
||||
$kontakt->kontakt_id=$row2->kontakt_id;
|
||||
$kontakt->new=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// insert, wenn datensatz noch nicht vorhanden
|
||||
$kontakt->new=true;
|
||||
$kontakt->person_id=$row1->person_portal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="person mit person_fk: $row->person_fk konnte in tbl_syncperson nicht gefunden werden! (".pg_num_rows($result1).")\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
If (!$error)
|
||||
{
|
||||
if(!$kontakt->save())
|
||||
{
|
||||
$error_log.=$kontakt->errormsg."\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//echo nl2br($text);
|
||||
echo nl2br($error_log);
|
||||
echo nl2br("\nGesamt: $anzahl_quelle / Eingefügt: $anzahl_eingefuegt / Fehler: $anzahl_fehler");
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
@@ -32,6 +32,8 @@ $conn=pg_connect(CONN_STRING) or die("Connection zur Portal Datenbank fehlgeschl
|
||||
//$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die("Connection zur Vilesci Datenbank fehlgeschlagen");
|
||||
$conn_fas=pg_connect(CONN_STRING_FAS) or die("Connection zur FAS Datenbank fehlgeschlagen");
|
||||
|
||||
//set_time_limit(60);
|
||||
|
||||
$adress='ruhan@technikum-wien.at';
|
||||
//$adress='fas_sync@technikum-wien.at';
|
||||
|
||||
@@ -41,6 +43,7 @@ $anzahl_quelle=0;
|
||||
$anzahl_eingefuegt=0;
|
||||
$anzahl_fehler=0;
|
||||
|
||||
|
||||
/*************************
|
||||
* FAS-PORTAL - Synchronisation
|
||||
*/
|
||||
@@ -53,7 +56,6 @@ $anzahl_fehler=0;
|
||||
<body>
|
||||
<?php
|
||||
//person
|
||||
flush();
|
||||
?>
|
||||
<?php
|
||||
$qry = "SELECT * FROM person";
|
||||
@@ -186,8 +188,8 @@ if($result = pg_query($conn_fas, $qry))
|
||||
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))
|
||||
$qryz="SELECT person_fas FROM tbl_syncperson WHERE person_fas='$row->person_pk' AND person_portal='$person->person_id'";
|
||||
if($resultz = pg_query($conn, $qryz))
|
||||
{
|
||||
if(pg_num_rows($resultz)==0) //wenn dieser eintrag noch nicht vorhanden ist
|
||||
{
|
||||
@@ -197,6 +199,9 @@ if($result = pg_query($conn_fas, $qry))
|
||||
}
|
||||
}
|
||||
$anzahl_eingefuegt++;
|
||||
echo "- ";
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<?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 Telefondatensaetze von FAS DB in PORTAL DB
|
||||
//*
|
||||
//*
|
||||
|
||||
include('../../../vilesci/config.inc.php');
|
||||
include('../../../include/kontakt.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)
|
||||
{
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - FAS -> Portal - Telefon</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
/*************************
|
||||
* FAS-PORTAL - Synchronisation
|
||||
*/
|
||||
|
||||
//nation
|
||||
$qry = "SELECT * FROM telefonnummer ORDER BY person_fk;";
|
||||
|
||||
if($result = pg_query($conn_fas, $qry))
|
||||
{
|
||||
echo nl2br("Telefon Sync\n-------------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
echo "- ";
|
||||
ob_flush();
|
||||
flush();
|
||||
|
||||
$error=false;
|
||||
$kontakt =new kontakt($conn);
|
||||
$kontakt->firma_id ='';
|
||||
$kontakt->kontakttyp ='telefon';
|
||||
$kontakt->anmerkung =$row->name;
|
||||
$kontakt->kontakt =$row->nummer;
|
||||
$kontakt->zustellung =false;
|
||||
$kontakt->updatevon ="SYNC";
|
||||
$kontakt->insertvon ="SYNC";
|
||||
$kontakt->ext_id =$row->telefonnummer_pk;
|
||||
|
||||
//Person_id feststellen
|
||||
if($row->nummer!='')
|
||||
{
|
||||
$qry1="SELECT person_portal FROM public.tbl_syncperson WHERE person_fas=".$row->person_fk.";";
|
||||
if($result1 = pg_query($conn, $qry1))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //eintrag gefunden
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
$qry2="SELECT kontakt_id, ext_id FROM tbl_kontakt WHERE ext_id=".$row->telefonnummer_pk." AND kontakttyp='telefon';";
|
||||
if($result2 = pg_query($conn, $qry2))
|
||||
{
|
||||
if(pg_num_rows($result2)>0) //eintrag gefunden
|
||||
{
|
||||
if($row2=pg_fetch_object($result2))
|
||||
{
|
||||
// update , wenn datensatz bereits vorhanden
|
||||
$kontakt->person_id=$row1->person_portal;
|
||||
$kontakt->kontakt_id=$row2->kontakt_id;
|
||||
$kontakt->new=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// insert, wenn datensatz noch nicht vorhanden
|
||||
$kontakt->new=true;
|
||||
$kontakt->person_id=$row1->person_portal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error=true;
|
||||
$error_log.="person mit person_fk: $row->person_fk konnte in tbl_syncperson nicht gefunden werden! (".pg_num_rows($result1).")\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
If (!$error)
|
||||
{
|
||||
if(!$kontakt->save())
|
||||
{
|
||||
$error_log.=$kontakt->errormsg."\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$anzahl_eingefuegt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//echo nl2br($text);
|
||||
echo nl2br($error_log);
|
||||
echo nl2br("\nGesamt: $anzahl_quelle / Eingefügt: $anzahl_eingefuegt / Fehler: $anzahl_fehler");
|
||||
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user