Erstversion Ampelsystem

This commit is contained in:
Andreas Österreicher
2011-11-29 08:50:02 +00:00
parent 12e6092178
commit a0bd89cbc8
13 changed files with 584 additions and 193 deletions
Executable
+52
View File
@@ -0,0 +1,52 @@
<?php
require_once('../config/cis.config.inc.php');
require_once('../include/functions.inc.php');
require_once('../include/ampel.class.php');
require_once('../include/datum.class.php');
if(is_user_logged_in())
{
$user = get_uid();
$ampel = new ampel();
$ampel->loadUserAmpel($user);
$rot=0;
$gelb=0;
$datum = new datum();
foreach($ampel->result as $row)
{
$ts_deadline = $datum->mktime_fromdate($row->deadline);
$vlz = "-".$row->vorlaufzeit." day";
$ts_vorlaufzeit = strtotime($vlz, $ts_deadline);
$ts_now = $datum->mktime_fromdate(date('Y-m-d'));
if($ts_deadline < $ts_now)
{
$rot++;
}
else
{
if($ts_vorlaufzeit<=$ts_now && $ts_now<=$ts_deadline)
{
$gelb++;
}
}
}
if($rot>0 || $gelb>0)
{
echo '[';
if($rot>0)
echo '<a href="private/tools/ampelverwaltung.php" target="content" title="Red Alert"><img src="../skin/images/ampel_rot.png" style="vertical-align: bottom;"> '.$rot.'</a>';
if($rot>0 && $gelb>0)
echo ' | ';
if($gelb>0)
echo '<a href="private/tools/ampelverwaltung.php" target="content" title="Yellow Alert"><img src="../skin/images/ampel_gelb.png" style="vertical-align: bottom;"> '.$gelb.'</a>';
echo ' ]';
}
}
else
{
echo "<script>window.setTimeout('loadampel()',5000);</script>";
//echo microtime();
}
?>
+18 -2
View File
@@ -54,8 +54,10 @@ else
<head>
<title>CIS - <?php echo CAMPUS_NAME; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../skin/jquery.css" type="text/css">
<link href="../skin/style.css.php" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
<script src="../include/js/jquery.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
function changeSprache(sprache)
@@ -69,8 +71,21 @@ function changeSprache(sprache)
window.location.href="index.php?sprache="+sprache+"&content_id=<?php echo $id;?>&menu="+menu+"&content="+content;
}
function gettimestamp()
{
var now = new Date();
var ret = now.getHours()*60*60*60;
ret = ret + now.getMinutes()*60*60;
ret = ret + now.getSeconds()*60;
ret = ret + now.getMilliseconds();
return ret;
}
function loadampel()
{
$('#ampel').load('ampel.php?'+gettimestamp());
}
</script>
<body style="margin-top:0; padding-top:0">
<body style="margin-top:0; padding-top:0" onload="loadampel()">
<table class="tabcontent">
<tr>
<td></td>
@@ -90,7 +105,8 @@ function changeSprache(sprache)
</tr>
<tr>
<td></td>
<td align="right" nowrap colspan="2">
<td align="right" nowrap colspan="2">
<span id="ampel"></span>
<?php require_once('../include/'.EXT_FKT_PATH.'/cis_menu_global.inc.php'); ?>
</td>
+149
View File
@@ -0,0 +1,149 @@
<?php
/* Copyright (C) 2011 FH Technikum-Wien
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Authors: Andreas Oesterreicher <[email protected]>
*/
require_once('../../../config/cis.config.inc.php');
require_once('../../../include/functions.inc.php');
require_once('../../../include/ampel.class.php');
require_once('../../../include/datum.class.php');
require_once('../../../include/phrasen.class.php');
$user = get_uid();
$sprache = getSprache();
$p = new phrasen($sprache);
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../skin/fhcomplete.css" type="text/css"/>
<link rel="stylesheet" href="../../../skin/style.css.php" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="../../../skin/tablesort.css" type="text/css"/>
<link rel="stylesheet" href="../../../skin/jquery.css" type="text/css"/>
<script type="text/javascript" src="../../../include/js/jquery.js"></script>
<title>',$p->t('tools/ampelsystem'),'</title>
<script type="text/javascript">
$(document).ready(function()
{
$("#myTable").tablesorter(
{
sortList: [[2,0]],
widgets: [\'zebra\']
});
});
</script>
</head>
<body>
<h1>',$p->t('tools/ampelsystem'),'</h1>
';
$datum_obj = new datum();
$type = isset($_GET['type'])?$_GET['type']:'';
$ampel_id = isset($_GET['ampel_id'])?$_GET['ampel_id']:'';
if($type=='bestaetigen' && is_numeric($ampel_id))
{
$ampel = new ampel();
if($ampel->load($ampel_id))
{
if($ampel->isZugeteilt($user, $ampel->benutzer_select))
{
if($ampel->bestaetigen($user, $ampel_id))
{
$message = '<span class="ok">OK</span>';
}
else
$message = '<span class="error">'.$ampel->errormsg.'</span>';
}
else
$message = '<span class="error">'.$p->t('tools/nichtZugeteilt').'</span>';
}
else
$message = '<span class="error">'.$p->t('tools/ampelNichtGefunden').'</span>';
}
$ampel = new ampel();
$ampel->loadUserAmpel($user, true);
echo '
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>'.$p->t('tools/ampelStatus').'</th>
<th>'.$p->t('tools/ampelBeschreibung').'</th>
<th>'.$p->t('tools/ampelDeadline').'</th>
<th>'.$p->t('tools/ampelAktion').'</th>
</tr>
</thead>
<tbody>
';
foreach($ampel->result as $row)
{
$ts_deadline = $datum_obj->mktime_fromdate($row->deadline);
$vlz = "-".$row->vorlaufzeit." day";
$ts_vorlaufzeit = strtotime($vlz, $ts_deadline);
$ts_now = $datum_obj->mktime_fromdate(date('Y-m-d'));
if($ts_vorlaufzeit<=$ts_now && $ts_now<=$ts_deadline)
$ampelstatus='gelb';
elseif($ts_now>$ts_deadline)
$ampelstatus='rot';
elseif($ts_now<$ts_deadline && $ts_vorlaufzeit>=$ts_now)
$ampelstatus='gruen';
echo '<tr>';
echo '<td align="center">';
switch($ampelstatus)
{
case 'rot':
echo '<img src="../../../skin/images/ampel_rot.png">';
break;
case 'gelb':
echo '<img src="../../../skin/images/ampel_gelb.png">';
break;
case 'gruen':
echo '<img src="../../../skin/images/ampel_gruen.png">';
break;
default:
break;
}
echo '</td>';
echo '<td>'.$row->beschreibung[$sprache].'</td>';
echo '<td>'.$datum_obj->formatDatum($row->deadline,'d.m.Y').'</td>';
if(!$ampel->isBestaetigt($user,$row->ampel_id))
echo '<td><a href="'.$_SERVER['PHP_SELF'].'?ampel_id='.$row->ampel_id.'&type=bestaetigen">bestätigen</a></td>';
else
echo '<td></td>';
// echo "<td>".date('d.m.Y',$ts_now)."</td>";
// echo "<td align=\"center\">".date('d.m.Y',$ts_vorlaufzeit)."</td>";
// echo "<td>".date('d.m.Y',$ts_deadline)."</td>";
echo '</tr>';
}
echo '</tbody></table>';
echo '</body>
</html>';
?>