-
Notifications
You must be signed in to change notification settings - Fork 0
/
view_product.php
97 lines (89 loc) · 3.54 KB
/
view_product.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
<!DOCTYPE html>
<html>
<head>
<title>Product</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
font-family: sans-serif;
}
th, td {
padding: 5px;
}
</style>
</head>
<body>
<h1>Product</h1>
<form action="controller_product.php" method="POST">
<fieldset>
<legend>
<h3>Register</h3>
</legend>
<table border="1" style="border-collapse: collapse;">
<tr>
<td>Name:</td>
<td><input type="text" name="name" value="" maxlength="80" autofocus="autofocus" title="Name" required="required"></td>
</tr>
<tr>
<td>Quantity:</td>
<td><input type="number" name="quantity" value="0" title="Quantity" required="required"></td>
</tr>
<tr>
<td>Release Date:</td>
<td><input type="date" name="releaseDate" value="<?php echo date("Y-m-d");?>" title="Release Date" required="required"></td>
</tr>
<tr>
<td>Active:</td>
<td>
Yes: <input type="radio" name="active" value="1" title="Active" checked="checked">
No: <input type="radio" name="active" value="0" title="Active">
</td>
</tr>
</table>
<p>
<input type="submit">
</p>
</fieldset>
</form>
<hr>
<h3>List</h3>
<table border="1" style="border-collapse: collapse;">
<thead>
<tr>
<?php
require_once 'Product.php';
$oProduct = new Product();
$classVars = classVars(get_class($oProduct));
$aAllProducts = $oProduct->all();
$iQuantity = count($aAllProducts);
foreach($classVars as $property) {
echo '<th>'. separateWordsByCaseToStr(ucfirst($property)).'</th>';
}
?>
</tr>
</thead>
<tbody>
<?php
if ( $iQuantity > 0) {
foreach ($aAllProducts as $aProduct) {
// This identation is simple and easy way to beautify HTML in browser without any "XML" lib
echo '<tr>';
foreach($classVars as $property) {
echo '<td>'.$aProduct[$property].'</td>';
}
echo'</tr>';
}
} else {
echo '<tr><td colspan="30">There are nothing registered.</td></tr>';
}
?>
</tbody>
<tfoot>
<tr>
<td colspan="5">Results: <?php echo count($aAllProducts);?></td>
</tr>
</tfoot>
</table>
</body>
</html>