From 78c6d4e88d39308e4df07c4922914708444ba773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 13 Jan 2011 13:56:49 +0000 Subject: [PATCH] =?UTF-8?q?Firmenverwaltung=20klein=20f=C3=BCr=20WaWi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/adresse.class.php | 5 + include/kontakt.class.php | 35 ++++ include/standort.class.php | 2 +- include/tw/wawi_menu_main.inc.php | 3 +- system/FH-Complete.txp | 70 ++++++-- system/checksystem.php | 2 + wawi/firma.php | 289 ++++++++++++++++++++++++++---- wawi/logout.php | 26 ++- 8 files changed, 378 insertions(+), 54 deletions(-) diff --git a/include/adresse.class.php b/include/adresse.class.php index 0a2b0b7fa..fe12e4f88 100644 --- a/include/adresse.class.php +++ b/include/adresse.class.php @@ -163,6 +163,11 @@ class adresse extends basis_db /** * Laedt alle Adressen zu der Firma die uebergeben wird + * + * ACHTUNG: Diese Funktion wird nur mehr fuer Lehrauftraege benoetigt. + * Die Adresse zu einer Firma wird nun ueber die Tabelle Standort hergestellt! + * + * @deprec 2.0 * @param $firma_id ID der Firma zu der die Adressen geladen werden sollen * @return true wenn ok, false im Fehlerfall */ diff --git a/include/kontakt.class.php b/include/kontakt.class.php index 613f98d27..2196f86d6 100644 --- a/include/kontakt.class.php +++ b/include/kontakt.class.php @@ -392,6 +392,41 @@ class kontakt extends basis_db return $this->result; } + /** + * Laedt einen Kontakt eines Standortes + * Es wird nur der erste Eintrag zurueckgeliefert! + * + * @param $standort_id + * @param $kontakttyp + */ + public function loadFirmaKontakttyp($standort_id, $kontakttyp) + { + if(!is_numeric($standort_id)) + { + $this->errormsg='StandortID ist ungueltig'; + return false; + } + + $qry = "SELECT * FROM public.tbl_kontakt WHERE standort_id='".addslashes($standort_id)."' AND kontakttyp='".addslashes($kontakttyp)."' ORDER BY kontakt_id LIMIT 1"; + + if($result = $this->db_query($qry)) + { + if($row = $this->db_fetch_object($result)) + { + $this->kontakt = $row->kontakt; + $this->kontakt_id = $row->kontakt_id; + return true; + } + else + return false; + } + else + { + $this->errormsg = 'Fehler beim Laden der Daten'; + return false; + } + } + /** * Laedt alle Kontakttypen * @return true wenn ok diff --git a/include/standort.class.php b/include/standort.class.php index ef0737211..b05060c66 100644 --- a/include/standort.class.php +++ b/include/standort.class.php @@ -186,7 +186,7 @@ class standort extends basis_db } //Lesen der Daten aus der Datenbank - $qry = "SELECT * FROM public.tbl_standort WHERE firma_id='".addslashes($firma_id)."'"; + $qry = "SELECT * FROM public.tbl_standort WHERE firma_id='".addslashes($firma_id)."' ORDER BY standort_id"; if(!$this->db_query($qry)) { diff --git a/include/tw/wawi_menu_main.inc.php b/include/tw/wawi_menu_main.inc.php index 14e891b03..6985d0a20 100644 --- a/include/tw/wawi_menu_main.inc.php +++ b/include/tw/wawi_menu_main.inc.php @@ -61,7 +61,8 @@ $menu=array ), 'Firma'=>array ( - 'name'=>'Firma anlegen', 'link'=>'firma.php?method=new', 'target'=>'content', + 'name'=>'Firma', 'link'=>'firma.php', 'target'=>'content','permissions'=>array('wawi/firma'), + 'FirmaNeu'=>array('name'=>'Neu', 'link'=>'firma.php?method=new', 'target'=>'content'), ) ), 'Auswertungen'=> array diff --git a/system/FH-Complete.txp b/system/FH-Complete.txp index 5b1cdbd87..95f0b6bc7 100644 --- a/system/FH-Complete.txp +++ b/system/FH-Complete.txp @@ -37121,7 +37121,7 @@ 233 0 809 - 356 + 395 0 1 1 @@ -38497,8 +38497,8 @@ {5FEF0B42-3911-4B97-A654-2AD1A67125FC} - 1987 - 2169 + 1986 + 2182 3131 @@ -38510,11 +38510,11 @@ 1073 - 3120 + 3146 1042 - 3120 + 3146 @@ -38540,8 +38540,8 @@ {5FEF0B42-3911-4B97-A654-2AD1A67125FC} - 1035 - 2610 + 1034 + 2616 1227 @@ -38553,11 +38553,11 @@ 1073 - 3002 + 3015 1042 - 3002 + 3015 @@ -39470,7 +39470,7 @@ Technikum Wien 2.0 2009-04-17T10:15:21.000+01:00 - 2011-01-10T16:05:43.919+01:00 + 2011-01-13T14:53:41.009+01:00 FH-Complete 2.0 @@ -122318,7 +122318,9 @@ Wenn FALSE haengt die Anzahl der Fragen pro Level von der Gesamtzahl pro Level a {361EF147-269D-4247-8F7C-5A3876A3999A} - + + {EE26D990-2EF8-4C27-846A-E29A5F16F708} + @@ -122659,7 +122661,51 @@ Wenn FALSE haengt die Anzahl der Fragen pro Level von der Gesamtzahl pro Level a {4739E579-AB3A-4CBC-B280-7D975698878A} - + + + {A896AD92-3CCA-4377-8B4F-F75BD0D1D6AA} + idx_aufteilung_bestellung_id + 0 + {7C26AA4C-866E-4132-B4AD-97534263104A} + 0 + 0 + 0 + 0 + 1 + + + + + 0 + idx_aufteilung_bestellung_id + + 0 + + + {EE26D990-2EF8-4C27-846A-E29A5F16F708} + bestellung_id + 0 + {97CE8268-1ACA-495D-9CA3-3940500307BA} + 0 + 1 + + + + + 0 + + {CEA0DBEA-7F1C-4512-878D-12D183FD78C7} + + + + + + btree + + + + + diff --git a/system/checksystem.php b/system/checksystem.php index c2b58989a..84ccbed3a 100644 --- a/system/checksystem.php +++ b/system/checksystem.php @@ -1595,6 +1595,8 @@ if(!@$db->db_query('SELECT * FROM wawi.tbl_konto LIMIT 1')) GRANT SELECT, UPDATE ON SEQUENCE wawi.seq_aufteilung_aufteilung_id TO wawi; GRANT SELECT, UPDATE ON SEQUENCE wawi.seq_bestellung_bestellung_id TO wawi; GRANT SELECT, UPDATE ON SEQUENCE wawi.seq_bestelldetail_bestelldetail_id TO wawi; + GRANT SELECT ON bis.tbl_nation TO wawi; + GRANT USAGE ON SCHEMA bis TO wawi; -- INDEX diff --git a/wawi/firma.php b/wawi/firma.php index c597dcf97..3c222f355 100644 --- a/wawi/firma.php +++ b/wawi/firma.php @@ -19,7 +19,12 @@ * Andreas Oesterreicher and * Karl Burkhart . */ - +/** + * Firmenverwaltung fuer WaWi + * + * Dies ist eine abgespeckte Version der Firmenverwaltung zum einfachen Anlegen und + * Bearbeiten von Firmen. + */ require_once('../config/wawi.config.inc.php'); require_once('auth.php'); require_once('../include/benutzerberechtigung.class.php'); @@ -36,6 +41,12 @@ require_once('../include/nation.class.php'); WaWi Firma + + + + + + @@ -45,9 +56,10 @@ $user=get_uid(); $rechte = new benutzerberechtigung(); $rechte->getBerechtigungen($user); -if(!$rechte->isBerechtigt('basis/firma')) +if(!$rechte->isBerechtigt('wawi/firma')) die('Sie haben keine Berechtigung für diese Seite'); -$method = isset($_GET['method'])?$_GET['method']:''; + +$method = isset($_GET['method'])?$_GET['method']:'search'; $strasse = ''; $name = ''; $plz = ''; @@ -56,7 +68,9 @@ $telefon = ''; $fax = ''; $email = ''; $nation = 'A'; +$id = isset($_GET['id'])?$_GET['id']:''; +//Speichern der Daten if(isset($_POST['save'])) { if(!isset($_POST['strasse']) || !isset($_POST['name']) || !isset($_POST['plz']) || !isset($_POST['ort']) || @@ -73,7 +87,16 @@ if(isset($_POST['save'])) $email = $_POST['email']; $nation = $_POST['nation']; + //Bei einem Update werden die IDs der Datensaetze uebergeben + $adresse_id = $_POST['adresse_id']; + $firma_id = $_POST['firma_id']; + $standort_id = $_POST['standort_id']; + $fax_id = $_POST['fax_id']; + $telefon_id = $_POST['telefon_id']; + $email_id = $_POST['email_id']; + $errormsg=''; + if($email!='' && !mb_strstr($email,'@')) { $errormsg = 'Email muss ein @ enthalten'; @@ -90,51 +113,99 @@ if(isset($_POST['save'])) if(!$error) { - + //Firmendatensatz anlegen/updaten $firma = new firma(); - $firma->firmentyp_kurzbz='Firma'; + + if($firma_id!='') + { + if(!$firma->load($firma_id)) + die('Firma wurde nicht gefunden'); + $firma->new = false; + $firma->updateamum = date('Y-m-d H:i:s'); + $firma->updatevon = $user; + } + else + { + $firma->schule=false; + $firma->gesperrt=false; + $firma->aktiv=true; + $firma->insertamum = date('Y-m-d H:i:s'); + $firma->insertvon = $user; + $firma->new = true; + $firma->firmentyp_kurzbz='Firma'; + } + $firma->name=$name; - $firma->schule=false; - $firma->gesperrt=false; - $firma->aktiv=true; - $firma->insertamum = date('Y-m-d H:i:s'); - $firma->insertvon = $user; - $firma->new = true; + if($firma->save()) { + //Adressdatensatz anlegen/updaten $adresse = new adresse(); - + + if($adresse_id!='') + { + $adresse->load($adresse_id); + $adresse->udpateamum = date('Y-m-d H:i:s'); + $adresse->updatevon = $user; + $adresse->new = false; + } + else + { + $adresse->zustelladresse = true; + $adresse->heimatadresse = false; + $adresse->new = true; + $adresse->insertamum = date('Y-m-d H:i:s'); + $adresse->insertvon = $user; + } + $adresse->strasse = $strasse; $adresse->plz = $plz; $adresse->ort = $ort; $adresse->nation = $nation; - $adresse->zustelladresse = true; - $adresse->heimatadresse = false; - $adresse->insertamum = date('Y-m-d H:i:s'); - $adresse->insertvon = $user; - $adresse->new = true; if($adresse->save()) { + //Standort anlegen/updaten $standort = new standort(); + + if($standort_id!='') + { + $standort->load($standort_id); + $standort->new = false; + $standort->insertamum = date('Y-m-d H:i:s'); + $standort->insertvon = $user; + $standort->new = false; + } + else + { + $standort->insertamum = date('Y-m-d H:i:s'); + $standort->insertvon = $user; + $standort->new = true; + } + $standort->firma_id = $firma->firma_id; - $standort->adresse_id = $adresse->adresse_id; + $standort->adresse_id = $adresse->adresse_id; $standort->kurzbz = mb_substr($firma->name, 0,16); - $standort->insertamum = date('Y-m-d H:i:s'); - $standort->insertvon = $user; - $standort->new = true; if($standort->save()) { + //Kontaktdaten anlegen/updaten if($fax!='') { $kontakt = new kontakt(); + if($fax_id!='') + { + $kontakt->load($fax_id); + $kontakt->new = false; + } + else + $kontakt->new = true; + $kontakt->kontakttyp='fax'; $kontakt->standort_id = $standort->standort_id; $kontakt->kontakt = $fax; - $kontakt->new = true; - + if(!$kontakt->save()) { $errormsg.=$kontakt->errormsg; @@ -144,11 +215,19 @@ if(isset($_POST['save'])) if($telefon!='') { $kontakt = new kontakt(); + if($telefon_id!='') + { + $kontakt->load($telefon_id); + $kontakt->new = false; + } + else + { + $kontakt->new = true; + } $kontakt->kontakttyp='telefon'; $kontakt->standort_id = $standort->standort_id; $kontakt->kontakt = $telefon; - $kontakt->new = true; - + if(!$kontakt->save()) { $errormsg.=$kontakt->errormsg; @@ -159,11 +238,20 @@ if(isset($_POST['save'])) if($email!='') { $kontakt = new kontakt(); + if($email_id!='') + { + $kontakt->load($email_id); + $kontakt->new = false; + } + else + { + $kontakt->new = true; + } + $kontakt->kontakttyp='email'; $kontakt->standort_id = $standort->standort_id; $kontakt->kontakt = $email; - $kontakt->new = true; - + if(!$kontakt->save()) { $errormsg.=$kontakt->errormsg; @@ -189,26 +277,104 @@ if(isset($_POST['save'])) $error=true; } } - + if($error) { echo 'Fehler: '.$errormsg.''; $db->db_query('ROLLBACK;'); - $method='new'; + if($firma_id!='') + { + $method='update'; + $id = $firma_id; + } + else + $method='new'; } else { $db->db_query('COMMIT;'); echo 'Die Firma wurde erfolgreich gespeichert'; + $method='update'; + $id=$firma_id; } } -if($method=='new') +// Update / Neuanlage +if($method=='new' || $method=='update') { - echo '

Neue Firma

'; + $firma_id=''; + $standort_id=''; + $adresse_id=''; + $fax_id=''; + $email_id=''; + $telefon_id=''; + + if($method=='new') + echo '

Neue Firma

'; + else + { + echo '

Firma Bearbeiten

'; + + if(!is_numeric($id)) + die('ID ist ungueltig'); + + //Firma Laden + $firma = new firma(); + if(!$firma->load($id)) + die('Firma konnte nicht geladen werden'); + + $name = $firma->name; + $firma_id = $firma->firma_id; + + //Standort Laden + $standort = new standort(); + $standort->load_firma($firma_id); + if(isset($standort->result[0])) + { + $standort_id = $standort->result[0]->standort_id; + $adresse_id = $standort->result[0]->adresse_id; + + //Adresse Laden + $adresse = new adresse(); + $adresse->load($adresse_id); + + $strasse = $adresse->strasse; + $plz = $adresse->plz; + $ort = $adresse->ort; + $nation = $adresse->nation; + if($nation=='') + $nation='A'; + + //Kontaktdaten Laden + $kontakt = new kontakt(); + $kontakt->loadFirmaKontakttyp($standort_id, 'telefon'); + + $telefon = $kontakt->kontakt; + $telefon_id = $kontakt->kontakt_id; + + $kontakt = new kontakt(); + $kontakt->loadFirmaKontakttyp($standort_id, 'fax'); + + $fax = $kontakt->kontakt; + $fax_id = $kontakt->kontakt_id; + + $kontakt = new kontakt(); + $kontakt->loadFirmaKontakttyp($standort_id, 'email'); + + $email = $kontakt->kontakt; + $email_id = $kontakt->kontakt_id; + } + } + echo '
'; echo ' + + + + + + @@ -265,6 +431,63 @@ if($method=='new') echo ''; } + +//Suchen von Firmen +if($method=='search') +{ + $filter = (isset($_POST['filter'])?$_POST['filter']:''); + + echo '

Firma suchen

'; + echo ''; + echo ''; + echo ' '; + echo ''; + + if($filter!='') + { + $firma = new firma(); + if($firma->searchFirma($filter)) + { + echo '

+ + +
Name:
+ + + + + + + + + '; + + + foreach($firma->result as $row) + { + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo '
 IDNameAdresse
',$row->firma_id,'',$row->name,'',$row->strasse,' ',$row->plz,' ',$row->ort,'
'; + } + } + +} + ?> - - \ No newline at end of file + + \ No newline at end of file diff --git a/wawi/logout.php b/wawi/logout.php index c407f57f4..9346a5f19 100644 --- a/wawi/logout.php +++ b/wawi/logout.php @@ -31,20 +31,32 @@ { document.location="login.php"; } - window.setTimeout("login()", 2500); + +
+
+ Sie wurden erfolgreich ausgeloggt!!
Sie werden sofort weitergeleitet!
+
+ + '; + } ?> -
- -
-
-Sie wurden erfolgreich ausgeloggt!!
Sie werden sofort weitergeleitet!
-

Sollten Sie nicht weitergeleitet werden klicken Sie bitte hier