-
Notifications
You must be signed in to change notification settings - Fork 0
/
food.php
109 lines (102 loc) · 2.57 KB
/
food.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
<?php
require "_core.php";
if(isset($_POST["submit"]) and isset($_POST["type"])) {
if($_POST["type"] === "food") {
$items = [];
foreach($_POST["id"] as $i=>$value) {
$items[$i]["id"] = $value;
}
foreach($_POST["name"] as $i=>$value) {
$items[$i]["name"] = $value;
}
foreach($_POST["buy"] as $i=>$value) {
$items[$i]["buy"] = $value;
}
foreach($_POST["sale"] as $i=>$value) {
$items[$i]["sale"] = $value;
}
// print_r($items);
foreach($items as $item) {
$db->update("foods", ["id"=>$item["id"]], $item);
// $db->insert("plans", $item);
}
}
if($_POST["type"] === "newFood") {
$values = [
"name"=>$_POST["name"],
"buy"=>$_POST["buy"],
"sale"=>$_POST["sale"],
// "count"=>$_POST["count"],
];
$db->insert("foods", $values);
}
}
$foods = $db->selects("foods");
?>
<title>سیستم گیم نت</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<a href="index.php">
برگشت به اتاق فرمان
</a>
<br>
<center>
<h1>ویرایش انبار</h1>
</center>
<form action="" method="POST">
<table width="100%" dir="rtl" border="1">
<tr>
<td>اسم</td>
<td>قیمت خرید</td>
<td>قیمت فروش</td>
<!-- <td>تعداد</td> -->
<!-- <td>مدیریت</td> -->
</tr>
<?php foreach($foods as $food) { ?>
<tr>
<td>
<input type="hidden" name="id[]" value="<?= $food["id"]?>">
<input type="text" name="name[]" value="<?= $food["name"]?>">
</td>
<td>
<input type="text" name="buy[]" value="<?= $food["buy"]?>"> تومان
</td>
<td>
<input type="number" name="sale[]" value="<?= $food["sale"]?>"> تومان
</td>
<!-- <td> -->
<!-- <a href="?type=deletePlan&id=<?= $food["id"] ?>">حذف کردن این پلن</a> -->
<!-- </td> -->
</tr>
<?php } ?>
</table>
<input type="hidden" name="type" value="food">
<button name="submit">ذخیره</button>
</form>
<center>
<h1>درج جنس جدید</h1>
</center>
<form action="" method="POST">
<table width="100%" dir="rtl" border="1">
<tr>
<td>اسم</td>
<td>
<input type="text" name="name" required="">
</td>
</tr>
<tr>
<td>قیمت خرید </td>
<td>
<input type="number" name="buy" required=""> تومان
</td>
</tr>
<tr>
<td>قیمت فروش</td>
<td>
<input type="number" name="sale" required=""> تومان
</td>
</tr>
</table>
<input type="hidden" name="type" value="newFood">
<button name="submit">درج</button>
</form>