-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_services_service_infobox.pdt
233 lines (225 loc) · 12.1 KB
/
client_services_service_infobox.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<div class="panel-pad">
<div class="row">
<div class="col-md-6 col-border service-info">
<label><?php $this->_('ClientServices.manage.heading_package');?></label>
<h4><?php (print (isset($service->package->name) ? $this->Html->safe($service->package->name) : null));?></h4>
<label><?php $this->_('ClientServices.manage.heading_service_name');?></label>
<h4><?php (print (isset($service->name) ? $this->Html->safe($service->name) : null));?></h4>
<label><?php $this->_('ClientServices.manage.heading_date_added');?></label>
<h4><?php echo $this->Date->cast($service->date_added);?></h4>
<label><?php $this->_('ClientServices.manage.heading_package_term');?></label>
<?php
$package_term = '';
if (($service->package_pricing->period ?? null) == 'onetime') {
$package_term = ($periods[$service->package_pricing->period] ?? null);
} else {
$term = (isset($service->package_pricing->term) ? $this->Html->safe($service->package_pricing->term) : null);
$package_term = $this->Html->concat(' ', $term, ($term == 1 ? ($periods[$service->package_pricing->period] ?? null) : ($periods[$service->package_pricing->period . '_plural'] ?? null)));
}
?>
<h4><?php (print (isset($package_term) ? $this->Html->safe($package_term) : null));?></h4>
</div>
<div class="col-md-6 service-info">
<label><?php $this->_('ClientServices.index.heading_status');?></label>
<?php
$button = [
'status' => $service->status,
'class' => in_array(($service->status ?? null), ['suspended', 'canceled']) ? 'danger' : (($service->status ?? null) == 'active' ? 'success' : 'warning')
];
?>
<h4>
<div class="badge badge-<?php (print (isset($button['class']) ? $this->Html->safe($button['class']) : null));?>">
<?php $this->_('ClientServices.manage.button_' . (isset($button['status']) ? $this->Html->safe($button['status']) : null));?>
</div>
</h4>
<label><?php $this->_('ClientServices.manage.heading_date_renews');?></label>
<h4>
<?php
if (!empty($service->date_renews)) {
echo $this->Date->cast($service->date_renews);
} else {
$this->_('ClientServices.manage.text_date_never');
}
?>
</h4>
<label><?php $this->_('ClientServices.manage.heading_date_next_invoice');?></label>
<h4>
<?php
if (($next_invoice_date ?? false)) {
echo $this->Date->cast($next_invoice_date);
} else {
$this->_('ClientServices.manage.text_date_never');
}
?>
</h4>
<label><?php $this->_('ClientServices.manage.heading_price' . (($service->package_pricing->period ?? null) == 'onetime' ? '_onetime' : ''));?></label>
<h4>
<?php
$currency = ($service->override_currency ?? ($service->package_pricing->currency ?? null));
if (($service->package_pricing->period ?? null) == 'onetime') {
$price = ($service->override_price ?? ($service->package_pricing->price ?? null));
echo $this->CurrencyFormat->format($price, ($currency ?? null));
} else {
echo $this->CurrencyFormat->format(($service->renewal_price ?? null), ($currency ?? null));
}
?>
</h4>
<?php
// Display the coupon that should apply when the service renews
if (($recurring_coupon ?? null)) {
?>
<label><?php $this->_('ClientServices.manage.heading_recurring_coupon');?></label>
<h4>
<?php
if (($recurring_coupon->recurring_amount->type ?? null) == 'percent') {
$this->_('ClientServices.manage.text_coupon_percent', false, $this->Html->safe((isset($recurring_coupon->code) ? $recurring_coupon->code : null)), $this->CurrencyFormat->cast((isset($recurring_coupon->recurring_amount->amount) ? $recurring_coupon->recurring_amount->amount : null), (isset($recurring_coupon->recurring_amount->currency) ? $recurring_coupon->recurring_amount->currency : null)));
} else {
$this->_('ClientServices.manage.text_coupon_amount', false, $this->Html->safe((isset($recurring_coupon->code) ? $recurring_coupon->code : null)), $this->CurrencyFormat->format((isset($recurring_coupon->recurring_amount->amount) ? $recurring_coupon->recurring_amount->amount : null), (isset($recurring_coupon->recurring_amount->currency) ? $recurring_coupon->recurring_amount->currency : null)));
}
?>
</h4>
<?php
}
?>
</div>
</div>
</div>
<?php
// Display the Configurable Options section
if (!empty($service->options)) {
?>
<hr />
<h4><?php $this->_('ClientServices.manage.heading_config_options');?></h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<?php
foreach ($service->options as $option) {
$is_user_defined_value = (in_array(($option->option_type ?? null), ['text', 'textarea', 'password']));
$display_name = ($is_user_defined_value ? ($option->value ?? null) : ($option->option_value_name ?? null));
?>
<tr>
<td><strong><?php (print (isset($option->option_label) ? $this->Html->safe($option->option_label) : null));?></strong></td>
<td><?php echo nl2br((isset($display_name) ? $this->Html->safe($display_name) : null));?></td>
<td>
<?php
$formatted_option_price = $this->CurrencyFormat->format(($option->option_pricing_price_renews ?? $option->option_pricing_price), ($option->option_pricing_currency ?? null));
if (($option->qty ?? false)) {
$this->_('ClientServices.manage.text_price', false, $this->CurrencyFormat->truncateDecimal(($option->qty ?? 1), 0), $formatted_option_price);
} else {
echo $formatted_option_price;
}
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<?php
}
// Set button options
$buttons = [
'change_service_package' => [
'enabled' => (($client_change_service_package ?? null) && ($service->status ?? null) == 'active' && empty($service->date_canceled) && !($queued_service_change ?? null)),
'icon' => 'fas fa-random fa-fw',
'button' => 'btn-light',
'lang' => 'ClientServices.manage.button_change_service_package',
'link' => $this->base_uri . 'services/upgrade/' . ($service->id ?? null)
],
'change_service_term' => [
'enabled' => (($client_change_service_term ?? null) && !empty($alternate_service_terms) && ($service->status ?? null) == 'active' && empty($service->date_canceled) && !($queued_service_change ?? null)),
'icon' => 'fas fa-edit fa-fw',
'button' => 'btn-light',
'lang' => 'ClientServices.manage.button_change_service_term',
'link' => $this->base_uri . 'services/changeterm/' . ($service->id ?? null)
],
'renew_service' => [
'enabled' => (($client_renew_service ?? null) && ($service->status ?? null) == 'active' && empty($service->date_canceled) && !($queued_service_change ?? null)),
'icon' => 'fas fa-retweet fa-fw',
'button' => 'btn-light',
'lang' => 'ClientServices.manage.button_renew'
],
'cancel_service' => [
'enabled' => (($client_cancel_service ?? null) && !in_array(($service->status ?? null), ['canceled', 'suspended'])),
'icon' => 'fas fa-ban fa-fw',
'button' => 'btn-danger',
'lang' => 'ClientServices.manage.button_cancel'
],
'change_configurable_options' => [
'enabled' => (($available_config_options ?? null) && !($queued_service_change ?? null) && ($service->status ?? null) == 'active'),
'icon' => 'fas fa-edit fa-fw',
'button' => 'btn-light',
'lang' => 'ClientServices.manage.button_config_options',
'link' => $this->base_uri . 'services/manageoptions/' . ($service->id ?? null)
]
];
$show_options = false;
foreach ($buttons as $button) {
if ($button['enabled']) {
$show_options = true;
break;
}
}
// Display the Options section
if ($show_options) {
?>
<hr />
<h4><?php $this->_('ClientServices.manage.heading_options');?></h4>
<?php
// Separate buttons into rows of 3
$i = 0;
$row_closed = true;
foreach ($buttons as $key => $button) {
// Skip buttons that are not active
if (!$button['enabled']) {
continue;
}
// Start a row
if ($i % 3 == 0) {
$row_closed = false;
?>
<div class="row<?php echo $i > 0 ? ' mt-2' : '';?>">
<?php
}
?>
<div class="col-md-4">
<a href="<?php echo (isset($button['link']) ? $this->Html->safe($button['link']) : '#');?>" class="btn btn-med btn-block <?php echo $this->Html->concat(' ', (isset($button['button']) ? $this->Html->safe($button['button']) : null), (isset($key) ? $this->Html->safe($key) : null));?>">
<?php
if (!empty($button['icon'])) {
?>
<i class="<?php (print (isset($button['icon']) ? $this->Html->safe($button['icon']) : null));?>"></i>
<?php
}
$this->_($button['lang']);
?>
</a>
</div>
<?php
// End a row
if ($i % 3 == 2) {
$row_closed = true;
?>
</div>
<?php
}
$i++;
}
// Add closing div if the last row has not been closed
if (!$row_closed) {
?>
</div>
<?php
}
?>
<?php
}
?>
<script type="text/javascript">
$(document).ready(function() {
$("a.cancel_service").blestaModal({url: "<?php echo $this->Html->safe($this->base_uri . 'services/cancel/' . ($service->id ?? null));?>"});
$("a.renew_service").blestaModal({url: "<?php echo $this->Html->safe($this->base_uri . 'services/renew/' . ($service->id ?? null));?>"});
});
</script>