added refunds

This commit is contained in:
O K
2025-05-31 15:35:42 +03:00
parent cae15fb881
commit 386023521a
3 changed files with 467 additions and 18 deletions

View File

@@ -0,0 +1,123 @@
{*
* Hutko PrestaShop Module
*
* This template is used to display the Hutko payment refund tab content
* on the PrestaShop admin order details page.
* It lists all Hutko payments for the order and provides a refund button
* which opens a modal for amount and comment input.
*}
{if $hutkoPayments->count()}
<div class="panel">
<div class="panel-heading">
<i class="icon-dollar"></i> {l s='Hutko Payments & Refunds' mod='hutko'}
</div>
<div class="panel-body">
<div id="hutko_payments_list">
<div class="table-responsive">
<table class="table" id="hutko_payments_table">
<thead>
<tr>
<th>{l s='Transaction ID' mod='hutko'}</th>
<th>{l s='Amount' mod='hutko'}</th>
<th>{l s='Payment Date' mod='hutko'}</th>
<th>{l s='Actions' mod='hutko'}</th>
</tr>
</thead>
<tbody>
{foreach from=$hutkoPayments item='payment'}
<form method="post" id="hutkoStatusForm-{$payment->id|intval}"></form>
<tr data-payment-id="{$payment->id|intval}" data-payment-amount="{$payment->amount|floatval}">
<td>{$payment->transaction_id|escape:'htmlall':'UTF-8'}</td>
<td>{displayPrice price=Tools::ps_round($payment->amount, 2) currency=$currency->id|floatval}
</td>
<td>{$payment->date_add|date_format:'%Y-%m-%d %H:%M:%S'}</td>
<td>
{if $payment->amount > 0}
<button type="button" class="btn btn-default btn-sm hutko-refund-btn"
data-toggle="modal" data-target="#hutkoRefundModal-{$payment->id|intval}"
data-payment-id="{$payment->id|intval}"
data-payment-amount="{$payment->amount|floatval}">
<i class="icon-undo"></i> {l s='Refund' mod='hutko'}
</button>
{/if}
<button type="submit" form="hutkoStatusForm-{$payment->id|intval}"
class="btn btn-default btn-sm hutko-status-btn" name="hutkoOrderStatus"
value="{$payment->transaction_id|escape:'htmlall':'UTF-8'}">
<i class="icon-info"></i> {l s='Status' mod='hutko'}
</button>
<div class="modal fade" id="hutkoRefundModal-{$payment->id|intval}" tabindex="-1"
role="dialog" aria-labelledby="hutkoRefundModalLabel-{$payment->id|intval}"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title"
id="hutkoRefundModalLabel-{$payment->id|intval}">
{l s='Initiate Refund' mod='hutko'}</h4>
</div>
<div class="modal-body">
<form id="hutkoRefundForm-{$payment->id|intval}" method="post">
<input type="hidden" name="id_order" value="{$id_order}">
<input type="hidden" name="action" value="process_refund">
<input type="hidden" name="orderPaymentId" value="{$payment->id}">
<div class="form-group">
<label
for="refund_amount">{l s='Refund Amount' mod='hutko'}</label>
<div class="input-group">
<span
class="input-group-addon">{$currency->sign|escape:'htmlall':'UTF-8'}</span>
<input type="number" value="{$payment->amount|floatval}"
step="0.01" min="0.01" max="{$payment->amount|floatval}"
class="form-control" id="refund_amount"
name="refund_amount" required>
<span class="input-group-addon"
id="max_refund_amount_display"></span>
</div>
<small
class="form-text text-muted">{l s='Enter the amount to refund for this payment.' mod='hutko'}</small>
</div>
<div class="form-group">
<label
for="refund_comment">{l s='Refund Reason/Comment' mod='hutko'}</label>
<textarea class="form-control" id="refund_comment"
maxlength="1024" name="comment" rows="3"></textarea>
<small
class="form-text text-muted">{l s='Optional: A brief reason for the refund.' mod='hutko'}</small>
</div>
</form>
<div id="hutko_refund_message" class="alert hidden" role="alert"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default"
data-dismiss="modal">{l s='Cancel' mod='hutko'}</button>
<button class="btn btn-primary" name="hutkoRefundsubmit"
form="hutkoRefundForm-{$payment->id|intval}"
type="submit">{l s='Process Refund' mod='hutko'}</button>
</div>
</div>
</div>
</div>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
</div>
</div>
{/if}