mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
SYNC OrtRaumtyp
This commit is contained in:
@@ -53,7 +53,7 @@ $qry = "SELECT * FROM tbl_ort";
|
||||
|
||||
if($result = pg_query($conn_vilesci, $qry))
|
||||
{
|
||||
echo nl2br("Ort Sync\n--------\n");
|
||||
echo nl2br("Ort Sync\n---------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
@@ -72,14 +72,14 @@ if($result = pg_query($conn_vilesci, $qry))
|
||||
//ort->updateamum='';
|
||||
//$ort->updatevon=$row->updatevon;
|
||||
|
||||
$qry = "SELECT ort_kurzbz FROM tbl_ort WHERE ort_kurzbz='$ort->ort_kurzbz'";
|
||||
$qry = "SELECT ort_kurzbz FROM tbl_ort WHERE ort_kurzbz='$row->ort_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))
|
||||
{
|
||||
//Funktionsdaten updaten
|
||||
//Ortdaten updaten
|
||||
$ort->new=false;
|
||||
$ort->ort_kurzbz=$row->ort_kurzbz;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
<?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 Funktiondatensaetze von Vilesci DB in PORTAL DB
|
||||
//*
|
||||
//*
|
||||
|
||||
include('../../vilesci/config.inc.php');
|
||||
include('../../include/fas/ortraumtyp.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_ortraumtyp";
|
||||
|
||||
if($result = pg_query($conn_vilesci, $qry))
|
||||
{
|
||||
echo nl2br("OrtRaumtyp Sync\n----------------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
$error=false;
|
||||
$ortraumtyp = new ortraumtyp($conn);
|
||||
$ortraumtyp->ort_kurzbz=$row->ort_kurzbz;
|
||||
$ortraumtyp->hierarchie=$row->hierarchie;
|
||||
$ortraumtyp->raumtyp_kurzbz=$row->raumtyp_kurzbz;
|
||||
//$ort->insertamum='';
|
||||
$ortraumtyp->insertvon='SYNC';
|
||||
//ort->updateamum='';
|
||||
//$ort->updatevon=$row->updatevon;
|
||||
|
||||
$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
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
//OrtRaumtypdaten updaten
|
||||
$ortraumtyp->new=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="ort_kurzbz von $row->ort_kurzbz konnte nicht ermittelt werden\n";
|
||||
$error=true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//OrtRaumtyp neu anlegen
|
||||
$ort->new=true;
|
||||
}
|
||||
|
||||
if(!$error)
|
||||
if(!$ortraumtyp->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';
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - Vilesci -> Portal - OrtRaumtyp</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>
|
||||
@@ -198,7 +198,6 @@ class funktion
|
||||
}
|
||||
|
||||
$qry = 'UPDATE tbl_funktion SET '.
|
||||
'funktion_kurzbz='.$this->addslashes($this->funktion_kurzbz).', '.
|
||||
'bezeichnung='.$this->addslashes($this->bezeichnung).', '.
|
||||
'aktiv='.($this->aktiv?'true':'false') .', '.
|
||||
'insertamum='.$this->addslashes($this->insertamum).', '.
|
||||
|
||||
@@ -144,7 +144,7 @@ class ort
|
||||
|
||||
/**
|
||||
* Loescht einen Datensatz
|
||||
* @param $fachb_id id des Datensatzes der geloescht werden soll
|
||||
* @param $ort_kurzbz ID des Datensatzes der geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function delete($ort_kurzbz)
|
||||
@@ -163,18 +163,24 @@ class ort
|
||||
function checkvars()
|
||||
{
|
||||
$this->bezeichnung = str_replace("'",'´',$this->bezeichnung);
|
||||
$this->ort_kurzbz = str_replace("'",'´',$this->ort_kurzbz);
|
||||
$this->planbezeichnung = str_replace("'",'´',$this->planbezeichnung);
|
||||
|
||||
|
||||
//Laenge Pruefen
|
||||
if(strlen($this->bezeichnung)>30)
|
||||
{
|
||||
$this->errormsg = "Bezeichnung darf nicht laenger als 30 Zeichen sein bei <b>$this->ext_id</b> - $this->bezeichnung";
|
||||
$this->errormsg = "Bezeichnung darf nicht laenger als 30 Zeichen sein bei <b>$this->ort_kurzbz</b> - $this->bezeichnung";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->planbezeichnung)>5)
|
||||
if(strlen($this->planbezeichnung)>30)
|
||||
{
|
||||
$this->errormsg = "Planbezeichnung darf nicht laenger als 5 Zeichen sein bei <b>$this->ext_id</b> - $this->kurzbz";
|
||||
$this->errormsg = "Planbezeichnung darf nicht laenger als 30 Zeichen sein bei <b>$this->ort_kurzbz</b> - $this->planbezeichnung";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->ort_kurzbz)>8)
|
||||
{
|
||||
$this->errormsg = "Ort_kurzbz darf nicht laenger als 8 Zeichen sein bei <b>$this->ort_kurzbz/b>";
|
||||
return false;
|
||||
}
|
||||
$this->errormsg = '';
|
||||
@@ -219,7 +225,7 @@ class ort
|
||||
else
|
||||
{
|
||||
//bestehenden Datensatz akualisieren
|
||||
|
||||
|
||||
//Pruefen ob ort_kurzbz gueltig ist
|
||||
if($this->ort_kurzbz == '')
|
||||
{
|
||||
@@ -228,7 +234,6 @@ class ort
|
||||
}
|
||||
|
||||
$qry = 'UPDATE tbl_ort SET '.
|
||||
'ort_kurzbz='.$this->addslashes($this->ort_kurzbz).', '.
|
||||
'bezeichnung='.$this->addslashes($this->bezeichnung).', '.
|
||||
'planbezeichnung='.$this->addslashes($this->planbezeichnung).', '.
|
||||
'max_person='.$this->addslashes($this->max_person).', '.
|
||||
|
||||
@@ -0,0 +1,243 @@
|
||||
<?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>.
|
||||
*/
|
||||
/**
|
||||
* Klasse ortraumtyp (FAS-Online)
|
||||
* @create 14-03-2006
|
||||
*/
|
||||
|
||||
class ortraumtyp
|
||||
{
|
||||
var $conn; // @var resource DB-Handle
|
||||
var $new; // @var boolean
|
||||
var $errormsg; // @var string
|
||||
var $result = array(); // @var fachbereich Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
var $ort_kurzbz; // @var string
|
||||
var $hierarchie; // @var smallint
|
||||
var $raumtyp_kurzbz; // @var string
|
||||
var $updateamum; // @var timestamp
|
||||
var $updatevon=0; // @var string
|
||||
var $insertamum; // @var timestamp
|
||||
var $insertvon=0; // @var string
|
||||
|
||||
|
||||
/**
|
||||
* Konstruktor
|
||||
* @param $conn Connection zur DB
|
||||
* $ort_kurzbz und hierarchie ID des zu ladenden OrtRaumtyps
|
||||
*/
|
||||
function ortraumtyp($conn, $ort_kurzbz=null, $hierarchie=0)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
if($ort_kurzbz != null && $hierarchie!=null && is_numeric($hierarchie))
|
||||
$this->load($ort_kurzbz, $hierarchie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt alle verfuegbaren OrtRaumtypen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function getAll()
|
||||
{
|
||||
$qry = 'SELECT * FROM tbl_ortraumtyp order by ort_kurzbz, hierarchie;';
|
||||
|
||||
if(!$res = pg_query($this->conn, $qry))
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Laden der Datensaetze';
|
||||
return false;
|
||||
}
|
||||
|
||||
while($row = pg_fetch_object($res))
|
||||
{
|
||||
$ortraumtyp_obj = new ort($this->conn);
|
||||
|
||||
$ortraumtyp_obj->ort_kurzbz = $row->ort_kurzbz;
|
||||
$ortraumtyp_obj->hierarchie = $row->hierarchie;
|
||||
$ortraumtyp_obj->raumtyp_kurzbz = $row->raumtyp_kurzbz;
|
||||
$ortraumtyp_obj->insertamum = $row->insertamum;
|
||||
$ortraumtyp_obj->insertvon = $row->insertvon;
|
||||
$ortraumtyp_obj->updateamum = $row->updateamum;
|
||||
$ortraumtyp_obj->updatevon = $row->updatevon;
|
||||
|
||||
$this->result[] = $ortraumtyp_obj;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt einen OrtRaumtyp
|
||||
* @param $ortraumtyp, hierarchie ID des zu ladenden OrtRaumtyps
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function load($ort_kurzbz, $hierarchie)
|
||||
{
|
||||
if($ort_kurzbz == '' || !is_numeric($hierarche) || $hierarchie=='')
|
||||
{
|
||||
$this->errormsg = 'Kein gültiger Schlüssel vorhanden';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "SELECT * FROM tbl_ortraumtyp WHERE ort_kurzbz = '$ort_kurzbz' AND hierarchie = '$hierarchie';";
|
||||
|
||||
if(!$res = pg_query($this->conn, $qry))
|
||||
{
|
||||
$this->errormsg = 'Fehler beim laden des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
|
||||
if($row=pg_fetch_object($res))
|
||||
{
|
||||
$this->ort_kurzbz = $row->ort_kurzbz;
|
||||
$this->hierarchie = $row->hierarchie;
|
||||
$this->raumtyp_kurzbz = $row->kurzbz;
|
||||
$this->insertamum = $row->insertamum;
|
||||
$this->insertvon = $row->insertvon;
|
||||
$this->updateamum = $row->updateamum;
|
||||
$this->updatevon = $row->updatevon;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loescht einen Datensatz
|
||||
* @param $ort_kurzbz, hierarchie ID des Datensatzes der geloescht werden soll
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function delete($ort_kurzbz)
|
||||
{
|
||||
$this->errormsg = 'Noch nicht implementiert';
|
||||
return false;
|
||||
}
|
||||
function addslashes($var)
|
||||
{
|
||||
return ($var!=''?"'".addslashes($var)."'":'null');
|
||||
}
|
||||
/**
|
||||
* Prueft die Gueltigkeit der Variablen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function checkvars()
|
||||
{
|
||||
$this->ort_kurzbz = str_replace("'",'´',$this->ort_kurzbz);
|
||||
$this->raumtyp_kurzbz = str_replace("'",'´',$this->raumtyp_kurzbz);
|
||||
|
||||
|
||||
//Laenge Pruefen
|
||||
if(strlen($this->ort_kurzbz)>8)
|
||||
{
|
||||
$this->errormsg = "Ort_kurzbz darf nicht laenger als 8 Zeichen sein bei <b>$this->kurzbz, $hierarchie</b>";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->raumtyp_kurzbz)>8)
|
||||
{
|
||||
$this->errormsg = "Raumtyp_kurzbz darf nicht laenger als 8 Zeichen sein bei <b>$this->kurzbz, $hierarchie</b> - $this->raumtyp_kurzbz";
|
||||
return false;
|
||||
}
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function save()
|
||||
{
|
||||
//Gueltigkeit der Variablen pruefen
|
||||
if(!$this->checkvars())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Pruefen ob id gültig ist
|
||||
if($this->ort_kurzbz == '' || !is_numeric($this->hierarchie) || $this_hierarchie=='')
|
||||
{
|
||||
$this->errormsg = 'Keine gültige ID';
|
||||
return false;
|
||||
}
|
||||
//Neuen Datensatz anlegen
|
||||
$qry = 'INSERT INTO tbl_ortraumtyp (ort_kurzbz, hierarchie, raumtyp_kurzbz,
|
||||
insertamum, insertvon, updateamum, updatevon) VALUES ('.
|
||||
$this->addslashes($this->ort_kurzbz).', '.
|
||||
$this->addslashes($this->hierarchie).', '.
|
||||
$this->addslashes($this->raumtyp_kurzbz).', '.
|
||||
$this->addslashes($this->insertamum).', '.
|
||||
$this->addslashes($this->insertvon).', '.
|
||||
$this->addslashes($this->updateamum).', '.
|
||||
$this->addslashes($this->updatevon).');';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//bestehenden Datensatz akualisieren
|
||||
|
||||
//Pruefen ob id gueltig ist
|
||||
if($this->ort_kurzbz == '' || !is_numeric($this->hierarchie) || $this->hierarchie=='')
|
||||
{
|
||||
$this->errormsg = 'Keine gültige ID';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = 'UPDATE tbl_ortraumtyp SET '.
|
||||
'raumtyp_kurzbz='.$this->addslashes($this->raumtyp_kurzbz).', '.
|
||||
'insertamum='.$this->addslashes($this->insertamum).', '.
|
||||
'insertvon='.$this->addslashes($this->insertvon).', '.
|
||||
'updateamum='.$this->addslashes($this->updateamum).', '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).' '.
|
||||
'WHERE ort_kurzbz = '.$this->addslashes($this->ort_kurzbz).' AND hierarchie = '.$this->addslashes($this->hierarchie).';';
|
||||
}
|
||||
|
||||
if(pg_query($this->conn, $qry))
|
||||
{
|
||||
/*//Log schreiben
|
||||
$sql = $qry;
|
||||
$qry = "SELECT nextval('log_seq') as id;";
|
||||
if(!$row = pg_fetch_object(pg_query($this->conn, $qry)))
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Auslesen der Log-Sequence';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "INSERT INTO log(log_pk, creationdate, creationuser, sql) VALUES('$row->id', now(), '$this->updatevon', '".addslashes($sql)."')";
|
||||
if(pg_query($this->conn, $qry))
|
||||
return true;
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Log-Eintrages';
|
||||
return false;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Datensatzes';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user