-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpackages_approve.php
84 lines (78 loc) · 3.51 KB
/
packages_approve.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
<?php
require_once 'includes/headx.php';
require_once "includes/classes/admin-class.php";
$admins = new Admins($dbh);
$page = isset($_GET[ 'p' ])?$_GET[ 'p' ]:'';
if($page == 'add'){
$name = htmlentities($_POST['name']);
$price = htmlentities($_POST['price']);
if (!$admins->addNewPackage($name, $price))
{
echo "Sorry Data could not be inserted !";
}else {
echo " Data inserted !";
}
}else if($page == 'del'){
$id = $_POST['id'];
if (!$admins->deletePackage($id))
{
echo "Sorry Data could not be deleted !";
}else {
echo "Well! You've successfully deleted a product!";
}
}else if($page == 'edit'){
$name = $_POST['name'];
$price = $_POST['price'];
$id = $_POST['id'];
if (!$admins->updatePackage($id, $name, $price))
{
echo "Sorry Data could not be inserted !";
}else {
$commons->redirectTo(SITE_PATH.'packages.php');
}
}else{
$packages = $admins->getPackages();
if (isset($packages) && sizeof($packages) > 0){
foreach ($packages as $package){
?>
<tr>
<td><?=$package->id?></td>
<td><?=$package->name?></td>
<td><?=$package->fee?></td>
<td>
<button type="button" class="btn btn-success btn-sm" id="edit" data-toggle="modal" data-target="#edit-<?=$package->id?>">EDIT</button>
<!-- Update modal -->
<div class="fade modal" id="edit-<?=$package->id?>">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4>Edit Packages</h4>
</div>
<form method="POST" action="packages_approve.php?p=edit">
<div class="modal-body">
<input type="hidden" id="<?=$package->id?>" value="<?=$package->id?>">
<div class="form-group has-success">
<label for="name">Name</label>
<input type="text" class="form-control" id="nm-<?=$package->id?>" value="<?=$package->name?>" required>
</div>
<div class="form-group">
<label for="price">Price</label>
<input type="text" class="form-control" id="pr-<?=$package->id?>" value="<?=$package->fee?>" required>
</div>
</div>
<div class="modal-footer">
<button type="submit" onclick="upData(<?=$package->id?>)" class="btn btn-primary">Update</button>
<a href="#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
</div>
</form>
</div>
</div>
</div>
<button type="button" id="delete" onclick="delData(<?=$package->id?>)" class="btn btn-warning btn-sm">DELETE</button>
</td>
</tr>
<?php }
}
}
?>