-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeitenklasse_pizzabaecker.php
executable file
·124 lines (106 loc) · 3.42 KB
/
Seitenklasse_pizzabaecker.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
require_once './Page.php';
class Bestellung extends Page
{
protected function __construct() {
parent::__construct();
}
protected function __destruct() {
parent::__destruct();
}
protected function getViewData() {
$sql = "SELECT fBestellungID, PizzaName, fPizzaNummer, PizzaID, Status FROM bestelltepizza
INNER JOIN angebot ON bestelltepizza.fPizzaNummer = angebot.PizzaNummer
ORDER BY fBestellungID";
$recordset = $this->database->query ($sql);
if (!$recordset)
{
throw new Exception("Abfrage fehlgeschlagen: ".$this->database->error);
}
// read selected records into result array
$bestelltepizzen = array();
$record = $recordset->fetch_assoc();
while ($record)
{
$bestelltepizzen[] = $record;
$record = $recordset->fetch_assoc();
}
$recordset->free();
return $bestelltepizzen;
}
private function insert_option($indent, $name){
echo ($indent."<option>".htmlspecialchars($name)."</option>\n");
}
protected function generateView() {
//$pizzen = $this->getViewData();
$this->generatePageHeader('Pizzabäcker');
$bestellungen = $this->getViewData();
echo <<<EOT
<section class="Lieferstatus">
<h2>Pizzabäcker (Lieferstatus)</h2>
EOT;
for($i=0; $i < count($bestellungen); $i++)
{
$checked = '';
if($bestellungen[$i]['Status'] == 'im Ofen') $checked = ' checked';
if($bestellungen[$i]['Status'] == 'im Ofen' || $bestellungen[$i]['Status'] == 'Bestellung eingegangen')
{
echo '<div class="Status">';
echo ' BestellungID: '. htmlspecialchars($bestellungen[$i]['fBestellungID']) .' <br>';
echo ''. htmlspecialchars($bestellungen[$i]['PizzaName']) .': '. htmlspecialchars($bestellungen[$i]['Status']) .'<br><br>';
echo <<<EOT
<span class="span-radio">Im Ofen</span>
<span class="span-radio">fertig</span>
<br>
<form id="fomr'.$i.'" action="Seitenklasse_pizzabaecker.php" method="POST" accept-charset="UTF-8">
<fieldset id="form'.$i.'">
<input type="radio" class="radio" name="radio-status" value="im Ofen" $checked/>
<input type="radio" class="radio" name="radio-status" value="fertig"/>
<br>
<button type="submit" value="$i" name="index_pizzanummer">Update</button>
</fieldset>
</form>
</div>
EOT;
}
}
echo '</section>';
$this->generatePageFooter();
}
protected function processReceivedData() {
parent::processReceivedData();
{
if(isset($_POST['radio-status']))
{
if($_POST['radio-status']=="im Ofen" || $_POST['radio-status']=="fertig")
{
$status= $_POST['radio-status'];
print_r($_POST);
$fbestellungid = mysqli_real_escape_string($this->database, $this->getViewData()[$_POST['index_pizzanummer']]['fBestellungID']);
echo ($fbestellungid);
$pizzaID = mysqli_real_escape_string($this->database, $this->getViewData()[$_POST['index_pizzanummer']]['PizzaID']);
echo ($pizzaID);
$sql= "UPDATE `BestelltePizza` SET `Status`= '$status' WHERE fBestellungID = '$fbestellungid' AND PizzaID = '$pizzaID'";
$recordset = $this->database->query($sql);
if (!$recordset)
{
throw new Exception("UPDATE fehlgeschlagen: ".$this->database->error);
}
}
}
}
}
public static function main() {
try {
$page = new Bestellung();
$page->processReceivedData();
$page->generateView();
}
catch (Exception $e) {
header("Content-type: text/plain; charset=UTF-8");
echo $e->getMessage();
}
}
}
Bestellung::main();
?>