137 lines
7.2 KiB
PHP
137 lines
7.2 KiB
PHP
<?php defined('BASEPATH') or exit('No direct script access allowed'); ?>
|
|
<?php init_head(); ?>
|
|
<div id="wrapper">
|
|
<div class="content">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="panel_s">
|
|
<div class="panel-body">
|
|
<h4 class="no-margin">
|
|
<?php echo _l('hubtel_sms_settings'); ?>
|
|
<a href="<?php echo admin_url('hubtel_sms'); ?>" class="btn btn-default pull-right">
|
|
<i class="fa fa-arrow-left"></i> <?php echo _l('back'); ?>
|
|
</a>
|
|
</h4>
|
|
<hr class="hr-panel-heading" />
|
|
|
|
<?php echo form_open(admin_url('hubtel_sms/settings')); ?>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="client_id"><?php echo _l('hubtel_client_id'); ?></label>
|
|
<input type="text" class="form-control" id="client_id" name="client_id"
|
|
value="<?php echo get_option('hubtel_sms_client_id'); ?>" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="client_secret"><?php echo _l('hubtel_client_secret'); ?></label>
|
|
<input type="password" class="form-control" id="client_secret" name="client_secret"
|
|
value="<?php echo get_option('hubtel_sms_client_secret'); ?>" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="sender_id"><?php echo _l('hubtel_sender_id'); ?></label>
|
|
<input type="text" class="form-control" id="sender_id" name="sender_id"
|
|
value="<?php echo get_option('hubtel_sms_sender_id'); ?>"
|
|
maxlength="11" required>
|
|
<small class="text-muted"><?php echo _l('hubtel_sender_id_help'); ?></small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="enabled"><?php echo _l('settings_yes'); ?> / <?php echo _l('settings_no'); ?></label>
|
|
<div class="checkbox checkbox-primary">
|
|
<input type="checkbox" name="enabled" id="enabled"
|
|
<?php if (get_option('hubtel_sms_enabled') == 1) { echo 'checked'; } ?>>
|
|
<label for="enabled"><?php echo _l('hubtel_sms_enable_module'); ?></label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<?php if (get_option('hubtel_sms_client_id') && get_option('hubtel_sms_client_secret')) { ?>
|
|
<div class="panel panel-info">
|
|
<div class="panel-heading">
|
|
<?php echo _l('hubtel_account_info'); ?>
|
|
</div>
|
|
<div class="panel-body" id="hubtel_account_info">
|
|
<!-- Account balance will be loaded here via AJAX -->
|
|
<div class="text-center">
|
|
<div class="spinner-border text-primary" role="status">
|
|
<span class="sr-only">Loading...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<div class="panel panel-warning">
|
|
<div class="panel-heading">
|
|
<?php echo _l('test_sms'); ?>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="form-group">
|
|
<label for="test_number"><?php echo _l('phone_number'); ?></label>
|
|
<input type="text" class="form-control" id="test_number"
|
|
placeholder="<?php echo _l('phone_placeholder'); ?>">
|
|
</div>
|
|
<button type="button" class="btn btn-info" id="send_test_sms">
|
|
<?php echo _l('send_test_sms'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<button type="submit" class="btn btn-info pull-right">
|
|
<?php echo _l('submit'); ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<?php echo form_close(); ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php init_tail(); ?>
|
|
|
|
<script>
|
|
$(function() {
|
|
// Load account info
|
|
<?php if (get_option('hubtel_sms_client_id') && get_option('hubtel_sms_client_secret')) { ?>
|
|
$.get(admin_url + 'hubtel_sms/get_account_info', function(response) {
|
|
if (response.success) {
|
|
var html = '<p><strong><?php echo _l('balance'); ?>:</strong> ' +
|
|
response.data.balance + ' ' + response.data.currency + '</p>';
|
|
$('#hubtel_account_info').html(html);
|
|
} else {
|
|
$('#hubtel_account_info').html('<div class="alert alert-danger">' + response.message + '</div>');
|
|
}
|
|
});
|
|
<?php } ?>
|
|
|
|
// Handle test SMS
|
|
$('#send_test_sms').on('click', function() {
|
|
var $btn = $(this);
|
|
var number = $('#test_number').val();
|
|
|
|
if (!number) {
|
|
alert_float('warning', '<?php echo _l('enter_phone_number'); ?>');
|
|
return;
|
|
}
|
|
|
|
$btn.prop('disabled', true)
|
|
.html('<i class="fa fa-spinner fa-spin"></i> <?php echo _l('sending'); ?>');
|
|
|
|
$.post(admin_url + 'hubtel_sms/send_test', {
|
|
number: number
|
|
}, function(response) {
|
|
if (response.success) {
|
|
alert_float('success', response.message);
|
|
} else {
|
|
alert_float('danger', response.message);
|
|
}
|
|
$btn.prop('disabled', false).html('<?php echo _l('send_test_sms'); ?>');
|
|
});
|
|
});
|
|
});
|
|
</script>
|