monitor-frontend/kfz.php
2018-10-01 12:12:24 +02:00

122 lines
5.6 KiB
PHP
Executable File

<?php
/*
* PHP Frontend for pocsag monitor
*
* Copyright (C) 2004-2005
* Manuel Weiser (manuelw@fire-devils.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
require('config.inc.php');
/**************************/
// Seite zusammenstellen
//
// Wenn zurcksetzen geklickt
if( $_GET["do"] == 'reset' )
{
$result = mysql_query("UPDATE kfz_fms SET status='2' WHERE org_id='$_GET[orgid]'") or die (mysql_error());
}
// Wenn einzel Status setzen
if( $_GET["do"] == 'setkfz' )
{
$result_kfz = mysql_query("SELECT num, status, richtung, text, zeit FROM status WHERE kennung = '$_GET[kennung]' ORDER BY zeit DESC LIMIT 0,1") or die (mysql_error());
$row_kfz = mysql_fetch_array($result_kfz);
$set_status_text = $status_kfz[$_GET[status]].' (S)';
echo ($row_kfz["zeit"] - $_GET["last"]);
if( $row_kfz["richtung"] == '1' && ($row_kfz["zeit"] - $_GET["last"]) < ($korr_status_zeit*100) )
{
$result = mysql_query("UPDATE status SET status='$_GET[status]', richtung='0', text='$set_status_text', zeit='$row_kfz[zeit]' WHERE num='$row_kfz[num]'") or die (mysql_error());
}
else
{
$result = mysql_query("INSERT INTO status (kennung, status, richtung, text, done) VALUES ('$_GET[kennung]', '$_GET[status]', '0', '$set_status_text', '1')") or die(mysql_error());
}
$result = mysql_query("UPDATE kfz_fms SET status='$_GET[status]' WHERE kennung='$_GET[kennung]'") or die (mysql_error());
}
// Organisationen abrufen
$result = mysql_query("SELECT id, org_name, org FROM organisation ORDER BY org ASC, org_name ASC") or die (mysql_error());
while($row = mysql_fetch_array($result))
{
// Fahrzeuge zur Organisation abrufen
$kfz = ''; $i = 0;
$result_kfz = mysql_query("SELECT id, kennung, bezeichnung, status, status_zeit, org_id FROM kfz_fms WHERE org_id = '$row[id]' ORDER BY bezeichnung ASC") or die (mysql_error());
while($row_kfz = mysql_fetch_array($result_kfz))
{
if( $row["org"] == 'RD' )
{
$set_status = "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=1&do=setkfz&last=$row_kfz[status_zeit]\'>1</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=2&do=setkfz&last=$row_kfz[status_zeit]\'>2</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=3&do=setkfz&last=$row_kfz[status_zeit]\'>3</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=4&do=setkfz&last=$row_kfz[status_zeit]\'>4</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=6&do=setkfz&last=$row_kfz[status_zeit]\'>6</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=7&do=setkfz&last=$row_kfz[status_zeit]\'>7</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=8&do=setkfz&last=$row_kfz[status_zeit]\'>8</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=9&do=setkfz&last=$row_kfz[status_zeit]\'>9</a><br>";
}
else
{
$set_status = "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=1&do=setkfz&last=$row_kfz[status_zeit]\'>1</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=2&do=setkfz&last=$row_kfz[status_zeit]\'>2</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=3&do=setkfz&last=$row_kfz[status_zeit]\'>3</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=4&do=setkfz&last=$row_kfz[status_zeit]\'>4</a><br>";
$set_status .= "<a href=\'$_SERVER[PHP_SELF]?kennung=$row_kfz[kennung]&status=6&do=setkfz&last=$row_kfz[status_zeit]\'>6</a><br>";
}
$i++;
if( $i == 1 ) $kfz = '<table><tr>';
$kfz .= '<td width="70" class="kfz_trennung" onClick="return overlib(\'<center>'.$set_status.'</center>\', STICKY, CAPTION, \'auf\', CENTER);" onmouseout="nd();"><span style="cursor:move;color:'.$status_color[$row_kfz["status"]].'; font-size:'.$status_size.'; font-weight:'.$status_format[$row_kfz["status"]].'"><center>'.$row_kfz["bezeichnung"].'</center></span></td>';
}
if( $i > 0 ) $kfz .= '</tr></table>';
if( $kfz )
{
if( $row[org] == 'FF' ) $bgcolor = 'red';
if( $row[org] == 'RD' ) $bgcolor = 'green';
$show_all .= '
<tr>
<td bgcolor="'.$bgcolor.'" width="150"><font color="white">'.$row["org_name"].'</font></td>
<td bgcolor="white">'.$kfz.'</td>
<td bgcolor="white" width="80"><div align="center"><a href="'.$_SERVER["php_self"].'?orgid='.$row["id"].'&do=reset">r&uuml;cksetzen</a></div></td>
</tr>
';
}
}
// Seiteninhalt ausgeben
eval ("\$page_middle .= \"".gettemplate($template_dir."body_kfz_uebersicht")."\";");
/**************************/
// Ausgabe Rahmen
//
eval ("dooutput(\"".gettemplate($template_dir."rahmen")."\");");
/**************************/
// Datenbank schliessen
//
mysql_close($dbconn);
?>