handle client resource and sub resources for notes and loanaccount summaries.
This commit is contained in:
+94
-51
@@ -12,8 +12,6 @@
|
||||
<jsp:include page="../common-head.jsp" />
|
||||
<c:url value="/" var="rootContext" />
|
||||
<c:url value="/portfolio/client/${clientId}" var="clientUrl" />
|
||||
<c:url value="/portfolio/client/${clientId}/note/all" var="allClientNotesUrl" />
|
||||
|
||||
<style>
|
||||
div.notecontainer {wdith:300px;min-width:300px;max-width:400px;}
|
||||
span.noteusername {font-weight:bold;font-style: italic;}
|
||||
@@ -314,16 +312,17 @@ $(document).ready(function() {
|
||||
}).dialog('open');
|
||||
}
|
||||
|
||||
function popupDialogWithFormView(url, titleCode, templateSelector, width, height, tabIndex, minOffset, defaultOffset, maxOffset) {
|
||||
// function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, tabIndex, minOffset, defaultOffset, maxOffset) {
|
||||
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
url: getUrl,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
|
||||
console.log(data);
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
@@ -333,25 +332,29 @@ $(document).ready(function() {
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
$('.multiSelectedItems option').each(function(i) {
|
||||
|
||||
$('#notSelectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var form_data = $('#entityform').serialize();
|
||||
|
||||
|
||||
$('#selectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: form_data,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
dialogDiv.dialog("close");
|
||||
$newtabs.tabs('load', tabIndex);
|
||||
url: postUrl,
|
||||
type: submitType,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: newFormData,
|
||||
success: saveSuccessFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
@@ -367,20 +370,19 @@ $(document).ready(function() {
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
$('.multiadd').click(function() {
|
||||
return !$('.multiNotSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
|
||||
$('#add').click(function() {
|
||||
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('.multiremove').click(function() {
|
||||
return !$('.multiSelectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
$('#remove').click(function() {
|
||||
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, minDate: minOffset, defaultDate: defaultOffset, maxDate: maxOffset, dateFormat: 'dd MM yy'});
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
|
||||
$("#entityform textarea").first().focus();
|
||||
$('#entityform input').first().focus();
|
||||
|
||||
calculateAnnualPercentageRate();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
@@ -389,7 +391,7 @@ $(document).ready(function() {
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var tab_counter = 1;
|
||||
var $newtabs = $("#newtabs").tabs({
|
||||
@@ -410,6 +412,9 @@ $(document).ready(function() {
|
||||
$(anchor.hash).html("error occured while ajax loading.");
|
||||
},
|
||||
success: function(data, status, xhr) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
var currentTabIndex = $newtabs.tabs('option', 'selected');
|
||||
var currentTabAnchor = $newtabs.data('tabs').anchors[currentTabIndex];
|
||||
//$(currentTabAnchor).data('cache.tabs', true)
|
||||
@@ -421,12 +426,20 @@ $(document).ready(function() {
|
||||
var maxOffset = 0; // today
|
||||
|
||||
if (currentTabIndex < 1) {
|
||||
console.log("success: client tab.");
|
||||
var tableHtml = $("#clientDataTabTemplate").render(data);
|
||||
$("#clienttab").html(tableHtml);
|
||||
|
||||
$("#clienttabname").html(data.displayName);
|
||||
|
||||
// retrieve accounts summary info
|
||||
refreshLoanSummaryInfo();
|
||||
|
||||
// retrieve additional info
|
||||
var extraDataParams = {
|
||||
url: '${rootContext}',
|
||||
datasetType: "portfolio_client",
|
||||
datasetPKValue: data.clientInfo.id,
|
||||
datasetPKValue: data.id,
|
||||
datasetTypeDiv: "clientadditionaldata",
|
||||
headingPrefix: "",
|
||||
headingClass: "",
|
||||
@@ -435,6 +448,7 @@ $(document).ready(function() {
|
||||
};
|
||||
jQuery.stretchyData.displayAllExtraData(extraDataParams);
|
||||
|
||||
// bind click listeners to buttons.
|
||||
$('.casflowbtn').button().click(function(e) {
|
||||
var linkId = this.id;
|
||||
var clientId = linkId.replace("cashflowbtn", "");
|
||||
@@ -456,27 +470,23 @@ $(document).ready(function() {
|
||||
$('.addnotebtn').button().click(function(e) {
|
||||
var linkId = this.id;
|
||||
var clientId = linkId.replace("addnotebtn", "");
|
||||
var url = '${rootContext}portfolio/client/' + clientId + '/note/new';
|
||||
var getAndPostUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/' + clientId + '/notes';
|
||||
|
||||
var templateSelector = "#noteFormTemplate";
|
||||
var width = 600;
|
||||
var height = 400;
|
||||
var defaultOffset = data.clientInfo.maxJoinedOnOffsetFromToday;
|
||||
popupDialogWithFormView(url, "dialog.title.add.note", templateSelector, width, height, currentTabIndex, defaultOffset, defaultOffset, maxOffset);
|
||||
|
||||
var saveSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
$("#dialog-form").dialog("close");
|
||||
refreshNoteWidget();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getAndPostUrl, getAndPostUrl, 'POST', "dialog.title.add.note", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
$('button.addnotebtn span').text(jQuery.i18n.prop('dialog.button.add.note'));
|
||||
|
||||
$("a.openloanaccount").click( function(e) {
|
||||
var tab_title = $(this).attr('title');
|
||||
var tab_href = this.href;
|
||||
|
||||
$newtabs.tabs( "add", tab_href, tab_title );
|
||||
tab_counter++;
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
refreshNoteWidget();
|
||||
|
||||
refreshNoteWidget();
|
||||
|
||||
} else {
|
||||
|
||||
@@ -654,22 +664,52 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
// function to retrieve and display loan summary information in it placeholder
|
||||
function refreshLoanSummaryInfo() {
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/loans',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
var tableHtml = $("#clientAccountSummariesTemplate").render(data);
|
||||
$("#clientaccountssummary").html(tableHtml);
|
||||
|
||||
$("a.openloanaccount").click( function(e) {
|
||||
var tab_title = $(this).attr('title');
|
||||
var tab_href = this.href;
|
||||
|
||||
$newtabs.tabs( "add", tab_href, tab_title );
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
|
||||
function refreshNoteWidget() {
|
||||
|
||||
var noteArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: '${allClientNotesUrl}',
|
||||
url: 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
|
||||
var noteParent = new Object();
|
||||
noteParent.title = jQuery.i18n.prop('widget.notes.heading');
|
||||
noteParent.items = data;
|
||||
noteParent.items = data.notes;
|
||||
|
||||
var tableHtml = $("#noteListViewTemplate").render(noteParent);
|
||||
$("#clienttabrightpane").html(tableHtml);
|
||||
@@ -677,14 +717,17 @@ $(document).ready(function() {
|
||||
$('.editclientnote').click(function(e) {
|
||||
var linkId = this.id;
|
||||
var noteId = linkId.replace("editclientnotelink", "");
|
||||
var url = '${rootContext}portfolio/client/${clientId}/note/' + noteId;
|
||||
var getAndPutUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}/notes/' + noteId;
|
||||
var templateSelector = "#noteFormTemplate";
|
||||
var width = 600;
|
||||
var height = 400;
|
||||
var defaultOffset = -400; // would be nice to return the max allowed offset for date for client note
|
||||
var maxOffset = 0;
|
||||
var currentTabIndex = 0;
|
||||
popupDialogWithFormView(url, "dialog.title.edit.note", templateSelector, width, height, currentTabIndex, defaultOffset, defaultOffset, maxOffset);
|
||||
|
||||
var saveSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
$("#dialog-form").dialog("close");
|
||||
refreshNoteWidget();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getAndPutUrl, getAndPutUrl, 'PUT', "dialog.title.edit.note", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
@@ -730,7 +773,7 @@ $(document).ready(function() {
|
||||
|
||||
<div id="newtabs">
|
||||
<ul>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}" title="clienttab" class="topleveltab">${clientDisplayName}</a></li>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients/${clientId}" title="clienttab" class="topleveltab"><span id="clienttabname">Loading...</span></a></li>
|
||||
</ul>
|
||||
<div id="clienttab">
|
||||
</div>
|
||||
|
||||
@@ -13,96 +13,72 @@
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// these helpers are registered for the jsViews and jsRender functionality to fix bug with display zero!
|
||||
$.views.registerHelpers({
|
||||
|
||||
money: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "n" + digits);
|
||||
},
|
||||
moneyWithCurrency: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "c" + digits);
|
||||
},
|
||||
decimal: function(number, digits) {
|
||||
try {
|
||||
return number.toFixed(digits);
|
||||
} catch(e) {
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
number: function(number) {
|
||||
try {
|
||||
return number.toFixed(0);
|
||||
} catch(e) {
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
numberGreaterThanZero: function(number) {
|
||||
money: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "n" + digits);
|
||||
},
|
||||
moneyWithCurrency: function(monetaryObj) {
|
||||
|
||||
Globalize.culture().numberFormat.currency.symbol = monetaryObj.displaySymbol;
|
||||
|
||||
var digits = monetaryObj.currencyDigitsAfterDecimal.toFixed(0);
|
||||
return Globalize.format(monetaryObj.amount, "c" + digits);
|
||||
},
|
||||
decimal: function(number, digits) {
|
||||
try {
|
||||
var num = number.toFixed(0);
|
||||
return num > 0;
|
||||
return Globalize.format(number, "n" + digits);
|
||||
} catch(e) {
|
||||
return false;
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
json: function(obj) {
|
||||
number: function(number) {
|
||||
try {
|
||||
return JSON.stringify(obj);
|
||||
return Globalize.format(number, "n0");
|
||||
} catch(e) {
|
||||
return "" + e;
|
||||
return number +"(NaN)";
|
||||
}
|
||||
},
|
||||
globalDate: function(dateParts) {
|
||||
try {
|
||||
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
var day = dateParts[2];
|
||||
|
||||
var d = new Date();
|
||||
d.setFullYear(year,month,day);
|
||||
|
||||
return Globalize.format(d,"dd MMMM yyyy");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
},
|
||||
globalDateTime: function(dateParts) {
|
||||
try {
|
||||
var d = new Date(dateParts);
|
||||
|
||||
return Globalize.format(d,"F");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
numberGreaterThanZero: function(number) {
|
||||
try {
|
||||
var num = number.toFixed(0);
|
||||
return num > 0;
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
globalDate: function(localDateAsISOString) {
|
||||
try {
|
||||
var dateParts = localDateAsISOString.split("-")
|
||||
var year = dateParts[0];
|
||||
var month = parseInt(dateParts[1]) - 1; // month is zero indexed
|
||||
var day = dateParts[2];
|
||||
|
||||
var d = new Date();
|
||||
d.setFullYear(year,month,day);
|
||||
|
||||
return Globalize.format(d,"dd MMMM yyyy");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
},
|
||||
globalDateTime: function(dateInMillis) {
|
||||
try {
|
||||
var d = new Date(dateInMillis);
|
||||
|
||||
return Globalize.format(d,"F");
|
||||
} catch(e) {
|
||||
return "??";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeholderDiv) {
|
||||
if (jqXHR.status === 0) {
|
||||
alert('No connection. Verify application is running.');
|
||||
} else if (jqXHR.status == 401) {
|
||||
alert('Unauthorized. [401]');
|
||||
} else if (jqXHR.status == 404) {
|
||||
alert('Requested page not found. [404]');
|
||||
} else if (jqXHR.status == 405) {
|
||||
alert('HTTP verb not supported [405]: ' + errorThrown);
|
||||
} else if (jqXHR.status == 500) {
|
||||
alert('Internal Server Error [500].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
alert('Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
alert('Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
alert('Ajax request aborted.');
|
||||
} else {
|
||||
|
||||
function removeErrors(placeholderDiv) {
|
||||
// remove error class from all input fields
|
||||
var $inputs = $('#entityform :input');
|
||||
|
||||
@@ -111,102 +87,196 @@ function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeh
|
||||
});
|
||||
|
||||
$(placeholderDiv).html("");
|
||||
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(jsonErrors, function() {
|
||||
var fieldId = '#' + this.field;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.field;
|
||||
errorObj.code = this.code;
|
||||
errorObj.message = jQuery.i18n.prop(this.code, this.args);
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
arrayIndex++
|
||||
});
|
||||
|
||||
var templateArray = new Array();
|
||||
var templateErrorObj = new Object();
|
||||
templateErrorObj.title = "You have the following errors:";
|
||||
templateErrorObj.errors = errorArray;
|
||||
|
||||
templateArray[0] = templateErrorObj;
|
||||
|
||||
var formErrorsHtml = $(templateSelector).render(templateArray);
|
||||
|
||||
$(placeholderDiv).append(formErrorsHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function popupDialogWithFormView(url, titleCode, templateSelector, width, height, successFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector, placeholderDiv) {
|
||||
if (jqXHR.status === 0) {
|
||||
alert('No connection. Verify application is running.');
|
||||
} else if (jqXHR.status == 401) {
|
||||
alert('Unauthorized. [401]');
|
||||
} else if (jqXHR.status == 404) {
|
||||
alert('Requested page not found. [404]');
|
||||
} else if (jqXHR.status == 405) {
|
||||
alert('HTTP verb not supported [405]: ' + errorThrown);
|
||||
} else if (jqXHR.status == 500) {
|
||||
alert('Internal Server Error [500].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
alert('Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
alert('Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
alert('Ajax request aborted.');
|
||||
} else {
|
||||
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
removeErrors(placeholderDiv);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
|
||||
var saveButton = jQuery.i18n.prop('dialog.button.save');
|
||||
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
$('.multiSelectedItems option').each(function(i) {
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
console.log(jsonErrors);
|
||||
var valErrors = jsonErrors.errors;
|
||||
console.log(valErrors);
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(valErrors, function() {
|
||||
var fieldId = '#' + this.parameterName;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.parameterName;
|
||||
errorObj.code = this.userMessageGlobalisationCode;
|
||||
|
||||
var argArray = new Array();
|
||||
var argArrayIndex = 0;
|
||||
$.each(this.args, function() {
|
||||
argArray[argArrayIndex] = this.value;
|
||||
argArrayIndex++;
|
||||
});
|
||||
console.log(argArray);
|
||||
// hardcoded support for six arguments
|
||||
errorObj.message = jQuery.i18n.prop(this.userMessageGlobalisationCode, argArray[0], argArray[1], argArray[2], argArray[3], argArray[4], argArray[5]);
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
arrayIndex++
|
||||
});
|
||||
|
||||
var templateArray = new Array();
|
||||
var templateErrorObj = new Object();
|
||||
templateErrorObj.title = jQuery.i18n.prop('error.msg.header');
|
||||
templateErrorObj.errors = errorArray;
|
||||
|
||||
templateArray[0] = templateErrorObj;
|
||||
|
||||
var formErrorsHtml = $(templateSelector).render(templateArray);
|
||||
|
||||
$(placeholderDiv).append(formErrorsHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function showNotAvailableDialog(titleCode) {
|
||||
var dialogDiv = $("<div id='notavailable-dialog-form'></div>");
|
||||
|
||||
dialogDiv.append("<p>" + jQuery.i18n.prop('dialog.messages.functionality.not.available') + "</p>");
|
||||
|
||||
var okButton = jQuery.i18n.prop('dialog.button.ok');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[okButton] = function() {$(this).dialog("close");};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: 300,
|
||||
height: 200,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
|
||||
$.fn.serializeObject = function()
|
||||
{
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
$.each(a, function() {
|
||||
if (o[this.name] !== undefined) {
|
||||
if (!o[this.name].push) {
|
||||
o[this.name] = [o[this.name]];
|
||||
}
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
|
||||
if (this.name === 'selectedItems' || this.name === 'notSelectedItems') {
|
||||
o[this.name] = new Array();
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
o[this.name] = this.value || '';
|
||||
}
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
|
||||
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: getUrl,
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
console.log(data);
|
||||
var formHtml = $(templateSelector).render(data);
|
||||
|
||||
dialogDiv.append(formHtml);
|
||||
|
||||
var saveButton = jQuery.i18n.prop('dialog.button.save');
|
||||
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
|
||||
$('#notSelectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
$('#selectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var form_data = $('#entityform').serialize();
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: form_data,
|
||||
success: successFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: width,
|
||||
height: height,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
$('.multiadd').click(function() {
|
||||
return !$('.multiNotSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('.multiremove').click(function() {
|
||||
return !$('.multiSelectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var newFormData = JSON.stringify($('#entityform').serializeObject());
|
||||
console.log(newFormData);
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: postUrl,
|
||||
type: submitType,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: newFormData,
|
||||
success: saveSuccessFunction,
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
|
||||
|
||||
dialogDiv.dialog({
|
||||
title: jQuery.i18n.prop(titleCode),
|
||||
width: width,
|
||||
height: height,
|
||||
modal: true,
|
||||
buttons: buttonsOpts,
|
||||
close: function() {
|
||||
// if i dont do this, theres a problem with errors being appended to dialog view second time round
|
||||
$(this).remove();
|
||||
},
|
||||
open: function (event, ui) {
|
||||
|
||||
$('#add').click(function() {
|
||||
return !$('#notSelectedItems option:selected').remove().appendTo('#selectedItems');
|
||||
});
|
||||
|
||||
$('#remove').click(function() {
|
||||
return !$('#selectedItems option:selected').remove().appendTo('#notSelectedItems');
|
||||
});
|
||||
|
||||
$('.datepickerfield').datepicker({constrainInput: true, maxDate: 0, dateFormat: 'dd MM yy'});
|
||||
|
||||
$("#entityform textarea").first().focus();
|
||||
$('#entityform input').first().focus();
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
jqxhr.error(function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate", "#formerrors");
|
||||
});
|
||||
}
|
||||
|
||||
$("#tabs").tabs({
|
||||
"ajaxOptions": {
|
||||
@@ -234,13 +304,13 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
}
|
||||
|
||||
$("#addclient").button().click(function(e) {
|
||||
|
||||
var url = '${rootContext}portfolio/client/new';
|
||||
var getUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients/template';
|
||||
var postUrl = 'http://localhost:8080/mifosng-provider/api/v1/clients';
|
||||
var templateSelector = "#clientFormTemplate";
|
||||
var width = 600;
|
||||
var height = 350;
|
||||
|
||||
popupDialogWithFormView(url, 'dialog.title.add.client', templateSelector, width, height, addClientSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, postUrl, 'POST', 'dialog.title.add.client', templateSelector, width, height, addClientSuccessFunction);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
@@ -253,9 +323,6 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
<div id="container">
|
||||
<jsp:include page="top-navigation.jsp" />
|
||||
|
||||
<c:url value="/portfolio/client/all" var="allClientsUrl" />
|
||||
<c:url value="/portfolio/client/add" var="addClientUrl" />
|
||||
|
||||
<div style="float:none; clear:both;">
|
||||
<div id="spacer" style="line-height: 15px;"> </div>
|
||||
<div id="content">
|
||||
@@ -264,7 +331,7 @@ function popupDialogWithFormView(url, titleCode, templateSelector, width, height
|
||||
</sec:authorize>
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="${allClientsUrl}" title="searchtab"><spring:message code="tab.search"/></a></li>
|
||||
<li><a href="http://localhost:8080/mifosng-provider/api/v1/clients" title="searchtab"><spring:message code="tab.search"/></a></li>
|
||||
</ul>
|
||||
<div id="searchtab"></div>
|
||||
</div>
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
<form id="entityform">
|
||||
<div id="formerrors"></div>
|
||||
<label for="office"><spring:message code="label.office"/></label>
|
||||
<select id="office" name="office" title="">
|
||||
<select id="officeId" name="officeId" title="">
|
||||
<option value=""><spring:message code="option.office.first.choice"/></option>
|
||||
{{#each allowedOffices}}
|
||||
{{#if $ctx.number($parent.parent.data.officeId)===$ctx.number(id)}}
|
||||
@@ -355,43 +355,13 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<label for="joiningDate"><spring:message code="label.joiningdate"/></label>
|
||||
<input id="joiningDate" name="joiningDate" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(joinedDate)}}"/>
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="joiningDateFormatted"><spring:message code="label.joiningdate"/></label>
|
||||
<input id="joiningDateFormatted" name="joiningDateFormatted" title="" type="text" class="datepickerfield" value="{{=$ctx.globalDate(joinedDate)}}"/>
|
||||
</form>
|
||||
</script>
|
||||
|
||||
<script id="clientDataTabTemplate" type="text/x-jquery-tmpl">
|
||||
<c:url value="/" var="rootContext" />
|
||||
|
||||
<span id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<!--
|
||||
<button id="cashflowbtn{{=clientInfo.id}}" class="casflowbtn">New cashflow analysis</button>
|
||||
-->
|
||||
<sec:authorize access="hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')">
|
||||
<button id="newloanbtn{{=clientInfo.id}}" class="newloanbtn">New loan application</button>
|
||||
</sec:authorize>
|
||||
|
||||
<button id="addnotebtn{{=clientInfo.id}}" class="addnotebtn">Add note</button>
|
||||
</span>
|
||||
<hr/>
|
||||
|
||||
<div id="clienttabcontent">
|
||||
<div id="clienttableftpane" style="float:left; max-width: 700px; width: 700px;">
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.name"/></span>
|
||||
<span class="rowvalue">{{=clientInfo.displayName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.branch"/></span>
|
||||
<span class="rowvalue">{{=clientInfo.officeName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.joinedon"/></span>
|
||||
<span class="rowvalue">{{=$ctx.globalDate(clientInfo.joinedDate)}}</span>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<p><b><spring:message code="heading.client.account.account.overview"/></b></p>
|
||||
<script id="clientAccountSummariesTemplate" type="text/x-jquery-tmpl">
|
||||
{{#if $ctx.numberGreaterThanZero(anyLoanCount)}}
|
||||
|
||||
{{#if $ctx.numberGreaterThanZero(pendingApprovalLoanCount)}}
|
||||
@@ -399,7 +369,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.pending.approval.loans"/> ({{=$ctx.number(pendingApprovalLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each pendingApprovalLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -410,7 +380,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.pending.disbursal.loans"/> ({{=$ctx.number(awaitingDisbursalLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each awaitingDisbursalLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -421,7 +391,7 @@
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.active.loans"/> ({{=$ctx.number(activeLoanCount)}}):</span>
|
||||
<span class="rowvalue">
|
||||
{{#each openLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</span>
|
||||
</div>
|
||||
@@ -432,7 +402,7 @@
|
||||
<div class="longrowlabel"><spring:message code="label.client.account.closed.loans"/> ({{=$ctx.number(closedLoanCount)}}):</div>
|
||||
<div class="rowvalue">
|
||||
{{#each closedLoans}}
|
||||
<span class="loanaccount"><a href="${rootContext}portfolio/loan/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
<span class="loanaccount"><a href="http://localhost:8080/mifosng-provider/api/v1/loans/{{=id}}" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: #{{=id}}">{{=loanProductName}}: #{{=id}}</a></span>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -443,14 +413,45 @@
|
||||
<spring:message code="label.client.account.no.loans.exist"/>
|
||||
</div>
|
||||
{{/if}}
|
||||
</script>
|
||||
|
||||
<div id="clientadditionaldata"></div>
|
||||
</div>
|
||||
<!-- end of left pane content -->
|
||||
<script id="clientDataTabTemplate" type="text/x-jquery-tmpl">
|
||||
<span id="toolbar" class="ui-widget-header ui-corner-all">
|
||||
<!--
|
||||
<button id="cashflowbtn{{=id}}" class="casflowbtn">New cashflow analysis</button>
|
||||
-->
|
||||
<sec:authorize access="hasAnyRole('PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE', 'CAN_SUBMIT_NEW_LOAN_APPLICATION_ROLE', 'CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE')">
|
||||
<button id="newloanbtn{{=id}}" class="newloanbtn">New loan application</button>
|
||||
</sec:authorize>
|
||||
|
||||
<div id="clienttabrightpane" style="float:right;">
|
||||
</div>
|
||||
<button id="addnotebtn{{=id}}" class="addnotebtn">Add note</button>
|
||||
</span>
|
||||
<hr/>
|
||||
|
||||
<div id="clienttabcontent">
|
||||
<div id="clienttableftpane" style="float:left; max-width: 700px; width: 700px;">
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.name"/></span>
|
||||
<span class="rowvalue">{{=displayName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.branch"/></span>
|
||||
<span class="rowvalue">{{=officeName}}</span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="longrowlabel"><spring:message code="label.client.account.joinedon"/></span>
|
||||
<span class="rowvalue">{{=$ctx.globalDate(joinedDate)}}</span>
|
||||
</div>
|
||||
|
||||
<p><b><spring:message code="heading.client.account.account.overview"/></b></p>
|
||||
<div id="clientaccountssummary"></div>
|
||||
|
||||
<div id="clientadditionaldata"></div>
|
||||
</div>
|
||||
<!-- end of left pane content -->
|
||||
|
||||
<!-- placeholder for notes content -->
|
||||
<div id="clienttabrightpane" style="float:right;"></div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user