diff --git a/include/tw/wawi_menu_main.inc.php b/include/tw/wawi_menu_main.inc.php index 644d867a3..14e891b03 100644 --- a/include/tw/wawi_menu_main.inc.php +++ b/include/tw/wawi_menu_main.inc.php @@ -58,6 +58,10 @@ $menu=array 'Personensuche'=>array ( 'name'=>'Personensuche', 'link'=>'https://cis.technikum-wien.at/cis/private/tools/psearch.php', 'target'=>'content', + ), + 'Firma'=>array + ( + 'name'=>'Firma anlegen', 'link'=>'firma.php?method=new', 'target'=>'content', ) ), 'Auswertungen'=> array diff --git a/wawi/firma.php b/wawi/firma.php new file mode 100644 index 000000000..c597dcf97 --- /dev/null +++ b/wawi/firma.php @@ -0,0 +1,270 @@ +, + * Andreas Oesterreicher and + * Karl Burkhart . + */ + +require_once('../config/wawi.config.inc.php'); +require_once('auth.php'); +require_once('../include/benutzerberechtigung.class.php'); +require_once('../include/firma.class.php'); +require_once('../include/standort.class.php'); +require_once('../include/kontakt.class.php'); +require_once('../include/adresse.class.php'); +require_once('../include/nation.class.php'); + +?> + + + + WaWi Firma + + + + +getBerechtigungen($user); + +if(!$rechte->isBerechtigt('basis/firma')) + die('Sie haben keine Berechtigung für diese Seite'); +$method = isset($_GET['method'])?$_GET['method']:''; +$strasse = ''; +$name = ''; +$plz = ''; +$ort = ''; +$telefon = ''; +$fax = ''; +$email = ''; +$nation = 'A'; + +if(isset($_POST['save'])) +{ + if(!isset($_POST['strasse']) || !isset($_POST['name']) || !isset($_POST['plz']) || !isset($_POST['ort']) || + !isset($_POST['telefon']) || !isset($_POST['fax']) || !isset($_POST['email'])) + die('Ungueltige Parameteruebergabe'); + + $error = false; + $strasse = $_POST['strasse']; + $name = $_POST['name']; + $plz = $_POST['plz']; + $ort = $_POST['ort']; + $telefon = $_POST['telefon']; + $fax = $_POST['fax']; + $email = $_POST['email']; + $nation = $_POST['nation']; + + $errormsg=''; + if($email!='' && !mb_strstr($email,'@')) + { + $errormsg = 'Email muss ein @ enthalten'; + $error = true; + } + if($name=='') + { + $errormsg = 'Es muss ein Firmennamen eingetragen werden!'; + $error = true; + } + $db = new basis_db(); + + $db->db_query('BEGIN;'); + + if(!$error) + { + + $firma = new firma(); + $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()) + { + $adresse = new adresse(); + + $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 = new standort(); + $standort->firma_id = $firma->firma_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()) + { + if($fax!='') + { + $kontakt = new kontakt(); + $kontakt->kontakttyp='fax'; + $kontakt->standort_id = $standort->standort_id; + $kontakt->kontakt = $fax; + $kontakt->new = true; + + if(!$kontakt->save()) + { + $errormsg.=$kontakt->errormsg; + $error = true; + } + } + if($telefon!='') + { + $kontakt = new kontakt(); + $kontakt->kontakttyp='telefon'; + $kontakt->standort_id = $standort->standort_id; + $kontakt->kontakt = $telefon; + $kontakt->new = true; + + if(!$kontakt->save()) + { + $errormsg.=$kontakt->errormsg; + $error = true; + } + } + + if($email!='') + { + $kontakt = new kontakt(); + $kontakt->kontakttyp='email'; + $kontakt->standort_id = $standort->standort_id; + $kontakt->kontakt = $email; + $kontakt->new = true; + + if(!$kontakt->save()) + { + $errormsg.=$kontakt->errormsg; + $error = true; + } + } + } + else + { + $errormsg.='Standort:'.$standort->errormsg; + $error = true; + } + } + else + { + $errormsg.='Adresse:'.$adresse->errormsg; + $error=true; + } + } + else + { + $errormsg.='Firma:'.$firma->errormsg; + $error=true; + } + } + + if($error) + { + echo 'Fehler: '.$errormsg.''; + $db->db_query('ROLLBACK;'); + $method='new'; + } + else + { + $db->db_query('COMMIT;'); + echo 'Die Firma wurde erfolgreich gespeichert'; + } +} + +if($method=='new') +{ + echo '

Neue Firma

'; + + echo '
'; + echo ' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name:
Strasse:
Plz / Ort:
Nation: + '; + $nat = new nation(); + $nat->getAll(); + + echo ''; + echo ' +
Telefon:
Fax:
E-Mail:
+ '; + + echo '
'; +} +?> + + \ No newline at end of file