-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment.php
136 lines (111 loc) · 3.59 KB
/
payment.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php include 'header.php';?>
<div class="container">
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6">
<div class="well">
<form class="form-inline" method="POST">
<table class="table table-bordered">
<tr>
<div class="form-group">
<td><label for="pwd">Order ID:</label></td>
<td><input type="text" name="orderid" id="orderid" class="form-control" required max="99">
<div id="datashowlist"></div>
<div id="detailsshow"></div>
</td>
</div>
</tr>
<tr>
<div class="form-group">
<td><label for="pwd">Payment</label></td>
<td><input type="Number" name="payment" id="payamount" class="form-control qntity"></td>
</div>
</tr>
<tr>
<div class="form-group">
<td><label for="pwd">Due</label></td>
<td><input type="Number" id="due" class="form-control qntity" disabled></td>
</div>
</tr>
<tr><td></td><td><button type="submit" name="hit" class="btn btn-default">Submit</button></td> </tr>
</table>
</form>
<?php
if (isset($_POST['hit'])) {
$data = array( 'orderid' => $_POST['orderid'],
'invoiceno' => $_POST['invoiceeeno'],
'totalamount' => $_POST['totalamount'],
'payamount' => $_POST['payment'],
'paymentdate' => date("Y-m-d")
);
if ($db->insert("payment",$data)) {
echo "<h3 style='color:blue'>Payment has been accomplished</h3>";
}else{
echo "<h3 style='color:red'>Payment has not been accomplished</h3>";
}
}
?>
</div>
</div>
<div class="col-md-3"></div>
</div>
</div>
<?php include 'footer.php';?>
<script type="text/javascript">
$("#orderid").on("keyup",function(event) { // to get the order id while onkeyup typing
/* Act on the event */
var id = $(this).val();
$.ajax({
url: 'ajax/orderid.php',
type: 'POST',
data: {value: id }
})
.done(function(res) {
console.log(res);
$("#datashowlist").fadeIn();
$("#datashowlist").html(res);
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
}); // end of order id
$(document).on("click","#searchid",function(){ // fading out on selecting order id from list
$("#orderid").val($(this).text());
$("#datashowlist").fadeOut();
}); // end fadeout list
$("#orderid").on('blur', function(event) {//printing order details to be paid
event.preventDefault();
/* Act on the event */
var orderid = $(this).val();
$.ajax({
url: 'ajax/gettheorderinformation.php',
type: 'POST',
dataType: 'html',
data: {id : orderid},
})
.done(function(res) {
console.log(res);
$("#detailsshow").html(res);
})
.fail(function() {
console.log("error");
})
.always(function() {
console.log("complete");
});
});
$("#payamount").on('blur', function(event) { // field calculation
event.preventDefault();
/* Act on the event */
$(this).attr('max',$("#totalamount").val());
var due = $("#totalamount").val()-$(this).val();
if (due<=0) {
$("#due").val(0);
}else{
$("#due").val(due);
}
});
</script>