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
|
<div id="squareup_buttons" class="form-control-static buttons clearfix">
{% if order_recurring_id %}
<div class="pull-right">
<button type="button" id="button-cancel" data-loading-text="{{ text_loading }}" class="btn btn-danger">{{ button_text }}</button>
</div>
{% endif %}
</div>
<script type="text/javascript"><!--
$(document).ready(function() {
var addOrderHistory = function(success_callback) {
$.ajax({
url: '{{ catalog }}index.php?route=api/order/history&api_token={{ api_token }}&order_id={{ order_id }}',
type: 'post',
dataType: 'json',
data: 'order_status_id={{ order_status_id }}¬ify={{ notify }}&override=0&append=0&comment=' + encodeURIComponent("{{ comment }}"),
success: function(json) {
if (json['error']) {
$('#squareup_buttons').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
}
if (json['success']) {
success_callback();
}
},
error: function(xhr, ajaxOptions, thrownError) {
$('#squareup_buttons').before('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + thrownError + "<br />" + xhr.statusText + "<br />" + xhr.responseText + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
}
});
}
$(document).delegate('#button-cancel', 'click', function() {
if (!confirm("{{ text_confirm_cancel }}")) {
return false;
}
$.ajax({
url: '{{ cancel }}',
dataType: 'json',
beforeSend: function() {
$('#button-cancel').button('loading');
},
success: function(json) {
$('.alert').remove();
if (json['success']) {
addOrderHistory(function() {
$('#squareup_buttons').before('<div class="alert alert-success">' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
$('#button-cancel').hide();
});
}
if (json['error']) {
$('#squareup_buttons').before('<div class="alert alert-danger">' + json['error'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>');
$('#button-cancel').button('reset');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
//--></script>
|