From df9bf4a01a7510986c45477c04e1758867999a31 Mon Sep 17 00:00:00 2001 From: Rudolf Hangl Date: Fri, 1 Dec 2006 10:16:55 +0000 Subject: [PATCH] SYSNC Raumtyp --- admin/sync/sync_vilesci_portal_ortraumtyp.php | 14 +- admin/sync/sync_vilesci_portal_raumtyp.php | 124 ++++++++++++++++++ include/fas/ortraumtyp.class.php | 2 +- ...aumtyp.class.php => raumtyp_old.class.php} | 0 4 files changed, 132 insertions(+), 8 deletions(-) create mode 100644 admin/sync/sync_vilesci_portal_raumtyp.php rename include/fas/{raumtyp.class.php => raumtyp_old.class.php} (100%) diff --git a/admin/sync/sync_vilesci_portal_ortraumtyp.php b/admin/sync/sync_vilesci_portal_ortraumtyp.php index 3d3d87d4f..18bb0fe39 100644 --- a/admin/sync/sync_vilesci_portal_ortraumtyp.php +++ b/admin/sync/sync_vilesci_portal_ortraumtyp.php @@ -53,7 +53,7 @@ $qry = "SELECT * FROM tbl_ortraumtyp"; if($result = pg_query($conn_vilesci, $qry)) { - echo nl2br("OrtRaumtyp Sync\n----------------\n"); + echo nl2br("OrtRaumtyp Sync\n------------------\n"); $anzahl_quelle=pg_num_rows($result); while($row = pg_fetch_object($result)) { @@ -62,12 +62,12 @@ if($result = pg_query($conn_vilesci, $qry)) $ortraumtyp->ort_kurzbz=$row->ort_kurzbz; $ortraumtyp->hierarchie=$row->hierarchie; $ortraumtyp->raumtyp_kurzbz=$row->raumtyp_kurzbz; - //$ort->insertamum=''; + //$ortraumtyp->insertamum=''; $ortraumtyp->insertvon='SYNC'; - //ort->updateamum=''; - //$ort->updatevon=$row->updatevon; + //ortraumtyp->updateamum=''; + //$ortraumtyp->updatevon=$row->updatevon; - $qry = "SELECT ort_kurzbz, hierarchie FROM tbl_ortraumtyp WHERE ort_kurzbz='$row->ort_kurzbz' AND hierarchie='$row->hierarchie'"; + $qry = "SELECT ort_kurzbz, hierarchie FROM tbl_ortraumtyp WHERE ort_kurzbz = '$row->ort_kurzbz' AND hierarchie = '$row->hierarchie'"; if($result1 = pg_query($conn, $qry)) { if(pg_num_rows($result1)>0) //wenn dieser eintrag schon vorhanden ist @@ -86,13 +86,13 @@ if($result = pg_query($conn_vilesci, $qry)) else { //OrtRaumtyp neu anlegen - $ort->new=true; + $ortraumtyp->new=true; } if(!$error) if(!$ortraumtyp->save()) { - $error_log.=$ort->errormsg."\n"; + $error_log.=$ortraumtyp->errormsg."\n"; $anzahl_fehler++; } else diff --git a/admin/sync/sync_vilesci_portal_raumtyp.php b/admin/sync/sync_vilesci_portal_raumtyp.php new file mode 100644 index 000000000..9c176d7c1 --- /dev/null +++ b/admin/sync/sync_vilesci_portal_raumtyp.php @@ -0,0 +1,124 @@ +, + * Andreas Oesterreicher and + * Rudolf Hangl . + */ + +//* +//* Synchronisiert Funktiondatensaetze von Vilesci DB in PORTAL DB +//* +//* + +include('../../vilesci/config.inc.php'); +include('../../include/fas/raumtyp.class.php'); + +$conn=pg_connect(CONN_STRING) or die("Connection zur Portal Datenbank fehlgeschlagen"); +$conn_vilesci=pg_connect(CONN_STRING_VILESCI) or die("Connection zur Vilesci 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) +{ +} + +/************************* + * VILESCI-PORTAL - Synchronisation + */ + +//funktion +$qry = "SELECT * FROM tbl_raumtyp"; + +if($result = pg_query($conn_vilesci, $qry)) +{ + echo nl2br("Raumtyp Sync\n---------------\n"); + $anzahl_quelle=pg_num_rows($result); + while($row = pg_fetch_object($result)) + { + $error=false; + $raumtyp = new raumtyp($conn); + $raumtyp->beschreibung=$row->beschreibung; + $raumtyp->raumtyp_kurzbz=$row->raumtyp_kurzbz; + //$raumtyp->insertamum=''; + $raumtyp->insertvon='SYNC'; + //raumtyp->updateamum=''; + //$raumtyp->updatevon=$row->updatevon; + + $qry = "SELECT raumtyp_kurzbz FROM tbl_raumtyp WHERE raumtyp_kurzbz = '$row->raumtyp_kurzbz'"; + if($result1 = pg_query($conn, $qry)) + { + if(pg_num_rows($result1)>0) //wenn dieser eintrag schon vorhanden ist + { + if($row1=pg_fetch_object($result1)) + { + //Raumtypdaten updaten + $raumtyp->new=false; + } + else + { + $error_log.="ort_kurzbz von $row->ort_kurzbz konnte nicht ermittelt werden\n"; + $error=true; + } + } + else + { + //Raumtyp neu anlegen + $raumtyp->new=true; + } + + if(!$error) + if(!$raumtyp->save()) + { + $error_log.=$ort->errormsg."\n"; + $anzahl_fehler++; + } + else + $anzahl_eingefuegt++; + else + $anzahl_fehler++; + } + } + echo nl2br("abgeschlossen\n\n"); +} +else + $error_log .= 'Funktiondatensaetze konnten nicht geladen werden'; + +?> + + + +Synchro - Vilesci -> Portal - Raumtyp + + + + + + \ No newline at end of file diff --git a/include/fas/ortraumtyp.class.php b/include/fas/ortraumtyp.class.php index 8841fd283..3857f659f 100644 --- a/include/fas/ortraumtyp.class.php +++ b/include/fas/ortraumtyp.class.php @@ -175,7 +175,7 @@ class ortraumtyp if($this->new) { //Pruefen ob id gültig ist - if($this->ort_kurzbz == '' || !is_numeric($this->hierarchie) || $this_hierarchie=='') + if($this->ort_kurzbz == '' || !is_numeric($this->hierarchie) || $this->hierarchie=='') { $this->errormsg = 'Keine gültige ID'; return false; diff --git a/include/fas/raumtyp.class.php b/include/fas/raumtyp_old.class.php similarity index 100% rename from include/fas/raumtyp.class.php rename to include/fas/raumtyp_old.class.php