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/ag-list.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
263 lines (254 sloc)
10.5 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>AG Liste</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']['admin']){ | |
echo "<h3>keine Rechte, diese Seite einzusehen!</h3>"; | |
exit; | |
} | |
if(!empty($_POST)){ | |
foreach($_POST as $key=>$post){ | |
$key = substr($key,0,-1); | |
if($key != "neu" && $key != "del"){ | |
$update = "update ag set name = '$post[name]', abk = '$post[abk]', | |
leiter = '$post[leiter]', gn = '$post[gn]', gnv = '$post[gnv]', | |
pr = '$post[pr]', prv = '$post[prv]' | |
where ag_ID = $key;"; | |
$update = str_replace("''", "NULL", $update); | |
$dbc->query($update); | |
if($dbc->error){ | |
echo "<h3 class='red'>UPDATE ERROR: ".$dbc->error."</h3>"; | |
echo $update; | |
exit; | |
} | |
} | |
if($key == "neu" && !empty($post['name'])){ | |
$insert = "insert into ag (name, abk, leiter, gn, gnv, pr, prv) values ('$post[name]', '$post[abk]', '$post[leiter]', '$post[gn]', '$post[gnv]', '$post[pr]', '$post[prv]');"; | |
$insert = str_replace("''", "NULL", $insert); | |
$dbc->query($insert); | |
if($dbc->error){ | |
echo "<h3 class='red'>INSERT ERROR: ".$dbc->error."</h3>"; | |
echo $insert; | |
echo "<br>"; | |
var_dump($post); | |
exit; | |
} | |
} | |
if($key == "del"){ | |
$delete = "delete from ag where ag_ID in ("; | |
foreach($post as $del){ | |
$delete .= "$del, "; | |
} | |
$delete = substr($delete, 0, -2); | |
$delete .= ");"; | |
$dbc->query($delete); | |
if($dbc->error){ | |
echo "<h3 class='red'>DELETE ERROR: ".$dbc->error."</h3>"; | |
echo $delete; | |
exit; | |
} | |
} | |
} | |
header('Location: ag-list.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='ag-list.php'><button>Abbrechen</button></a></div> | |
<b>AG-Liste</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='' method='post' action=''>"; | |
if($_GET['success'] === 'true') echo "<h3 class='light-green'>ERFOLGREICH GESPEICHERT!</h3>"; | |
echo "<b>Tabelle ist editierbar!</b> // Suchen per Strg+F | |
<table> | |
<tr> | |
<th>ID</th> | |
<th>Name</th> | |
<th class='narrow'>Abkürzung</th> | |
<th>Verantwortlichkeiten <span class='help' title='L: Leiter\nGN: Genehmiger\nGNV: Genehmiger Vertreter\nPR: Prüfer\nPRV: Prüfer Vertreter'>(?)</span></th> | |
<td class='red centered'>X</td> | |
</tr>"; | |
$getag = $dbc->query("select ag_ID, name, abk, leiter, gn, gnv, pr, prv from ag order by name;"); | |
$getnames = $dbc->query("select maID, concat(nachname, ', ', vorname) as name from mitarbeiter order by nachname;"); | |
foreach($getnames as $name){ | |
//array mit ID->Name bauen | |
$names[$name['maID']] = $name['name']; | |
} | |
$switch = false; | |
foreach($getag as $ag){ | |
$switch = !$switch; | |
if($switch){ | |
$line = "line1"; | |
}else{ | |
$line = "line2"; | |
} | |
$key = $ag['ag_ID']; | |
echo "<tr class='$line'>"; | |
echo "<td rowspan='6'><input type='hidden' name='$key [ag_ID]' value='$ag[ag_ID]'>$ag[ag_ID]</td> | |
<td rowspan='6'><input type='text' placeholder='hier eingeben...' name='$key [name]' value='$ag[name]'></td> | |
<td rowspan='6'><input type='text' maxlength='5' placeholder='...' name='$key [abk]' value='$ag[abk]'></td> | |
<td class='nullflach'></td> | |
<td rowspan='6' class='centered'><input id='deletebox$key' type='checkbox' onclick='if(this.checked) alert(\"Dies LÖSCHT den Eintrag!\")' class='checkbox' name='del []' value='$key'><label for='deletebox$key'></label></td> | |
<tr> | |
<td class='notopborder topline'> | |
Leiter: | |
<select onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat' name='$key [leiter]'> | |
<option value=''>- nicht gesetzt -</option>"; | |
foreach($names as $id=>$name){ | |
if($id == $ag['leiter']){ | |
$selected = 'selected'; | |
}else{ | |
$selected = ''; | |
} | |
echo "<option $selected value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td class='green'> | |
Genehmiger: | |
<select onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat' name='$key [gn]'> | |
<option value=''>- nicht gesetzt -</option>"; | |
foreach($names as $id=>$name){ | |
if($id == $ag['gn']){ | |
$selected = 'selected'; | |
}else{ | |
$selected = ''; | |
} | |
echo "<option $selected value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td class='green-half'> | |
Vertreter Genehmiger: | |
<select onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat' name='$key [gnv]'> | |
<option value=''>- nicht gesetzt -</option>"; | |
foreach($names as $id=>$name){ | |
if($id == $ag['gnv']){ | |
$selected = 'selected'; | |
}else{ | |
$selected = ''; | |
} | |
echo "<option $selected value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td class='yellow'> | |
Prüfer: | |
<select onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat' name='$key [pr]'> | |
<option value=''>- nicht gesetzt -</option>"; | |
foreach($names as $id=>$name){ | |
if($id == $ag['pr']){ | |
$selected = 'selected'; | |
}else{ | |
$selected = ''; | |
} | |
echo "<option $selected value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td class='yellow-half'> | |
Vertreter Prüfer: | |
<select onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat' name='$key [prv]'> | |
<option value=''>- nicht gesetzt -</option>"; | |
foreach($names as $id=>$name){ | |
if($id == $ag['prv']){ | |
$selected = 'selected'; | |
}else{ | |
$selected = ''; | |
} | |
echo "<option $selected value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr>"; | |
} | |
echo "<tr class='topline'><td colspan='5'></td></tr>"; | |
echo "<tr> | |
<td rowspan='6'><input type='hidden' name='neu [ag_ID]' value='neu'>neu</td> | |
<td rowspan='6'><input type='text' name='neu [name]' placeholder='neu'></td> | |
<td rowspan='6'><input type='text' maxlength='5' name='neu [abk]' placeholder='neu'></td> | |
<td class='nullflach'></td> | |
</tr>"; | |
echo "<tr> | |
<td class='notopborder'>L: | |
<select name='neu [leiter]' onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat'> | |
<option value=''>- nichts ausgewählt -</option>"; | |
foreach($names as $id=>$name){ | |
echo "<option value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td >GN: | |
<select name='neu [gn]' onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat'> | |
<option value=''>- nichts ausgewählt -</option>"; | |
foreach($names as $id=>$name){ | |
echo "<option value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td >GNV: | |
<select name='neu [gnv]' onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat'> | |
<option value=''>- nichts ausgewählt -</option>"; | |
foreach($names as $id=>$name){ | |
echo "<option value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td >PR: | |
<select name='neu [pr]' onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat'> | |
<option value=''>- nichts ausgewählt -</option>"; | |
foreach($names as $id=>$name){ | |
echo "<option value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
<tr> | |
<td >PRV: | |
<select name='neu [prv]' onmousedown='this.size=10' onblur='this.size=1' class='auswahl rechtsfloat'> | |
<option value=''>- nichts ausgewählt -</option>"; | |
foreach($names as $id=>$name){ | |
echo "<option value='$id'>$name</option>"; | |
} | |
echo "</select> | |
</td> | |
</tr> | |
"; | |
echo "</table> | |
</form>"; | |
?> | |
</body> | |
</html> |