-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteOrder.php
More file actions
96 lines (71 loc) · 2.08 KB
/
deleteOrder.php
File metadata and controls
96 lines (71 loc) · 2.08 KB
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
<script>
var delVar = null;
var upVar = null;
</script>
<?php
if(!empty($_POST['delete'])) {
$xml = new DomDocument("1.0","UTF-8");
$xml->load('orderDataBase.xml');
$list = $xml->getElementsByTagName("order");
$id = $_POST["ID"];
$targetNode = null;
foreach($list as $domElement){
$IDNUMTag = $domElement->getElementsByTagName("ID");
$attrValue = $IDNUMTag->item(0)->nodeValue;
if($attrValue == $id){
$targetNode = $domElement;
}
}
if($targetNode != null){
$targetNode->parentNode->removeChild($targetNode);
}
$xml->formatoutput = true;
$xml->save('orderDataBase.xml');
}
if(!empty($_POST['update'])) {
$xml = new DomDocument("1.0","UTF-8");
$xml->load('orderDataBase.xml');
$id = $_POST["ID"];
$product_quantities = $_POST["product_quantities "];
$final_price = $_POST["final_price"];
if($admin == null){
$admin = "false";
} else $admin = "true";
$list = $xml->getElementsByTagName("order");
$targetNode = null;
foreach($list as $domElement){
$IDNUMTag = $domElement->getElementsByTagName("ID");
$attrValue = $IDNUMTag->item(0)->nodeValue;
if($attrValue == $id){
$targetNode = $domElement;
}
}
if($targetNode != null){
$targetNode->parentNode->removeChild($targetNode);
}
$rootTag = $xml->getElementsByTagName("root")->item(0);
$orderTag = $xml->createElement("order");
$idTag = $xml->createElement("id", $id);
$product_quantitiesTag = $xml->createElement("product_quantities", $product_quantities);
$final_PriceTag = $xml->createElement("final_price", $final_price);
$orderTag->appendChild($idTag);
$orderTag->appendChild($product_quantitiesTag);
$orderTag->appendChild($final_PriceTag);
$rootTag->appendChild($orderTag);
$xml->save('orderDataBase.xml');
}
?>
<script>
<?php
if(!empty($_POST['update']))
echo "upVar = '$id';";
else echo "delVar = '$id';";
?>
if(delVar == null){
alert("Order with id " + upVar + " has been successfully modified.");
window.location.href = "allOrders.php";
} else {
alert("Order with id " + delVar + " has been successfully deleted.");
window.location.href = "allOrder.php";
}
</script>