-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathartikel_kaufen_backup.php
135 lines (113 loc) · 4.68 KB
/
artikel_kaufen_backup.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
125
126
127
128
129
130
131
132
133
134
135
<?php
$checkme = "a30ee472364c50735ad1d43cc09be0a1";
require_once "include/constant.php";
$pageRestricted = false; // defines if the page is restricted to logged-in Users only
$userLevel = ""; // uses a PERM_ const now and hasPermission($userLevel) now if fails a 403 Error-Page is returned
$title = "Bestellübersicht"; // defines the name of the current page, displayed in the title and as a header on the page
include "include/init.php"; // includes base function like session handling
include "include/page/top.php"; // top-part of html-template (stylesheets, navigation, ..)
//POST & SESSION
$amount = $_POST["amount"];
$articleID = $_POST["update"];
$employee=$_SESSION[USER_ID];
// Time and Date
$time = time();
$date = date("Y-m-d", $time);
//SQL Abfragen und Variable $orderID befüllen
//Name und Wert des Artikels und LieferantenID aus der DB auslesen
$sql = "SELECT article.name , article.price, article.supplierUserFID as supplier FROM article WHERE article.objectID=$articleID ";
$db = connectDB();
$statement = $db->query($sql);
while ($row = $statement->fetch()) {
$supplierID = $row["supplier"];
$articleName = $row["name"];
$articlePrice = $row["price"];
}
$wholeAmount = $articlePrice * $amount;
//Bestellerdaten auslesen (user)
$sql = "SELECT user.branchName, user.email, user.street, user.houseNumber,user.stairs, user.door, user.postCode, user.city, user.country FROM user
WHERE objectID=$employee";
$statement = $db->query($sql);
while ($row = $statement->fetch()) {
$email = $row["email"];
$branchName = $row["branchName"];
$street = $row["street"];
$house = $row["houseNumber"];
$stairs = $row["stairs"];
$door = $row["door"];
$PLZ = $row["postCode"];
$city = $row["city"];
$country = $row["country"];
}
//order Tabelle befüllen
$sql = "INSERT INTO `order`
(employeeUserFID, dateTime, supplierUserFID)
VALUES
(:employee, :date, :supplier)";
$statement = $db->prepare($sql);
$statement->bindParam(":employee", $employee);
$statement->bindParam(":supplier", $supplierID);
$statement->bindParam(":date", $date);
$statement->execute();
//orderID abfragen
$orderID = $db->lastInsertId();
// Bestellung in die orderitems Tabelle einfügen
$sql = "INSERT INTO orderitems
(count, articleFID, price, orderFID)
VALUES
(:count, :articleFID, :price, :order)";
$statement = $db->prepare($sql);
$statement->bindParam(":count",$amount);
$statement->bindParam(":articleFID", $articleID);
$statement->bindParam(":price", $wholeAmount);
$statement->bindParam(":order", $orderID);
$statement->execute();
?>
<div class="container-fluid">
<h1 class="h3 mb-4 text-gray-800"><?php echo $title ?></h1>
<div class="content">
<div class="row">
<div class="col-md-4">
<!-- Content -->
<table id="overview">
<tr>
<th>Stück</th>
<td><?php echo $amount ?></td>
</tr>
<tr>
<th>Artikel</th>
<td><?php echo $articleName ?></td>
</tr>
<tr>
<th>Stückpreis</th>
<td><?php echo number_format($articlePrice,2,',','\'')." €"; ?></td>
</tr>
<tr>
<th>Gesamtpreis</th>
<td><?php echo number_format($wholeAmount,2,',','\'')." €"; ?></td>
</tr>
<tr>
<th>Benutzer</th>
<td><?php echo $email ?></td>
</tr>
<tr>
<th>Filiale</th>
<td><?php echo $branchName ?></td>
</tr>
<tr>
<th>Adresse</th>
<td><?php echo "$street $house , $PLZ $city $country"; ?></td>
</tr>
</table>
<hr>
<form action="DOMpdf.php" target="_blank" method="POST">
<input type="hidden" name="orderID" value="<?php echo $orderID ?>">
<button name="pdf" title="PDF Datei: Bestellung, öffnet in neuem Fenster." class="btn btn-danger form-button">
<i class="fas fa-file-pdf"></i> PDF
</button>
</form>
</div>
</div>
</div>
</div>
<?php include "include/page/bottom.php"; // bottom-part of html-template (footer, scripts, .. ) ?>