Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
timerec3public/zeittyp.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
124 lines (118 sloc)
5.28 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Zeittypen</title> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
<link rel="shortcut icon" href="favicon.ico"> | |
</head> | |
<body> | |
<?php | |
session_start(); | |
if(!$_SESSION['userid']){ | |
session_destroy(); | |
include('login.php'); | |
exit; | |
} | |
$infoarray = $_SESSION['infoarray']; | |
$userarray = $_SESSION['userarray']; | |
include('dbconnect.php'); | |
if(!$_SESSION['userarray']){ | |
header('Location: index.php'); | |
} | |
if(!$_SESSION['userarray']['admin']){ | |
echo "<h3>keine Rechte, diese Seite einzusehen!</h3>"; | |
exit; | |
} | |
if(!empty($_POST)){ | |
//update | |
foreach($_POST as $id=>$post){ | |
$id = substr($id, 0, -1); //unterstrich entfernen | |
if($id != "neu" && $id != "del"){ | |
$update = "update zeittyp set zt_ID = $post[zt_ID], zt_bez = '$post[zt_bez]', zt_op = '$post[zt_op]' where zt_ID = $id;"; | |
$update = str_replace("''", "NULL", $update); //leere einträge mit NULL füllen statt mit '' | |
//echo $update."<br>"; | |
$dbc->query($update); | |
if($dbc->error){ | |
echo "<h3 class='red'>ERROR: ".$dbc->error."</h3>"; | |
exit; | |
} | |
}elseif($id == "neu" && !empty($post['zt_ID'])){ | |
$insert = "insert into zeittyp (zt_ID, zt_bez, zt_op) values ($post[zt_ID], '$post[zt_bez]', '$post[zt_op]');"; | |
$insert = str_replace("''", "NULL", $insert); //leere einträge mit NULL füllen statt mit '' | |
//echo $insert."<br>"; | |
$dbc->query($insert); | |
if($dbc->error){ | |
echo "<h3 class='red'>ERROR: ".$dbc->error."</h3>"; | |
exit; | |
} | |
} | |
if($id == "del"){ | |
$delete = "delete from zeittyp where zt_ID in ("; | |
foreach($post as $delitem){ | |
$delete .= "$delitem, "; | |
} | |
$delete = substr($delete, 0, -2); | |
$delete .= ");"; | |
//echo $delete."<br>"; | |
$dbc->query($delete); | |
if($dbc->error){ | |
echo "<h3 class='red'>ERROR: ".$dbc->error."</h3>"; | |
exit; | |
} | |
} | |
} | |
header('Location: zeittyp.php?success=true'); | |
} | |
echo "<div id='headline'> | |
<div id='home'> | |
<a href='index.php?ma=".$infoarray['maID']."'><button><< Menü</button></a> | |
</div> | |
<div id='back'><a href='zeittyp.php'><button>Abbrechen</button></a></div> | |
<b>Zeittypen</b> | |
<div id='forward'><button type='submit' form='azmodell' onclick='return confirm(\"Sicher?\")'>Speichern</button></div> | |
<div class='scroll down' onclick='window.scrollTo(0,document.documentElement.scrollHeight)'>runter ↓</div> | |
<div class='scroll up' onclick='window.scrollTo(0,0)'>↑ rauf</div> | |
</div>"; | |
echo "<form id='azmodell' style='width: 34%; margin-left: -17%;' method='post' action=''>"; | |
if($_GET['success'] === 'true') echo "<h3 class='light-green'>SUCCESS!</h3>"; | |
echo "<b>Tabelle ist editierbar!</b> // Suchen per Strg+F | |
<table> | |
<tr> | |
<th>ID</th> | |
<th>Bezeichnung</th> | |
<th>Gleitzeit Stunden <span class='help' title='Bei Gleitzeit werden Stunden entsprechend dem Tagessoll addiert (+) oder subtrahiert (-).\n Beispiel: Bei Urlaub darf der Saldo trotz Nicht-Erscheinens nicht verändert werden, es muss also ein \"+\" gesetzt werden.'>(?)</span><br> + / - </th> | |
<td class='help centered red' title='zum Löschen Haken setzen'>X</td> | |
</tr>"; | |
$gettyp = $dbc->query("select * from zeittyp;"); | |
$switch = true; | |
foreach($gettyp as $typ){ | |
if($switch){ | |
$color = "line1"; | |
}else{ | |
$color = "line2"; | |
} | |
$switch = !$switch; | |
echo "<tr class='$color'>"; | |
$key = $typ['zt_ID']; | |
if(in_array($key, array(0, 9, 10, 20))){ | |
$disabled = "disabled"; | |
}else{ | |
$disabled = ""; | |
} | |
echo "<td class='narrow'><div><input type='number' $disabled name='$key [zt_ID]' value='".$typ['zt_ID']."'></div></td>"; | |
echo "<td><div><input type='text' $disabled name='$key [zt_bez]' value='".$typ['zt_bez']."'></div></td>"; | |
echo "<td class='narrow'><div><input $disabled type='text' pattern='[\+|\-]{1}' maxlength='1' title='Muss leer, plus (+) oder minus (-) enthalten' name='$key [zt_op]' value='".$typ['zt_op']."'></div></td>"; | |
echo "<td class='centered'><input id='deletebox$key' type='checkbox' $disabled onclick='if(this.checked) alert(\"Dies LÖSCHT den Eintrag!\")' class='checkbox' name='del []' value='$key'><label for='deletebox$key'></label></td>"; | |
echo "</tr>"; | |
} | |
echo "<tr class='topline'><td colspan='10'></td></tr> | |
<tr> | |
<td class='narrow'><input type='number' name='neu [zt_ID]' value='' placeholder='neu'></td> | |
<td><div class='longtext'><input type='text' name='neu [zt_bez]' placeholder='name...'></div></td> | |
<td class='narrow'><div><input type='text' pattern='[\+|\-]{1}' maxlength='1' name='neu [zt_op]' placeholder='opt. +/-' title='Muss leer, plus (+) oder minus (-) enthalten'></div></td>"; | |
echo "</table> | |
</form>"; | |
?> | |
</body> | |
</html> |