Compare commits

...

16 Commits

Author SHA1 Message Date
Paolo e022f75943 Merge branch 'master' into feature-7264/Dauerampel_fuer_fehlende_Timesheets 2021-08-22 21:05:19 +02:00
Andreas Österreicher 2c8c3b2141 Merge branch 'master' into feature-7264/Dauerampel_fuer_fehlende_Timesheets 2021-07-27 19:32:25 +02:00
Andreas Österreicher e6ce33a302 Merge branch 'master' into feature-7264/Dauerampel_fuer_fehlende_Timesheets 2021-01-29 15:31:53 +01:00
Cris 28b5761116 Added info-tooltip to Dauerampel 2020-05-14 14:23:28 +02:00
Cris d1d219cc2c Added parse_bool to dauerampel in ampel.class 2020-05-14 14:22:56 +02:00
Cris 4bcb2cc059 Fixed: Active Ampeln now matching correctly time conditions
Before missing braces between AND/OR operands delivered wrong results.
This is fixed now.
2020-04-29 13:16:32 +02:00
Cris 5267bc5d7a Added parameter ampel_id to method active() in Ampel_model 2020-04-29 13:11:39 +02:00
Cris ef69a1a2f3 Changed: Now single ampel_id is checked, if it is active + better code
. If parameter ampel_id is passed to the job, it will now get the
ampel data only if it is active.
. Clearer way of treating dauerampel in code.
2020-04-29 13:10:20 +02:00
Cris 37aa23ee1e Adapted job generateAmpelMail in AmpelMail
Now an ampel_id can be given to generateAmpelMail.
If an ampel_id is set, only this ampel is loaded.
Otherwise all active Ampeln are loaded.

Dauerampeln are always set as 'new': the status is then set to yellow and
the message template for new ampeln fits well too.
2020-04-28 16:41:39 +02:00
Cris ebe5cbe797 Added Dauerampel to CIS GUI
Dauerampeln do not have Faelligkeitsdatum and do not have
Bestaetigen-button. They are dismissed automatically when the
benutzer_select-condition is not valid anymore.
2020-04-28 16:35:17 +02:00
Cris fc2845ad72 Adapted method active() in Ampel_model
. Added parameter dauerampel
. Set both params to default null to have real usage of boolean param in
the query.
2020-04-28 16:31:35 +02:00
Cris 9f42beaeb3 Fixed: Query getAll in Ampel Class
Query was not retrieving correctly active Ampeln.
Adapted time conditions.
2020-04-28 16:24:30 +02:00
Cris a37b81c57a Added property 'dauerampel' to all Ampel Class methods 2020-04-28 16:20:01 +02:00
Cris 7060fd81c9 Added column 'dauerampel' to tbl_ampel 2020-04-28 16:17:09 +02:00
Cris f1565fea85 Added checkbox 'dauerampel' to Ampel Details
If checkbox 'dauerampel' is checked, the checkbox 'verpflichtend' is
disabled.
Dauerampeln should not pop up each time.
2020-04-28 16:16:05 +02:00
Cris 2f2a5ea6f7 Optimized VILESCI GUI for Ampeln
. Added links to display active or all ampeln (default: active)
. Added column 'dauerampel' in ampel overview
2020-04-28 16:13:01 +02:00
7 changed files with 976 additions and 855 deletions
+27 -7
View File
@@ -42,10 +42,19 @@ class AmpelMail extends CLI_Controller
* Ampel is overdue when the cronjob runs after the deadline date.
* @return void
*/
public function generateAmpelMail()
public function generateAmpelMail($ampel_id = null)
{
// Get all notifications, that are not expired, not before vorlaufzeit AND email is true
$result_active_ampeln = $this->AmpelModel->active(true);
// if ampel_id is given, get this ampel only
if (is_numeric($ampel_id))
{
$result_active_ampeln = $this->AmpelModel->active($ampel_id, true);
}
// else get all active ampeln
else
{
// Get all notifications, that are not expired, not before vorlaufzeit AND email is true
$result_active_ampeln = $this->AmpelModel->active(null, true);
}
// Stores users, description, deadline and system-link of notifications
$new_ampel_data_arr = array(); // data of new notifications that are not confirmed
@@ -67,6 +76,7 @@ class AmpelMail extends CLI_Controller
$qry_all_ampel_user = $ampel->benutzer_select; // sql select to get all user who get this ampel
$new = false;
$overdue = false;
$dauerampel = $ampel->dauerampel;
// get all user, who get this ampel
$result_ampel_user = $this->AmpelModel->execBenutzerSelect($qry_all_ampel_user);
@@ -84,11 +94,21 @@ class AmpelMail extends CLI_Controller
if($this->AmpelModel->isConfirmed($ampel_id, $uid))
continue;
// check if ampel is new (inserted within last week, as cronjob will run every week)
if ($now->diff($insert_date)->days <= 7) $new = true;
/**
* check if ampel is new
* inserted within last week, as cronjob will run every week
* OR if ampel is dauerampel (cannot be overdued -> treat always as new)
* */
if (($now->diff($insert_date)->days <= 7) || $dauerampel)
{
$new = true;
}
//check if ampel is overdue
if ($now > $deadline) $overdue = true;
// check if ampel is overdue
if (($now > $deadline) && !$dauerampel)
{
$overdue = true;
}
// if ampel is new
if ($new)
+29 -8
View File
@@ -16,27 +16,48 @@ class Ampel_model extends DB_Model
* 1. not after the deadline date
* 2. not before the vorlaufszeit
* @param bool $email If true, then only ampeln are retrieved that are marked to be sent by mail.
* @param bool $dauerampel
* @return array Returns array of objects.
*/
public function active($email = false)
public function active($ampel_id = null, $email = null, $dauerampel = null)
{
$parametersArray = null;
$query = '
SELECT *
FROM public.tbl_ampel
WHERE';
if ($email === true)
if (is_numeric($ampel_id))
{
$parametersArray['ampel_id'] = $ampel_id;
$query .= ' ampel_id = ? AND';
}
if (is_bool($email))
{
$parametersArray['email'] = $email;
$query .= ' email = ? AND';
}
if (is_bool($dauerampel))
{
$parametersArray['dauerampel'] = $dauerampel;
$query .= ' dauerampel = ? AND';
}
$query .= '(
(NOW()<(deadline+(COALESCE(verfallszeit,0) || \' days\')::interval)::date)
OR (verfallszeit IS NULL)
AND (NOW()>(deadline-(COALESCE(vorlaufzeit,0) || \' days\')::interval)::date)
OR (vorlaufzeit IS NULL AND NOW() < deadline))';
$query .= ' (
/* now < ( deadline + verfallszeit ) */
NOW() < (deadline + (COALESCE(verfallszeit, 0) || \' days\')::interval)::date
/* oder keine verfallszeit */
OR verfallszeit IS NULL
)
AND
(
/* now > ( deadline - vorlaufzeit ) */
NOW() > (deadline - (COALESCE(vorlaufzeit, 0) || \' days\')::interval)::date
/* oder keine vorlaufzeit (ab sofort) */
OR vorlaufzeit IS NULL
)';
$query .= ' ORDER BY deadline DESC';
+8 -3
View File
@@ -219,7 +219,8 @@ function getUserAmpelData($user)
'verfallszeit' => $row->verfallszeit,
'beschreibung' => $row->beschreibung,
'abgelaufen' => $abgelaufen,
'active' => $active);
'active' => $active,
'dauerampel' => $row->dauerampel);
}
return array($user_ampel_arr, $cnt_ueberfaellig);
@@ -458,8 +459,10 @@ function typeWrite(span){
<?php echo $user_ampel['kurzbz'] ?>
</a>
</h5>
<small <?php if ($user_ampel['status'] == 'rot' && !$user_ampel['abgelaufen']) echo 'style="color: red; font-weight : bold;"'?>><?php echo $p->t('global/faelligAm') . ' '; echo date('d.m.Y', strtotime($user_ampel['deadline'])) ?></small>
</div>
<?php if ($user_ampel['dauerampel'] == false): ?>
<small <?php if ($user_ampel['status'] == 'rot' && !$user_ampel['abgelaufen']) echo 'style="color: red; font-weight : bold;"'?>><?php echo $p->t('global/faelligAm') . ' '; echo date('d.m.Y', strtotime($user_ampel['deadline'])) ?></small>
<?php endif; ?>
</div>
<div class="col-xs-2">
<?php echo $user_ampel['status_ampel'] ?>
</div>
@@ -489,11 +492,13 @@ function typeWrite(span){
<div class="panel-body" style="font-size: 12px;">
<?php echo $user_ampel['beschreibung'][$sprache] ?>
<p><br></p>
<?php if ($user_ampel['dauerampel'] == false): ?>
<form method="POST" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']) . '?ampel_id='. urlencode($user_ampel['ampel_id']) . '&type=bestaetigen'; ?>">
<button type="type" type="submit" class="btn btn-default pull-right"
<?php if ($user_ampel['abgelaufen'] || $user_ampel['bestaetigt']) echo 'disabled data-toggle="tooltip" data-placement="top" title="' . $p->t('tools/ampelBestaetigtAbgelaufen'). '"'?>><?php echo $p->t('global/bestaetigen') ?>
</button>
</form>
<?php endif; ?>
</div>
</div>
</div>
+590 -579
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -1685,6 +1685,19 @@ if($result = @$db->db_query("SELECT * FROM information_schema.role_table_grants
}
}
// dauerampel fuer public.tbl_ampel
if(!@$db->db_query("SELECT dauerampel FROM public.tbl_ampel LIMIT 1"))
{
$qry = "ALTER TABLE public.tbl_ampel ADD COLUMN dauerampel boolean NOT NULL DEFAULT false;
COMMENT ON COLUMN public.tbl_ampel.dauerampel IS 'If true, the ampel is valid until benutzerselect condition no longer applies';
";
if(!$db->db_query($qry))
echo '<strong>App: '.$db->db_last_error().'</strong><br>';
else
echo '<br>Neue Spalte dauerampel in public.tbl_ampel hinzugefügt';
}
/**
* Kommentare fuer Datenbanktabellen
+281 -250
View File
@@ -1,250 +1,281 @@
<?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 < andreas.oesterreicher@technikum-wien.at >
* Cristina Hainberger <hainberg@technikum-wien.at>
*/
/**
* Seite zur Wartung der Ampeln
*/
require_once('../../config/vilesci.config.inc.php');
require_once('../../include/ampel.class.php');
require_once('../../include/benutzerberechtigung.class.php');
require_once('../../include/datum.class.php');
if (!$db = new basis_db())
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
$user = get_uid();
$rechte = new benutzerberechtigung();
$rechte->getBerechtigungen($user);
if(!$rechte->isBerechtigt('basis/ampel'))
die($rechte->errormsg);
$datum_obj = new datum();
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ampel - Details</title>
<link rel="stylesheet" href="../../skin/fhcomplete.css" type="text/css">
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">
<link rel="stylesheet" href="../../vendor/components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../../vendor/components/jqueryui/themes/base/jquery-ui.min.css">
<script type="text/javascript" src="../../vendor/components/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../vendor/components/jqueryui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../../vendor/christianbach/tablesorter/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="../../vendor/twbs/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../include/js/jquery.ui.datepicker.translation.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$( ".datepicker_datum" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd.mm.yy',
});
});
</script>
<style>
/*remove input type="date" arrows*/
input[type=date]::-webkit-inner-spin-button,
input[type=date]::-webkit-outer-spin-button {
-webkit-appearance: none;
}
</style>
</head>
<body>
<?php
$action = (isset($_GET['action'])?$_GET['action']:'new');
$ampel_id = (isset($_REQUEST['ampel_id'])?$_REQUEST['ampel_id']:'');
$ampel = new ampel();
if($action=='save')
{
$kurzbz = (isset($_POST['kurzbz'])?$_POST['kurzbz']:die('Kurzbz fehlt'));
$beschreibung = '';
$buttontext = '';
foreach ($_POST as $key=>$value)
{
if(mb_strstr($key,'beschreibung'))
{
$idx = mb_substr($key, mb_strlen('beschreibung'));
$beschreibung[$idx] = $value;
}
elseif(mb_strstr($key,'buttontext'))
{
$idx = mb_substr($key, mb_strlen('buttontext'));
$buttontext[$idx] = $value;
}
}
$benutzer_select = (isset($_POST['benutzer_select'])?$_POST['benutzer_select']:die('Benutzer_select fehlt'));
$deadline = (isset($_POST['deadline'])?$_POST['deadline']:die('Deadline fehlt'));
$vorlaufzeit = (isset($_POST['vorlaufzeit'])?$_POST['vorlaufzeit']:die('Vorlaufzeit fehlt'));
$verfallszeit = (isset($_POST['verfallszeit'])?$_POST['verfallszeit']:die('verfallszeit fehlt'));
$email = isset($_POST['email']);
$verpflichtend = isset($_POST['verpflichtend']);
$new = (isset($_POST['new'])?$_POST['new']:'true');
if($new=='true')
{
$ampel->insertamum=date('Y-m-d H:i:s');
$ampel->insertvon = $user;
$ampel->new = true;
}
else
{
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
$ampel->new=false;
}
$ampel->kurzbz=$kurzbz;
$ampel->beschreibung = $beschreibung;
$ampel->benutzer_select = $benutzer_select;
$ampel->deadline = $datum_obj->formatDatum($deadline,'Y-m-d');
$ampel->vorlaufzeit = $vorlaufzeit;
$ampel->verfallszeit = $verfallszeit;
$ampel->email = $email;
$ampel->verpflichtend = $verpflichtend;
$ampel->buttontext = $buttontext;
$ampel->updateamum = date('Y-m-d H:i:s');
$ampel->updatevon = $user;
if($ampel->save())
{
echo '<span class="ok">Daten erfolgreich gespeichert</span>';
echo "<script type='text/javascript'>\n";
echo " parent.uebersicht_ampel.location.href='ampel_uebersicht.php';";
echo "</script>\n";
$action='update';
$ampel_id = $ampel->ampel_id;
}
else
{
$action='new';
echo '<span class="error">'.$ampel->errormsg.'</span>';
}
}
echo '<fieldset>';
switch($action)
{
case 'new':
echo '<legend>Neu</legend>';
$new = 'true';
break;
case 'update':
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
echo "<legend>Bearbeiten von ID $ampel_id</legend>";
$new = 'false';
break;
case 'copy':
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
echo "<legend>Kopieren von ID $ampel_id</legend>";
$new = 'true';
$ampel->ampel_id='';
break;
default:
die('Invalid Action');
break;
}
echo '<form action="'.$_SERVER['PHP_SELF'].'?action=save" method="POST">
<input type="hidden" name="new" value="'.htmlspecialchars($new).'">
<input type="hidden" name="ampel_id" value="'.htmlspecialchars($ampel->ampel_id).'">
<table>
<tr>
<td>Kurzbz (64)</td>
<td><input type="text" name="kurzbz" size="60" maxlength="64" value="'.htmlspecialchars($ampel->kurzbz).'" required></td>
<td></td>
<td>Deadline&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Die Deadline gibt den Tag an, ab dem die Ampel von gelb auf rot gesetzt wird."></i>
</td>
<td><input type="text" class="datepicker_datum" name="deadline" size="10" maxlength="10" value="'.htmlspecialchars($datum_obj->formatDatum($ampel->deadline,'Y-m-d')).'" required></td>
</tr>
<tr valign="top">
<td rowspan="3">Benutzer Select</td>
<td rowspan="3"><textarea name="benutzer_select" cols="60" rows="5" required>'.htmlspecialchars($ampel->benutzer_select).'</textarea></td>
<td></td>
<td valign="middle">Vorlaufzeit (in Tagen)&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Anzahl der Tage VOR der Deadline, an denen die Ampel gezeigt werden soll.&#013Wenn keine Angabe, dann wird die Ampel gleich nach ihrer Erstellung angezeigt."></i>
</td>
<td valign="middle"><input type="text" name="vorlaufzeit" size="4" maxlength="4" value="'.htmlspecialchars($ampel->vorlaufzeit).'"></td>
</tr>
<tr valign="top">
<td></td>
<td>Verfallszeit (in Tagen)&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Anzahl der Tage NACH der Deadline, an denen die Ampel gezeigt werden soll.&#013Wenn keine Angabe, dann wird die Ampel solange angezeigt, bis sie bestätigt wird."></i>
</td>
<td><input type="text" name="verfallszeit" size="4" maxlength="4" value="'.htmlspecialchars($ampel->verfallszeit).'"></td>
</tr>
<tr valign="top">
<td></td>
<td>Erinnerung per Email</td>
<td><input type="checkbox" name="email" '.($db->db_parse_bool($ampel->email)?'checked':'').'></td>
</tr>
<tr valign="top">
<td></td>
<td></td>
<td></td>
<td>Verpflichtend</td>
<td><input type="checkbox" name="verpflichtend" '.($db->db_parse_bool($ampel->verpflichtend)?'checked':'').'></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Beschreibung</td>
<td>&nbsp;</td>
<td>Buttonbeschriftung (64)</td>
<td>&nbsp;</td>
</tr>';
$sprache = new sprache();
$sprache->getAll(null, 'index');
foreach($sprache->result as $lang)
{
//only show languages which are set true
if ($lang->content == true)
{
echo '
<tr valign="top">
<td>'.$lang->sprache.'</td>
<td><textarea name="beschreibung'.$lang->sprache.'" cols="60" rows="5">'.htmlspecialchars((isset($ampel->beschreibung[$lang->sprache])?$ampel->beschreibung[$lang->sprache]:'')).'</textarea></td>
<td></td>
<td colspan="2"><input size="70" maxlength="64" name="buttontext'.$lang->sprache.'" value="'.htmlspecialchars((isset($ampel->buttontext[$lang->sprache])?$ampel->buttontext[$lang->sprache]:'')).'"></td>
</tr>';
}
}
echo '
<tr valign="bottom">
<td colspan="5"><input type="submit" value="Speichern" name="save"></td>
</tr>
</table></form>';
echo '</fieldset>';
?>
</body>
</html>
<?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 < andreas.oesterreicher@technikum-wien.at >
* Cristina Hainberger <hainberg@technikum-wien.at>
*/
/**
* Seite zur Wartung der Ampeln
*/
require_once('../../config/vilesci.config.inc.php');
require_once('../../include/ampel.class.php');
require_once('../../include/benutzerberechtigung.class.php');
require_once('../../include/datum.class.php');
if (!$db = new basis_db())
die('Es konnte keine Verbindung zum Server aufgebaut werden.');
$user = get_uid();
$rechte = new benutzerberechtigung();
$rechte->getBerechtigungen($user);
if(!$rechte->isBerechtigt('basis/ampel'))
die($rechte->errormsg);
$datum_obj = new datum();
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Ampel - Details</title>
<link rel="stylesheet" href="../../skin/fhcomplete.css" type="text/css">
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">
<link rel="stylesheet" href="../../vendor/components/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="../../vendor/components/jqueryui/themes/base/jquery-ui.min.css">
<script type="text/javascript" src="../../vendor/components/jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../vendor/components/jqueryui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../../vendor/christianbach/tablesorter/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="../../vendor/twbs/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../include/js/jquery.ui.datepicker.translation.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$( ".datepicker_datum" ).datepicker({
changeMonth: true,
changeYear: true,
dateFormat: 'dd.mm.yy',
});
// if dauerampel is checked, disable verpflichtend
$('#dauerampel').click(function(){
if (this.checked) {
$("#verpflichtend").attr("disabled", true);
} else {
$("#verpflichtend").attr("disabled", false);
}
})
});
</script>
<style>
/*remove input type="date" arrows*/
input[type=date]::-webkit-inner-spin-button,
input[type=date]::-webkit-outer-spin-button {
-webkit-appearance: none;
}
</style>
</head>
<body>
<?php
$action = (isset($_GET['action'])?$_GET['action']:'new');
$ampel_id = (isset($_REQUEST['ampel_id'])?$_REQUEST['ampel_id']:'');
$ampel = new ampel();
if($action=='save')
{
$kurzbz = (isset($_POST['kurzbz'])?$_POST['kurzbz']:die('Kurzbz fehlt'));
$beschreibung = '';
$buttontext = '';
foreach ($_POST as $key=>$value)
{
if(mb_strstr($key,'beschreibung'))
{
$idx = mb_substr($key, mb_strlen('beschreibung'));
$beschreibung[$idx] = $value;
}
elseif(mb_strstr($key,'buttontext'))
{
$idx = mb_substr($key, mb_strlen('buttontext'));
$buttontext[$idx] = $value;
}
}
$benutzer_select = (isset($_POST['benutzer_select'])?$_POST['benutzer_select']:die('Benutzer_select fehlt'));
$dauerampel = (isset($_POST['dauerampel']));
$deadline = (isset($_POST['deadline'])?$_POST['deadline']:die('Deadline fehlt'));
$vorlaufzeit = (isset($_POST['vorlaufzeit'])?$_POST['vorlaufzeit']:die('Vorlaufzeit fehlt'));
$verfallszeit = (isset($_POST['verfallszeit'])?$_POST['verfallszeit']:die('verfallszeit fehlt'));
$email = isset($_POST['email']);
$verpflichtend = isset($_POST['verpflichtend']);
$new = (isset($_POST['new'])?$_POST['new']:'true');
if($new=='true')
{
$ampel->insertamum=date('Y-m-d H:i:s');
$ampel->insertvon = $user;
$ampel->new = true;
}
else
{
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
$ampel->new=false;
}
$ampel->kurzbz=$kurzbz;
$ampel->beschreibung = $beschreibung;
$ampel->benutzer_select = $benutzer_select;
$ampel->deadline = $datum_obj->formatDatum($deadline,'Y-m-d');
$ampel->vorlaufzeit = $vorlaufzeit;
$ampel->verfallszeit = $verfallszeit;
$ampel->email = $email;
$ampel->verpflichtend = $verpflichtend;
$ampel->buttontext = $buttontext;
$ampel->updateamum = date('Y-m-d H:i:s');
$ampel->updatevon = $user;
$ampel->dauerampel = $dauerampel;
if($ampel->save())
{
echo '<span class="ok">Daten erfolgreich gespeichert</span>';
echo "<script type='text/javascript'>\n";
echo " parent.uebersicht_ampel.location.href='ampel_uebersicht.php';";
echo "</script>\n";
$action='update';
$ampel_id = $ampel->ampel_id;
}
else
{
$action='new';
echo '<span class="error">'.$ampel->errormsg.'</span>';
}
}
echo '<fieldset>';
switch($action)
{
case 'new':
echo '<legend>Neu</legend>';
$new = 'true';
break;
case 'update':
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
echo "<legend>Bearbeiten von ID $ampel_id</legend>";
$new = 'false';
break;
case 'copy':
if(!$ampel->load($ampel_id))
die($ampel->errormsg);
echo "<legend>Kopieren von ID $ampel_id</legend>";
$new = 'true';
$ampel->ampel_id='';
break;
default:
die('Invalid Action');
break;
}
echo '<form action="'.$_SERVER['PHP_SELF'].'?action=save" method="POST">
<input type="hidden" name="new" value="'.htmlspecialchars($new).'">
<input type="hidden" name="ampel_id" value="'.htmlspecialchars($ampel->ampel_id).'">
<table>
<tr>
<td>Kurzbz (64)</td>
<td><input type="text" name="kurzbz" size="60" maxlength="64" value="'.htmlspecialchars($ampel->kurzbz).'" required></td>
<td></td>
<td>Dauerampel
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Eine Dauerampel kann nicht bestätigt werden. Sie läuft solange der Benutzerselect gilt und die Ampel aktiv (innerhalb Vorlauf- und Verfallszeit) ist."></i>
</td>
<td><input type="checkbox" id="dauerampel" name="dauerampel" '. ($db->db_parse_bool($ampel->dauerampel) ? 'checked' : ''). '></td>
</tr>
<tr valign="top">
<td rowspan="3">Benutzer Select</td>
<td rowspan="3"><textarea name="benutzer_select" cols="60" rows="5" required>'.htmlspecialchars($ampel->benutzer_select).'</textarea></td>
<td></td>
<td valign="middle">Deadline&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Die Deadline gibt den Tag an, ab dem die Ampel von gelb auf rot gesetzt wird."></i>
</td>
<td><input type="text" class="datepicker_datum" name="deadline" size="10" maxlength="10" value="'.htmlspecialchars($datum_obj->formatDatum($ampel->deadline,'Y-m-d')).'" required></td>
</tr>
<tr valign="top">
<td></td>
<td valign="middle">Vorlaufzeit (in Tagen)&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Anzahl der Tage VOR der Deadline, an denen die Ampel gezeigt werden soll.&#013Wenn keine Angabe, dann wird die Ampel gleich nach ihrer Erstellung angezeigt."></i>
</td>
<td valign="middle"><input type="text" name="vorlaufzeit" size="4" maxlength="4" value="'.htmlspecialchars($ampel->vorlaufzeit).'"></td>
</tr>
<tr valign="top">
<td></td>
<td>Verfallszeit (in Tagen)&nbsp
<i class="fa fa-info-circle fa-lg" aria-hidden="true" data-toggle="tooltip" data-placement="left" title="Anzahl der Tage NACH der Deadline, an denen die Ampel gezeigt werden soll.&#013Wenn keine Angabe, dann wird die Ampel solange angezeigt, bis sie bestätigt wird."></i>
</td>
<td><input type="text" name="verfallszeit" size="4" maxlength="4" value="'.htmlspecialchars($ampel->verfallszeit).'"></td>
</tr>
<tr valign="top">
<td></td>
<td></td>
<td></td>
<td>Erinnerung per Email</td>
<td><input type="checkbox" name="email" '.($db->db_parse_bool($ampel->email)?'checked':'').'></td>
</tr>
<tr valign="top">
<td></td>
<td></td>
<td></td>
<td>Verpflichtend</td>
<td>
<input type="checkbox" id="verpflichtend" name="verpflichtend" '.
($db->db_parse_bool($ampel->verpflichtend) ? "checked" : "" ).
($db->db_parse_bool($ampel->dauerampel) ? "disabled" : ""). '>
</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>Beschreibung</td>
<td>&nbsp;</td>
<td>Buttonbeschriftung (64)</td>
<td>&nbsp;</td>
</tr>';
$sprache = new sprache();
$sprache->getAll(null, 'index');
foreach($sprache->result as $lang)
{
//only show languages which are set true
if ($lang->content == true)
{
echo '
<tr valign="top">
<td>'.$lang->sprache.'</td>
<td><textarea name="beschreibung'.$lang->sprache.'" cols="60" rows="5">'.htmlspecialchars((isset($ampel->beschreibung[$lang->sprache])?$ampel->beschreibung[$lang->sprache]:'')).'</textarea></td>
<td></td>
<td colspan="2"><input size="70" maxlength="64" name="buttontext'.$lang->sprache.'" value="'.htmlspecialchars((isset($ampel->buttontext[$lang->sprache])?$ampel->buttontext[$lang->sprache]:'')).'"></td>
</tr>';
}
}
echo '
<tr valign="bottom">
<td colspan="5"><input type="submit" value="Speichern" name="save"></td>
</tr>
</table></form>';
echo '</fieldset>';
?>
</body>
</html>
+28 -8
View File
@@ -41,11 +41,11 @@ echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<link rel="stylesheet" href="../../skin/tablesort.css" type="text/css"/>
<link rel="stylesheet" href="../../skin/fhcomplete.css" type="text/css">
<link rel="stylesheet" href="../../skin/vilesci.css" type="text/css">
<link rel="stylesheet" type="text/css" href="../../skin/jquery-ui-1.9.2.custom.min.css">
<script type="text/javascript" src="../../vendor/jquery/jqueryV1/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="../../vendor/christianbach/tablesorter/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="../../vendor/components/jqueryui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../../include/js/jquery.ui.datepicker.translation.js"></script>
<link rel="stylesheet" type="text/css" href="../../skin/jquery-ui-1.9.2.custom.min.css">
<script type="text/javascript" src="../../vendor/jquery/jqueryV1/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="../../vendor/christianbach/tablesorter/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="../../vendor/components/jqueryui/jquery-ui.min.js"></script>
<script type="text/javascript" src="../../include/js/jquery.ui.datepicker.translation.js"></script>
<script type="text/javascript" src="../../vendor/jquery/sizzle/sizzle.js"></script>
<script type="text/javascript">
@@ -67,9 +67,13 @@ echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
</head>
<body>
<h2>Ampel &Uuml;bersicht</h2>
<div style="text-align:right">
<div>
<a href="ampel_uebersicht.php?action=active" target="">Nur aktive | </a>
<a href="ampel_uebersicht.php?action=all" target="">Alle | </a>
<a href="ampel_details.php?action=new" target="detail_ampel">Neu</a>
</div>';
if(isset($_GET['action']) && $_GET['action']=='delete')
{
if(!$rechte->isBerechtigt('basis/ampel', null, 'suid'))
@@ -87,14 +91,29 @@ if(isset($_GET['action']) && $_GET['action']=='delete')
$ampel = new ampel();
if(!$ampel->getAll())
die($ampel->errormsg);
// nur bei Auswahl 'Alle' alle Ampeln zeigen
if (isset($_GET['action']) && $_GET['action'] == 'all')
{
if(!$ampel->getAll())
{
die($ampel->errormsg);
}
}
// default: nur aktive Ampeln zeigen
else
{
if(!$ampel->getAll(true))
{
die($ampel->errormsg);
}
}
echo '<table class="tablesorter" id="myTable">
<thead>
<tr>
<th>ID</th>
<th>Kurzbz</th>
<th>Dauerampel</th>
<th>Deadline</th>
<th>Vorlaufzeit</th>
<th>Verfallszeit</th>
@@ -109,6 +128,7 @@ foreach($ampel->result as $row)
echo '<tr>';
echo '<td><a href="ampel_details.php?action=update&ampel_id=',$row->ampel_id,' " target="detail_ampel">',$row->ampel_id,'</a></td>';
echo '<td>',$row->kurzbz,'</td>';
echo '<td>',($row->dauerampel == 't' ? 'Ja' : 'Nein'),'</td>';
echo '<td>',$datum_obj->formatDatum($row->deadline,'d.m.Y'),'</td>';
echo '<td>',$row->vorlaufzeit,'</td>';
echo '<td>',$row->verfallszeit,'</td>';