mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 10:22:18 +00:00
Diverse Sync Scripte Vilesci->Portal
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
<?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>.
|
||||
*/
|
||||
|
||||
class zeitwunsch
|
||||
{
|
||||
var $conn; // resource DB-Handle
|
||||
var $errormsg; // string
|
||||
var $new; // boolean
|
||||
var $zeitwuensche = array(); // zeitwunsch Objekt
|
||||
|
||||
//Tabellenspalten
|
||||
var $stunde; // smalint
|
||||
var $uid; // varchar(16)
|
||||
var $tag; // smalint
|
||||
var $gewicht; // smalint
|
||||
|
||||
// *************************************************************************
|
||||
// * Konstruktor - Uebergibt die Connection und laedt optional eine Lehrform
|
||||
// * @param $conn Datenbank-Connection
|
||||
// * $uid Uid des Mitarbeiters
|
||||
// * $tag Tag des Zeitwunsches
|
||||
// * $stunde Stunde des Zeitwunsches
|
||||
// * $unicode Gibt an ob die Daten mit UNICODE Codierung
|
||||
// * oder LATIN9 Codierung verarbeitet werden sollen
|
||||
// *************************************************************************
|
||||
function zeitwunsch($conn, $uid=null, $tag=null, $stunde=null, $unicode=false)
|
||||
{
|
||||
$this->conn = $conn;
|
||||
|
||||
if($unicode)
|
||||
$qry = "SET CLIENT_ENCODING TO 'UNICODE';";
|
||||
else
|
||||
$qry = "SET CLIENT_ENCODING TO 'LATIN9';";
|
||||
|
||||
if(!pg_query($conn,$qry))
|
||||
{
|
||||
$this->errormsg = 'Encoding konnte nicht gesetzt werden';
|
||||
return false;
|
||||
}
|
||||
|
||||
if($uid != null && $tag!=null && $stunde!=null)
|
||||
$this->load($uid, $tag, $stunde);
|
||||
}
|
||||
|
||||
// *********************************************************
|
||||
// * Laedt einen Zeitwunsch
|
||||
// * @param
|
||||
// *********************************************************
|
||||
function load($uid, $tag, $stunde)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// *******************************************
|
||||
// * Prueft die Variablen vor dem Speichern
|
||||
// * auf Gueltigkeit.
|
||||
// * @return true wenn ok, false im Fehlerfall
|
||||
// *******************************************
|
||||
function validate()
|
||||
{
|
||||
if(strlen($this->uid)>16)
|
||||
{
|
||||
$this->errormsg = 'UID darf nicht laenger als 16 Zeichen sein.';
|
||||
return false;
|
||||
}
|
||||
if($this->uid == '')
|
||||
{
|
||||
$this->errormsg = 'UID muss angegeben werden';
|
||||
return false;
|
||||
}
|
||||
if(!is_numeric($this->stunde))
|
||||
{
|
||||
$this->errormsg = 'Stunde muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
if(!is_numeric($this->gewicht))
|
||||
{
|
||||
$this->errormsg = 'Gewicht muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
if(!is_numeric($this->tag))
|
||||
{
|
||||
$this->errormsg = 'Tag muss eine gueltige Zahl sein';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ************************************************
|
||||
// * wenn $var '' ist wird NULL zurueckgegeben
|
||||
// * wenn $var !='' ist werden Datenbankkritische
|
||||
// * Zeichen mit Backslash versehen und das Ergbnis
|
||||
// * unter Hochkomma gesetzt.
|
||||
// ************************************************
|
||||
function addslashes($var)
|
||||
{
|
||||
return ($var!=''?"'".addslashes($var)."'":'null');
|
||||
}
|
||||
|
||||
// ************************************************************
|
||||
// * Speichert einen Zeitwunsch in die Datenbank
|
||||
// * Wenn $new auf true gesetzt ist wird ein neuer Datensatz
|
||||
// * angelegt, ansonsten der Datensatz mit $lehrfach_nr upgedated
|
||||
// * @return true wenn erfolgreich, false im Fehlerfall
|
||||
// ************************************************************
|
||||
function save()
|
||||
{
|
||||
//Variablen auf Gueltigkeit pruefen
|
||||
if(!$this->validate())
|
||||
return false;
|
||||
|
||||
if($this->new)
|
||||
{
|
||||
$qry = "INSERT INTO tbl_zeitwunsch (uid, tag, stunde, gewicht)
|
||||
VALUES('".addslashes($this->uid)."',".
|
||||
$this->tag.','.$this->stunde.','.$this->gewicht.');';
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = 'UPDATE tbl_zeitwunsch SET'.
|
||||
' gewicht='.$this->gewicht.
|
||||
" WHERE uid='".addslashes($this->uid)."' AND
|
||||
tag=".$this->tag.' AND stunde='.$this->stunde;
|
||||
}
|
||||
|
||||
if(pg_query($this->conn,$qry))
|
||||
{
|
||||
//Log schreiben
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errormsg = 'Fehler beim Speichern des Zeitwunsches:'.$qry;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user