171 lines
5.2 KiB
JavaScript
Vendored
171 lines
5.2 KiB
JavaScript
Vendored
$(document).ready(function(){
|
|
console.log('foo bar');
|
|
$('.scdates').datetimepicker({
|
|
format: 'YYYY-MM-DD'
|
|
});
|
|
$('select').select2();
|
|
// $('#shortCodeDelBtn').on('click', function(evt) {
|
|
$(document).on('click', '.linkButton', function(){
|
|
var theVal = $(this).siblings('.hiddenInput').val();
|
|
console.log('heere at the wall' + theVal );
|
|
$.ajax({
|
|
type: "GET",
|
|
url: base_url + '/clients/get_shortcode/' + theVal,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
console.log(data);
|
|
$('#shortCodeIDEdit').val(theVal);
|
|
$('#nameEdit').val(data.result.name);
|
|
$('#shortCodeClientIdEdit').val(data.result.client_id);
|
|
$('#shortCodeTypeEdit').val(data.result.code_type);
|
|
$('#shortCodeEdit').val(data.result.shortcode);
|
|
$('#tollFreeEdit').val(data.result.toll_free).change();
|
|
$('#monthlyFeeEdit').val(data.result.monthly_fee);
|
|
$('#launchDateEdit').val(data.result.launch_date);
|
|
$('#expiryDateEdit').val(data.result.expiry_date);
|
|
$('#codeStatusEdit').val(data.result.status).change();
|
|
$('#network').val(data.result.network).change();
|
|
$('#remarksEdit').val(data.result.remarks);
|
|
$('#shortCodeEditMain').modal('show');
|
|
}
|
|
else if (data.code > 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
$('.shortCodeDelBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$.confirm({
|
|
title: 'Confirm Deletion',
|
|
content: 'Are you sure you want to delete this Short Code?',
|
|
buttons: {
|
|
confirm: function() {
|
|
var shortCodeId = $('#shortCodeIDEdit').val();
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: base_url + '/allshortcode/remove_code/' + shortCodeId,
|
|
// data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Short Code Details successfully Removed',
|
|
});
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 8000);
|
|
}
|
|
else if (data.code > 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
},
|
|
cancel: function() {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'You cancelled the request. The Short Code has not been deleted!',
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
});
|
|
$('#createSmsShortCodeBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$('#shortCodeType').val('sms');
|
|
$('#newShortCodeFormModal').modal('show');
|
|
});
|
|
$('#createUssdShortCodeBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$('#shortCodeType').val('ussd');
|
|
$('#newShortCodeFormModal').modal('show');
|
|
});
|
|
$('#createVoiceShortCodeBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$('#shortCodeType').val('voice');
|
|
$('#newShortCodeFormModal').modal('show');
|
|
});
|
|
|
|
|
|
|
|
$('#shortCodeForm').submit(function(evt){
|
|
evt.preventDefault();
|
|
var formData = new FormData($(this)[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: base_url + '/clients/shortcode_store',
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Short code details successfully saved',
|
|
});
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 5000);
|
|
}
|
|
else if (data.code > 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
},
|
|
error: function (data) {
|
|
var output = $.parseJSON(data.responseText);
|
|
// console.log(output.errors);
|
|
$('#notifyArea').removeClass('hidden');
|
|
$.each(output.errors, function (key, value) {
|
|
// console.log(value[0]);
|
|
$('#notifyArea').text(value[0]);
|
|
});
|
|
},
|
|
fail : function(errordata){
|
|
// console.log(errordata);
|
|
}
|
|
});
|
|
});
|
|
}); |