-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_accounts.pdt
135 lines (125 loc) · 7.89 KB
/
client_accounts.pdt
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
<div class="col-md-3">
<?php echo ($navigation ?? null); ?>
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-12">
<?php
echo (isset($message) ? $message : null);
$link_buttons = [
['name' => $this->_('ClientAccounts.index.create_account', true), 'attributes' => ['href' => $this->base_uri . 'accounts/add/']]
];
$this->WidgetClient->clear();
$this->WidgetClient->setLinkButtons($link_buttons);
$this->WidgetClient->create($this->_('ClientAccounts.index.boxtitle_accounts', true), ['id' => 'client_accounts'], (isset($render_section) ? $render_section : null));
$this->WidgetClient->startBody();
$this->Form->create(null, ['class' => 'disable-on-submit']);
if ((isset($accounts) ? $accounts : false) && (($num_accounts = count($accounts)) > 0)) {
?>
<div class="table-responsive">
<table class="table table-curved table-striped mb-2" id="contacts">
<thead>
<th><?php $this->Form->fieldRadio('account_id', 'none', ((isset($vars->account_id) ? $this->Html->safe($vars->account_id) : null) == 'none'));?></th>
<th><?php $this->_('ClientAccounts.index.heading_name');?></th>
<th><?php $this->_('ClientAccounts.index.heading_type');?></th>
<th><?php $this->_('ClientAccounts.index.heading_last4');?></th>
<th><?php $this->_('ClientAccounts.index.heading_options');?></th>
</thead>
<tbody>
<?php
// Save the account type of the account that is checked
$account_type = 'cc';
// Loop through all accounts
for ($i = 0; $i < $num_accounts; $i++) {
?>
<tr<?php echo $this->Html->concat(' ', ($i % 2 == 1) ? ' class="odd_row"' : '', '');?>>
<?php
// Radio is checked if both account ID and account type match
$radio_checked = false;
if (((isset($vars->account_id) ? $this->Html->safe($vars->account_id) : null) == (isset($accounts[$i]->id) ? $accounts[$i]->id : null)) &&
((isset($vars->type) ? $this->Html->safe($vars->type) : null) == (isset($accounts[$i]->account_type) ? $accounts[$i]->account_type : null))) {
$radio_checked = true;
$account_type = (isset($accounts[$i]->account_type) ? $accounts[$i]->account_type : null);
}
?>
<td>
<?php
$this->Form->fieldRadio('account_id', (isset($accounts[$i]->id) ? $accounts[$i]->id : null), $radio_checked);
$this->Form->fieldHidden('account_type', (isset($accounts[$i]->account_type) ? $accounts[$i]->account_type : null));
?>
</td>
<td><?php echo $this->Html->concat(' ', (isset($accounts[$i]->first_name) ? $this->Html->safe($accounts[$i]->first_name) : null), (isset($accounts[$i]->last_name) ? $this->Html->safe($accounts[$i]->last_name) : null));?></td>
<td><?php $this->_('ClientAccounts.index.type_' . $accounts[$i]->account_type, false, $account_types[$accounts[$i]->account_type], (isset($ach_types[$accounts[$i]->type]) ? $ach_types[$accounts[$i]->type] : (isset($cc_types[$accounts[$i]->type]) ? $cc_types[$accounts[$i]->type] : null)));?></td>
<td><?php (print (isset($accounts[$i]->last4) ? $this->Html->safe($accounts[$i]->last4) : null));?></td>
<td>
<div class="btn-group">
<?php
if (($accounts[$i]->status ?? 'active') == 'active') {
?>
<a href="<?php echo $this->Html->safe($this->base_uri . 'accounts/edit' . (($accounts[$i]->account_type ?? null) == 'cc' ? 'cc' : 'ach') . '/' . (isset($accounts[$i]->id) ? $this->Html->safe($accounts[$i]->id) : null) . '/');?>" class="btn btn-xs btn-light">
<i class="fas fa-edit fa-fw"></i> <?php $this->_('ClientAccounts.index.option_edit');?>
</a>
<?php
} elseif (($accounts[$i]->account_type ?? null) == 'ach') {
?>
<a href="<?php echo $this->Html->safe($this->base_uri . 'accounts/verifyach/' . (isset($accounts[$i]->id) ? $this->Html->safe($accounts[$i]->id) : null) . '/');?>" class="btn btn-xs btn-light">
<i class="fas fa-check fa-fw"></i> <?php $this->_('ClientAccounts.index.option_verify');?>
</a>
<?php
}
?>
<button class="btn btn-xs btn-light dropdown-toggle" data-toggle="dropdown" type="button">
<span class="caret"></span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="<?php echo $this->Html->safe($this->base_uri . 'accounts/delete' . ((isset($accounts[$i]->account_type) ? $accounts[$i]->account_type : null) == 'cc' ? 'cc' : 'ach') . '/' . (isset($accounts[$i]->id) ? $this->Html->safe($accounts[$i]->id) : null) . '/');?>" rel="<?php echo $this->Html->safe($this->_('ClientAccounts.index.confirm_delete', true));?>">
<?php
$this->Form->fieldHidden('id', (isset($accounts[$i]->id) ? $accounts[$i]->id : null));
?>
<i class="fas fa-trash fa-fw"></i> <?php $this->_('ClientAccounts.index.option_delete');?>
</a>
</div>
</div>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php $this->Form->fieldHidden('type', (isset($account_type) ? $this->Html->safe($account_type) : null), ['id' => 'account_type']);?>
<button class="btn btn-light float-right" type="submit">
<i class="fas fa-plus-circle"></i> <?php $this->_('ClientAccounts.index.field_accountsubmit');?>
</button>
<?php
} else {
?>
<div class="alert alert-info">
<p><?php $this->_('ClientAccounts.index.no_results');?></p>
</div>
<?php
}
$this->Form->end();
$this->WidgetClient->endBody();
$this->WidgetClient->end();
?>
</div>
</div>
</div>
<?php
$this->Javascript->setInline("
$(document).ready(function() {
$('#client_accounts input[name=\'account_id\']').click(function() {
$('#account_type').val($('input[name=\'account_type\']', $(this).parent()).val());
});
// Handle confirmation on delete action
$('#client_accounts a[rel]').each(function() {
$(this).blestaModalConfirm({
base_url: '" . $this->base_uri . "',
confirm_data: {id: $('input[name=\"id\"]', $(this)).val()}
});
});
});
");
?>