From da66c02f8e27fd7b5133bd62564f90fbf5a70a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Mon, 11 Oct 2010 13:45:20 +0000 Subject: [PATCH] =?UTF-8?q?WaWi=20Kontoverwaltung=20Grundger=C3=BCst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/wawi_konto.class.php | 282 +++++++++++++++++++++++++++++++++++ skin/wawi.css | 201 +++++++++++++++++++++++++ wawi/kontouebersicht.php | 55 +++++++ 3 files changed, 538 insertions(+) create mode 100644 include/wawi_konto.class.php create mode 100644 skin/wawi.css create mode 100644 wawi/kontouebersicht.php diff --git a/include/wawi_konto.class.php b/include/wawi_konto.class.php new file mode 100644 index 000000000..35475c610 --- /dev/null +++ b/include/wawi_konto.class.php @@ -0,0 +1,282 @@ +, + * Andreas Oesterreicher and + * Karl Burkhart . + */ +/** + * Klasse WaWi Konto + */ +require_once(dirname(__FILE__).'/basis_db.class.php'); + +class wawi_konto extends basis_db +{ + public $new; // boolean + public $result = array(); // adresse Objekt + + //Tabellenspalten + public $adresse_id; // integer + public $person_id; // integer + public $name; // string + public $strasse; // string + public $plz; // string + public $ort; // string + public $gemeinde; // string + public $nation; // string + public $typ; // string + public $heimatadresse; // boolean + public $zustelladresse; // boolean + public $firma_id; // integer + public $updateamum; // timestamp + public $updatevon; // string + public $insertamum; // timestamp + public $insertvon; // string + public $ext_id; // integer + + /** + * Konstruktor + * @param $konto_id ID des Kontos das geladen werden soll (Default=null) + */ + public function __construct($konto_id=null) + { + parent::__construct(); + + if(!is_null($konto_id)) + $this->load($konto_id); + } + + /** + * Laedt das Konto mit der ID $konto_id + * @param $konto_id ID des zu ladenden Kontos + * @return true wenn ok, false im Fehlerfall + */ + public function load($konto_id) + { + //Pruefen ob konto_id eine gueltige Zahl ist + if(!is_numeric($konto_id) || $konto_id == '') + { + $this->errormsg = 'Konto_id muss eine Zahl sein'; + return false; + } + + //Daten aus der Datenbank lesen + $qry = "SELECT * FROM wawi.tbl_konto WHERE konto_id='".addslashes($konto_id)."'"; + + if(!$this->db_query($qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + if($row = $this->db_fetch_object()) + { + $this->konto_id = $row->konto_id; + $this->aktiv = ($row->aktiv=='t'?true:false); + + //... + } + else + { + $this->errormsg = 'Es ist kein Datensatz mit dieser ID vorhanden'; + return false; + } + + return true; + } + + /** + * Laedt alle Konten + * @param $aktiv wenn true werden nur die aktiven Datensaetze geladen, sonst alle + * @param $order Sortierreihenfolge + * @return true wenn ok, false im Fehlerfall + */ + public function getAll($aktiv=null, $order='beschreibung DESC') + { + //Daten aus der Datenbank lesen + $qry = 'SELECT * FROM wawi.tbl_konto'; + if(!is_null($aktiv)) + { + $qry.='WHERE aktiv='.($aktiv?'true':'false'); + } + + if($order!='') + $qry .= ' ORDER BY '.$order; + + if(!$this->db_query($qry)) + { + $this->errormsg = 'Fehler bei einer Datenbankabfrage'; + return false; + } + + while($row = $this->db_fetch_object()) + { + $obj = new wawi_konto(); + + $obj->konto_id = $row->konto_id; + //... + + $this->result[] = $obj; + } + + return true; + } + + /** + * Prueft die Variablen auf Gueltigkeit + * @return true wenn ok, false im Fehlerfall + */ + protected function validate() + { + if(mb_strlen($this->bezeichnung)>265) + { + $this->errormsg = 'Bezeichnung darf nicht laenger als 256 Zeichen sein.'; + return false; + } + + $this->errormsg = ''; + return true; + } + + /** + * Speichert den aktuellen Datensatz in die Datenbank + * Wenn $neu auf true gesetzt ist wird ein neuer Datensatz angelegt + * andernfalls wird der Datensatz mit der ID in $adresse_id aktualisiert + * @param $new wenn true wird ein Insert durchgefuehrt, wenn false ein Update + * und wenn null wird das new-Objekt der Klasse verwendet + * @return true wenn ok, false im Fehlerfall + */ + public function save($new=null) + { + if(is_null($new)) + $new = $this->new; + + //Variablen pruefen + if(!$this->validate()) + return false; + + if($this->new) + { + //Neuen Datensatz einfuegen + $qry='BEGIN;INSERT INTO public.tbl_adresse (person_id, name, strasse, plz, typ, ort, nation, insertamum, insertvon, + gemeinde, heimatadresse, zustelladresse, firma_id, updateamum, updatevon, ext_id) VALUES('. + $this->addslashes($this->person_id).', '. + $this->addslashes($this->name).', '. + $this->addslashes($this->strasse).', '. + $this->addslashes($this->plz).', '. + $this->addslashes(trim($this->typ)).', '. + $this->addslashes($this->ort).', '. + $this->addslashes($this->nation).', now(), '. + $this->addslashes($this->insertvon).', '. + $this->addslashes($this->gemeinde).', '. + ($this->heimatadresse?'true':'false').', '. + ($this->zustelladresse?'true':'false').', '. + ($this->firma_id!=null?$this->addslashes($this->firma_id):'null').', now(), '. + $this->addslashes($this->updatevon).', '. + $this->addslashes($this->ext_id).');'; + } + else + { + //Pruefen ob adresse_id eine gueltige Zahl ist + if(!is_numeric($this->adresse_id)) + { + $this->errormsg = 'adresse_id muss eine gültige Zahl sein: '.$this->adresse_id."\n"; + return false; + } + $qry='UPDATE public.tbl_adresse SET'. + ' person_id='.$this->addslashes($this->person_id).', '. + ' name='.$this->addslashes($this->name).', '. + ' strasse='.$this->addslashes($this->strasse).', '. + ' plz='.$this->addslashes($this->plz).', '. + ' typ='.$this->addslashes(trim($this->typ)).', '. + ' ort='.$this->addslashes($this->ort).', '. + ' nation='.$this->addslashes($this->nation).', '. + ' gemeinde='.$this->addslashes($this->gemeinde).', '. + ' firma_id='.$this->addslashes($this->firma_id).','. + ' updateamum= now(), '. + ' updatevon='.$this->addslashes($this->updatevon).', '. + ' heimatadresse='.($this->heimatadresse?'true':'false').', '. + ' zustelladresse='.($this->zustelladresse?'true':'false').' '. + 'WHERE adresse_id='.$this->adresse_id.';'; + } + + if($this->db_query($qry)) + { + if($this->new) + { + //naechste ID aus der Sequence holen + $qry="SELECT currval('public.tbl_adresse_adresse_id_seq') as id;"; + if($this->db_query($qry)) + { + if($row = $this->db_fetch_object()) + { + $this->adresse_id = $row->id; + $this->db_query('COMMIT'); + } + else + { + $this->db_query('ROLLBACK'); + $this->errormsg = "Fehler beim Auslesen der Sequence"; + return false; + } + } + else + { + $this->db_query('ROLLBACK'); + $this->errormsg = 'Fehler beim Auslesen der Sequence'; + return false; + } + } + + } + else + { + $this->errormsg = 'Fehler beim Speichern des Adress-Datensatzes'; + return false; + } + return $this->adresse_id; + } + + /** + * Loescht den Datenensatz mit der ID die uebergeben wird + * @param $adresse_id ID die geloescht werden soll + * @return true wenn ok, false im Fehlerfall + */ + public function delete($adresse_id) + { + //Pruefen ob adresse_id eine gueltige Zahl ist + if(!is_numeric($adresse_id) || $adresse_id == '') + { + $this->errormsg = 'adresse_id muss eine gültige Zahl sein'."\n"; + return false; + } + + //loeschen des Datensatzes + $qry="DELETE FROM public.tbl_adresse WHERE adresse_id='".addslashes($adresse_id)."';"; + + if($this->db_query($qry)) + { + return true; + } + else + { + $this->errormsg = 'Fehler beim Löschen der Daten'."\n"; + return false; + } + } +} +?> \ No newline at end of file diff --git a/skin/wawi.css b/skin/wawi.css new file mode 100644 index 000000000..4410adf1e --- /dev/null +++ b/skin/wawi.css @@ -0,0 +1,201 @@ + +A:link {text-decoration: none; + color: blue; + + } +A:visited {text-decoration: none; + color: blue; + } +A:active {text-decoration: underline; + color: blue; + } + +A.neutral:link {text-decoration: underline; + color: black; + + } +A.neutral:visited {text-decoration: underline; + color: black; + } +A.neutral:active {text-decoration: underline; + color: black; + } + +B { + font-family: Verdana,Lucida,Helvetica,Arial; + } + +BODY,H1,H2,H3,H4,H5,H6,P,I,TD,TH { + font-family: Verdana,Lucida,Helvetica,Arial; + color:black; + } + +BODY,TD,TH,P,I { + font-size: 9pt; + } + +td.blue { font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 1pt; + background:blue + } + +td.darkgray { + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 1pt; + background:darkgray; + } + +td.grays{white-space:nowrap; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 8pt; + font-weight: normal; + background:#EEEEEE; + } + +td.white{ width:170pt; + text-align:right; + white-space:nowrap; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 10pt; + font-weight: normal; + background:#FFFFFF; + } + + +td.yellow { + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 10pt; + background:#E1DD00; + } + +th.yellow { + white-space:nowrap; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 9pt; + font-weight: 900; + background:#E1DD00; + background:#DCE4EF; + } + +th.yellows { + white-space:nowrap; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 8pt; + font-weight: 600; + background:#E1DD00; + background:#DCE4EF; + } + + +H1 { + font-size: 14pt; + font-weight: 900; + } + + +H3,H2 { + font-size: 12pt; + font-weight: 900; + } + +div.firma { + border-style:none; + border-width:thin; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 10pt; + font-weight: 900; + background-color:yellow; + width:627; + vertical-align:middle; + } + +div.DCE4EF { + border-style:none; + border-width:thin; + font-family: Verdana,Lucida,Helvetica,Arial; + font-size: 10pt; + font-weight: 900; + background:#DCE4EF; + width:627; + vertical-align:middle; + } + + + +.liste { + font-family: Arial,Lucida,Verdana,Helvetica; + FONT-SIZE: 9pt; + color:black; + } + +.mod { + color: #000; +} + + +.del { + color: #ee2222; +} + +.new { + color: #22bb22; +} + +INPUT, SELECT { + font-family: Courier New,Arial,TimesNewRoman; + font-size: 9pt; + border: 1px solid #ccc; + } + +.number { + text-align: right; +} + +.button_gr { + font-family: Arial,Helvetica; + font-size: 9pt; + background: #aaffaa; +} + +.button { + font-family: Arial,Helvetica; + font-size: 9pt; +} + +TD.black { + font-family: Lucida,Verdana,Helvetica,Arial; + font-size: 9pt; + color:black; + } + +TD.content { + font-family: Lucida,Verdana,Helvetica,Arial; + FONT-SIZE: 9pt; + color:lightgreen; + } + +TD.small { + text-align:left; + font-family: Lucida,Verdana,Helvetica,Arial; + font-size: 8pt; + font-weight: normal; + color:white; + background:blue + } + +BODY { background-color:#F5F5F5; + margin-left:5pt; + } + +BODY.v1 { + background-color:#F5F5F5; + padding:0pt; + margin:0pt; + margin-height=0pt; + margin-width=0pt; + } + +ul {list-style-type:none} +ul.disc {list-style-type:disc} + +.frmField {background: #dedede;} diff --git a/wawi/kontouebersicht.php b/wawi/kontouebersicht.php new file mode 100644 index 000000000..257d03b1c --- /dev/null +++ b/wawi/kontouebersicht.php @@ -0,0 +1,55 @@ +getAll()) +{ + foreach($konto->result as $row) + { + //Zeilen der Tabelle ausgeben + $row->kontonummer; + if($row->akiv) + + } +} + +if($isset($_GET['edit']) || isset($_GET['new'])) +{ + //Formular ausgeben +} + +if($isset($_GET['delete'])) +{ + //Eintrag loeschen + $konto->delete($id); +} + +if(isset($_GET['save'])) +{ + //Daten in der DB speichern + $konto = new wawi_konto(); + $aktiv = isset($_POST['aktiv']); + + if(isset($_POST['konto_id'])) + { + //Update eines bestehenden Datensatzes + if(!$konto->load($id)) + die('ID nicht gefunden'); + $konto->new = false; + } + else + { + //Neuer Datensatz + $konto->new = true; + } + + $konto->beschreibung = $beschreibung; + //... + + if(!$konto->save()) + { + die('Fehler beim Speichern:'.$konto->errormsg); + } +} +?> \ No newline at end of file