aboutsummaryrefslogtreecommitdiffstats
path: root/public/admin/view/template/extension/payment/cardinity_order_ajax.twig
blob: 1208f83a9a4659ec8630956ebfb84fe56b9fa24a (plain)
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
{% if payment %}
<table class="table table-bordered">
  <tr>
	<td>{{ column_refund_history }}</td>
	<td>
		<table class="table table-bordered">
		  <thead>
			<tr>
			  <td class="text-left">{{ column_date }}</td>
			  <td class="text-left">{{ column_amount }}</td>
			  <td class="text-left">{{ column_status }}</td>
			  <td class="text-left">{{ column_description }}</td>
			</tr>
		  </thead>
		  <tbody>
			{% if refunds %}
			{% for refund in refunds %}
			<tr>
			  <td>{{ refund.date_added }}</td>
			  <td>{{ refund.amount }}</td>
			  <td>{{ refund.status }}</td>
			  <td>{{ refund.description }}</td>
			</tr>
			{% endfor %}
			{% else %}
			<tr>
			  <td class="text-center" colspan="3">{{ text_no_refund }}</td>
			</tr>
			{% endif %}
		  </tbody>
		</table>
	</td>
  </tr>
  <tr>
	<td>{{ column_action }}</td>
	<td>
		<table class="table table-bordered">
		  <thead>
			<tr>
			  <td class="text-left">{{ column_refund }}</td>
			</tr>
		  </thead>
		  <tbody>
			<tr>
			  <td>
				  {% if refund_action %}
				  <label class="control-label">Amount:</label>
				  <input id="refund-amount" text="text" name="refund_amount" value="{{ max_refund_amount }}" />
				  <label class="control-label">Description:</label>
				  <input id="refund-description" text="text" name="refund_description" value="" />
				  <a class="btn btn-primary button-command" data-type="refund">{{ button_refund }}</a>
				  {% else %}
				  {{ text_na }}
				  {% endif %}
			  </td>
			</tr>
		  </tbody>
		</table>
	</td>
  </tr>
</table>
{% else %}
Unable to find transaction for this order.
{% endif %}

<script type="text/javascript"><!--
$('.button-command').on('click', function() {
	var confirm_text = '';

	{% if symbol_left %}
	confirm_text = '{{ text_confirm_refund }} ' + '{{ symbol_left }}' + $('#refund-amount').val();
	{% elseif symbol_right %}
	confirm_text = '{{ text_confirm_refund }} ' + $('#refund-amount').val() + '{{ symbol_right }}';
	{% endif %}

	if (confirm(confirm_text)) {
		$.ajax({
			url: 'index.php?route=extension/payment/cardinity/refund&user_token={{ user_token }}',
			type: 'post',
			data: {
				payment_id: '{{ payment_id }}',
				amount: $('#refund-amount').val(),
				description: $('#refund-description').val()
			},
			dataType: 'json',
			beforeSend: function() {
				$('#button-settle').button('loading');

				$('.alert').hide();

				$('.alert').removeClass('alert-success alert-danger');
			},
			complete: function() {
				$('#button-settle').button('reset');
			},
			success: function(json) {
				if (json.error) {
					$('.alert').show();

					$('.alert').addClass('alert-danger');

					$('.alert').html('<i class="fa fa-check-circle"></i> ' + json.error);
				}

				if (json.success) {
					$('.alert').show();

					$('.alert').addClass('alert-success');

					$('.alert').html('<i class="fa fa-exclamation-circle"></i> ' + json.success);
				}

				getPayment('{{ payment_id }}');
			}
		});
	}
});
//--></script>