
        <?php
        // Don't show this container when only rendering the widget section
        if (!(isset($render_section) ? $render_section : null) && !(isset($is_ajax) ? $is_ajax : null)) {
        ?>
    <div class="col-md-12">
        <?php
        }
        $links = [
            ['name' => $this->_('ClientTransactions.index.category_approved', true) . ' <span class="badge">' . (isset($status_count['approved']) ? $this->Html->safe($status_count['approved']) : null) . '</span>', 'current' => ((isset($status) ? $status : null) == 'approved' ? true : false), 'attributes' => ['href' => $this->base_uri . 'transactions/index/approved/', 'class' => 'ajax']],
            ['name' => $this->_('ClientTransactions.index.category_pending', true) . ' <span class="badge">' . (isset($status_count['pending']) ? $this->Html->safe($status_count['pending']) : null) . '</span>', 'current' => ((isset($status) ? $status : null) == 'pending' ? true : false), 'attributes' => ['href' => $this->base_uri . 'transactions/index/pending/', 'class' => 'ajax']],
            ['name' => $this->_('ClientTransactions.index.category_declined', true) . ' <span class="badge">' . (isset($status_count['declined']) ? $this->Html->safe($status_count['declined']) : null) . '</span>', 'current' => ((isset($status) ? $status : null) == 'declined' ? true : false), 'attributes' => ['href' => $this->base_uri . 'transactions/index/declined/', 'class' => 'ajax']]
        ];

        $this->WidgetClient->clear();
        $this->WidgetClient->setLinks($links);
        $this->WidgetClient->setFilters((isset($filters) ? $filters : null), $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $this->Html->safe($status) : null)), !empty($filter_vars));
        $this->WidgetClient->setAjaxFiltering();
        $this->WidgetClient->create($this->_('ClientTransactions.index.boxtitle_transactions', true), ['id' => 'client_transactions'], (isset($render_section) ? $render_section : null));
        $this->WidgetClient->startBody();
        $this->WidgetClient->buildFilters();

        if ((isset($transactions) ? $transactions : false) && ($num_transactions = count($transactions)) > 0) {
        ?>
        <div class="table-responsive">
            <table class="table table-curved table-striped-alt table-hover" id="transactions">
                <thead>
                    <tr>
                        <th><a href="<?php echo $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $status : null) . '/?sort=type&order=' . ($sort == 'type' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'type' ? ' ' . $order : '');?>"><?php $this->_('ClientTransactions.index.heading_type');?></a></th>
                        <th><a href="<?php echo $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $status : null) . '/?sort=amount&order=' . ($sort == 'amount' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'amount' ? ' ' . $order : '');?>"><?php $this->_('ClientTransactions.index.heading_amount');?></a></th>
                        <th><?php $this->_('ClientTransactions.index.heading_credited');?></th>
                        <th><a href="<?php echo $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $status : null) . '/?sort=applied_amount&order=' . ($sort == 'applied_amount' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'applied_amount' ? ' ' . $order : '');?>"><?php $this->_('ClientTransactions.index.heading_applied');?></a></th>
                        <th><a href="<?php echo $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $status : null) . '/?sort=transaction_id&order=' . ($sort == 'transaction_id' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'transaction_id' ? ' ' . $order : '');?>"><?php $this->_('ClientTransactions.index.heading_number');?></a></th>
                        <th><a href="<?php echo $this->Html->safe($this->base_uri . 'transactions/index/' . (isset($status) ? $status : null) . '/?sort=date_added&order=' . ($sort == 'date_added' ? $negate_order : $order));?>" class="ajax<?php echo $this->Html->safe($sort == 'date_added' ? ' ' . $order : '');?>"><?php $this->_('ClientTransactions.index.heading_date');?></a></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    // Display all transactions
                    for ($i = 0; $i < $num_transactions; $i++) {
                        if ((isset($transactions[$i]->type) ? $transactions[$i]->type : null) == 'other' && (isset($transactions[$i]->gateway_type) ? $transactions[$i]->gateway_type : null) == 'nonmerchant') {
                            $trans_type = $transactions[$i]->gateway_name;
                        } else {
                            $trans_type = (isset($transaction_types[($transactions[$i]->type_name != '' ? $transactions[$i]->type_name : $transactions[$i]->type)]) ? $transaction_types[($transactions[$i]->type_name != '' ? $transactions[$i]->type_name : $transactions[$i]->type)] : null);
                        }
                    ?>
                    <tr class="expand transaction_applied">
                        <td><?php (print (isset($trans_type) ? $this->Html->safe($trans_type) : null));?></td>
                        <td><?php echo $this->CurrencyFormat->format((isset($transactions[$i]->amount) ? $this->Html->safe($transactions[$i]->amount) : null), (isset($transactions[$i]->currency) ? $this->Html->safe($transactions[$i]->currency) : null), ['html_code' => true]);?></td>
                        <td><?php echo $this->CurrencyFormat->format((isset($transactions[$i]->credited_amount) ? $this->Html->safe($transactions[$i]->credited_amount) : null), (isset($transactions[$i]->currency) ? $this->Html->safe($transactions[$i]->currency) : null), ['html_code' => true]);?></td>
                        <td><?php echo $this->CurrencyFormat->format((isset($transactions[$i]->applied_amount) ? $this->Html->safe($transactions[$i]->applied_amount) : null), (isset($transactions[$i]->currency) ? $this->Html->safe($transactions[$i]->currency) : null), ['html_code' => true]);?></td>
                        <td><?php (print (isset($transactions[$i]->transaction_id) ? $this->Html->safe($transactions[$i]->transaction_id) : null));?></td>
                        <td><?php echo $this->Date->cast((isset($transactions[$i]->date_added) ? $this->Html->safe($transactions[$i]->date_added) : null), 'date');?></td>
                    </tr>
                    <tr class="expand_details" id="transactions_<?php (print (isset($transactions[$i]->id) ? $this->Html->safe($transactions[$i]->id) : null));?>">
                        <td colspan="8" class="subtable">
                        </td>
                    </tr>
                    <?php
                    }
                    ?>
                </tbody>
            </table>
        </div>
        <?php
        } else {
        ?>
        <div class="alert alert-info">
            <p>
                <?php
                $section_language = $this->_('ClientTransactions.index.category_' . (isset($status) ? $status : null), true);
                $this->_('ClientTransactions.index.no_results', false, $section_language);
                ?>
            </p>
        </div>
        <?php
        }
        $this->WidgetClient->endBody();
        if ($this->Pagination->hasPages()) {
            $this->WidgetClient->startFooter();
            $this->Pagination->build();
            $this->WidgetClient->endFooter();
        }
        $this->WidgetClient->end();
        // Don't show this container when only rendering the widget section
        if (!(isset($render_section) ? $render_section : null) && !(isset($is_ajax) ? $is_ajax : null)) {
        ?>
    </div>
        <?php
        }
        ?>

<script type="text/javascript">
$(document).ready(function() {
    // Fetch all invoices the given transaction has been applied to
    $(".transaction_applied").click(function() {
        $(this).blestaUpdateRow("<?php echo $this->Html->safe((isset($this->base_uri) ? $this->Html->safe($this->base_uri) : null) . 'transactions/applied/');?>" + $(this).next("tr").attr("id").split("_")[1], ".subtable");
    });
});
</script>