';
}
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_admin_dme-kfz_update")."\";");
}
//
// Wenn dme updaten
elseif( $_GET["show"] == 'dme' && $_GET["do"] == 'update' )
{
// Zusammenstellung bekannter Organisationen
$result = mysqli_query("SELECT id, org_name, org FROM organisation ORDER BY org ASC, org_name ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
if( $_REQUEST["org"] == $row["id"] ) { $selected = 'selected'; } else { $selected = ''; }
$option_org .= '';
}
// Zusammenstellung der Formatierungen
$result = mysqli_query("SELECT id, beschreibung FROM formatierung ORDER BY beschreibung ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
if( $_REQUEST["form"] == $row["id"] ) { $selected = 'selected'; } else { $selected = ''; }
$option_format .= '';
}
// Abfrage des verlangten Datensatzes
$result = mysqli_query("SELECT id, adresse, bezeichnung, rec_typ FROM ric_zvei WHERE id = '$_GET[id]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_admin_dme2org")."\";");
}
//
// Wenn dme l�schen
elseif( $_GET["show"] == 'dme' && $_GET["do"] == 'delete' )
{
$result = mysqli_query("DELETE FROM ric_zvei WHERE id = '$_GET[id]'") or die (mysqli_error());
$result = mysqli_query("DELETE FROM alarm2mail WHERE adresse = '$_GET[adresse]'") or die (mysqli_error());
// Pr�fen ob noch weitere Eintr�ge zur Org da sind, wenn nicht l�schen
if( $_GET["org"] )
{
$result = mysqli_query("SELECT a.id AS dme_id, b.id AS kfz_id
FROM ric_zvei a
LEFT JOIN kfz_fms b ON b.org_id = $_GET[org]
WHERE a.org_id = '$_GET[org]' OR b.org_id = '$_GET[org]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
if( !$row["dme_id"] && !$row["kfz_id"] )
{
$result = mysqli_query("DELETE FROM organisation WHERE id = '$_GET[org]'") or die (mysqli_error());
}
}
// Wohin gehen nach Aktion
if( !$_GET["org"] )
{
echo gohome($_SERVER["PHP_SELF"].'?show=dme&org=0');
}
else
{
echo gohome($_SERVER["PHP_SELF"]);
}
}
//
// dme Update ausf�hren
elseif( $_GET["show"] == 'dme' && $_GET["do"] == 'setupdate' )
{
// Schauen ob neue oder bestehende Organistaion gew�hlt wurde
if( $_REQUEST["new_org"] )
{
/////////////////$organisation = $_REQUEST["new_org"];
// Pr�fen ob die Org schon existiert, wenn ja update kein eintrag
$result = mysqli_query("SELECT id FROM organisation WHERE org_name = '$_REQUEST[new_org]' AND org = '$_REQUEST[new_org_typ]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
if( $row["id"] )
{
$org_id = $row["id"];
}
if( !$org_id )
{
$result = mysqli_query("INSERT INTO organisation (org_name, org) VALUES ('$_REQUEST[new_org]', '$_REQUEST[new_org_typ]')");
$result = mysqli_query("SELECT MAX(id) as new_id FROM organisation");
$row = mysql_fetch_row($result);
$org_id = $row[0];
}
}
else
{
$org_id = $_REQUEST["select_org"];
}
$result = mysqli_query("UPDATE ric_zvei SET bezeichnung = '$_REQUEST[bezeichnung]', formatierung_id = '$_REQUEST[formatierung]', org_id = '$org_id' WHERE id='$_REQUEST[id]'") or die (mysqli_error());
// Pr�fen ob noch weitere Eintr�ge zur Org da sind, wenn nicht l�schen
if( $_REQUEST["old_org"] )
{
$result = mysqli_query("SELECT a.id AS dme_id, b.id AS kfz_id
FROM ric_zvei a
LEFT JOIN kfz_fms b ON b.org_id = $_REQUEST[old_org]
WHERE a.org_id = '$_REQUEST[old_org]' OR b.org_id = '$_REQUEST[old_org]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
if( !$row["dme_id"] && !$row["kfz_id"] )
{
$result = mysqli_query("DELETE FROM organisation WHERE id = '$_REQUEST[old_org]'") or die (mysqli_error());
}
}
echo gohome($_SERVER["PHP_SELF"]);
}
//
// Wenn kfz ohne org anzusehen ist
elseif( $_GET["show"] == 'kfz' && !$_GET["do"] )
{
// Alle DME ohne Organisation holen
$result = mysqli_query("SELECT id, bezeichnung FROM kfz_fms WHERE org_id = '0' ORDER BY bezeichnung ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
$show_all .= '
';
}
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_admin_dme-kfz_update")."\";");
}
//
// Wenn kfz updaten
elseif( $_GET["show"] == 'kfz' && $_GET["do"] == 'update' )
{
// Zusammenstellung bekannter Organisationen
$result = mysqli_query("SELECT id, org_name, org FROM organisation ORDER BY org ASC, org_name ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
if( $_REQUEST["org"] == $row["id"] ) { $selected = 'selected'; } else { $selected = ''; }
$option_org .= '';
}
// Abfrage des verlangten Datensatzes
$result = mysqli_query("SELECT id, bezeichnung FROM kfz_fms WHERE id = '$_GET[id]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_admin_kfz2org")."\";");
}
//
// Wenn kfz l�schen
elseif( $_GET["show"] == 'kfz' && $_GET["do"] == 'delete' )
{
$result = mysqli_query("DELETE FROM kfz_fms WHERE id = '$_GET[id]'") or die (mysqli_error());
// Pr�fen ob noch weitere Eintr�ge zur Org da sind, wenn nicht l�schen
if( $_GET["org"] )
{
$result = mysqli_query("SELECT a.id AS dme_id, b.id AS kfz_id
FROM ric_zvei a
LEFT JOIN kfz_fms b ON b.org_id = $_GET[org]
WHERE a.org_id = '$_GET[org]' OR b.org_id = '$_GET[org]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
if( !$row["dme_id"] && !$row["kfz_id"] )
{
$result = mysqli_query("DELETE FROM organisation WHERE id = '$_GET[org]'") or die (mysqli_error());
}
}
// Wohin gehen nach Aktion
if( !$_GET["org"] )
{
echo gohome($_SERVER["PHP_SELF"].'?show=kfz&org=0');
}
else
{
echo gohome($_SERVER["PHP_SELF"]);
}
}
//
// kfz Update ausfhren
elseif( $_GET["show"] == 'kfz' && $_GET["do"] == 'setupdate' )
{
// Schauen ob neue oder bestehende Organistaion gewhlt wurde
if( $_REQUEST["new_org"] )
{
$organisation = $_REQUEST["new_org"];
$result = mysqli_query("INSERT INTO organisation (org_name, org) VALUES ('$organisation', '$_REQUEST[new_org_typ]')");
$result = mysqli_query("SELECT MAX(id) as new_id FROM organisation");
$row = mysql_fetch_row($result);
$organisation = $row[0];
}
else
{
$organisation = $_REQUEST["select_org"];
}
$result = mysqli_query("UPDATE kfz_fms SET bezeichnung = '$_REQUEST[bezeichnung]', org_id = '$organisation' WHERE id='$_REQUEST[id]'") or die (mysqli_error());
// Pr�fen ob noch weitere Eintr�ge zur Org da sind, wenn nicht l�schen
if( $_REQUEST["old_org"] )
{
$result = mysqli_query("SELECT a.id AS dme_id, b.id AS kfz_id
FROM ric_zvei a
LEFT JOIN kfz_fms b ON b.org_id = $_REQUEST[old_org]
WHERE a.org_id = '$_REQUEST[old_org]' OR b.org_id = '$_REQUEST[old_org]'") or die (mysqli_error());
$row = mysqli_fetch_array($result);
if( !$row["dme_id"] && !$row["kfz_id"] )
{
$result = mysqli_query("DELETE FROM organisation WHERE id = '$_REQUEST[old_org]'") or die (mysqli_error());
}
}
echo gohome($_SERVER["PHP_SELF"]);
}
//
// Wenn Userliste anzeigen
elseif( $_GET["show"] == 'user' && !$_GET["do"] )
{
// Alle DME ohne Organisation holen
$result = mysqli_query("SELECT id, a_name, real_name, a_admin, a_mail FROM admin_users ORDER BY a_admin DESC, a_name ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
if( $row["a_admin"] == '0' ) $status = '(User) ';
elseif( $row["a_admin"] == '1' ) $status = '(Admin) ';
elseif( $row["a_admin"] == '2' ) $status = '(New) ';
elseif( $row["a_admin"] == '3' ) $status = '(Closed) ';
if( $row["a_admin"] != '1') {
$show_del_button = 'löschen';
} else {
$show_del_button = "";
}
$show_all .= '
'.$status.$row["real_name"].'
'.$row["a_mail"].'
'.$row["a_name"].'
'.$show_del_button.'
';
}
// Benutzer eintragen
$show_all .= '
Neuer User
Vorname / Name
EMail
';
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_admin_dme-kfz_update")."\";");
}
// User eintragen
elseif( $_GET["show"] == 'user' && $_GET["do"] == 'insert' )
{
list($vorname, $nachname) = explode(" ", trim($_REQUEST["ins_name"]));
$ins_user_name = trim($vorname) .".". substr(trim($nachname),0,1);
$result = mysqli_query("SELECT id FROM admin_users WHERE a_name = '$ins_user_name'");
$row = mysqli_fetch_array($result);
if (!empty($row["id"])) $ins_user_name = trim($vorname) .".". substr(trim($nachname),0,1) ."". rand(1,99);
$result = mysqli_query("INSERT INTO admin_users (a_name, real_name, a_mail, pm_allow) VALUES ('$ins_user_name', '$_REQUEST[ins_name]', '$_REQUEST[ins_mail]', '1')") or die(mysqli_error);
echo gohome($_SERVER["PHP_SELF"].'?show=user');
}
//
// Wenn user l�schen
elseif( $_GET["show"] == 'user' && $_GET["do"] == 'delete' )
{
$result = mysqli_query("DELETE FROM messages WHERE userid_to = '$_GET[id]'") or die (mysqli_error());
$result = mysqli_query("DELETE FROM alarm2mail WHERE userid = '$_GET[id]'") or die (mysqli_error());
$result = mysqli_query("DELETE FROM admin_users WHERE id = '$_GET[id]'") or die (mysqli_error());
echo gohome($_SERVER["PHP_SELF"].'?show=user');
}
//
// Wenn nichts vorgegeben
else
{
// Wir schauen nach dme die keiner Org zugeordnet sind
$result = mysqli_query("SELECT id FROM ric_zvei WHERE org_id = '0'") or die (mysqli_error());
$num_dme = mysql_num_rows($result);
// Wir schauen nach kfz die keiner Org zugeordnet sind
$result = mysqli_query("SELECT id FROM kfz_fms WHERE org_id = '0'") or die (mysqli_error());
$num_kfz = mysql_num_rows($result);
// Wir schauen nach der Userzahl
$result = mysqli_query("SELECT id FROM admin_users") or die (mysqli_error());
$num_user = mysql_num_rows($result);
$result = mysqli_query("SELECT id FROM admin_users WHERE a_admin = '2'") or die (mysqli_error());
$num_new_user = mysql_num_rows($result);
// Ausklappmenu erstellen
$select_search_org = '
';
// Ausgabe zusammenstellen wenn org zum bearbeiten gew�hlt
if( $_REQUEST["search_org"] )
{
$show_ric = '--- RIC/ZVEI ---------- ';
$result = mysqli_query("SELECT id, adresse, bezeichnung, rec_typ, org_id, formatierung_id FROM ric_zvei WHERE org_id = '$_REQUEST[search_org]' ORDER BY rec_typ ASC, adresse ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
$show_ric .= ' '.$row["adresse"].' | '.$row["rec_typ"].' | '.$row["bezeichnung"].' ';
}
$show_ric .= ' --- KFZ/FMS ---------- ';
$result = mysqli_query("SELECT id, kennung, bezeichnung, org_id FROM kfz_fms WHERE org_id = '$_REQUEST[search_org]' ORDER BY kennung ASC") or die (mysqli_error());
while($row = mysqli_fetch_array($result))
{
$show_ric .= ' '.$row["kennung"].' | '.$row["bezeichnung"].' ';
}
$show_to_edit = '