first commit
This commit is contained in:
74
views/templates/hook/breadcrumb.tpl
Normal file
74
views/templates/hook/breadcrumb.tpl
Normal file
@@ -0,0 +1,74 @@
|
||||
{if $show_switch}
|
||||
<style>
|
||||
.payments-selection {
|
||||
justify-content: flex-end;
|
||||
margin: 10px 0;
|
||||
}
|
||||
</style>
|
||||
<div class="col-md-6 col-lg-3">
|
||||
<div class="payments-selection">
|
||||
|
||||
|
||||
{* The select dropdown *}
|
||||
<select id="b2b-group-select" name="b2b_group_type" class="custom-select" onchange="switchB2Bpayment();">
|
||||
|
||||
{* Option for Prepaid *}
|
||||
<option value="prepaid" {if !$current_group_is_postpaid}selected{/if}>
|
||||
{l s='Prepaid' d='Modules.B2bpayments.ShopBreadcrumb'}
|
||||
</option>
|
||||
|
||||
{* Option for Postpaid *}
|
||||
<option value="postpaid" {if $current_group_is_postpaid}selected{/if}>
|
||||
{l s='Postpaid' d='Modules.B2bpayments.ShopBreadcrumb'}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function switchB2Bpayment() {
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '{$switch_url|escape:'javascript'}');
|
||||
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); // Required for POST requests
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
try {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success) {
|
||||
// Success: Reload the page to reflect the change
|
||||
location.reload();
|
||||
} else {
|
||||
|
||||
alert('{$error_message|escape:'javascript'}');
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('JSON Parsing Error:', e, xhr.responseText);
|
||||
alert('An error occurred while processing the response. Please try again.');
|
||||
}
|
||||
} else {
|
||||
// HTTP error: Show generic error
|
||||
console.error('HTTP Error:', xhr.status, xhr.statusText);
|
||||
alert('An error occurred while switching groups (HTTP ' + xhr.status + '). Please try again.');
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
// Network or other request error
|
||||
console.error('Request failed');
|
||||
alert(
|
||||
'An error occurred while switching groups (Network Error). Please check your connection and try again.'
|
||||
);
|
||||
|
||||
};
|
||||
const params = 'ajax=true&action=switchGroup'; // Build the query string
|
||||
xhr.send(params);
|
||||
};
|
||||
</script>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user