Firmenverwaltung klein für WaWi

This commit is contained in:
Andreas Österreicher
2011-01-13 13:56:49 +00:00
parent e375353658
commit 78c6d4e88d
8 changed files with 378 additions and 54 deletions
+5
View File
@@ -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
*/
+35
View File
@@ -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
+1 -1
View File
@@ -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))
{
+2 -1
View File
@@ -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
+58 -12
View File
@@ -37121,7 +37121,7 @@
<Left>233</Left>
<z>0</z>
<Width>809</Width>
<Height>356</Height>
<Height>395</Height>
<dz>0</dz>
<RecalculateSizes>1</RecalculateSizes>
<UseWorkSpaceRecalculateSizes>1</UseWorkSpaceRecalculateSizes>
@@ -38497,8 +38497,8 @@
<WorkSpaceShape2>
<Id>{5FEF0B42-3911-4B97-A654-2AD1A67125FC}</Id>
</WorkSpaceShape2>
<NamePositionX>1987</NamePositionX>
<NamePositionY>2169</NamePositionY>
<NamePositionX>1986</NamePositionX>
<NamePositionY>2182</NamePositionY>
<Points>
<Point>
<x>3131</x>
@@ -38510,11 +38510,11 @@
</Point>
<Point>
<x>1073</x>
<y>3120</y>
<y>3146</y>
</Point>
<Point>
<x>1042</x>
<y>3120</y>
<y>3146</y>
</Point>
</Points>
</WorkSpaceLinePERRelationPG83>
@@ -38540,8 +38540,8 @@
<WorkSpaceShape2>
<Id>{5FEF0B42-3911-4B97-A654-2AD1A67125FC}</Id>
</WorkSpaceShape2>
<NamePositionX>1035</NamePositionX>
<NamePositionY>2610</NamePositionY>
<NamePositionX>1034</NamePositionX>
<NamePositionY>2616</NamePositionY>
<Points>
<Point>
<x>1227</x>
@@ -38553,11 +38553,11 @@
</Point>
<Point>
<x>1073</x>
<y>3002</y>
<y>3015</y>
</Point>
<Point>
<x>1042</x>
<y>3002</y>
<y>3015</y>
</Point>
</Points>
</WorkSpaceLinePERRelationPG83>
@@ -39470,7 +39470,7 @@
<Company>Technikum Wien</Company>
<Version>2.0</Version>
<CreatedDate>2009-04-17T10:15:21.000+01:00</CreatedDate>
<ModifiedDate>2011-01-10T16:05:43.919+01:00</ModifiedDate>
<ModifiedDate>2011-01-13T14:53:41.009+01:00</ModifiedDate>
<Project>FH-Complete 2.0</Project>
<Description></Description>
</ModelTitlePG83>
@@ -122318,7 +122318,9 @@ Wenn FALSE haengt die Anzahl der Fragen pro Level von der Gesamtzahl pro Level a
<Id>{361EF147-269D-4247-8F7C-5A3876A3999A}</Id>
</DataType>
<UserDataType/>
<IndexItems/>
<IndexItems>
<Id>{EE26D990-2EF8-4C27-846A-E29A5F16F708}</Id>
</IndexItems>
<Default/>
<CheckConstraints/>
<KeyConstraint/>
@@ -122659,7 +122661,51 @@ Wenn FALSE haengt die Anzahl der Fragen pro Level von der Gesamtzahl pro Level a
<PK>
<Id>{4739E579-AB3A-4CBC-B280-7D975698878A}</Id>
</PK>
<Indexes/>
<Indexes>
<PERIndexPG83 ObjectType="2012" CSAOName="PERIndexPG83">
<Id>{A896AD92-3CCA-4377-8B4F-F75BD0D1D6AA}</Id>
<Name>idx_aufteilung_bestellung_id</Name>
<Ordinal>0</Ordinal>
<HistoryID>{7C26AA4C-866E-4132-B4AD-97534263104A}</HistoryID>
<GlobalOrder>0</GlobalOrder>
<RNOffset>0</RNOffset>
<RNLength>0</RNLength>
<IgnoreNC>0</IgnoreNC>
<GenerateCode>1</GenerateCode>
<BeforeScript></BeforeScript>
<AfterScript></AfterScript>
<Notes></Notes>
<Comments></Comments>
<Unique>0</Unique>
<Caption>idx_aufteilung_bestellung_id</Caption>
<Expression></Expression>
<GenerateExpression>0</GenerateExpression>
<IndexItems>
<PERIndexItemPG83 ObjectType="2013" CSAOName="PERIndexItemPG83">
<Id>{EE26D990-2EF8-4C27-846A-E29A5F16F708}</Id>
<Name>bestellung_id</Name>
<Ordinal>0</Ordinal>
<HistoryID>{97CE8268-1ACA-495D-9CA3-3940500307BA}</HistoryID>
<GlobalOrder>0</GlobalOrder>
<GenerateCode>1</GenerateCode>
<BeforeScript></BeforeScript>
<AfterScript></AfterScript>
<Notes></Notes>
<Comments></Comments>
<SortDescending>0</SortDescending>
<Attribute>
<Id>{CEA0DBEA-7F1C-4512-878D-12D183FD78C7}</Id>
</Attribute>
<ForeignKeys/>
</PERIndexItemPG83>
</IndexItems>
<Relations/>
<IxAccess>btree</IxAccess>
<Predicate></Predicate>
<Tablespace/>
<FillFactor></FillFactor>
</PERIndexPG83>
</Indexes>
<CheckConstraints/>
<Category/>
<Triggers/>
+2
View File
@@ -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
+249 -26
View File
@@ -19,7 +19,12 @@
* Andreas Oesterreicher <andreas.oesterreicher@technikum-wien.at> and
* Karl Burkhart <burkhart@technikum-wien.at>.
*/
/**
* 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');
<head>
<title>WaWi Firma</title>
<link rel="stylesheet" href="../skin/wawi.css" type="text/css"/>
<link rel="stylesheet" href="../skin/tablesort.css" type="text/css"/>
<link rel="stylesheet" href="../include/js/jquery.css" type="text/css"/>
<script type="text/javascript" src="../include/js/jquery.js"></script>
<script type="text/javascript" src="../include/js/jquery.metadata.js"></script>
<script type="text/javascript" src="../include/js/jquery.tablesorter.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
@@ -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,50 +113,98 @@ 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->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())
{
@@ -144,10 +215,18 @@ 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())
{
@@ -159,10 +238,19 @@ 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())
{
@@ -194,21 +282,99 @@ if(isset($_POST['save']))
{
echo '<span class="error">Fehler: '.$errormsg.'</span>';
$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 '<h1>Neue Firma</h1>';
$firma_id='';
$standort_id='';
$adresse_id='';
$fax_id='';
$email_id='';
$telefon_id='';
if($method=='new')
echo '<h1>Neue Firma</h1>';
else
{
echo '<h1>Firma Bearbeiten</h1>';
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 '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
echo '
<input type="hidden" name="firma_id" value="'.$firma_id.'">
<input type="hidden" name="standort_id" value="'.$standort_id.'">
<input type="hidden" name="adresse_id" value="'.$adresse_id.'">
<input type="hidden" name="telefon_id" value="'.$telefon_id.'">
<input type="hidden" name="fax_id" value="'.$fax_id.'">
<input type="hidden" name="email_id" value="'.$email_id.'">
<table>
<tr>
<td>Name:</td>
@@ -265,6 +431,63 @@ if($method=='new')
echo '</form>';
}
//Suchen von Firmen
if($method=='search')
{
$filter = (isset($_POST['filter'])?$_POST['filter']:'');
echo '<H1>Firma suchen</H1>';
echo '<form action="'.$_SERVER['PHP_SELF'].'?method=search" method="POST">';
echo '<input type="text" size="30" name="filter" value="'.$filter.'">';
echo ' <input type="submit" name="send" value="Suchen">';
echo '</form>';
if($filter!='')
{
$firma = new firma();
if($firma->searchFirma($filter))
{
echo '<br /><br />
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter(
{
sortList: [[2,0]],
widgets: ["zebra"]
});
});
</script>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>&nbsp;</th>
<th>ID</th>
<th>Name</th>
<th>Adresse</th>
</tr>
</thead>
<tbody>';
foreach($firma->result as $row)
{
echo '<tr>';
echo '<td><a href="firma.php?method=update&amp;id='.$row->firma_id.'" title="Bearbeiten"> <img src="../skin/images/edit.gif"> </a></td>';
echo '<td>',$row->firma_id,'</td>';
echo '<td>',$row->name,'</td>';
echo '<td>',$row->strasse,' ',$row->plz,' ',$row->ort,'</td>';
echo '</tr>';
}
echo '</tbody></table>';
}
}
}
?>
</html>
</body>
</html>
+19 -7
View File
@@ -31,20 +31,32 @@
{
document.location="login.php";
}
window.setTimeout("login()", 2500);
</script>
</head>
<body>
<?php
session_start();
session_destroy();
if(isset($_SERVER['REMOTE_USER']))
{
echo 'ACHTUNG! Sie sind per BASIC-Authentifizierung angemeldet. Ein Logout ist hierbei nicht möglich. Um sich korrekt auszuloggen schliessen Sie bitte ALLE Browserfenster.';
}
else
{
echo '
<center>
<strong>
<br />
<br />
Sie wurden erfolgreich ausgeloggt!!<br /> Sie werden sofort weitergeleitet!<br />
</strong>
<script type="text/javascript">
window.setTimeout("login()", 2500);
</script>
';
}
?>
<center>
<strong>
<br />
<br />
Sie wurden erfolgreich ausgeloggt!!<br /> Sie werden sofort weitergeleitet!<br />
</strong>
<br />
Sollten Sie nicht weitergeleitet werden klicken Sie bitte <a href="login.php">hier</a>
</center>