-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcharge_fee_confirm_2.php
158 lines (143 loc) · 6.91 KB
/
charge_fee_confirm_2.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
require_once 'common/config.php';
?>
<!DOCTYPE html>
<html lang="jp">
<head>
<?php require_once 'common/header.php' ?>
</head>
<body>
<!-- Navigation -->
<?php require_once 'common/navigation.php'?>
<!-- Page Content -->
<div class="container">
<!-- Page Heading/Breadcrumbs -->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"><small>2_1.商品代金、輸送料、送金手数料 確認(ログイン前)</small>
</h1>
<ol class="breadcrumb">
<li><a href="index.html">Home</a>
</li>
<li class="active">About</li>
</ol>
</div>
</div>
<!-- /.row -->
<!-- Intro Content -->
<div class="row">
<div class="col-lg-12">
<form class="form-horizontal" method="post" action="temporary_quotes.php">
<div class="form-group">
<label class="control-label col-sm-2" for="item_amount">Item amount:</label>
<div class="col-sm-10">
<input type="number" class="form-control" id="item_amount" name="item_amount" placeholder="Item Amount" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="item_currency">Item Amount Currency:</label>
<div class="col-sm-10">
<!-- <input type="text" class="form-control" name="item_currency" placeholder="Item Amount Currency">-->
<select class="form-control" id="item_currency" name="item_currency" placeholder="Item Amount Currency" required>
<option value="JPY">JPY</option>
<option value="JPY">USD</option>
<option value="JPY">VND</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="shipping_fee">Shipping fee:</label>
<div class="col-sm-10">
<input type="number" class="form-control " id="shipping_fee" name="shipping_fee" placeholder="Shipping fee" required>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="shipping_currency">Shipping Fee Currency:</label>
<div class="col-sm-10">
<!-- <input type="text" class="form-control" name="shipping_fee_currency" placeholder="Shipping fee Currency">-->
<select class="form-control" id="shipping_currency" name="shipping_currency" required>
<option value="JPY">JPY</option>
<option value="USD">USD</option>
<option value="VND">VND</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-6">
<button type="button" class="btn btn-default calculate">計算</button>
</div>
<div class="col-sm-4 pull-right">
<div id="loading" style="display:none">計算中</div>
<p><label class="control-label" style="width: 200px">Source Amount:</label><span id="result_source_amount"></span></p>
<p><label class="control-label" style="width: 200px">Target Amount:</label><span id="result_target_amount"></span></p>
<p><label class="control-label" style="width: 200px">手数料:</label><span id="result_fee"></span></p>
<p class="text-center"><span id="error_message" class="error"></span></p>
</div>
</div>
</form>
</div>
</div>
<!-- /.row -->
<?php require_once 'common/footer.php'?>
</div>
<div class="modal"><!-- Place at bottom of page --></div>
<!-- /.container -->
<script>
// Initial jquery validate
$('form').validate();
// Calculate button on click event
$('.calculate').on('click', function () {
calculate();
});
$('#item_amount, #item_currency, #shipping_fee, #shipping_currency').on('change', function () {
calculate();
});
// Calculate temporary quotation
function calculate() {
// Validate
if($('form').valid()){
var itemCurrency = $('#item_currency').val();
var shippingCurrency = $('#shipping_currency').val();
// Call temporary quotes API using Ajax
$.ajax({
method: "GET",
url: "api_temporary_quotes.php",
data: {
source: itemCurrency,
target: shippingCurrency,
amount: parseInt($('#item_amount').val()) + parseInt($('#shipping_fee').val())
},
beforeSend: function( xhr ) {
$("body").addClass("loading");
$('#result_source_amount').text('');
$('#result_target_amount').text('');
$('#result_fee').text('');
$('#error_message').text('');
}
})
.done(function( response ) {
console.log(response);
response = JSON.parse(response);
if(response.status.code == 0){
// Set result value
$('#result_source_amount').text(response.data.sourceAmount + ' ' + itemCurrency);
$('#result_target_amount').text(response.data.targetAmount + ' ' + shippingCurrency);
$('#result_fee').text(response.data.fee + ' ' + itemCurrency);
$('#error_message').text('');
}else{
// Alert error message
$('#error_message').text(response.status.message)
}
})
.fail(function (response) {
$('#error_message').text('Fail to call server api');
})
.always(function() {
$("body").removeClass("loading");
});
;
}
}
</script>
</body>
</html>