-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathaddFoodElement.php
104 lines (69 loc) · 2.84 KB
/
addFoodElement.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
<?php
session_start();
$pageName="Ajouter Aliment";
include_once 'assets/bootstrapAsset.php';
include_once 'autoload.php';
if($_SESSION['role']=='user'){
header('Location:404page.php');
}
$categoryRepo=new FoodCategoryRepository();
if(isset($_POST['addFood'])){
$name=$_POST['name'];
$cat=$_POST['category'];
$allowed=$_POST['permission'];
$catResult=$categoryRepo->findOneBy(array('name' => $cat)) ;
$foodRepo=new FoodAlimentRepository();
$foodRepo->insert(array('name' => $name , 'permission' => $allowed , 'catgeoryId' => $catResult['id'] ));
}
?>
</head>
<body>
<div class="container add">
<div class="add__admin">
<div class="wavy">
<span style="--i:1;">A</span>
<span style="--i:2;">J</span>
<span style="--i:3;">O</span>
<span style="--i:4;">U</span>
<span style="--i:4;">T</span>
<span style="--i:5;">E</span>
<span style="--i:6;">R</span>
<span style="--i:7;"></span>
<span style="--i:8;"></span>
<span style="--i:9;">U</span>
<span style="--i:10;">N</span>
<span style="--i:11;"></span>
<span style="--i:12;"></span>
<span style="--i:13;">E</span>
<span style="--i:14;">L</span>
<span style="--i:15;">E</span>
<span style="--i:16;">M</span>
<span style="--i:17;">E</span>
<span style="--i:18;">N</span>
<span style="--i:19;">T</span>
</div>
<form method="post" action="addFoodElement.php">
<div class="form-group">
<input type="text" class="form-control" name="name" placeholder="Nom Aliment">
</div>
<div class="form-group">
<h6>Catégorie</h6>
<select name="category" id="">
<?php
$categorys=$categoryRepo->findAll();
foreach($categorys as $cat){
?>
<option value="<?php echo $cat['name'] ?>"><?php echo $cat['name'] ?></option>
<?php } ?>
</select>
</div>
<input type="radio" name="permission" value="1" style="margin:0 10px 0 10px"><span>Autorisé</span>
<input type="radio" name="permission" value="0" style="margin:0 10px 0 10px"><span>Non Autorisé</span>
<br><br>
<button type="submit" name="addFood" class="btn btn3">Submit</button>
</form>
</div>
</div>
<script src="js/admin.js"></script>
</body>
</html>