249 lines
7.2 KiB
JavaScript
Vendored
249 lines
7.2 KiB
JavaScript
Vendored
$(document).ready(function(){
|
|
//console.log('foo bar');
|
|
var d = new Date();
|
|
var month = d.getMonth()+1;
|
|
var day = d.getDate();
|
|
var currentDate = d.getFullYear() + '/' + ((''+month).length<2 ? '0' : '') + month + '/' + ((''+day).length<2 ? '0' : '') + day;
|
|
|
|
$('select').select2();
|
|
$('#myDatepicker2').datetimepicker({
|
|
format: 'YYYY-MM-DD',
|
|
maxDate: currentDate
|
|
});
|
|
$('#launchDate').datetimepicker({
|
|
format: 'YYYY-MM-DD'
|
|
});
|
|
$('#createNotesBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$('#newNotesForm').modal('show');
|
|
});
|
|
|
|
$('#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');
|
|
});
|
|
|
|
$('#createPaymentBtn').click(function(evt){
|
|
evt.preventDefault();
|
|
$('#financePaymentsForm').modal('show');
|
|
});
|
|
$('.paymentEntryEditBtn').click(function(tve){
|
|
tve.preventDefault();
|
|
//var theIDD = $("input[name=payment_entry_id]").val();
|
|
var theIDD = $(this).siblings('.paymentEntryRowId').val();
|
|
console.log(theIDD);
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: base_url + '/clients/get_payment/' + theIDD,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
console.log(theIDD);
|
|
$('#paymentIdEdit').val(theIDD);
|
|
$('#financeServicesEdit').val(data.services_arr).change();
|
|
$('#invoiceNumberEdit').val(data.result.invoice_number);
|
|
$('#invoiceAmountEdit').val(data.result.invoice_amount);
|
|
$('#invoiceDateEdit').val(data.result.invoice_date);
|
|
$('#invoiceStatusEdit').val(data.result.invoice_status).change();
|
|
$('#remarksEdit').val(data.result.remarks);
|
|
$('#financePaymentsEditForm').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 !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
$('#newNotesFormForm').submit(function(evt){
|
|
evt.preventDefault();
|
|
var formData = new FormData($(this)[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: base_url + '/clients/notes_store',
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$("#newNotesFormForm")[0].reset();
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Notes added successfully',
|
|
});
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 8000);
|
|
}
|
|
else if (data.code > 5) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
$('#financeForm').submit(function(evt){
|
|
evt.preventDefault();
|
|
var formData = new FormData($(this)[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: base_url + '/clients/finance_store',
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$("#financeForm")[0].reset();
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Payment Details added successfully',
|
|
});
|
|
setTimeout(function(){
|
|
location.reload();
|
|
}, 8000);
|
|
}
|
|
else if (data.code > 5) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: data.msg,
|
|
});
|
|
}
|
|
else {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Your request could not be handled. Try again !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#financeEditForm').submit(function(evt){
|
|
evt.preventDefault();
|
|
var formData = new FormData($(this)[0]);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: base_url + '/clients/finance_update',
|
|
data : formData,
|
|
processData: false,
|
|
contentType: false,
|
|
async: false,
|
|
success: function (data){
|
|
if (data.code === 1) {
|
|
$.alert({
|
|
title: 'Alert!',
|
|
content: 'Payment Details successfully updated',
|
|
});
|
|
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 !',
|
|
});
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#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();
|
|
}, 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 !',
|
|
});
|
|
|
|
}
|
|
},
|
|
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);
|
|
}
|
|
});
|
|
});
|
|
|
|
//
|
|
|
|
}); |