mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Fachbereich sync
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
<?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 Fachbereichsdatensaetze von Vilesci DB in PORTAL DB
|
||||
//*
|
||||
//*
|
||||
|
||||
include('../../vilesci/config.inc.php');
|
||||
include('../../include/fas/fachbereich.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
|
||||
*/
|
||||
|
||||
//fachbereich
|
||||
$qry = "SELECT * FROM tbl_fachbereich";
|
||||
|
||||
if($result = pg_query($conn_vilesci, $qry))
|
||||
{
|
||||
echo nl2br("Fachbereich Sync\n---------------\n");
|
||||
$anzahl_quelle=pg_num_rows($result);
|
||||
while($row = pg_fetch_object($result))
|
||||
{
|
||||
$error=false;
|
||||
$fachbereich = new fachbereich($conn);
|
||||
$fachbereich->fachbereich_id=$row->fachbereich_id;
|
||||
$fachbereich->studiengang_kz=$row->studiengang_kz;
|
||||
$fachbereich->bezeichnung=$row->bezeichnung;
|
||||
$fachbereich->kurzbz=$row->kurzbz;
|
||||
$fachbereich->farbe=$row->farbe;
|
||||
//$fachbereich->insertamum=now();
|
||||
$fachbereich->insertvon='SYNC';
|
||||
//$fachbereich->updateamum=now();
|
||||
//$fachbereich->updatevon=$row->updatevon;
|
||||
$fachbereich->ext_id=$row->fachbereich_id;
|
||||
|
||||
$qry = "SELECT ext_id FROM tbl_fachbereich WHERE ext_id='$fachbereich->ext_id'";
|
||||
if($result1 = pg_query($conn, $qry))
|
||||
{
|
||||
if(pg_num_rows($result1)>0) //wenn dieser eintrag schon vorhanden ist
|
||||
{
|
||||
if($row1=pg_fetch_object($result1))
|
||||
{
|
||||
//Lehrveranstaltungsdaten updaten
|
||||
$fachbereich->new=false;
|
||||
$fachbereich->fachbereich_id=$row->fachbereich_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$error_log.="fachbereich_id von $row->fachbereich_id konnte nicht ermittelt werden\n";
|
||||
$error=true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Fachbereich neu anlegen
|
||||
$fachbereich->new=true;
|
||||
}
|
||||
|
||||
if(!$error)
|
||||
if(!$fachbereich->save())
|
||||
{
|
||||
$error_log.=$fachbereich->errormsg."\n";
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
else
|
||||
$anzahl_eingefuegt++;
|
||||
else
|
||||
$anzahl_fehler++;
|
||||
}
|
||||
}
|
||||
echo nl2br("abgeschlossen\n\n");
|
||||
}
|
||||
else
|
||||
$error_log .= 'Fachbereichsdatensaetze konnten nicht geladen werden';
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Synchro - Vilesci -> Portal - Fachbereiche</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>
|
||||
@@ -1,4 +1,24 @@
|
||||
<?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 fachbereich (FAS-Online)
|
||||
* @create 14-03-2006
|
||||
@@ -16,6 +36,7 @@ class fachbereich
|
||||
var $bezeichnung; // @var string
|
||||
var $kurzbz; // @var string
|
||||
var $farbe; // @var string
|
||||
var $studiengang_kz; // @var integer
|
||||
var $updateamum; // @var timestamp
|
||||
var $updatevon=0; // @var string
|
||||
var $insertamum; // @var timestamp
|
||||
@@ -112,11 +133,38 @@ class fachbereich
|
||||
$this->errormsg = 'Noch nicht implementiert';
|
||||
return false;
|
||||
}
|
||||
|
||||
function addslashes($var)
|
||||
{
|
||||
return ($var!=''?"'".addslashes($var)."'":'null');
|
||||
}
|
||||
/**
|
||||
* Speichert den aktuellen Datensatz
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
/**
|
||||
* Prueft die Gueltigkeit der Variablen
|
||||
* @return true wenn ok, false im Fehlerfall
|
||||
*/
|
||||
function checkvars()
|
||||
{
|
||||
$this->bezeichnung = str_replace("'",'´',$this->bezeichnung);
|
||||
$this->kurzbz = str_replace("'",'´',$this->kurzbz);
|
||||
|
||||
|
||||
//Laenge Pruefen
|
||||
if(strlen($this->bezeichnung)>128)
|
||||
{
|
||||
$this->errormsg = "Bezeichnung darf nicht laenger als 128 Zeichen sein bei <b>$this->ext_id</b> - $this->bezeichnung";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->kurzbz)>16)
|
||||
{
|
||||
$this->errormsg = "Kurzbez darf nicht laenger als 16 Zeichen sein bei <b>$this->ext_id</b> - $this->kurzbz";
|
||||
return false;
|
||||
}
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
function save()
|
||||
{
|
||||
//Gueltigkeit der Variablen pruefen
|
||||
@@ -125,33 +173,54 @@ class fachbereich
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
//Pruefen ob fachbereich_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->fachbereich_id) || $this->fachbereich_id == '')
|
||||
{
|
||||
$this->errormsg = 'fachbereich_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
//Neuen Datensatz anlegen
|
||||
|
||||
$qry = "INSERT INTO fachbereich (bezeichnung, kurzbz, farbe, ".
|
||||
"ext_id, insertamum, insertvon, updateamum, updatevon) VALUES (".
|
||||
"'$this->bezeichnung', '$this->kurzbz', '$this->farbe'".
|
||||
"'$this->ext_id', '$this->insertamum', '$this->insertvon', '$this->updateamum', '$this->updatevon');";
|
||||
$qry = 'INSERT INTO tbl_fachbereich (fachbereich_id, bezeichnung, kurzbz, farbe, ext_id, insertamum, insertvon,
|
||||
updateamum, updatevon, studiengang_kz) VALUES ('.
|
||||
$this->addslashes($this->fachbereich_id).', '.
|
||||
$this->addslashes($this->bezeichnung).', '.
|
||||
$this->addslashes($this->kurzbz).', '.
|
||||
$this->addslashes($this->farbe).', '.
|
||||
$this->addslashes($this->ext_id).', '.
|
||||
$this->addslashes($this->insertamum).', '.
|
||||
$this->addslashes($this->insertvon).', '.
|
||||
$this->addslashes($this->updateamum).', '.
|
||||
$this->addslashes($this->updatevon).', '.
|
||||
$this->addslashes($this->studiengang_kz).');';
|
||||
}
|
||||
else
|
||||
{
|
||||
//bestehenden Datensatz akualisieren
|
||||
|
||||
//Pruefen ob lehrveranstaltung_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->fachbereich_id_id) || $this->fachbereich_id == '')
|
||||
//Pruefen ob fachbereich_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->fachbereich_id) || $this->fachbereich_id == '')
|
||||
{
|
||||
$this->errormsg = 'fachbereich_id muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = "UPDATE fachbereich SET fachbereich_id='$this->fachbereich_id', bezeichnung='$this->bezeichnung', ".
|
||||
"kurzbz='$this->kurzbz', farbe='$this->farbe', ext_id='$this->ext_id', insertamum='$this->insertamum', ".
|
||||
"insertvon='$this->insertvon', updateamum='$this->updateamum', updatevon='$this->updatevon' ".
|
||||
"WHERE fachbereich_id = '$this->fachbereich_id';";
|
||||
$qry = 'UPDATE tbl_fachbereich SET '.
|
||||
'fachbereich_id='.$this->addslashes($this->fachbereich_id).', '.
|
||||
'bezeichnung='.$this->addslashes($this->bezeichnung).', '.
|
||||
'kurzbz='.$this->addslashes($this->kurzbz).', '.
|
||||
'farbe='.$this->addslashes($this->farbe).', '.
|
||||
'ext_id='.$this->addslashes($this->ext_id).', '.
|
||||
'insertamum='.$this->addslashes($this->insertamum).', '.
|
||||
'insertvon='.$this->addslashes($this->insertvon).', '.
|
||||
'updateamum='.$this->addslashes($this->updateamum).', '.
|
||||
'updatevon='.$this->addslashes($this->updatevon).', '.
|
||||
'studiengang_kz='.$this->addslashes($this->studiengang_kz).' '.
|
||||
'WHERE fachbereich_id = '.$this->addslashes($this->fachbereich_id).';';
|
||||
}
|
||||
|
||||
if(pg_query($this->conn, $qry))
|
||||
{
|
||||
//Log schreiben
|
||||
/*//Log schreiben
|
||||
$sql = $qry;
|
||||
$qry = "SELECT nextval('log_seq') as id;";
|
||||
if(!$row = pg_fetch_object(pg_query($this->conn, $qry)))
|
||||
@@ -167,7 +236,8 @@ class fachbereich
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Log-Eintrages';
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,4 +1,24 @@
|
||||
<?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 lehrveranstaltung (FAS-Online)
|
||||
* @create 16-03-2006
|
||||
@@ -37,11 +57,11 @@ class lehrveranstaltung
|
||||
* @param $conn Connection zur Datenbank
|
||||
* $lehrveranstaltung_id ID der zu ladenden Lehrveranstaltung
|
||||
*/
|
||||
function lehrveranstaltung($conn, $lehrveranstaltung_id=null)
|
||||
function lehrveranstaltung($conn, $lehrveranstaltung_nr=null)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
if($lehrveranstaltung_id != null)
|
||||
$this->load($lehrveranstaltung_id);
|
||||
if($lehrveranstaltung_nr != null)
|
||||
$this->load($lehrveranstaltung_nr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,50 +248,59 @@ class lehrveranstaltung
|
||||
//Laenge Pruefen
|
||||
if(strlen($this->bezeichnung)>64)
|
||||
{
|
||||
$this->errormsg = 'Bezeichnung darf nicht laenger als 64 Zeichen sein';
|
||||
$this->errormsg = "Bezeichnung darf nicht laenger als 64 Zeichen sein bei <b>$this->ext_id</b> - $this->bezeichnung";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->kurzbz)>16)
|
||||
{
|
||||
$this->errormsg = 'Kurzbez darf nicht laenger als 16 Zeichen sein';
|
||||
$this->errormsg = "Kurzbez darf nicht laenger als 16 Zeichen sein bei <b>$this->ext_id</b> - $this->kurzbz";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->anmerkung)>64)
|
||||
{
|
||||
$this->errormsg = 'Anmerkung darf nicht laenger als 64 Zeichen sein';
|
||||
$this->errormsg = "Anmerkung darf nicht laenger als 64 Zeichen sein bei <b>$this->ext_id</b> - $this->anmerkung";
|
||||
return false;
|
||||
}
|
||||
if(strlen($this->lehreverzeichnis)>16)
|
||||
{
|
||||
$this->errormsg = "Lehreverzeichnis darf nicht laenger als 16 Zeichen sein bei <b>$this->ext_id</b> - $this->lehreverzeichnis";
|
||||
return false;
|
||||
}
|
||||
if(!is_numeric($this->studiengang_kz))
|
||||
{
|
||||
$this->errormsg = 'Studiengang_kz ist ungueltig: '.$this->studiengang_kz;
|
||||
$this->errormsg = "Studiengang_kz ist ungueltig bei <b>$this->ext_id</b> - $this->studiengang_kz";
|
||||
return false;
|
||||
}
|
||||
if($this->semester!='' && !is_numeric($this->semester))
|
||||
{
|
||||
$this->errormsg = 'Semester ist ungueltig';
|
||||
$this->errormsg = "Semester ist ungueltig bei <b>$this->ext_id</b> - $this->semester";
|
||||
return false;
|
||||
}
|
||||
if($this->planfaktor!='' && !is_numeric($this->planfaktor))
|
||||
{
|
||||
$this->errormsg = 'Planfaktor ist ungueltig';
|
||||
$this->errormsg = "Planfaktor ist ungueltig bei <b>$this->ext_id</b> - $this->planfaktor";
|
||||
return false;
|
||||
}
|
||||
if($this->semesterstunden!='' && !is_numeric($this->semesterstunden))
|
||||
{
|
||||
$this->errormsg = 'Semesterstunden ist ungueltig';
|
||||
$this->errormsg = "Semesterstunden ist ungueltig bei <b>$this->ext_id</b> - $this->semesterstunden";
|
||||
return false;
|
||||
}
|
||||
if($this->planlektoren!='' && !is_numeric($this->planlektoren))
|
||||
{
|
||||
$this->errormsg = "Planlektoren ist ungueltig";
|
||||
$this->errormsg = "Planlektoren ist ungueltig bei <b>$this->ext_id</b> - $this->planlektoren";
|
||||
return false;
|
||||
}
|
||||
if($this->ects!='' && !is_numeric($this->ects))
|
||||
{
|
||||
$this->errormsg = 'ECTS sind ungueltig';
|
||||
$this->errormsg = "ECTS sind ungueltig bei <b>$this->ext_id</b> - $this->ects";
|
||||
return false;
|
||||
}
|
||||
if($this->ects>40)
|
||||
{
|
||||
$this->errormsg = "ECTS größer als 40 bei <b>$this->ext_id</b> - $this->ects";
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->errormsg = '';
|
||||
return true;
|
||||
}
|
||||
@@ -289,8 +318,6 @@ class lehrveranstaltung
|
||||
if($this->new)
|
||||
{
|
||||
//Neuen Datensatz anlegen
|
||||
|
||||
//naechste ID aus der Sequence holen
|
||||
$qry = 'INSERT INTO tbl_lehrveranstaltung (studiengang_kz, bezeichnung, kurzbz,
|
||||
semester, ects, semesterstunden, gemeinsam, anmerkung, lehre, lehreverzeichnis, aktiv, ext_id, insertamum,
|
||||
insertvon, planfaktor, planlektoren, planpersonalkosten, updateamum, updatevon) VALUES ('.
|
||||
@@ -321,15 +348,14 @@ class lehrveranstaltung
|
||||
//Pruefen ob lehrveranstaltung_id eine gueltige Zahl ist
|
||||
if(!is_numeric($this->lehrveranstaltung_nr) || $this->lehrveranstaltung_nr == '')
|
||||
{
|
||||
$this->errormsg = 'lehrveranstaltung_id muss eine gueltige Zahl sein';
|
||||
$this->errormsg = 'lehrveranstaltung_nr muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
$qry = 'UPDATE tbl_lehrveranstaltung SET '.
|
||||
'lehrveranstaltung_nr='.$this->addslashes($this->lehrveranstaltung_nr) .','.
|
||||
//'lehrveranstaltung_nr= '.$this->addslashes($this->lehrveranstaltung_nr) .', '.
|
||||
'studiengang_kz='.$this->addslashes($this->studiengang_kz) .', '.
|
||||
'bezeichnung='.$this->addslashes($this->bezeichnung) .', '.
|
||||
'kurzbez='.$this->addslashes($this->kurzbz) .','.
|
||||
'kurzbz='.$this->addslashes($this->kurzbz) .', '.
|
||||
'semester='.$this->addslashes($this->semester) .', '.
|
||||
'ects='.$this->addslashes($this->ects) .', '.
|
||||
'semesterstunden='.$this->addslashes($this->semesterstunden) .', '.
|
||||
@@ -345,14 +371,14 @@ class lehrveranstaltung
|
||||
'planlektoren='.$this->addslashes($this->planlektoren) .', '.
|
||||
'planpersonalkosten='.$this->addslashes($this->planpersonalkosten) .', '.
|
||||
'updateamum='.$this->addslashes($this->updateamum) .','.
|
||||
'updatevon='.$this->addslashes($this->updatevon) .','.
|
||||
'WHERE lehrveranstaltung_nr = '.$this->this->addslashes(lehrveranstaltung_nr).';';
|
||||
'updatevon='.$this->addslashes($this->updatevon) .' '.
|
||||
'WHERE ext_id = '.$this->addslashes($this->lehrveranstaltung_nr).';';
|
||||
}
|
||||
|
||||
/*if(pg_query($this->conn, $qry))
|
||||
if(pg_query($this->conn, $qry))
|
||||
{
|
||||
//Log schreiben
|
||||
$sql = $qry;
|
||||
/*$sql = $qry;
|
||||
$qry = "SELECT nextval('log_seq') as id;";
|
||||
if(!$row = pg_fetch_object(pg_query($this->conn, $qry)))
|
||||
{
|
||||
@@ -367,13 +393,14 @@ class lehrveranstaltung
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Log-Eintrages';
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim speichern des Datensatzes';
|
||||
$this->errormsg = 'Fehler beim Speichern des Datensatzes';
|
||||
return false;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user