Skip to content

Commit f417a1c

Browse files
committed
order delete
1 parent 99c6abc commit f417a1c

3 files changed

Lines changed: 81 additions & 0 deletions

File tree

dashboard/datatable/order/fetch.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
</button>
5050
<div class="dropdown-menu">
5151
<a class="dropdown-item view" id="'.$row["or_ID"].'">View</a>
52+
<a class="dropdown-item delete" id="'.$row["or_ID"].'">Delete</a>
5253
</div>
5354
</div>';
5455
$data[] = $sub_array;

dashboard/datatable/order/insert.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,30 @@
1414

1515
echo "Process Complete";
1616
}
17+
18+
19+
if($_POST["operation"] == "delete_order")
20+
{
21+
$statement = $conn->prepare(
22+
"DELETE FROM `order_item` WHERE `order_item`.`or_ID` = '".$_POST["order_ID"]."';"
23+
);
24+
$statement->execute();
25+
26+
27+
28+
$statement1 = $conn->prepare(
29+
"DELETE FROM `order` WHERE `order`.`or_ID` = '".$_POST["order_ID"]."';"
30+
);
31+
$statement1->execute();
32+
$result = $statement1->fetchAll();
33+
34+
if ($statement1->rowCount() > 0 ) {
35+
echo "Data Delete";
36+
}
37+
38+
}
39+
40+
1741
}
1842
?>
1943

dashboard/orders.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,32 @@
134134
</div>
135135
</div>
136136

137+
138+
139+
140+
<div class="modal fade" id="delorder_modal" tabindex="-1" role="dialog" aria-labelledby="product_modal_title" aria-hidden="true">
141+
<div class="modal-dialog modal-lg" role="document">
142+
<div class="modal-content">
143+
<div class="modal-header">
144+
<h5 class="modal-title" id="harvest_modal_title">Delete this Product</h5>
145+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
146+
<span aria-hidden="true">&times;</span>
147+
</button>
148+
</div>
149+
<div class="modal-body">
150+
<div class="text-center">
151+
<div class="btn-group">
152+
<button type="submit" class="btn btn-danger" id="order_delform">Delete</button>
153+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
154+
</div>
155+
</div>
156+
</div>
157+
<div class="modal-footer">
158+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
159+
</div>
160+
</div>
161+
</div>
162+
</div>
137163
</div>
138164
</main>
139165
</div>
@@ -230,6 +256,36 @@
230256

231257

232258
});
259+
260+
$(document).on('click', '.delete', function(){
261+
var order_ID = $(this).attr("id");
262+
$('#delorder_modal').modal('show');
263+
$('.submit').hide();
264+
265+
$('#order_ID').val(order_ID);
266+
});
267+
268+
269+
270+
271+
$(document).on('click', '#order_delform', function(event){
272+
var order_ID = $('#order_ID').val();
273+
274+
$.ajax({
275+
type : 'POST',
276+
url:"datatable/order/insert.php",
277+
data : {operation:"delete_order",order_ID:order_ID},
278+
dataType : 'json',
279+
complete : function(data) {
280+
$('#delorder_modal').modal('hide');
281+
alert(data.responseText);
282+
dataTable.ajax.reload();
283+
284+
}
285+
})
286+
287+
});
288+
233289

234290
} );
235291

0 commit comments

Comments
 (0)