[prev in list] [next in list] [prev in thread] [next in thread]
List: mifos-developer
Subject: Re: [Mifos-developer] [RESENDING] Mifos X Patch Release
From: A A <abiyats () gmail ! com>
Date: 2019-02-28 17:01:50
Message-ID: CAK9nzyYeJ5xZeyGzDSdz11AJKV8pLE-ZVtPDD5cMbyi5UcuO1Q () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/related)]
[Attachment #4 (multipart/alternative)]
First Stop Mifos
Clear Yoour Browser Caches for best result
Edit .../webapps/ROOT/global-translations/locale-en.json
"reportRunFrequency.monthly": "Monthly",
"reportRunFrequency.yearly": "Yearly",
"reportRunFrequency.custom": "Custom",
"----End---": "--End of file--- "
Add
"label.heading.activate.group": "Activate Group",
"reportRunFrequency.monthly": "Monthly",
"reportRunFrequency.yearly": "Yearly",
"reportRunFrequency.custom": "Custom",
"label.heading.activate.group": "Activate Group",
"----End---": "--End of file--- "
***************************************************
Go to .../webapps/ROOT/scripts/controllers/
Remove controllers.85405de5.js
Replace with the one I am attaching you.
Open controllers.85405de5.txt save as controllers.85405de5.js (sent as text
for ease of attachment)
*************************************
Go to .../webapps/ROOT/scripts/directives/
Remove directives.9ddc8aa2.js
Replace with the one I am attaching you.
Open directives.9ddc8aa2.txt save as directives.9ddc8aa2.js (sent as text
for ease of attachment)
*************************************
Go to .../webapps/ROOT/views/groups/
Remove editgroup.html
Replace with the one I am attaching you.
editgroup.html
******
Start Mifos, then ...
Enjoy!
Regards,
On Thu, Feb 28, 2019 at 7:24 PM Zayyad A. Said <
zayyad@intrasofttechnologies.com> wrote:
> Devs,
>
>
>
> Kindly advise where I can download Mifos 18.03.01 Patch Release.
>
>
>
> I downloaded
> https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip
> but in this release we still have the datatable issue and unable to edit
> groups
>
>
>
> Regards;
>
>
>
> *********
>
> *Zayyad A. Said | Chairman & C.E.O*
>
>
>
> Cell No.: +254 716 615274 | Skype: *zsaid2011*
>
> Email: zayyad@intrasofttechnologies.com
>
> Schedule Meetings: https://calendly.com/zayyadsaid
>
> [image: Description: Email banner]
>
>
>
> *From:* Zayyad A. Said [mailto:zayyad@intrasofttechnologies.com]
> *Sent:* 18 February 2019 09:08 AM
> *To:* mifos-developer@lists.sourceforge.net
> *Subject:* Mifos X Patch Release
>
>
>
> Devs,
>
>
>
> Kindly advise where I can download Mifos 18.03.01 Patch Release.
>
>
>
> I downloaded
> https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip
> but in this release we still have the datatable issue and unable to edit
> groups
>
>
>
> *Regards;*
>
>
>
> *********
>
> *Zayyad A. Said | Chairman & C.E.O*
>
>
>
> Cell No.: +254 716 615274 | Skype: *zsaid2011*
>
> Email: zayyad@intrasofttechnologies.com
>
> Schedule Meetings: https://calendly.com/zayyadsaid
>
> [image: Description: Email banner]
>
>
> Mifos-developer mailing list
> mifos-developer@lists.sourceforge.net
> Unsubscribe or change settings at:
> https://lists.sourceforge.net/lists/listinfo/mifos-developer
[Attachment #7 (text/html)]
<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:"comic \
sans ms",sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div \
class="gmail_default"><div class="gmail_default"><font color="#000000" face="comic \
sans ms, sans-serif">First Stop Mifos</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, sans-serif">Clear \
Yoour Browser Caches for best result</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif">Edit \
.../webapps/ROOT/global-translations/locale-en.json</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, sans-serif"> \
</font></div><div class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.monthly": \
"Monthly", </font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.yearly": \
"Yearly", </font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.custom": \
"Custom",</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif">"----End---": "--End \
of file--- "</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif">Add</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"label.heading.activate.group": \
"Activate Group",</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.monthly": \
"Monthly", </font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.yearly": \
"Yearly", </font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">"reportRunFrequency.custom": \
"Custom",</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, \
sans-serif">"label.heading.activate.group": "Activate \
Group",</font></div><div class="gmail_default"><font color="#000000" face="comic \
sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif">"----End---": "--End \
of file--- "</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, \
sans-serif">***************************************************</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Go to \
.../webapps/ROOT/scripts/controllers/</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, sans-serif">Remove \
controllers.85405de5.js</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Replace with the one I am attaching \
you.</font></div><div class="gmail_default"><font color="#000000" face="comic sans \
ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Open controllers.85405de5.txt save as \
controllers.85405de5.js (sent as text for ease of attachment)</font><br></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, \
sans-serif">*************************************</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Go to \
.../webapps/ROOT/scripts/directives/</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, sans-serif">Remove \
directives.9ddc8aa2.js</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Replace with the one I am attaching \
you.</font></div><div class="gmail_default"><font color="#000000" face="comic sans \
ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Open directives.9ddc8aa2.txt save as </font><span \
style="color:rgb(0,0,0);font-family:"comic sans \
ms",sans-serif">directives.9ddc8aa2.js</span><font color="#000000" face="comic \
sans ms, sans-serif"> </font><span style="color:rgb(0,0,0);font-family:"comic \
sans ms",sans-serif">(sent as text for ease of attachment)</span></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, \
sans-serif">*************************************</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Go to \
.../webapps/ROOT/views/groups/</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, sans-serif">Remove \
editgroup.html</font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif"><br></font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif">Replace with the one I am attaching \
you.</font></div><div class="gmail_default"><font color="#000000" face="comic sans \
ms, sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">editgroup.html</font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default">******<br>Start Mifos, then \
...</div><div class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif"><br></font></div><div class="gmail_default"><font color="#000000" \
face="comic sans ms, sans-serif">Enjoy!</font></div><div class="gmail_default"><font \
color="#000000" face="comic sans ms, sans-serif"><br></font></div><div \
class="gmail_default"><font color="#000000" face="comic sans ms, \
sans-serif">Regards,</font></div></div></div></div></div></div></div></div></div><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 28, 2019 at 7:24 PM \
Zayyad A. Said <<a \
href="mailto:zayyad@intrasofttechnologies.com">zayyad@intrasofttechnologies.com</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-GB"><div \
class="gmail-m_7155670254059796842WordSection1"><p class="MsoNormal"><span \
style="color:rgb(68,84,106)">Devs,<u></u><u></u></span></p><p class="MsoNormal"><span \
style="color:rgb(68,84,106)"><u></u> <u></u></span></p><p class="MsoNormal">Kindly \
advise where I can download Mifos 18.03.01 Patch Release.<u></u><u></u></p><p \
class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I downloaded <a \
href="https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip" \
target="_blank">https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip</a> \
but in this release we still have the datatable issue and unable to edit \
groups<u></u><u></u></p><p class="MsoNormal"><span \
style="color:rgb(68,84,106)"><u></u> <u></u></span></p><div><p \
class="MsoNormal"><span style="color:rgb(68,84,106)">Regards;</span><b><span \
lang="EN-US" style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></b></p><p \
class="MsoNormal" style="background:white"><b><span lang="EN-US" \
style="font-family:Helvetica,sans-serif;color:black"><u></u> \
<u></u></span></b></p><p class="MsoNormal" style="background:white"><b><span \
lang="EN-US" style="font-family:Helvetica,sans-serif;color:black">*******</span></b><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="background:white"><b><span lang="EN-US" \
style="font-size:14pt;font-family:Helvetica,sans-serif;color:black">Zayyad A. Said | \
Chairman & C.E.O</span></b><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black"> </span><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black">Cell No.: +254 \
716 615274 | Skype: <b>zsaid2011</b></span><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black">Email: <a \
href="mailto:zayyad@intrasofttechnologies.com" target="_blank"><span \
style="color:blue">zayyad@intrasofttechnologies.com</span></a> \
<u></u><u></u></span></p><p class="MsoNormal" \
style="line-height:10.5pt;background:white"><span \
style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(68,84,106)">Schedule \
Meetings: <a href="https://calendly.com/zayyadsaid" target="_blank"><span \
style="color:blue">https://calendly.com/zayyadsaid</span></a> \
<u></u><u></u></span></p><p class="MsoNormal"><span \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black"><img border="0" \
width="623" height="176" id="gmail-m_7155670254059796842_x0000_i1026" \
src="cid:1693502dbb15b006a1" alt="Description: Email \
banner"><u></u><u></u></span></p></div><p class="MsoNormal"><span \
style="color:rgb(68,84,106)"><u></u> <u></u></span></p><div><div \
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid \
rgb(181,196,223);padding:3pt 0cm 0cm"><p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span \
lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> Zayyad A. Said \
[mailto:<a href="mailto:zayyad@intrasofttechnologies.com" \
target="_blank">zayyad@intrasofttechnologies.com</a>] <br><b>Sent:</b> 18 February \
2019 09:08 AM<br><b>To:</b> <a href="mailto:mifos-developer@lists.sourceforge.net" \
target="_blank">mifos-developer@lists.sourceforge.net</a><br><b>Subject:</b> Mifos X \
Patch Release<u></u><u></u></span></p></div></div><p class="MsoNormal"><u></u> \
<u></u></p><p class="MsoNormal">Devs,<u></u><u></u></p><p class="MsoNormal"><u></u> \
<u></u></p><p class="MsoNormal">Kindly advise where I can download Mifos 18.03.01 \
Patch Release.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p \
class="MsoNormal">I downloaded <a \
href="https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip" \
target="_blank">https://sourceforge.net/projects/mifos/files/Mifos%20X/mifosplatform-18.03.01.RELEASE.zip</a> \
but in this release we still have the datatable issue and unable to edit \
groups<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" \
style="background:white"><b><span lang="EN-US" \
style="font-family:Helvetica,sans-serif;color:black">Regards;<u></u><u></u></span></b></p><p \
class="MsoNormal" style="background:white"><b><span lang="EN-US" \
style="font-family:Helvetica,sans-serif;color:black"><u></u> \
<u></u></span></b></p><p class="MsoNormal" style="background:white"><b><span \
lang="EN-US" style="font-family:Helvetica,sans-serif;color:black">*******</span></b><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="background:white"><b><span lang="EN-US" \
style="font-size:14pt;font-family:Helvetica,sans-serif;color:black">Zayyad A. Said | \
Chairman & C.E.O</span></b><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black"> </span><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black">Cell No.: +254 \
716 615274 | Skype: <b>zsaid2011</b></span><span \
style="font-family:Helvetica,sans-serif;color:black"><u></u><u></u></span></p><p \
class="MsoNormal" style="line-height:10.5pt;background:white"><span lang="EN-US" \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black">Email: <a \
href="mailto:zayyad@intrasofttechnologies.com" target="_blank"><span \
style="color:blue">zayyad@intrasofttechnologies.com</span></a> \
<u></u><u></u></span></p><p class="MsoNormal" \
style="line-height:10.5pt;background:white"><span \
style="font-size:10pt;font-family:Arial,sans-serif">Schedule Meetings: <a \
href="https://calendly.com/zayyadsaid" target="_blank"><span \
style="color:blue">https://calendly.com/zayyadsaid</span></a> \
<u></u><u></u></span></p><p class="MsoNormal"><span \
style="font-size:10pt;font-family:Helvetica,sans-serif;color:black"><img border="0" \
width="623" height="176" id="gmail-m_7155670254059796842Picture_x0020_1" \
src="cid:1693502dbb16917eb2" alt="Description: Email \
banner"><u></u><u></u></span></p><p class="MsoNormal"><u></u> \
<u></u></p></div></div>Mifos-developer mailing list<br> <a \
href="mailto:mifos-developer@lists.sourceforge.net" \
<a href="https://lists.sourceforge.net/lists/listinfo/mifos-developer" \
rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/mifos-developer</a></blockquote></div>
--000000000000d5778e0582f73fb5--
["image002.jpg" (image/jpeg)]
["image003.jpg" (image/jpeg)]
["controllers.85405de5.txt" (text/plain)]
(function (module) {
mifosX.controllers = _.extend(module, {
AccCoaController: function (scope,$rootScope, translate, resourceFactory, \
location) {
$rootScope.tempNodeID = -100; // variable used to store nodeID (from directive), \
so it(nodeID) is available for detail-table
scope.coadata = [];
scope.isTreeView = false;
scope.routeTo = function (id) {
location.path('/viewglaccount/' + id);
};
if (!scope.searchCriteria.acoa) {
scope.searchCriteria.acoa = null;
scope.saveSC();
}
scope.filterText = scope.searchCriteria.acoa;
scope.onFilter = function () {
scope.searchCriteria.acoa = scope.filterText || '';
scope.saveSC();
};
scope.deepCopy = function (obj) {
if (Object.prototype.toString.call(obj) === '[object Array]') {
var out = [], i = 0, len = obj.length;
for (; i < len; i++) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
if (typeof obj === 'object') {
var out = {}, i;
for (i in obj) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
return obj;
}
scope.ChartsPerPage = 15;
resourceFactory.accountCoaResource.getAllAccountCoas(function (data) {
scope.coadatas = scope.deepCopy(data);
scope.ASSET = translate.instant('ASSET') ;
scope.LIABILITY = translate.instant('LIABILITY') ;
scope.EQUITY = translate.instant('EQUITY') ;
scope.INCOME = translate.instant('INCOME') ;
scope.EXPENSE = translate.instant('EXPENSE') ;
scope.Accounting = translate.instant('Accounting') ;
var assetObject = {id: -1, name: scope.ASSET, parentId: -999, \
children: []};
var liabilitiesObject = {id: -2, name: scope.LIABILITY, parentId: \
-999, children: []};
var equitiyObject = {id: -3, name: scope.EQUITY, parentId: -999, \
children: []};
var incomeObject = {id: -4, name: scope.INCOME, parentId: -999, \
children: []};
var expenseObject = {id: -5, name: scope.EXPENSE, parentId: -999, \
children: []};
var rootObject = {id: -999, name: scope.Accounting, children: []};
var rootArray = [rootObject, assetObject, liabilitiesObject, \
equitiyObject, incomeObject, expenseObject];
var idToNodeMap = {};
for (var i in rootArray) {
idToNodeMap[rootArray[i].id] = rootArray[i];
}
for (i = 0; i < data.length; i++) {
if (data[i].type.value == "ASSET") {
if (data[i].parentId == null) data[i].parentId = -1;
} else if (data[i].type.value == "LIABILITY") {
if (data[i].parentId == null) data[i].parentId = -2;
} else if (data[i].type.value == "EQUITY") {
if (data[i].parentId == null) data[i].parentId = -3;
} else if (data[i].type.value == "INCOME") {
if (data[i].parentId == null) data[i].parentId = -4;
} else if (data[i].type.value == "EXPENSE") {
if (data[i].parentId == null) data[i].parentId = -5;
}
delete data[i].disabled;
delete data[i].manualEntriesAllowed;
delete data[i].type;
delete data[i].usage;
delete data[i].description;
delete data[i].nameDecorated;
delete data[i].tagId;
data[i].children = [];
idToNodeMap[data[i].id] = data[i];
}
function sortByParentId(a, b) {
return a.parentId - b.parentId;
}
data.sort(sortByParentId);
var glAccountsArray = rootArray.concat(data);
var root = [];
for (var i = 0; i < glAccountsArray.length; i++) {
var currentObj = glAccountsArray[i];
if (typeof currentObj.parentId === "undefined") {
root.push(currentObj);
} else {
parentNode = idToNodeMap[currentObj.parentId];
parentNode.children.push(currentObj);
currentObj.collapsed = "true";
}
}
scope.treedata = root;
});
}
});
mifosX.ng.application.controller('AccCoaController', ['$scope','$rootScope', \
'$translate', 'ResourceFactory', '$location', \
mifosX.controllers.AccCoaController]).run(function ($log) { \
$log.info("AccCoaController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccCreateGLAccountController: function (scope, resourceFactory, location, \
$routeParams) { scope.coadata = [];
scope.accountTypes = [];
scope.usageTypes = [];
scope.headerTypes = [];
resourceFactory.accountCoaTemplateResource.get({type: '0'}, function \
(data) { scope.coadata = data;
scope.accountTypes = data.accountTypeOptions;
scope.usageTypes = data.usageOptions;
scope.formData = {
manualEntriesAllowed: true,
type: scope.accountTypes[0].id,
usage: scope.usageTypes[0].id
};
scope.formData.type;
scope.formData.parentId;
for (var i = 0; i < data.accountTypeOptions.length; i++) {
if(data.accountTypeOptions[i].value == $routeParams.acctype ) {
console.log($routeParams.acctype + \
data.accountTypeOptions[i].value) scope.formData.type = scope.accountTypes[i].id;
}
}
//by default display assetTagsOptions and assetHeaderAccountOptions
scope.types = data.allowedAssetsTagOptions,
scope.headerTypes = data.assetHeaderAccountOptions;
scope.changeType();
for (var i = 0; i < scope.headerTypes.length; i++) {
if(scope.headerTypes[i].id == $routeParams.parent ) {
console.log($routeParams.parent + scope.headerTypes[i].id)
scope.formData.parentId = scope.headerTypes[i].id;
}
}
});
scope.changeType = function () {
if (scope.formData.type == 1) {
scope.types = scope.coadata.allowedAssetsTagOptions;
scope.headerTypes = scope.coadata.assetHeaderAccountOptions
} else if (scope.formData.type == 2) {
scope.types = scope.coadata.allowedLiabilitiesTagOptions;
scope.headerTypes = scope.coadata.liabilityHeaderAccountOptions;
} else if (scope.formData.type == 3) {
scope.types = scope.coadata.allowedEquityTagOptions;
scope.headerTypes = scope.coadata.equityHeaderAccountOptions;
} else if (scope.formData.type == 4) {
scope.types = scope.coadata.allowedIncomeTagOptions;
scope.headerTypes = scope.coadata.incomeHeaderAccountOptions;
} else if (scope.formData.type == 5) {
scope.types = scope.coadata.allowedExpensesTagOptions;
scope.headerTypes = scope.coadata.expenseHeaderAccountOptions;
}
} ;
if($routeParams.parent){
scope.cancel = '#/viewglaccount/' + $routeParams.parent
}else{
scope.cancel = "#/accounting_coa"
}
scope.submit = function () {
resourceFactory.accountCoaResource.save(this.formData, function \
(data) { location.path('/viewglaccount/' + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('AccCreateGLAccountController', ['$scope', \
'ResourceFactory', '$location','$routeParams', \
mifosX.controllers.AccCreateGLAccountController]).run(function ($log) { \
$log.info("AccCreateGLAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccCreateRuleController: function (scope, resourceFactory, location) {
scope.formData = {};
scope.creditRuleType = 'Account';
scope.debitRuleType = 'Account';
scope.formData.creditTags = [];
scope.formData.debitTags = [];
resourceFactory.accountingRulesTemplateResource.get(function (data) {
scope.glAccounts = data.allowedAccounts;
scope.offices = data.allowedOffices;
scope.creditTagOptions = data.allowedCreditTagOptions;
scope.debitTagOptions = data.allowedDebitTagOptions;
scope.formData.officeId = scope.offices[0].id;
scope.formData.accountToCredit = scope.glAccounts[0];
scope.formData.accountToDebit = scope.glAccounts[1];
});
scope.addDebitTag = function () {
for (var i in this.availableDebit) {
for (var j in scope.debitTagOptions) {
if (scope.debitTagOptions[j].id == this.availableDebit[i].id) \
{ var temp = {};
temp.id = this.availableDebit[i].id;
temp.name = this.availableDebit[i].name;
scope.formData.debitTags.push(temp);
scope.debitTagOptions.splice(j, 1);
}
}
}
};
scope.removeDebitTag = function () {
for (var i in this.selectedDebit) {
for (var j in scope.formData.debitTags) {
if (scope.formData.debitTags[j].id == \
this.selectedDebit[i].id) { var temp = {};
temp.id = this.selectedDebit[i].id;
temp.name = this.selectedDebit[i].name;
scope.debitTagOptions.push(temp);
scope.formData.debitTags.splice(j, 1);
}
}
}
};
scope.addCreditTag = function () {
for (var i in this.availableCredit) {
for (var j in scope.creditTagOptions) {
if (scope.creditTagOptions[j].id == \
this.availableCredit[i].id) { var temp = {};
temp.id = this.availableCredit[i].id;
temp.name = this.availableCredit[i].name;
scope.formData.creditTags.push(temp);
scope.creditTagOptions.splice(j, 1);
}
}
}
};
scope.removeCreditTag = function () {
for (var i in this.selectedCredit) {
for (var j in scope.formData.creditTags) {
if (scope.formData.creditTags[j].id == \
this.selectedCredit[i].id) { var temp = {};
temp.id = this.selectedCredit[i].id;
temp.name = this.selectedCredit[i].name;
scope.creditTagOptions.push(temp);
scope.formData.creditTags.splice(j, 1);
}
}
}
};
scope.resetCredits = function () {
scope.formData.creditTags = [];
}
scope.resetDebits = function () {
scope.formData.debitTags = [];
}
scope.submit = function () {
var accountingRule = new Object();
accountingRule.name = this.formData.name;
accountingRule.officeId = this.formData.officeId;
accountingRule.description = this.formData.description;
//Construct creditsTags array
if (this.creditRuleType == 'tags') {
accountingRule.allowMultipleCreditEntries = \
this.formData.allowMultipleCreditEntries; accountingRule.creditTags = [];
for (var i = 0; i < this.formData.creditTags.length; i++) {
\
accountingRule.creditTags.push(this.formData.creditTags[i].id); }
} else {
accountingRule.accountToCredit = \
this.formData.accountToCredit.id; }
//Construct debitTags array
if (this.debitRuleType == 'tags') {
accountingRule.allowMultipleDebitEntries = \
this.formData.allowMultipleDebitEntries; accountingRule.debitTags = [];
for (var i = 0; i < this.formData.debitTags.length; i++) {
accountingRule.debitTags.push(this.formData.debitTags[i].id);
}
} else {
accountingRule.accountToDebit = this.formData.accountToDebit.id;
}
resourceFactory.accountingRulesResource.save(accountingRule, function \
(data) { location.path('/viewaccrule/' + data.resourceId);
});
}
}
});
mifosX.ng.application.controller('AccCreateRuleController', ['$scope', \
'ResourceFactory', '$location', \
mifosX.controllers.AccCreateRuleController]).run(function ($log) { \
$log.info("AccCreateRuleController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AccEditGLAccountController: function (scope, routeParams, resourceFactory, \
location) { scope.coadata = [];
scope.accountTypes = [];
scope.usageTypes = [];
scope.headerTypes = [];
scope.accountOptions = [];
resourceFactory.accountCoaResource.get({glAccountId: routeParams.id, \
template: 'true'}, function (data) { scope.coadata = data;
scope.glAccountId = data.id;
scope.accountTypes = data.accountTypeOptions;
scope.usageTypes = data.usageOptions;
scope.formData = {
name: data.name,
glCode: data.glCode,
manualEntriesAllowed: data.manualEntriesAllowed,
description: data.description,
type: data.type.id,
tagId: data.tagId.id,
usage: data.usage.id,
parentId: data.parentId
};
scope.changeType() ;
});
scope.changeType = function () {
if (scope.formData.type == 1) {
scope.types = scope.coadata.allowedAssetsTagOptions;
scope.headerTypes = scope.coadata.assetHeaderAccountOptions
} else if (scope.formData.type == 2) {
scope.types = scope.coadata.allowedLiabilitiesTagOptions;
scope.headerTypes = scope.coadata.liabilityHeaderAccountOptions;
} else if (scope.formData.type == 3) {
scope.types = scope.coadata.allowedEquityTagOptions;
scope.headerTypes = scope.coadata.equityHeaderAccountOptions;
} else if (scope.formData.type == 4) {
scope.types = scope.coadata.allowedIncomeTagOptions;
scope.headerTypes = scope.coadata.incomeHeaderAccountOptions;
} else if (scope.formData.type == 5) {
scope.types = scope.coadata.allowedExpensesTagOptions;
scope.headerTypes = scope.coadata.expenseHeaderAccountOptions;
}
} ;
scope.submit = function () {
resourceFactory.accountCoaResource.update({'glAccountId': \
routeParams.id}, this.formData, function (data) { location.path('/viewglaccount/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('AccEditGLAccountController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', \
mifosX.controllers.AccEditGLAccountController]).run(function ($log) { \
$log.info("AccEditGLAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccEditRuleController: function (scope, resourceFactory, location, \
routeParams) {
scope.formData = {};
scope.creditRuleType = 'Account';
scope.debitRuleType = 'Account';
scope.formData.creditTags = [];
scope.formData.debitTags = [];
scope.offices = [];
resourceFactory.accountingRulesResource.getById({accountingRuleId: \
routeParams.id, template: true}, function (data) { //Initialize the template options
scope.glAccounts = data.allowedAccounts;
scope.offices = data.allowedOffices;
scope.creditTagOptions = data.allowedCreditTagOptions;
scope.debitTagOptions = data.allowedDebitTagOptions;
scope.accountingRuleId = data.id;
//update text fields
scope.formData.name = data.name;
scope.formData.officeId = data.officeId;
scope.formData.description = data.description;
//update formData for view previous details.
for (var i = 0; i < data.allowedOffices.length; i++) {
if (data.officeId == data.allowedOffices[i].id) {
scope.formData.office = data.allowedOffices[i].id;
}
}
//update credits
if (data.creditAccounts) {
//if the selected type is account then creditAccounts array will \
have only 1 account, which is a selected account.
scope.formData.accountToCredit = data.creditAccounts[0].id;
scope.creditRuleType = 'Account';
} else {
//if the selected type is tags then push the tags into creditTags \
array scope.formData.creditTags = [];
scope.creditRuleType = 'tags';
scope.formData.allowMultipleCreditEntries = \
data.allowMultipleCreditEntries; for (var i = 0; i < data.creditTags.length; i++) {
scope.formData.creditTags.push(data.creditTags[i].tag);
}
}
//update debits
if (data.debitAccounts) {
//if the selected type is account then debitAccounts array will \
have only 1 account, which is a selected account.
scope.formData.accountToDebit = data.debitAccounts[0].id;
scope.debitRuleType = 'Account';
} else {
//if the selected type is tags then push the tags into debitTags \
array scope.formData.debitTags = [];
scope.debitRuleType = 'tags';
scope.formData.allowMultipleDebitEntries = \
data.allowMultipleDebitEntries; for (var i = 0; i < data.debitTags.length; i++) {
scope.formData.debitTags.push(data.debitTags[i].tag);
}
}
});
scope.addDebitTag = function () {
for (var i in this.availableDebit) {
for (var j in scope.debitTagOptions) {
if (scope.debitTagOptions[j].id == this.availableDebit[i].id) \
{ var temp = {};
temp.id = this.availableDebit[i].id;
temp.name = this.availableDebit[i].name;
scope.formData.debitTags.push(temp);
scope.debitTagOptions.splice(j, 1);
}
}
}
};
scope.removeDebitTag = function () {
for (var i in this.selectedDebit) {
for (var j in scope.formData.debitTags) {
if (scope.formData.debitTags[j].id == \
this.selectedDebit[i].id) { var temp = {};
temp.id = this.selectedDebit[i].id;
temp.name = this.selectedDebit[i].name;
scope.debitTagOptions.push(temp);
scope.formData.debitTags.splice(j, 1);
}
}
}
};
scope.addCreditTag = function () {
for (var i in this.availableCredit) {
for (var j in scope.creditTagOptions) {
if (scope.creditTagOptions[j].id == \
this.availableCredit[i].id) { var temp = {};
temp.id = this.availableCredit[i].id;
temp.name = this.availableCredit[i].name;
scope.formData.creditTags.push(temp);
scope.creditTagOptions.splice(j, 1);
}
}
}
};
scope.removeCreditTag = function () {
for (var i in this.selectedCredit) {
for (var j in scope.formData.creditTags) {
if (scope.formData.creditTags[j].id == \
this.selectedCredit[i].id) { var temp = {};
temp.id = this.selectedCredit[i].id;
temp.name = this.selectedCredit[i].name;
scope.creditTagOptions.push(temp);
scope.formData.creditTags.splice(j, 1);
}
}
}
};
scope.resetCredits = function () {
scope.formData.creditTags = [];
}
scope.resetDebits = function () {
scope.formData.debitTags = [];
}
scope.submit = function () {
var accountingRule = new Object();
accountingRule.name = this.formData.name;
accountingRule.officeId = this.formData.officeId;
accountingRule.description = this.formData.description;
//Construct creditsTags array
if (this.creditRuleType == 'tags') {
accountingRule.allowMultipleCreditEntries = \
this.formData.allowMultipleCreditEntries; accountingRule.creditTags = [];
for (var i = 0; i < this.formData.creditTags.length; i++) {
\
accountingRule.creditTags.push(this.formData.creditTags[i].id); }
} else {
accountingRule.accountToCredit = this.formData.accountToCredit;
}
//Construct debitTags array
if (this.debitRuleType == 'tags') {
accountingRule.allowMultipleDebitEntries = \
this.formData.allowMultipleDebitEntries; accountingRule.debitTags = [];
for (var i = 0; i < this.formData.debitTags.length; i++) {
accountingRule.debitTags.push(this.formData.debitTags[i].id);
}
} else {
accountingRule.accountToDebit = this.formData.accountToDebit;
}
resourceFactory.accountingRulesResource.update({accountingRuleId: \
routeParams.id}, accountingRule, function (data) { location.path('/viewaccrule/' + \
data.resourceId); });
}
}
});
mifosX.ng.application.controller('AccEditRuleController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', \
mifosX.controllers.AccEditRuleController]).run(function ($log) { \
$log.info("AccEditRuleController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AccFreqPostingController: function (scope, resourceFactory, location, \
dateFilter) {
scope.formData = {};
scope.formData.crAccounts = [];
scope.formData.dbAccounts = [];
scope.first = {};
scope.allowCreditEntries = true;
scope.allowDebitEntries = true;
scope.errorcreditevent = false;
scope.errordebitevent = false;
scope.restrictDate = new Date();
scope.showPaymentDetails = false;
resourceFactory.accountingRulesResource.getAllRules({associations: \
'all'}, function (data) { scope.rules = data;
});
resourceFactory.paymentTypeResource.getAll( function (data) {
scope.paymentTypes = data;
});
resourceFactory.currencyConfigResource.get({fields: \
'selectedCurrencyOptions'}, function (data) { scope.currencyOptions = \
data.selectedCurrencyOptions;
scope.formData.currencyCode = scope.currencyOptions[0].code;
});
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
scope.formData.officeId = scope.offices[0].id;
});
//event for rule change
scope.resetCrAndDb = function (rule) {
scope.rule = rule;
scope.formData.crAccounts = [{}];
scope.formData.dbAccounts = [{}];
if(rule.allowMultipleDebitEntries) {
scope.allowDebitEntries = true;
}else{
scope.allowDebitEntries = false;
}
if(rule.allowMultipleCreditEntries) {
scope.allowCreditEntries = true;
}else{
scope.allowCreditEntries = false;
}
}
//events for credits
scope.addCrAccount = function () {
scope.errorcreditevent = false;
scope.formData.crAccounts.push({});
scope.formData.crAmountTemplate = undefined;
if (scope.formData.rule) {
if (!scope.formData.rule.allowMultipleCreditEntries) {
scope.allowCreditEntries = false;
}
}
}
scope.removeCrAccount = function (index) {
scope.formData.crAccounts.splice(index, 1);
if (scope.formData.crAccounts.length == 0) {
scope.allowCreditEntries = true;
}
}
//events for debits
scope.addDebitAccount = function () {
scope.errordebitevent = false;
scope.formData.dbAccounts.push({});
scope.formData.debitAmountTemplate = undefined;
if (scope.formData.rule) {
if (!scope.formData.rule.allowMultipleDebitEntries) {
scope.allowDebitEntries = false;
}
}
}
scope.removeDebitAccount = function (index) {
scope.formData.dbAccounts.splice(index, 1);
if (scope.formData.dbAccounts.length == 0) {
scope.allowDebitEntries = true;
}
}
scope.submit = function () {
var jeTransaction = new Object();
var reqDate = dateFilter(scope.first.date, scope.df);
jeTransaction.locale = scope.optlang.code;
jeTransaction.dateFormat = scope.df;
jeTransaction.officeId = this.formData.officeId;
jeTransaction.transactionDate = reqDate;
jeTransaction.referenceNumber = this.formData.referenceNumber;
jeTransaction.comments = this.formData.comments;
if (this.formData.rule) {
jeTransaction.accountingRule = this.formData.rule.id;
}
jeTransaction.currencyCode = this.formData.currencyCode;
jeTransaction.paymentTypeId = this.formData.paymentTypeId;
jeTransaction.accountNumber = this.formData.accountNumber;
jeTransaction.checkNumber = this.formData.checkNumber;
jeTransaction.routingCode = this.formData.routingCode;
jeTransaction.receiptNumber = this.formData.receiptNumber;
jeTransaction.bankNumber = this.formData.bankNumber;
//Construct credits array
jeTransaction.credits = [];
for (var i = 0; i < this.formData.crAccounts.length; i++) {
var temp = new Object();
temp.glAccountId = this.formData.crAccounts[i].select.id;
temp.amount = this.formData.crAccounts[i].crAmount;
jeTransaction.credits.push(temp);
}
//construct debits array
jeTransaction.debits = [];
for (var i = 0; i < this.formData.dbAccounts.length; i++) {
var temp = new Object();
temp.glAccountId = this.formData.dbAccounts[i].select.id;
temp.amount = this.formData.dbAccounts[i].debitAmount;
jeTransaction.debits.push(temp);
}
resourceFactory.journalEntriesResource.save(jeTransaction, function \
(data) {
location.path('/viewtransactions/' + data.transactionId);
});
}
}
});
mifosX.ng.application.controller('AccFreqPostingController', ['$scope', \
'ResourceFactory', '$location', 'dateFilter', \
mifosX.controllers.AccFreqPostingController]).run(function ($log) { \
$log.info("AccFreqPostingController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccOGMController: function (scope, resourceFactory, \
paginatorService,routeParams, location,$uibModal) { scope.routeTo = function (id) {
location.path('/viewofficeglmapping/' + id);
};
var fetchFunction = function () {
var params = {};
resourceFactory.officeToGLAccountMappingResource.search(params, \
callback); };
scope.mappingDatas = paginatorService.paginate();
}
});
mifosX.ng.application.controller('AccOGMController', ['$scope', \
'ResourceFactory', 'PaginatorService', '$routeParams','$location','$uibModal', \
mifosX.controllers.AccOGMController]).run(function ($log) { \
$log.info("AccOGMController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AccViewGLAccountContoller: function (scope, routeParams, location, \
resourceFactory, route, $uibModal) { scope.glaccountdata = [];
scope.accountOptions = [];
resourceFactory.accountCoaResource.get({glAccountId: routeParams.id, \
template: 'true'}, function (data) {
//to display parent name
if (data.type.value == "ASSET") {
scope.accountOptions = data.assetHeaderAccountOptions || [];
for (var i = 0; i < scope.accountOptions.length; i++) {
if (scope.accountOptions[i].id == data.parentId) {
data.parentName = scope.accountOptions[i].name;
}
}
} else if (data.type.value == "LIABILITY") {
scope.accountOptions = data.liabilityHeaderAccountOptions || [];
for (var i = 0; i < scope.accountOptions.length; i++) {
if (scope.accountOptions[i].id == data.parentId) {
data.parentName = scope.accountOptions[i].name;
}
}
} else if (data.type.value == "EQUITY") {
scope.accountOptions = data.equityHeaderAccountOptions || [];
for (var i = 0; i < scope.accountOptions.length; i++) {
if (scope.accountOptions[i].id == data.parentId) {
data.parentName = scope.accountOptions[i].name;
}
}
} else if (data.type.value == "INCOME") {
scope.accountOptions = data.incomeHeaderAccountOptions || [];
for (var i = 0; i < scope.accountOptions.length; i++) {
if (scope.accountOptions[i].id == data.parentId) {
data.parentName = scope.accountOptions[i].name;
}
}
} else if (data.type.value == "EXPENSE") {
scope.accountOptions = data.expenseHeaderAccountOptions || [];
for (var i = 0; i < scope.accountOptions.length; i++) {
if (scope.accountOptions[i].id == data.parentId) {
data.parentName = scope.accountOptions[i].name;
}
}
}
scope.glaccount = data;
});
scope.deleteGLAccount = function () {
$uibModal.open({
templateUrl: 'deleteglacc.html',
controller: GlAccDeleteCtrl
});
};
var GlAccDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.accountCoaResource.delete({glAccountId: \
routeParams.id}, {}, function (data) { $uibModalInstance.close('delete');
location.path('/accounting_coa');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.changeState = function (disabled) {
resourceFactory.accountCoaResource.update({'glAccountId': \
routeParams.id}, {disabled: !disabled}, function (data) { route.reload();
});
};
}
});
mifosX.ng.application.controller('AccViewGLAccountContoller', ['$scope', \
'$routeParams', '$location', 'ResourceFactory', '$route', '$uibModal', \
mifosX.controllers.AccViewGLAccountContoller]).run(function ($log) { \
$log.info("AccViewGLAccountContoller initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccountingClosureController: function (scope, resourceFactory, location, \
translate, routeParams, dateFilter) { scope.first = {};
scope.formData = {};
scope.first.date = new Date();
scope.accountClosures = [];
scope.restrictDate = new Date();
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
var params = {}
if (routeParams.officeId != undefined) {
params.officeId = routeParams.officeId;
}
resourceFactory.accountingClosureResource.get(params, function (data) {
scope.accountClosures = data;
});
scope.routeTo = function (id) {
location.path('/view_close_accounting/' + id);
};
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.closingDate = reqDate;
resourceFactory.accountingClosureResource.save(this.formData, \
function (data) {
location.path('/view_close_accounting/' + data.resourceId);
});
}
scope.updateLastClosed = function (officeId) {
resourceFactory.accountingClosureResource.get({officeId: officeId}, \
function (data) { scope.accountClosures = data;
scope.lastClosed = undefined;
if (data.length > 0) {
scope.lastClosed = data[0].closingDate;
}
});
}
scope.closedAccountingDetails = function (officeId) {
resourceFactory.accountingClosureResource.get({officeId: officeId}, \
function (data) { scope.accountClosures = data;
});
}
}
});
mifosX.ng.application.controller('AccountingClosureController', ['$scope', \
'ResourceFactory', '$location', '$translate', '$routeParams', 'dateFilter', \
mifosX.controllers.AccountingClosureController]).run(function ($log) { \
$log.info("AccountingClosureController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AccountingRuleController: function (scope, resourceFactory, location) {
scope.routeTo = function (id) {
location.path('/viewaccrule/' + id);
};
resourceFactory.accountingRulesResource.get(function (data) {
scope.rules = data;
});
}
});
mifosX.ng.application.controller('AccountingRuleController', ['$scope', \
'ResourceFactory', '$location', \
mifosX.controllers.AccountingRuleController]).run(function ($log) { \
$log.info("AccountingRuleController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AddFinancialMappingController: function (scope, resourceFactory, location) {
scope.formData = {};
resourceFactory.officeToGLAccountMappingResource.get({mappingId:'template'}, \
function (data) { scope.formData.financialActivityId = 100;
scope.glAccountOptions = data.glAccountOptions;
scope.financialActivityOptions = data.financialActivityOptions;
scope.accountOptions = scope.glAccountOptions.assetAccountOptions;
});
scope.updateActivityOptions = function(activityId){
if(activityId === 100){
scope.accountOptions = \
scope.glAccountOptions.assetAccountOptions; }else if(activityId === 200 || \
activityId === 201){
scope.accountOptions = \
scope.glAccountOptions.liabilityAccountOptions; }else if(activityId === 300){
scope.accountOptions = \
scope.glAccountOptions.equityAccountOptions; }
};
scope.submit = function () {
resourceFactory.officeToGLAccountMappingResource.create(this.formData, \
function (data) {
location.path('/viewfinancialactivitymapping/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('AddFinancialMappingController', ['$scope', \
'ResourceFactory', '$location', \
mifosX.controllers.AddFinancialMappingController]).run(function ($log) { \
$log.info("AddFinancialMappingController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportCOAController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + '/glaccounts/downloadtemplate' + \
'?tenantIdentifier=' + $rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"chartofaccounts"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/glaccounts/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportCOAController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportCOAController]).run(function ($log) { \
$log.info("BulkImportCOAController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportJournalEntriesController: function (scope, resourceFactory, \
location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/journalentries/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
scope.first.queryParams += 'officeId=' + \
scope.formData.officeId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"gljournalentries"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/journalentries/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportJournalEntriesController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportJournalEntriesController]).run(function ($log) { \
$log.info("BulkImportJournalEntriesController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
DefineOpeningBalancesController: function (scope, resourceFactory, location, \
translate, routeParams, dateFilter) { scope.first = {};
scope.formData = {};
scope.first.date = new Date();
scope.accountClosures = [];
scope.restrictDate = new Date();
scope.totalDebitAmount = 0;
scope.totalCreditAmount = 0;
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
resourceFactory.currencyConfigResource.get({fields: \
'selectedCurrencyOptions'}, function (data) { scope.currencyOptions = \
data.selectedCurrencyOptions;
scope.formData.currencyCode = scope.currencyOptions[0].code;
});
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.transactionDate = reqDate;
this.formData.currencyCode = scope.formData.currencyCode;
this.formData.credits = [];
this.formData.debits = [];
scope.errorDetails = [];
var noErrors = true;
for (var i in scope.allGls) {
if (scope.allGls[i].credit && scope.allGls[i].credit != "" && \
scope.allGls[i].debit && scope.allGls[i].debit != "") { if(noErrors){
noErrors = false;
var errorObj = new Object();
errorObj.code = \
'error.msg.accounting.defining.openingbalance.both.credit.debits.are.passed'; \
scope.errorDetails.push([errorObj]); }
} else if (scope.allGls[i].debit && scope.allGls[i].debit != "") \
{
\
this.formData.debits.push({"glAccountId":scope.allGls[i].glAccountId, \
"amount":scope.allGls[i].debit});
} else if (scope.allGls[i].credit && scope.allGls[i].credit) {
\
this.formData.credits.push({"glAccountId":scope.allGls[i].glAccountId, \
"amount":scope.allGls[i].credit}); }
}
if(noErrors){
delete scope.errorDetails;
resourceFactory.journalEntriesResource.save({command:"defineOpeningBalance"}, \
this.formData, function (data) {
location.path('/viewtransactions/' + data.transactionId);
});
}
}
scope.keyPress = function(){
this.formData.credits = [];
this.formData.debits = [];
scope.totalDebitAmount = 0;
scope.totalCreditAmount = 0;
for(var l in scope.allGls) {
if (scope.allGls[l].debit != null && scope.allGls[l].debit != "") \
{
scope.totalDebitAmount += parseFloat(scope.allGls[l].debit);
}
if(scope.allGls[l].credit != null && scope.allGls[l].credit != \
""){
scope.totalCreditAmount += parseFloat(scope.allGls[l].credit)
}
}
};
scope.updateDebitCreditAmounts = function (gl) {
if (gl.amount) {
if (gl.entryType) {
if (gl.entryType.value == "DEBIT") {
gl.debit = gl.amount;
} else if (gl.entryType.value == "CREDIT") {
gl.credit = gl.amount;
}
}
}
}
scope.mergeAllGLs = function () {
scope.allGls = [];
scope.debitTotal = 0;
_.each(scope.data.assetAccountOpeningBalances, function(gl){
scope.updateDebitCreditAmounts(gl);
scope.allGls.push(gl);
});
_.each(scope.data.liabityAccountOpeningBalances, function(gl){
scope.updateDebitCreditAmounts(gl);
scope.allGls.push(gl);
});
_.each(scope.data.equityAccountOpeningBalances, function(gl){
scope.updateDebitCreditAmounts(gl);
scope.allGls.push(gl);
});
_.each(scope.data.incomeAccountOpeningBalances, function(gl){
scope.updateDebitCreditAmounts(gl);
scope.allGls.push(gl);
});
_.each(scope.data.expenseAccountOpeningBalances, function(gl){
scope.updateDebitCreditAmounts(gl);
scope.allGls.push(gl);
});
}
scope.retrieveOpeningBalances = function (officeId, currencyCode) {
resourceFactory.officeOpeningResource.get({officeId: officeId, \
currencyCode: currencyCode}, function (data) { scope.data = data;
scope.mergeAllGLs();
});
}
}
});
mifosX.ng.application.controller('DefineOpeningBalancesController', ['$scope', \
'ResourceFactory', '$location', '$translate', '$routeParams', 'dateFilter', \
mifosX.controllers.DefineOpeningBalancesController]).run(function ($log) { \
$log.info("DefineOpeningBalancesController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditFinancialActivityMappingController: function (scope, resourceFactory, \
location,routeParams) { scope.formData = {};
scope.accountOptions = [];
resourceFactory.officeToGLAccountMappingResource.withTemplate({mappingId: \
routeParams.mappingId},function (data) { scope.mapping = data;
scope.glAccountOptions = data.glAccountOptions;
scope.formData.financialActivityId = data.financialActivityData.id;
scope.formData.glAccountId = data.glAccountData.id;
scope.financialActivityOptions = data.financialActivityOptions;
scope.updateActivityOptions(scope.formData.financialActivityId);
});
scope.updateActivityOptions = function(activityId){
if(activityId === 100 || activityId === 101 || activityId === 102 || \
activityId === 103){
scope.accountOptions = \
scope.glAccountOptions.assetAccountOptions; }else if(activityId === 200 || \
activityId === 201){
scope.accountOptions = \
scope.glAccountOptions.liabilityAccountOptions; }else if(activityId === 300){
scope.accountOptions = \
scope.glAccountOptions.equityAccountOptions; }
};
scope.submit = function () {
resourceFactory.officeToGLAccountMappingResource.update({mappingId: \
routeParams.mappingId},this.formData, function (data) {
location.path('/viewfinancialactivitymapping/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('EditFinancialActivityMappingController', \
['$scope', 'ResourceFactory', '$location','$routeParams', \
mifosX.controllers.EditFinancialActivityMappingController]).run(function ($log) { \
$log.info("EditFinancialActivityMappingController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
FinancialActivityMappingsController: function (scope, resourceFactory, \
location) {
resourceFactory.officeToGLAccountMappingResource.getAll(function (data) {
scope.mappings = data;
});
scope.routeTo = function (resourceId){
location.path('/viewfinancialactivitymapping/' + resourceId);
};
}
});
mifosX.ng.application.controller('FinancialActivityMappingsController', \
['$scope', 'ResourceFactory', '$location', \
mifosX.controllers.FinancialActivityMappingsController]).run(function ($log) { \
$log.info("FinancialActivityMappingsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
JournalEntryController: function (scope, resourceFactory, location, \
dateFilter) {
scope.formData = {};
scope.formData.crAccounts = [{}];
scope.formData.dbAccounts = [{}];
scope.first = {};
scope.errorcreditevent = false;
scope.errordebitevent = false;
scope.creditaccounttemplate = false;
scope.debitaccounttemplate = false;
scope.restrictDate = new Date();
scope.showPaymentDetails = false;
resourceFactory.accountCoaResource.getAllAccountCoas({manualEntriesAllowed: \
true, usage: 1, disabled: false}, function (data) { scope.glAccounts = data;
});
resourceFactory.paymentTypeResource.getAll( function (data) {
scope.paymentTypes = data;
});
resourceFactory.currencyConfigResource.get({fields: \
'selectedCurrencyOptions'}, function (data) { scope.currencyOptions = \
data.selectedCurrencyOptions;
scope.formData.currencyCode = scope.currencyOptions[0].code;
});
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
scope.formData.officeId = scope.offices[0].id;
});
//events for credits
scope.addCrAccount = function () {
scope.formData.crAccounts.push({});
}
scope.removeCrAccount = function (index) {
scope.formData.crAccounts.splice(index, 1);
}
//events for debits
scope.addDebitAccount = function () {
scope.formData.dbAccounts.push({});
}
scope.removeDebitAccount = function (index) {
scope.formData.dbAccounts.splice(index, 1);
}
scope.submit = function () {
var jeTransaction = new Object();
var reqDate = dateFilter(scope.first.date, scope.df);
jeTransaction.locale = scope.optlang.code;
jeTransaction.dateFormat = scope.df;
jeTransaction.officeId = this.formData.officeId;
jeTransaction.transactionDate = reqDate;
jeTransaction.referenceNumber = this.formData.referenceNumber;
jeTransaction.comments = this.formData.comments;
jeTransaction.currencyCode = this.formData.currencyCode;
jeTransaction.paymentTypeId = this.formData.paymentTypeId;
jeTransaction.accountNumber = this.formData.accountNumber;
jeTransaction.checkNumber = this.formData.checkNumber;
jeTransaction.routingCode = this.formData.routingCode;
jeTransaction.receiptNumber = this.formData.receiptNumber;
jeTransaction.bankNumber = this.formData.bankNumber;
//Construct credits array
jeTransaction.credits = [];
for (var i = 0; i < this.formData.crAccounts.length; i++) {
var temp = new Object();
if(this.formData.crAccounts[i].select){
temp.glAccountId = this.formData.crAccounts[i].select.id;
}
temp.amount = this.formData.crAccounts[i].crAmount;
jeTransaction.credits.push(temp);
}
//construct debits array
jeTransaction.debits = [];
for (var i = 0; i < this.formData.dbAccounts.length; i++) {
var temp = new Object();
if(this.formData.dbAccounts[i].select){
temp.glAccountId = this.formData.dbAccounts[i].select.id;
}
temp.amount = this.formData.dbAccounts[i].debitAmount;
jeTransaction.debits.push(temp);
}
resourceFactory.journalEntriesResource.save(jeTransaction, function \
(data) {
location.path('/viewtransactions/' + data.transactionId);
});
}
}
});
mifosX.ng.application.controller('JournalEntryController', ['$scope', \
'ResourceFactory', '$location', 'dateFilter', \
mifosX.controllers.JournalEntryController]).run(function ($log) { \
$log.info("JournalEntryController initialized"); });
}(mifosX.controllers || {}));;
(function (module) {
mifosX.controllers = _.extend(module, {
PeriodicAccrualAccountingController: function (scope, resourceFactory, \
location, translate, routeParams, dateFilter) { scope.first = {};
scope.formData = {};
scope.accrueTill = new Date();
scope.restrictDate = new Date();
scope.submit = function () {
var reqDate = dateFilter(scope.accrueTill, scope.df);
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.tillDate = reqDate;
resourceFactory.periodicAccrualAccountingResource.run(this.formData, \
function (data) { location.path('/accounting');
});
}
}
});
mifosX.ng.application.controller('PeriodicAccrualAccountingController', \
['$scope', 'ResourceFactory', '$location', '$translate', '$routeParams', \
'dateFilter', mifosX.controllers.PeriodicAccrualAccountingController]).run(function \
($log) { $log.info("PeriodicAccrualAccountingController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
SearchTransactionController: function (scope, resourceFactory, \
paginatorService, dateFilter, location) { scope.filters = [
{option: "All", value: ""},
{option: "Manual Entries", value: true},
{option: "System Entries", value: false}
];
scope.isCollapsed = true;
scope.displayResults = false;
scope.transactions = [];
scope.glAccounts = [];
scope.offices = [];
scope.date = {};
scope.formData = {};
scope.routeTo = function (id) {
location.path('/viewtransactions/' + id);
};
resourceFactory.accountCoaResource.getAllAccountCoas({
manualEntriesAllowed: true,
usage: 1,
disabled: false
}, function (data) {
scope.glAccounts = data;
});
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
if (!scope.searchCriteria.journals) {
scope.searchCriteria.journals = [null, null, null, null, null, null];
scope.saveSC();
}
scope.formData.transactionId = scope.searchCriteria.journals[0];
scope.formData.glAccount = scope.searchCriteria.journals[1];
scope.formData.officeId = scope.searchCriteria.journals[2];
scope.formData.manualEntriesOnly = scope.searchCriteria.journals[3];
scope.date.first = scope.searchCriteria.journals[4];
scope.date.second = scope.searchCriteria.journals[5];
var fetchFunction = function (offset, limit, callback) {
var reqFirstDate = dateFilter(scope.date.first, scope.df);
var reqSecondDate = dateFilter(scope.date.second, scope.df);
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
if (scope.formData.transactionId) {
params.transactionId = scope.formData.transactionId;
scope.searchCriteria.journals[0] = params.transactionId;
} else
scope.searchCriteria.journals[0] = null;
if (scope.formData.glAccount) {
params.glAccountId = scope.formData.glAccount;
scope.searchCriteria.journals[1] = params.glAccountId;
} else
scope.searchCriteria.journals[1] = null;
if (scope.formData.officeId) {
params.officeId = scope.formData.officeId;
scope.searchCriteria.journals[2] = params.officeId;
} else
scope.searchCriteria.journals[2] = null;
if (scope.formData.manualEntriesOnly == true || \
scope.formData.manualEntriesOnly == false) {
params.manualEntriesOnly = scope.formData.manualEntriesOnly;
scope.searchCriteria.journals[3] = params.manualEntriesOnly;
} else
scope.searchCriteria.journals[3] = null;
if (scope.date.first) {
params.fromDate = reqFirstDate;
scope.searchCriteria.journals[4] = params.fromDate;
} else
scope.searchCriteria.journals[4] = null;
if (scope.date.second) {
params.toDate = reqSecondDate;
scope.searchCriteria.journals[5] = params.toDate;
} else
scope.searchCriteria.journals[5] = null;
if(scope.formData.loanaccountId){
params.loanId = scope.formData.loanaccountId;
scope.searchCriteria.journals[6] = params.loanId;
} else
scope.searchCriteria.journals[6] = null;
if(scope.formData.savingsaccountId){
params.savingsId = scope.formData.savingsaccountId;
scope.searchCriteria.journals[7] = params.savingsId;
} else
scope.searchCriteria.journals[7] = null;
scope.saveSC();
resourceFactory.journalEntriesResource.search(params, callback);
};
scope.clearFilters = function () {
scope.formData.transactionId = null;
scope.formData.glAccount = null;
document.getElementById('glAccounts_chosen').childNodes[0].childNodes[0].innerHTML \
= "Select Account name Or Code"; scope.formData.officeId = null;
document.getElementById('offices_chosen').childNodes[0].childNodes[0].innerHTML \
= "Select office"; scope.formData.manualEntriesOnly = null;
document.getElementById('filters_chosen').childNodes[0].childNodes[0].innerHTML \
= "Select filter"; scope.date.first = null;
scope.date.second = null;
scope.formData.loanaccountId = null;
scope.formData.savingsaccountId = null;
};
scope.searchTransaction = function () {
scope.displayResults = true;
scope.transactions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
};
if(location.search().loanId != null){
scope.formData.loanaccountId = location.search().loanId;
scope.displayResults = true;
scope.transactions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
scope.isValid = true;
scope.path = "#/viewloanaccount/" + scope.formData.loanaccountId;
}
if(location.search().savingsId != null){
scope.formData.savingsaccountId = location.search().savingsId;
scope.displayResults = true;
scope.transactions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
scope.isValid = true;
scope.path = "#/viewsavingaccount/" + \
scope.formData.savingsaccountId; }
}
});
mifosX.ng.application.controller('SearchTransactionController', ['$scope', \
'ResourceFactory', 'PaginatorService', 'dateFilter', '$location', \
mifosX.controllers.SearchTransactionController]).run(function ($log) { \
$log.info("SearchTransactionController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ViewAccRuleController: function (scope, resourceFactory, routeParams, \
location, $uibModal) {
resourceFactory.accountingRulesResource.getById({accountingRuleId: \
routeParams.id}, function (data) { scope.rule = data;
});
scope.deleteRule = function () {
$uibModal.open({
templateUrl: 'deleteaccrule.html',
controller: AccRuleDeleteCtrl
});
};
var AccRuleDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.accountingRulesResource.delete({accountingRuleId: \
routeParams.id}, {}, function (data) { $uibModalInstance.close('delete');
location.path('/accounting_rules');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewAccRuleController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', '$uibModal', \
mifosX.controllers.ViewAccRuleController]).run(function ($log) { \
$log.info("ViewAccRuleController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ViewAccountingClosureController: function (scope, resourceFactory, location, \
routeParams, $uibModal) { scope.accountClosure = {};
scope.choice = 0;
resourceFactory.accountingClosureResource.getView({accId: \
routeParams.id}, function (data) { scope.accountClosure = data;
});
scope.deleteAcc = function () {
$uibModal.open({
templateUrl: 'deleteacc.html',
controller: AccDeleteCtrl
});
};
var AccDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.accountingClosureResource.delete({accId: \
routeParams.id}, {}, function (data) { $uibModalInstance.close('delete');
location.path('/accounts_closure');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewAccountingClosureController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', '$uibModal', \
mifosX.controllers.ViewAccountingClosureController]).run(function ($log) { \
$log.info("ViewAccountingClosureController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewFinancialActivityController: function (scope, resourceFactory, \
routeParams, location, $uibModal) {
resourceFactory.officeToGLAccountMappingResource.get({mappingId: \
routeParams.mappingId},function (data) { scope.mapping = data;
});
scope.deletemapping = function () {
$uibModal.open({
templateUrl: 'deletemapping.html',
controller: AccRuleDeleteCtrl
});
};
var AccRuleDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.officeToGLAccountMappingResource.delete({mappingId: \
routeParams.mappingId}, {}, function (data) { $uibModalInstance.close('delete');
location.path('/financialactivityaccountmappings');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewFinancialActivityController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', '$uibModal', \
mifosX.controllers.ViewFinancialActivityController]).run(function ($log) { \
$log.info("ViewFinancialActivityController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewTransactionController: function (scope, routeParams, resourceFactory, \
location, route, $uibModal) { scope.flag = false;
scope.manualEntry = false;
scope.productName = routeParams.productName;
scope.clientName = routeParams.clientName;
scope.accountNo = routeParams.accountNo;
scope.clientId = routeParams.clientId;
scope.loanId = routeParams.loanId;
scope.groupId = routeParams.groupId;
scope.groupName = routeParams.groupName;
scope.journalEntryTransactionId = routeParams.transactionId;
if(scope.journalEntryTransactionId != null && \
scope.journalEntryTransactionId !=""){
scope.journalEntryTransactionId = \
scope.journalEntryTransactionId.substring(1,scope.journalEntryTransactionId.length); \
}
resourceFactory.journalEntriesResource.get({transactionId: \
routeParams.transactionId, transactionDetails:true}, function (data) { \
scope.transactionNumber = routeParams.transactionId; scope.transactions = \
data.pageItems; for (var i in data.pageItems) {
scope.manualEntry = data.pageItems[i].manualEntry;
if (data.pageItems[i].reversed == false) {
scope.flag = true;
}
}
});
scope.confirmation = function () {
$uibModal.open({
templateUrl: 'confirmation.html',
controller: ConfirmationCtrl,
resolve: {
id: function () {
return scope.trxnid;
}
}
});
};
var ConfirmationCtrl = function ($scope, $uibModalInstance, id) {
$scope.transactionnumber = id.transactionId;
$scope.redirect = function () {
$uibModalInstance.close('delete');
location.path('/viewtransactions/' + id.transactionId);
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.showTransaction = function (transaction) {
scope.transaction = transaction;
$uibModal.open({
templateUrl: 'viewjournalentry.html',
controller: ViewJournalEntryCtrl,
resolve: {
transaction: function () {
return scope.transaction;
}
}
});
};
var ViewJournalEntryCtrl = function ($scope, $uibModalInstance, \
transaction) { $scope.transaction = transaction;
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.reverseTransaction = function (transactionId) {
$uibModal.open({
templateUrl: 'reverseTransaction.html',
controller: ReverseJournalEntriesCtrl,
resolve: {
transactionId: function () {
return transactionId;
}
}
});
}
var ReverseJournalEntriesCtrl = function ($scope, $uibModalInstance, \
transactionId) { $scope.data = {
reverseComments:""
};
$scope.reverse = function () {
reverseData = {transactionId: transactionId, comments: \
$scope.data.reverseComments};
resourceFactory.journalEntriesResource.reverse(reverseData, \
function (data) { $uibModalInstance.dismiss('cancel');
scope.trxnid = data;
scope.confirmation();
route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewTransactionController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', '$route', '$uibModal', \
mifosX.controllers.ViewTransactionController]).run(function ($log) { \
$log.info("ViewTransactionController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CreateProvisoningEntriesController: function (scope, resourceFactory, \
location, dateFilter, translate) { scope.template = [];
scope.formData = {};
scope.translate = translate;
scope.submitteddate = new Date();
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.date = dateFilter(this.submitteddate, scope.df);
resourceFactory.provisioningentries.post(this.formData, function \
(data) {
location.path('/viewprovisioningentry/' + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('CreateProvisoningEntriesController', ['$scope', \
'ResourceFactory', '$location', 'dateFilter', '$translate', \
mifosX.controllers.CreateProvisoningEntriesController]).run(function ($log) { \
$log.info("CreateProvisoningEntriesController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewAllProvisoningEntriesController: function (scope, routeParams, \
paginatorService, resourceFactory, location, $uibModal) {
scope.routeTo = function (id) {
location.path('/viewprovisioningentry/' + id);
};
scope.viewJournals = function (id) {
location.path('/viewprovisioningjournalentry/' + id);
};
scope.recreate = function (id) {
resourceFactory.provisioningentries.reCreateProvisioningEntries({entryId: \
id}, this.formData, function (data) { location.path('/viewprovisioningentry/'+id);
});
};
scope.searchTransaction = function () {
scope.entries = paginatorService.paginate(fetchFunction, 10);
};
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
scope.saveSC();
resourceFactory.provisioningentries.getAll(params, callback) ;
};
paginatorService.currentOffset = 0 ;
scope.entries = paginatorService.paginate(fetchFunction, 10);
}
});
mifosX.ng.application.controller('ViewAllProvisoningEntriesController', \
['$scope', '$routeParams', 'PaginatorService', 'ResourceFactory', '$location', \
'$uibModal', mifosX.controllers.ViewAllProvisoningEntriesController]).run(function \
($log) { $log.info("ViewAllProvisoningEntriesController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewProvisioningEntryController: function (scope, routeParams, \
paginatorService, resourceFactory, location, $uibModal) { scope.charge = [];
scope.choice = 0;
var i = 0 ;
var temp = 0 ;
scope.totalReservedAmount;
scope.formData = {};
scope.transactions = [];
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
resourceFactory.loanProductResource.getAllLoanProducts(function (data) {
scope.loanproducts = data;
}) ;
resourceFactory.provisioningcategory.getAll(function (data) {
scope.provisioningcategories = data;
}) ;
resourceFactory.provisioningentries.get({entryId: routeParams.entryId}, \
function (data) { scope.data = data ;
scope.createdby = data.createdUser ;
scope.createdDate = data.createdDate ;
scope.totalReservedAmount = data.reservedAmount ;
scope.isjournalEntriesCreated = !data.journalEntry ;
});
scope.searchTransaction = function () {
scope.transactions = paginatorService.paginate(fetchFunction, 10);
};
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.entryId = routeParams.entryId ;
params.offset = offset;
params.limit = limit;
if (scope.formData.officeId) {
params.officeId = scope.formData.officeId;
}
if (scope.formData.loanproductId) {
params.productId = scope.formData.loanproductId;
}
if (scope.formData.categoryId) {
params.categoryId = scope.formData.categoryId;
}
scope.saveSC();
resourceFactory.provisioningentriesSearch.get(params, callback);
};
paginatorService.currentOffset = 0 ;
scope.transactions = paginatorService.paginate(fetchFunction, 10);
scope.submit = function () {
resourceFactory.provisioningentries.createJournals({entryId: \
routeParams.entryId}, this.formData, function (data) { \
location.path('/viewprovisioningentries/'); });
};
}
});
mifosX.ng.application.controller('ViewProvisioningEntryController', ['$scope', \
'$routeParams', 'PaginatorService', 'ResourceFactory', '$location', '$uibModal', \
mifosX.controllers.ViewProvisioningEntryController]).run(function ($log) { \
$log.info("ViewProvisioningEntryController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewProvisioningJournalEntriesController: function (scope, routeParams, \
paginatorService, resourceFactory, location, $uibModal) { scope.charge = [];
scope.choice = 0;
scope.transactions = [];
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.entryId = routeParams.entryId ;
params.offset = offset;
params.limit = limit;
scope.saveSC();
resourceFactory.provisioningjournals.get(params, callback);
};
paginatorService.currentOffset = 0 ;
scope.transactions = paginatorService.paginate(fetchFunction, 10);
scope.displayResults = true;
scope.submit = function () {
resourceFactory.provisioningentries.createJournals({entryId: \
routeParams.entryId}, this.formData, function (data) { \
location.path('/viewprovisioningentries/'); });
};
}
});
mifosX.ng.application.controller('ViewProvisioningJournalEntriesController', \
['$scope', '$routeParams', 'PaginatorService', 'ResourceFactory', '$location', \
'$uibModal', mifosX.controllers.ViewProvisioningJournalEntriesController]).run(function \
($log) { $log.info("ViewProvisioningJournalEntriesController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CreateStandingInstructionController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.restrictDate = new Date();
var params = {clientId: \
routeParams.clientId,officeId:routeParams.officeId}; var accountType = \
routeParams.accountType || ''; if (accountType == 'fromsavings') \
params.fromAccountType = 2;
else if (accountType == 'fromloans') params.fromAccountType = 1;
else params.fromAccountType = 0;
scope.toOffices = [];
scope.toClients = [];
scope.toAccountTypes = [];
scope.toAccounts = [];
scope.destinationOptions = [{id:1,name:'own account'},{id:2,name:'with in \
bank'}]; scope.showselctclient = 'false';
scope.allowclientedit = 'true';
scope.formData = {fromOfficeId: Number(params.officeId), fromClientId: \
Number(params.clientId),fromAccountType:params.fromAccountType};
resourceFactory.standingInstructionTemplateResource.get(scope.formData, \
function (data) { scope.standinginstruction = data;
scope.toOffices = data.toOfficeOptions;
scope.toAccountTypes = data.toAccountTypeOptions;
});
scope.changeEvent = function () {
var params = scope.formData;
resourceFactory.standingInstructionTemplateResource.get(params, \
function (data) { scope.standinginstruction = data;
scope.toOffices = data.toOfficeOptions;
scope.toAccountTypes = data.toAccountTypeOptions;
scope.toClients = data.toClientOptions;
scope.toAccounts = data.toAccountOptions;
scope.formData.transferAmount = data.transferAmount;
});
};
scope.changedestination = function () {
if(scope.destination == 1){
scope.allowclientedit = 'false';
scope.formData.toOfficeId = scope.formData.fromOfficeId;
scope.formData.toClientId = scope.formData.fromClientId;
console.log(scope.formData);
scope.changeEvent();
}else{
scope.allowclientedit = 'true';
scope.formData.toOfficeId = null;
scope.formData.toClientId = null;
}
}
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (this.formData.validFrom) this.formData.validFrom = \
dateFilter(this.formData.validFrom, scope.df);
if (this.formData.validTill) this.formData.validTill = \
dateFilter(this.formData.validTill, scope.df); if(this.recurrenceOnMonthDay){
var reqDate = dateFilter(this.recurrenceOnMonthDay, 'dd MMMM');
this.formData.recurrenceOnMonthDay = reqDate;
this.formData.monthDayFormat = 'dd MMMM';
}
this.formData.fromClientId = scope.standinginstruction.fromClient.id;
this.formData.fromOfficeId = \
scope.standinginstruction.fromClient.officeId;
resourceFactory.standingInstructionResource.save(this.formData, \
function (data) { location.path('/viewclient/' + data.clientId);
});
};
}
});
mifosX.ng.application.controller('CreateStandingInstructionController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.CreateStandingInstructionController]).run(function ($log) { \
$log.info("CreateStandingInstructionController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
EditStandingInstructionController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.restrictDate = new Date();
var params = {};
scope.formData = {};
scope.showselctclient = 'false';
scope.allowclientedit = 'true';
scope.standingInstructionId = routeParams.instructionId;
if(routeParams.from == 'list'){
scope.fromlist = true;
}
scope.from = routeParams.from;
params.standingInstructionId = scope.standingInstructionId;
resourceFactory.standingInstructionResource.withTemplate(params, function \
(data) { scope.standinginstruction = data;
scope.formData = {
priority:data.priority.id,
status:data.status.id,
instructionType:data.instructionType.id,
amount:data.amount,
validFrom:data.validFrom,
validTill:data.validTill,
recurrenceType:data.recurrenceType.id,
recurrenceInterval:data.recurrenceInterval
}
if(data.recurrenceFrequency){
scope.formData.recurrenceFrequency=data.recurrenceFrequency.id; \
}
if(data.fromClient.id == data.toClient.id){
scope.allowclientedit = false;
}
if (data.recurrenceOnMonthDay) {
var d = new Date();
var n = d.getFullYear();
data.recurrenceOnMonthDay.push(n);
var actDate = dateFilter(data.recurrenceOnMonthDay, 'dd MMMM');
scope.recurrenceOnMonthDay = new Date(actDate);
}
scope.formData.validFrom = new Date(scope.formData.validFrom);
if(scope.formData.validTill){
scope.formData.validTill = new Date(scope.formData.validTill);
}
});
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (this.formData.validFrom) this.formData.validFrom = \
dateFilter(this.formData.validFrom, scope.df);
if (this.formData.validTill) this.formData.validTill = \
dateFilter(this.formData.validTill, scope.df); if(this.recurrenceOnMonthDay){
var reqDate = dateFilter(this.recurrenceOnMonthDay, 'dd MMMM');
this.formData.recurrenceOnMonthDay = reqDate;
this.formData.monthDayFormat = 'dd MMMM';
}
resourceFactory.standingInstructionResource.update({standingInstructionId: \
scope.standingInstructionId},this.formData, function (data) {
location.path('/viewstandinginstruction/' + \
scope.standingInstructionId); });
};
scope.cancel = function(){
if(scope.fromlist){
scope.viewliststandinginstruction();
}else{
scope.viewstandinginstruction();
}
}
scope.viewstandinginstruction = function () {
location.path('/viewstandinginstruction/'+ \
scope.standingInstructionId); };
scope.viewliststandinginstruction = function () {
location.path('/liststandinginstructions/'+scope.standinginstruction.fromClient.officeId+'/'+scope.standinginstruction.fromClient.id);
};
}
});
mifosX.ng.application.controller('EditStandingInstructionController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.EditStandingInstructionController]).run(function ($log) { \
$log.info("EditStandingInstructionController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ListStandingInstructionController: function (scope, resourceFactory, \
paginatorService,routeParams, dateFilter, location,$uibModal) { scope.restrictDate = \
new Date();
var params = {officeId:routeParams.officeId,clientId: \
routeParams.clientId}; if(routeParams.clientId){
scope.formData = {fromOfficeId: Number(params.officeId), \
fromClientId: Number(params.clientId),fromAccountType:2}; scope.fromClient = true;
}else{
scope.formData = {fromAccountType:2};
scope.fromClient = false;
}
resourceFactory.standingInstructionTemplateResource.get(scope.formData, \
function (data) { scope.standinginstruction = data;
if(data.fromClient){
scope.formData.clientName = data.fromClient.displayName;
scope.searchTransaction();
}
});
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
if (scope.formData.transferType) {
params.transferType = scope.formData.transferType;
}
if (scope.formData.clientName) {
params.clientName = scope.formData.clientName;
}
if (scope.formData.fromClientId) {
params.clientId = scope.formData.fromClientId;
}
if (scope.formData.fromAccountId) {
params.fromAccountId = scope.formData.fromAccountId;
params.fromAccountType = scope.formData.fromAccountType;
}
resourceFactory.standingInstructionResource.search(params, callback);
};
scope.searchTransaction = function () {
scope.displayResults = true;
scope.instructions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
};
scope.deletestandinginstruction = function (id) {
$uibModal.open({
templateUrl: 'delInstruction.html',
controller: DelInstructionCtrl,
resolve: {
ids: function () {
return id;
}
}
});
};
var DelInstructionCtrl = function ($scope, $uibModalInstance, ids) {
$scope.delete = function () {
resourceFactory.standingInstructionResource.cancel({standingInstructionId: \
ids}, function (data) { scope.searchTransaction();
$uibModalInstance.close('delete');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ListStandingInstructionController', ['$scope', \
'ResourceFactory', 'PaginatorService', '$routeParams','dateFilter', \
'$location','$uibModal', \
mifosX.controllers.ListStandingInstructionController]).run(function ($log) { \
$log.info("ListStandingInstructionController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ListTransactionsController: function (scope, resourceFactory, \
paginatorService,routeParams, dateFilter, location) {
scope.standingInstructionId = routeParams.instructionId;
scope.details ={};
scope.transactions={};
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
params.standingInstructionId = scope.standingInstructionId;
resourceFactory.standingInstructionResource.getTransactions(params, \
function (data) { scope.details.fromAccount = data.fromAccount;
scope.details.toAccount = data.toAccount;
scope.details.fromAccountType = data.fromAccountType;
scope.details.toAccountType = data.toAccountType;
scope.details.toClient = data.toClient;
scope.details.name = data.name;
scope.details.id = data.id;
callback(data.transactions);
});
};
scope.transactions = paginatorService.paginate(fetchFunction, 14);
}
});
mifosX.ng.application.controller('ListTransactionsController', ['$scope', \
'ResourceFactory', 'PaginatorService', '$routeParams','dateFilter', '$location', \
mifosX.controllers.ListTransactionsController]).run(function ($log) { \
$log.info("ListTransactionsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
MakeAccountTransferController: function (scope, resourceFactory, location, \
routeParams, dateFilter) { scope.restrictDate = new Date();
var params = {fromAccountId: routeParams.accountId};
var accountType = routeParams.accountType || '';
if (accountType == 'fromsavings') params.fromAccountType = 2;
else if (accountType == 'fromloans') params.fromAccountType = 1;
else params.fromAccountType = 0;
scope.toOffices = [];
scope.toClients = [];
scope.toAccountTypes = [];
scope.toAccounts = [];
scope.back = function () {
window.history.back();
};
scope.formData = {fromAccountId: params.fromAccountId, fromAccountType: \
params.fromAccountType};
resourceFactory.accountTransfersTemplateResource.get(params, function \
(data) { scope.transfer = data;
scope.toOffices = data.toOfficeOptions;
scope.toAccountTypes = data.toAccountTypeOptions;
scope.formData.transferAmount = data.transferAmount;
});
scope.changeClient = function (client) {
scope.formData.toClientId = client.id;
scope.changeEvent();
};
scope.changeEvent = function () {
var params = scope.formData;
delete params.transferAmount;
delete params.transferDate;
delete params.transferDescription;
resourceFactory.accountTransfersTemplateResource.get(params, function \
(data) { scope.transfer = data;
scope.toOffices = data.toOfficeOptions;
scope.toAccountTypes = data.toAccountTypeOptions;
scope.toClients = data.toClientOptions;
scope.toAccounts = data.toAccountOptions;
scope.formData.transferAmount = data.transferAmount;
});
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (this.formData.transferDate) this.formData.transferDate = \
dateFilter(this.formData.transferDate, scope.df); this.formData.fromClientId = \
scope.transfer.fromClient.id;
this.formData.fromOfficeId = scope.transfer.fromClient.officeId;
resourceFactory.accountTransferResource.save(this.formData, function \
(data) { if (params.fromAccountType == 1) {
location.path('/viewloanaccount/' + data.loanId);
} else if (params.fromAccountType == 2) {
location.path('/viewsavingaccount/' + data.savingsId);
}
});
};
}
});
mifosX.ng.application.controller('MakeAccountTransferController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.MakeAccountTransferController]).run(function ($log) { \
$log.info("MakeAccountTransferController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
StandingInstructionsHistoryController: function (scope, resourceFactory, \
paginatorService, dateFilter, $uibModal) { scope.date = {};
scope.formData = {};
scope.transactions = {};
scope.isCollapsed = true;
scope.displayResults = false;
resourceFactory.standingInstructionTemplateResource.get({}, function \
(data) { scope.template = data;
});
if (!scope.searchCriteria.sih) {
scope.searchCriteria.sih = [null, null, null, null, null, null, \
null]; scope.saveSC();
}
scope.formData.clientName = scope.searchCriteria.sih[0];
scope.formData.clientId = scope.searchCriteria.sih[1];
scope.formData.transferType = scope.searchCriteria.sih[2];
scope.formData.fromAccountType = scope.searchCriteria.sih[3];
scope.formData.fromAccountId = scope.searchCriteria.sih[4];
scope.date.first = scope.searchCriteria.sih[5];
scope.date.second = scope.searchCriteria.sih[6];
var fetchFunction = function (offset, limit, callback) {
var reqFirstDate = dateFilter(scope.date.first, scope.df);
var reqSecondDate = dateFilter(scope.date.second, scope.df);
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
if (scope.formData.clientName) {
params.clientName = scope.formData.clientName;
scope.searchCriteria.sih[0] = params.clientName;
} else
scope.searchCriteria.sih[0] = null;
if (scope.formData.clientId) {
params.clientId = scope.formData.clientId;
scope.searchCriteria.sih[1] = params.clientId;
} else
scope.searchCriteria.sih[1] = null;
if (scope.formData.transferType) {
params.transferType = scope.formData.transferType;
scope.searchCriteria.sih[2] = params.transferType;
} else
scope.searchCriteria.sih[2] = null;
if (scope.formData.fromAccountType) {
params.fromAccountType = scope.formData.fromAccountType;
scope.searchCriteria.sih[3] = params.fromAccountType;
} else
scope.searchCriteria.sih[3] = null;
if (scope.formData.fromAccountId) {
params.fromAccountId = scope.formData.fromAccountId;
scope.searchCriteria.sih[4] = params.fromAccountId;
} else
scope.searchCriteria.sih[4] = null;
if (scope.date.first) {
params.fromDate = reqFirstDate;
scope.searchCriteria.sih[5] = params.fromDate;
} else
scope.searchCriteria.sih[5] = null;
if (scope.date.second) {
params.toDate = reqSecondDate;
scope.searchCriteria.sih[6] = params.toDate;
} else
scope.searchCriteria.sih[6] = null;
scope.saveSC();
resourceFactory.standingInstructionHistoryResource.get(params, \
callback); };
scope.getTransactions = function () {
scope.transactions = paginatorService.paginate(fetchFunction, 14);
scope.displayResults = true;
scope.isCollapsed = false;
}
scope.isFailed = function (transaction) {
return transaction.status == 'failed' && transaction.errorLog.length \
> 0; };
scope.errorLog = function (transaction) {
$uibModal.open({
templateUrl: 'errorlog.html',
controller: ErrorLogCtrl,
resolve: {
transaction: function () {
return transaction;
}
}
});
};
var ErrorLogCtrl = function ($scope, $uibModalInstance, transaction) {
$scope.error = transaction.errorLog;
$scope.cancel = function () {
$uibModalInstance.dismiss('close');
};
};
}
});
mifosX.ng.application.controller('StandingInstructionsHistoryController', \
['$scope', 'ResourceFactory', 'PaginatorService', 'dateFilter', '$uibModal', \
mifosX.controllers.StandingInstructionsHistoryController]).run(function ($log) { \
$log.info("StandingInstructionsHistoryController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ViewAccountTransferDetailsController: function (scope, resourceFactory, \
location, routeParams) {
resourceFactory.accountTransferResource.get({transferId: routeParams.id}, \
function (data) { scope.transferData = data;
});
}
});
mifosX.ng.application.controller('ViewAccountTransferDetailsController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', \
mifosX.controllers.ViewAccountTransferDetailsController]).run(function ($log) { \
$log.info("ViewAccountTransferDetailsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewStandingInstructionController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.restrictDate = new Date();
var params = {};
scope.formData = {};
scope.showselctclient = 'false';
scope.allowclientedit = 'true';
scope.standingInstructionId = routeParams.instructionId;
params.standingInstructionId = scope.standingInstructionId;
resourceFactory.standingInstructionResource.get(params, function (data) {
scope.standinginstruction = data;
if(data.fromClient.id == data.toClient.id){
scope.allowclientedit = false;
}
});
scope.cancel = function(){
location.path('/liststandinginstructions/'+scope.standinginstruction.fromClient.officeId+'/'+scope.standinginstruction.fromClient.id);
}
}
});
mifosX.ng.application.controller('ViewStandingInstructionController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.ViewStandingInstructionController]).run(function ($log) { \
$log.info("ViewStandingInstructionController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AdHocQueryListController: function (scope, resourceFactory, location) {
scope.adhocquerys = [];
scope.routeTo = function (id) {
location.path('/viewadhocquery/' + id);
};
resourceFactory.adHocQueryResource.getAllAdHocQuery(function (data) {
scope.adhocquerys = data;
for (var j = 0; j < data.length; j+= 1) {
var d = data[j];
for (var i = 0; i < d.reportRunFrequencies.length; i+= 1) {
if (d.reportRunFrequency === d.reportRunFrequencies[i].id) {
d.reportRunFrequency = d.reportRunFrequencies[i].code;
break;
}
}
}
});
}
});
mifosX.ng.application.controller('AdHocQueryListController', ['$scope', \
'ResourceFactory', '$location', \
mifosX.controllers.AdHocQueryListController]).run(function ($log) { \
$log.info("AdHocQueryListController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CreateAdHocQueryController: function (scope, location, resourceFactory) {
scope.formData = {};
scope.template = {};
scope.customReportRunFrequencyFieldShow = false;
resourceFactory.adHocQueryTemplateResource.get(function(data) {
scope.template = data;
});
scope.reportRunFrequencySelected = function(id) {
scope.customReportRunFrequencyFieldShow = id === 5;
};
scope.submit = function () {
resourceFactory.adHocQueryResource.save(this.formData, function \
(data) { //alert(this.formData.isActive);
//this.formData.isActive=this.formData.isActive ? 1 : 0;
location.path("/viewadhocquery/" + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('CreateAdHocQueryController', ['$scope', \
'$location', 'ResourceFactory', \
mifosX.controllers.CreateAdHocQueryController]).run(function ($log) { \
$log.info("CreateAdHocQueryController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditAdHocQueryController: function (scope, routeParams, resourceFactory, \
location) {
scope.formData = {};
scope.adhocquery = [];
scope.template = {};
scope.customReportRunFrequencyFieldShow = false;
resourceFactory.adHocQueryResource.get({adHocId: routeParams.id, \
template: 'true'}, function (data) { scope.formData.name = data.name;
scope.formData.query = data.query;
scope.formData.tableFields = data.tableFields;
scope.formData.tableName = data.tableName;
scope.adHocId = data.id;
scope.formData.isActive=data.isActive;
scope.formData.email=data.email;
scope.formData.email=data.email;
scope.formData.email=data.email;
scope.formData.reportRunFrequency= data.reportRunFrequency;
scope.formData.reportRunEvery= data.reportRunEvery;
scope.template.reportRunFrequencies= data.reportRunFrequencies;
scope.customReportRunFrequencyFieldShow = data.reportRunFrequency === \
5; });
scope.reportRunFrequencySelected = function(id) {
scope.customReportRunFrequencyFieldShow = id === 5;
};
scope.submit = function () {
//this.formData.isActive=this.formData.isActive ? 1 : 0;
// alert(this.formData.email);
resourceFactory.adHocQueryResource.update({'adHocId': scope.adHocId}, \
this.formData, function (data) {
location.path('/viewadhocquery/' + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('EditAdHocQueryController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', \
mifosX.controllers.EditAdHocQueryController]).run(function ($log) { \
$log.info("EditAdHocQueryController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewAdHocQueryController: function (scope, routeParams, route, location, \
resourceFactory, $modal) { scope.adhocquery = [];
scope.formData = {};
scope.customReportRunFrequencyFieldShow = false;
resourceFactory.adHocQueryResource.get({'adHocId': routeParams.id}, \
function (data) { scope.adhocquery = data;
scope.customReportRunFrequencyFieldShow = data.reportRunFrequency === \
5;
for (var i = 0; i < data.reportRunFrequencies.length; i+= 1) {
if (data.reportRunFrequency === data.reportRunFrequencies[i].id) \
{
data.reportRunFrequency = data.reportRunFrequencies[i].code;
break;
}
}
});
var AdHocDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.adHocQueryResource.delete({adHocId: \
routeParams.id}, {}, function (data) { $uibModalInstance.close('delete');
location.path('/adhocquery');
// added dummy request param because Content-Type header gets \
removed
// if the request does not contain any data (a request body)
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.deleteadhocquery = function () {
$modal.open({
templateUrl: 'deleteadhocquery.html',
controller: AdHocDeleteCtrl
});
};
}
});
mifosX.ng.application.controller('ViewAdHocQueryController', ['$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', '$uibModal', \
mifosX.controllers.ViewAdHocQueryController]).run(function ($log) { \
$log.info("ViewAdHocQueryController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportCentersController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + '/centers/downloadtemplate' + \
'?tenantIdentifier=' + $rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.centerTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.centerTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.centerTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: "centers"}, \
function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/centers/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportCentersController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportCentersController]).run(function ($log) { \
$log.info("BulkImportCentersController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CenterAttendanceController: function (scope, resourceFactory, routeParams, \
location, dateFilter) { scope.center = [];
scope.tempData = {};
scope.formData = {};
scope.first = {};
scope.first.date = new Date();
scope.centerId = routeParams.centerId;
resourceFactory.centerResource.get({centerId: routeParams.centerId, \
associations: 'groupMembers,collectionMeetingCalendar'}, function (data) { \
scope.center = data; scope.meeting = data.collectionMeetingCalendar;
});
resourceFactory.centerMeetingResource.getMeetingInfo({centerId: \
routeParams.centerId, templateSource: 'template', calenderId: \
routeParams.calendarId}, function (data) { scope.clients = data.clients;
scope.attendanceOptions = data.attendanceTypeOptions;
for (var i = 0; i < scope.clients.length; i++) {
scope.tempData[scope.clients[i].id] = \
data.attendanceTypeOptions[0].id;
}
});
scope.attendanceUpdate = function (id) {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.meetingDate = reqDate;
this.formData.clientsAttendance = [];
for (var i = 0; i < scope.clients.length; i++) {
this.formData.clientsAttendance[i] = {clientId: \
scope.clients[i].id, attendanceType: this.tempData[scope.clients[i].id]};
}
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.calendarId = id;
resourceFactory.centerMeetingResource.save({centerId: \
routeParams.centerId, calendarId: routeParams.calendarId}, this.formData, function \
(data) { location.path('/viewcenter/' + routeParams.centerId);
}, function(response){
if(!response.status) {
scope.errorStatus = "Attendance already exist";
} else {
scope.errorStatus = "";
}
});
}
}
});
mifosX.ng.application.controller('CenterAttendanceController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.CenterAttendanceController]).run(function ($log) { \
$log.info("CenterAttendanceController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CenterController: function (scope, resourceFactory, location) {
scope.centers = [];
scope.actualCenters = [];
scope.searchText = "";
scope.searchResults = [];
scope.showClosed = false;
scope.routeTo = function (id) {
location.path('/viewcenter/' + id);
};
if (!scope.searchCriteria.centers) {
scope.searchCriteria.centers = null;
scope.saveSC();
}
scope.filterText = scope.searchCriteria.centers || '';
scope.onFilter = function () {
scope.searchCriteria.centers = scope.filterText;
scope.saveSC();
};
scope.centersPerPage = 15;
scope.getResultsPage = function (pageNumber) {
if(scope.searchText){
var startPosition = (pageNumber - 1) * scope.centersPerPage;
scope.centers = scope.actualCenters.slice(startPosition, \
startPosition + scope.centersPerPage); return;
}
var items = resourceFactory.centerResource.get({
offset: ((pageNumber - 1) * scope.centersPerPage),
limit: scope.centersPerPage,
paged: 'true',
orderBy: 'name',
sortOrder: 'ASC'
}, function (data) {
scope.centers = data.pageItems;
});
}
scope.initPage = function () {
var items = resourceFactory.centerResource.get({
offset: 0,
limit: scope.centersPerPage,
paged: 'true',
orderBy: 'name',
sortOrder: 'ASC'
}, function (data) {
scope.totalCenters = data.totalFilteredRecords;
scope.centers = data.pageItems;
});
}
scope.initPage();
scope.search = function () {
scope.actualCenters = [];
scope.searchResults = [];
scope.filterText = "";
var searchString = scope.searchText;
searchString = searchString.replace(/(^"|"$)/g, '');
var exactMatch=false;
var n = searchString.localeCompare(scope.searchText);
if(n!=0)
{
exactMatch=true;
}
if(!scope.searchText){
scope.initPage();
} else {
resourceFactory.globalSearch.search({query: searchString , \
resource: "groups",exactMatch: exactMatch}, function (data) { var arrayLength = \
data.length; for (var i = 0; i < arrayLength; i++) {
var result = data[i];
var center = {};
center.status = {};
center.subStatus = {};
if(result.entityType == 'CENTER') {
center.name = result.entityName;
center.id = result.entityId;
center.accountNo = result.entityAccountNo;
center.officeName = result.parentName;
center.status.value = result.entityStatus.value;
center.status.code = result.entityStatus.code;
center.externalId = result.entityExternalId;
scope.actualCenters.push(center);
}
}
var numberOfCenters = scope.actualCenters.length;
scope.totalCenters = numberOfCenters;
scope.centers = scope.actualCenters.slice(0, \
scope.centersPerPage); });
}
}
}
});
mifosX.ng.application.controller('CenterController', ['$scope', \
'ResourceFactory', '$location', mifosX.controllers.CenterController]).run(function \
($log) { $log.info("CenterController initialized");
});
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CloseCenterController: function (scope, routeParams, route, location, \
resourceFactory, dateFilter) { scope.template = [];
scope.center = [];
scope.first = {};
scope.formData = {};
scope.restrictDate = new Date();
scope.first.date = new Date();
resourceFactory.centerResource.get({centerId: routeParams.id, \
associations: 'groupMembers,collectionMeetingCalendar'}, function (data) { \
scope.center = data; });
resourceFactory.centerTemplateResource.get({command: 'close'}, function \
(data) { scope.template = data;
if(data.closureReasons[0]) {
scope.formData.closureReasonId = data.closureReasons[0].id;
}
});
scope.closeGroup = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.closureDate = reqDate;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.centerResource.save({centerId: routeParams.id, \
command: 'close'}, this.formData, function (data) { location.path('/viewcenter/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('CloseCenterController', ['$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', 'dateFilter', \
mifosX.controllers.CloseCenterController]).run(function ($log) { \
$log.info("CloseCenterController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CreateCenterController: function (scope, resourceFactory, location, \
dateFilter) { scope.offices = [];
scope.staffs = [];
scope.data = {};
scope.first = {};
scope.first.submitondate = new Date ();
scope.formData = {};
scope.restrictDate = new Date();
scope.first.date = new Date();
scope.addedGroups = [];
resourceFactory.centerTemplateResource.get({staffInSelectedOfficeOnly:true},function \
(data) { scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
scope.groups = data.groupMembersOptions;
scope.formData.officeId = data.officeOptions[0].id;
scope.getGroups();
});
scope.getGroups = function() {
resourceFactory.groupResource.getAllGroups({officeId: \
scope.formData.officeId }, function (data) { scope.groups = data;
});
}
scope.changeOffice = function () {
resourceFactory.centerTemplateResource.get({staffInSelectedOfficeOnly:true, \
officeId: scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.getGroups();
};
scope.setChoice = function () {
if (this.formData.active) {
scope.choice = 1;
}
else if (!this.formData.active) {
scope.choice = 0;
}
};
scope.viewGroup = function (item) {
scope.group = item;
};
scope.add = function () {
if(scope.available != ""){
var temp = {};
temp.id = scope.available.id;
temp.name = scope.available.name;
scope.addedGroups.push(temp);
}
};
scope.sub = function (id) {
for (var i = 0; i < scope.addedGroups.length; i++) {
if (scope.addedGroups[i].id == id) {
scope.addedGroups.splice(i, 1);
break;
}
}
};
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.activationDate = reqDate;
if (scope.first.submitondate) {
reqDate = dateFilter(scope.first.submitondate, scope.df);
this.formData.submittedOnDate = reqDate;
}
scope.formData.groupMembers = [];
for (var i in scope.addedGroups) {
scope.formData.groupMembers[i] = scope.addedGroups[i].id;
}
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.active = this.formData.active || false;
resourceFactory.centerResource.save(this.formData, function (data) {
location.path('/viewcenter/' + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('CreateCenterController', ['$scope', \
'ResourceFactory', '$location', 'dateFilter', \
mifosX.controllers.CreateCenterController]).run(function ($log) { \
$log.info("CreateCenterController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditCenterController: function (scope, resourceFactory, location, \
routeParams, dateFilter) { scope.managecode = routeParams.managecode;
scope.first = {};
scope.first.date = new Date();
scope.centerId = routeParams.id;
scope.restrictDate = new Date();
resourceFactory.centerResource.get({centerId: routeParams.id, template: \
'true',staffInSelectedOfficeOnly:true}, function (data) { scope.edit = data;
scope.staffs = data.staffOptions;
scope.formData = {
name: data.name,
externalId: data.externalId,
staffId: data.staffId
};
if (data.activationDate) {
var newDate = dateFilter(data.activationDate, scope.df);
scope.first.date = new Date(newDate);
}
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.updateGroup = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.activationDate = reqDate;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.centerResource.update({centerId: routeParams.id}, \
this.formData, function (data) { location.path('/viewcenter/' + routeParams.id);
});
};
scope.activate = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
var newActivation = new Object();
newActivation.activationDate = reqDate;
newActivation.locale = scope.optlang.code;
newActivation.dateFormat = scope.df;
resourceFactory.centerResource.save({centerId: routeParams.id, \
command: 'activate'}, newActivation, function (data) { location.path('/viewcenter/' \
+ routeParams.id); });
};
}
});
mifosX.ng.application.controller('EditCenterController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.EditCenterController]).run(function ($log) { \
$log.info("EditCenterController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ManageGroupMembersController: function ($q, scope, resourceFactory, location, \
routeParams, $uibModal) {
scope.centerId = routeParams.id;
scope.indexOfClientToBeDeleted = "";
scope.viewGroup = function (item) {
scope.group = item;
};
resourceFactory.centerResource.get({centerId: routeParams.id, template: \
'true', associations: 'groupMembers'}, function (data) { scope.data = data;
scope.groups = data.groupMembers;
resourceFactory.groupResource.getAllGroups({orderBy: 'name', \
sortOrder: 'ASC',orphansOnly: true, officeId : scope.data.officeId},function(data){
scope.allGroups = data;
});
});
scope.groupsOptions = function(value){
return _.filter(scope.allGroups,function(group){
return group.name.indexOf(value) != -1
});
};
scope.add = function () {
if(scope.available != ""){
scope.associate = {};
scope.associate.groupMembers = [];
scope.associate.groupMembers[0] = scope.available.id;
var temp = {};
temp.id = scope.available.id;
temp.name = scope.available.name;
resourceFactory.centerResource.save({centerId: routeParams.id, \
command: 'associateGroups' }, scope.associate, function (data) { \
scope.groups.push(temp); scope.available = "";
});
}
};
scope.remove = function (index,id) {
scope.indexOfClientToBeDeleted = index;
$uibModal.open({
templateUrl: 'delete.html',
controller: GroupDeleteCtrl
});
scope.disassociate = {};
scope.disassociate.groupMembers = [];
scope.disassociate.groupMembers.push(id);
};
var GroupDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.centerResource.save({centerId: routeParams.id, \
command: 'disassociateGroups' }, scope.disassociate, function (data) \
{
scope.groups.splice(scope.indexOfClientToBeDeleted, 1);
scope.available = "";
$uibModalInstance.close('activate');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ManageGroupMembersController', ['$q','$scope', \
'ResourceFactory', '$location', '$routeParams', '$uibModal', \
mifosX.controllers.ManageGroupMembersController]).run(function ($log) { \
$log.info("ManageGroupMembersController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ViewCenterController: function (scope, routeParams, resourceFactory, \
location, route, http, $uibModal, dateFilter, API_VERSION, $sce, $rootScope) {
scope.center = [];
scope.staffData = {};
scope.formData = {};
scope.report = false;
scope.hidePentahoReport = true;
resourceFactory.centerResource.get({centerId: routeParams.id, \
associations: 'groupMembers,collectionMeetingCalendar'}, function (data) { \
scope.center = data;
scope.isClosedCenter = scope.center.status.value == 'Closed';
scope.staffData.staffId = data.staffId;
if(data.collectionMeetingCalendar) {
scope.meeting = data.collectionMeetingCalendar;
}
});
scope.routeTo = function (id) {
location.path('/viewsavingaccount/' + id);
};
resourceFactory.runReportsResource.get({reportSource: \
'GroupSummaryCounts', genericResultSet: 'false', R_groupId: routeParams.id}, function \
(data) { scope.summary = data[0];
});
resourceFactory.centerAccountResource.get({centerId: routeParams.id}, \
function (data) { scope.accounts = data;
});
resourceFactory.groupNotesResource.getAllNotes({groupId: routeParams.id}, \
function (data) { scope.notes = data;
});
scope.deleteCenter = function () {
$uibModal.open({
templateUrl: 'delete.html',
controller: CenterDeleteCtrl
});
};
scope.unassignStaffCenter = function () {
$uibModal.open({
templateUrl: 'unassignstaff.html',
controller: CenterUnassignCtrl
});
};
var CenterDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.centerResource.delete({centerId: routeParams.id}, \
{}, function (data) { $uibModalInstance.close('activate');
location.path('/centers');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
var CenterUnassignCtrl = function ($scope, $uibModalInstance) {
$scope.unassign = function () {
resourceFactory.groupResource.save({groupId: routeParams.id, \
command: 'unassignStaff'}, scope.staffData, function (data) { \
$uibModalInstance.close('activate'); route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.saveNote = function () {
resourceFactory.groupNotesResource.save({groupId: routeParams.id}, \
this.formData, function (data) { var today = new Date();
temp = { id: data.resourceId, note: scope.formData.note, \
createdByUsername: "test", createdOn: today }; scope.notes.push(temp);
scope.formData.note = "";
scope.predicate = '-id';
});
}
resourceFactory.DataTablesResource.getAllDataTables({apptable: \
'm_center'}, function (data) { scope.centerdatatables = data;
});
scope.viewDataTable = function (registeredTableName,data){
if (scope.datatabledetails.isMultirow) {
location.path("/viewdatatableentry/"+registeredTableName+"/"+scope.center.id+"/"+data.row[0]);
}else{
location.path("/viewsingledatatableentry/"+registeredTableName+"/"+scope.center.id);
}
};
scope.dataTableChange = function (datatable) {
resourceFactory.DataTablesResource.getTableDetails({datatablename: \
datatable.registeredTableName, entityId: routeParams.id, genericResultSet: 'true'}, \
function (data) { scope.datatabledetails = data;
scope.datatabledetails.isData = data.data.length > 0 ? true : \
false;
scope.datatabledetails.isMultirow = \
data.columnHeaders[0].columnName == "id" ? true : false;
scope.showDataTableAddButton = !scope.datatabledetails.isData || \
scope.datatabledetails.isMultirow;
scope.showDataTableEditButton = scope.datatabledetails.isData && \
!scope.datatabledetails.isMultirow; scope.singleRow = [];
for (var i in data.columnHeaders) {
if (scope.datatabledetails.columnHeaders[i].columnCode) {
for (var j in \
scope.datatabledetails.columnHeaders[i].columnValues) { for (var k in data.data) {
if (data.data[k].row[i] == \
scope.datatabledetails.columnHeaders[i].columnValues[j].id) {
data.data[k].row[i] = \
scope.datatabledetails.columnHeaders[i].columnValues[j].value; }
}
}
}
}
if (scope.datatabledetails.isData) {
for (var i in data.columnHeaders) {
if (!scope.datatabledetails.isMultirow) {
var row = {};
row.key = data.columnHeaders[i].columnName;
row.value = data.data[0].row[i];
scope.singleRow.push(row);
}
}
}
});
};
//viewStaffAssignmentHistory [Report]
scope.viewStaffAssignmentHistory = function () {
//alert("center id : "+ scope.center.id);
scope.hidePentahoReport = true;
scope.formData.outputType = 'HTML';
scope.baseURL = $rootScope.hostUrl + API_VERSION + "/runreports/" + \
encodeURIComponent("Staff Assignment History"); scope.baseURL += "?output-type=" + \
encodeURIComponent(scope.formData.outputType) + "&tenantIdentifier=" + \
$rootScope.tenantIdentifier+"&locale="+scope.optlang.code; //alert("url: "+ \
scope.baseURL); var reportParams = "";
var paramName = "R_centerId";
reportParams += encodeURIComponent(paramName) + "=" + \
encodeURIComponent(scope.center.id); if (reportParams > "") {
scope.baseURL += "&" + reportParams;
}
// allow untrusted urls for iframe \
http://docs.angularjs.org/error/$sce/insecurl scope.baseURL = \
$sce.trustAsResourceUrl(scope.baseURL);
};
scope.deleteAll = function (apptableName, entityId) {
resourceFactory.DataTablesResource.delete({datatablename: \
apptableName, entityId: entityId, genericResultSet: 'true'}, {}, function (data) { \
route.reload(); });
};
}
});
mifosX.ng.application.controller('ViewCenterController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', '$route', '$http', '$uibModal', \
'dateFilter', 'API_VERSION', '$sce', '$rootScope', \
mifosX.controllers.ViewCenterController]).run(function ($log) { \
$log.info("ViewCenterController initialized"); });
}(mifosX.controllers || {}));
;/**
* Created by nikpa on 26-06-2017.
*/
(function (module) {
mifosX.controllers = _.extend(module, {
AddFamilyMembersController: function (scope, resourceFactory, \
routeParams,dateFilter, location) {
scope.formData={};
scope.date = {};
clientId=routeParams.clientId;
familyMemberId=routeParams.familyMemberId;
resourceFactory.familyMemberTemplate.get({clientId:clientId},function(data)
{
scope.relationshipIdOptions=data.relationshipIdOptions;
scope.genderIdOptions=data.genderIdOptions;
scope.maritalStatusIdOptions=data.maritalStatusIdOptions;
scope.professionIdOptions=data.professionIdOptions;
});
scope.routeTo=function()
{
location.path('/viewclient/'+clientId);
}
scope.addClientMember=function()
{
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if(scope.date.dateOfBirth){
this.formData.dateOfBirth = dateFilter(scope.date.dateOfBirth, \
scope.df); }
resourceFactory.familyMembers.post({clientId:clientId},scope.formData,function(data)
{
location.path('/viewclient/'+clientId);
})
}
}
});
mifosX.ng.application.controller('AddFamilyMembersController', \
['$scope','ResourceFactory', '$routeParams','dateFilter', '$location', \
mifosX.controllers.AddFamilyMembersController]).run(function ($log) { \
$log.info("AddFamilyMemberController initialized"); });
}
(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddNewClientChargeController: function (scope, resourceFactory, location, \
routeParams, dateFilter) { scope.clientId = routeParams.id;
scope.offices = [];
scope.date = {};
resourceFactory.clientChargesResource.get({clientId: routeParams.id, \
resourceType: 'template'}, function (data) { scope.chargeOptions = \
data.chargeOptions; });
scope.chargeSelected = function (id) {
resourceFactory.chargeResource.get({chargeId: id, template: 'true'}, \
function (data) {
scope.chargeCalculationType = data.chargeCalculationType.id;
scope.chargeTimeType = data.chargeTimeType.id;
scope.chargeDetails = data;
scope.formData.amount = data.amount;
});
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (scope.date.specificduedate) {
this.formData.dueDate = dateFilter(scope.date.specificduedate, \
scope.df); }
resourceFactory.clientChargesResource.save({clientId: \
routeParams.id}, this.formData, function (data) { location.path('/viewclient/' + \
routeParams.id); });
};
}
});
mifosX.ng.application.controller('AddNewClientChargeController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.AddNewClientChargeController]).run(function ($log) { \
$log.info("AddNewClientChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportClientsController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + '/clients/downloadtemplate' + \
'?tenantIdentifier=' + $rootScope.tenantIdentifier + '&locale=' + scope.optlang.code \
+ '&dateFormat=' + scope.df; scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) {
scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.centerTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.centerTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.changeLegalForm=function () {
if (scope.formData.legalForm){
var changedLegalForm;
if(scope.formData.legalForm=="Person"){
changedLegalForm="CLIENTS_PERSON";
}else if(scope.formData.legalForm=="Entity") {
changedLegalForm = "CLIENTS_ENTTTY";
}
if (scope.first.queryParams.indexOf("legalFormType") == -1) {
scope.first.queryParams = scope.first.queryParams + '&' + \
'legalFormType=' + changedLegalForm; } else {
scope.first.queryParams = \
scope.first.queryParams.replace(/&legalFormType=\w+/i, "&legalFormType=" \
+changedLegalForm); }
}
}
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
scope.formData.entityType=null;
if (scope.formData.file.name.toLowerCase().indexOf("person")!=-1) {
scope.formData.entityType = "CLIENTS_PERSON";
}else if \
(scope.formData.file.name.toLowerCase().indexOf("entity")!=-1){ \
scope.formData.entityType="CLIENTS_ENTTTY"; }
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: "client"}, \
function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/clients/uploadtemplate?legalFormType='+scope.formData.entityType+'',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportClientsController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportClientsController]).run(function ($log) { \
$log.info("BulkImportClientsController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ClientActionsController: function (scope, resourceFactory, location, \
routeParams, dateFilter) {
scope.action = routeParams.action || "";
scope.clientId = routeParams.id;
scope.formData = {};
scope.entityformData = {};
scope.entityformData.datatables = {};
scope.restrictDate = new Date();
scope.taskPermissionName = 'ALL_FUNCTIONS';
scope.submittedDatatables = [];
var submitStatus = [];
scope.RequestEntities = function(entity,status){
resourceFactory.entityDatatableChecksResource.getAll({limit:-1},function \
(response) {
scope.entityDatatableChecks = _.filter(response.pageItems , \
function(datatable){
var AllTables = (datatable.entity == entity && \
datatable.status.value == status); return AllTables;
});
scope.entityDatatableChecks = \
_.pluck(scope.entityDatatableChecks,'datatableName'); scope.datatables = [];
var k=0;
_.each(scope.entityDatatableChecks,function(entitytable) {
\
resourceFactory.DataTablesResource.getTableDetails({datatablename:entitytable,entityId: \
routeParams.id, genericResultSet: 'true'}, function (data) { \
data.registeredTableName = entitytable;
var colName = data.columnHeaders[0].columnName;
if (colName == 'id') {
data.columnHeaders.splice(0, 1);
}
colName = data.columnHeaders[0].columnName;
if (colName == 'client_id' || colName == 'office_id' || \
colName == 'group_id' || colName == 'center_id' || colName == 'loan_id' || colName == \
'savings_account_id') { data.columnHeaders.splice(0, 1);
scope.isCenter = (colName == 'center_id') ? true : \
false; }
data.noData = (data.data.length == 0);
if(data.noData){
scope.datatables.push(data);
scope.entityformData.datatables[k] = {data:{}};
submitStatus[k] = "save";
_.each(data.columnHeaders,function(Header){
\
scope.entityformData.datatables[k].data[Header.columnName] = ""; });
k++;
scope.isEntityDatatables = true;
}
});
});
});
};
// Transaction UI Related
switch (scope.action) {
case "activate":
resourceFactory.clientResource.get({clientId: routeParams.id}, \
function (data) { scope.client = data;
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.labelName = 'label.input.activationdate';
scope.breadcrumbName = 'label.anchor.activate';
scope.modelName = 'activationDate';
scope.showActivationDateField = true;
scope.showDateField = false;
scope.taskPermissionName = 'ACTIVATE_CLIENT';
scope.RequestEntities('m_client','ACTIVATE');
break;
case "assignstaff":
scope.breadcrumbName = 'label.anchor.assignstaff';
scope.labelName = 'label.input.staff';
scope.staffField = true;
resourceFactory.clientResource.get({clientId: routeParams.id, \
template: 'true',staffInSelectedOfficeOnly:true}, function (data) { if \
(data.staffOptions) { scope.staffOptions = data.staffOptions;
scope.formData.staffId = scope.staffOptions[0].id;
}
});
scope.taskPermissionName = 'ASSIGNSTAFF_CLIENT';
break;
case "close":
scope.labelName = 'label.input.closuredate';
scope.labelNamereason = 'label.input.closurereason';
scope.breadcrumbName = 'label.anchor.close';
scope.modelName = 'closureDate';
scope.reasonmodelName = 'closureReasonId';
scope.reasonField = true;
scope.showDateField = true;
resourceFactory.clientResource.get({anotherresource: 'template', \
commandParam: 'close'}, function (data) { scope.reasons = data.narrations;
scope.formData.reasonId = scope.narrations[0].id;
});
scope.taskPermissionName = 'CLOSE_CLIENT';
scope.RequestEntities('m_client','CLOSE');
break;
case "delete":
scope.breadcrumbName = 'label.anchor.delete';
scope.labelName = 'label.areyousure';
scope.showDeleteClient = true;
scope.taskPermissionName = 'DELETE_CLIENT';
break;
case "unassignstaff":
scope.labelName = 'label.heading.unassignstaff';
scope.breadcrumbName = 'label.anchor.activate';
scope.showDeleteClient = true;
scope.taskPermissionName = 'UNASSIGNSTAFF_CLIENT';
break;
case "updatedefaultaccount":
scope.breadcrumbName = 'label.anchor.updatedefaultaccount';
scope.labelName = 'label.input.savingsaccount';
scope.savingsField = false;
resourceFactory.clientResource.get({clientId: routeParams.id, \
template: 'true'}, function (data) { if (data.savingAccountOptions) {
scope.savingsField = true;
scope.savingAccountOptions = data.savingAccountOptions;
scope.formData.savingsAccountId = \
scope.savingAccountOptions[0].id; if(data.savingsAccountId){
scope.formData.savingsAccountId = \
data.savingsAccountId; }
}
});
break;
case "acceptclienttransfer":
scope.breadcrumbName = 'label.anchor.acceptclienttransfer';
scope.showNoteField = true;
scope.taskPermissionName = 'ACCEPTTRANSFER_CLIENT';
break;
case "rejecttransfer":
scope.breadcrumbName = 'label.anchor.rejecttransfer';
scope.showNoteField = true;
scope.taskPermissionName = 'REJECTTRANSFER_CLIENT';
break;
case "undotransfer":
scope.breadcrumbName = 'label.anchor.undotransfer';
scope.showNoteField = true;
scope.taskPermissionName = 'WITHDRAWTRANSFER_CLIENT';
break;
case "reject":
scope.labelName = 'label.input.rejectiondate';
scope.labelNamereason = 'label.input.rejectionreason';
scope.breadcrumbName = 'label.anchor.reject';
scope.modelName = 'rejectionDate';
scope.reasonmodelName = 'rejectionReasonId';
scope.reasonField = true;
scope.showDateField = true;
resourceFactory.clientResource.get({anotherresource: 'template', \
commandParam: 'reject'}, function (data) { scope.reasons = data.narrations;
if(data.narrations != "") {
scope.formData.rejectionReasonId = data.narrations[0].id;
}
});
scope.taskPermissionName = 'REJECT_CLIENT';
break;
case "withdraw":
scope.labelName = 'label.input.withdrawaldate';
scope.labelNamereason = 'label.input.withdrawalreason';
scope.breadcrumbName = 'label.anchor.withdraw';
scope.modelName = 'withdrawalDate';
scope.reasonmodelName = 'withdrawalReasonId';
scope.reasonField = true;
scope.showDateField = true;
resourceFactory.clientResource.get({anotherresource: 'template', \
commandParam: 'withdraw'}, function (data) { scope.reasons = data.narrations;
if(data.narrations != "") {
scope.formData.withdrawalReasonId = \
data.narrations[0].id; }
});
scope.taskPermissionName = 'WITHDRAW_CLIENT';
break;
case "reactivate":
resourceFactory.clientResource.get({clientId: routeParams.id}, \
function (data) { scope.client = data;
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.labelName = 'label.input.reactivationdate';
scope.breadcrumbName = 'label.anchor.reactivate';
scope.modelName = 'reactivationDate';
scope.showActivationDateField = true;
scope.showDateField = false;
scope.taskPermissionName = 'REACTIVATE_CLIENT';
break;
case "undoReject":
resourceFactory.clientResource.get({clientId: routeParams.id}, \
function (data) { scope.client = data;
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.labelName = 'label.input.reopeneddate';
scope.breadcrumbName = 'label.anchor.undoReject';
scope.modelName = 'reopenedDate';
scope.showActivationDateField = true;
scope.showDateField = false;
scope.taskPermissionName = 'UNDOREJECT_CLIENT';
break;
case "undoWithdrawn":
resourceFactory.clientResource.get({clientId: routeParams.id}, \
function (data) { scope.client = data;
if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.labelName = 'label.input.reopeneddate';
scope.breadcrumbName = 'label.anchor.undoWithdrawn';
scope.modelName = 'reopenedDate';
scope.showActivationDateField = true;
scope.showDateField = false;
scope.taskPermissionName = 'UNDOWITHDRAWAL_CLIENT';
break;
}
function asyncLoop(iterations, func, callback) {
var index = 0;
var done = false;
var loop = {
next: function() {
if (done) {
return;
}
if (index < iterations) {
index++;
func(loop);
} else {
done = true;
callback();
}
},
iteration: function() {
return index - 1;
},
break: function() {
done = true;
}
};
loop.next();
return loop;
}
scope.fieldType = function (type) {
var fieldType = "";
if (type) {
if (type == 'CODELOOKUP' || type == 'CODEVALUE') {
fieldType = 'SELECT';
} else if (type == 'DATE') {
fieldType = 'DATE';
} else if (type == 'DATETIME') {
fieldType = 'DATETIME';
} else if (type == 'BOOLEAN') {
fieldType = 'BOOLEAN';
} else {
fieldType = 'TEXT';
}
}
return fieldType;
};
scope.submitDatatable = function(){
if(scope.datatables) {
asyncLoop(Object.keys(scope.entityformData.datatables).length,function(loop){
var cnt = loop.iteration();
var formData = scope.entityformData.datatables[cnt];
formData.registeredTableName = \
scope.datatables[cnt].registeredTableName;
var params = {
datatablename: formData.registeredTableName,
entityId: routeParams.id,
genericResultSet: 'true'
};
angular.extend(formData.data,{dateFormat: scope.df, locale: \
scope.optlang.code});
_.each(formData.data, function (columnHeader) {
if (columnHeader.dateType) {
columnHeader = dateFilter(columnHeader.dateType.date, \
params.dateFormat); }
else if (columnHeader.dateTimeType) {
columnHeader = \
dateFilter(columnHeader.columnName.date, scope.df) + " " + \
dateFilter(columnHeader.columnName.time, scope.tf); }
});
var action = submitStatus[cnt];
resourceFactory.DataTablesResource[action](params, \
formData.data, function (data) {
submitStatus[cnt] = "update";
\
scope.submittedDatatables.push(scope.datatables[cnt].registeredTableName); \
loop.next();
},function(){
\
rootScope.errorDetails[0].push({datatable:scope.datatables[cnt].registeredTableName});
loop.break();
});
},function(){
scope.submit();
});
}
else{
scope.submit();
}
};
scope.cancel = function () {
location.path('/viewclient/' + routeParams.id);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (this.formData[scope.modelName]) {
this.formData[scope.modelName] = \
dateFilter(this.formData[scope.modelName], scope.df); }
if (scope.action == "activate") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'activate'}, this.formData, function (data) { location.path('/viewclient/' \
+ data.clientId); });
}
if (scope.action == "assignstaff") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'assignStaff'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "unassignstaff") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'unassignstaff'}, {staffId: routeParams.staffId}, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "close") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'close'}, this.formData, function (data) { location.path('/viewclient/' + \
data.clientId); });
}
if (scope.action == "reject") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'reject'}, this.formData, function (data) { location.path('/viewclient/' + \
data.clientId); });
}
if (scope.action == "withdraw") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'withdraw'}, this.formData, function (data) { location.path('/viewclient/' \
+ data.clientId); });
}
if (scope.action == "reactivate") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'reactivate'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "undoReject") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'undoRejection'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "undoWithdrawn") {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'undoWithdrawal'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "acceptclienttransfer") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'acceptTransfer'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "rejecttransfer") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'rejectTransfer'}, this.formData, function (data) {
resourceFactory.clientResource.save({clientId: \
routeParams.id, command: 'withdrawTransfer'}, {} ,function (data) { \
location.path('/viewclient/' + data.clientId); });
});
}
if (scope.action == "undotransfer") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'withdrawTransfer'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
if (scope.action == "updatedefaultaccount") {
delete this.formData.locale;
delete this.formData.dateFormat;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'updateSavingsAccount'}, this.formData, function (data) { \
location.path('/viewclient/' + data.clientId); });
}
};
}
});
mifosX.ng.application.controller('ClientActionsController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.ClientActionsController]).run(function ($log) { \
$log.info("ClientActionsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ClientChargesOverviewController: function (scope, resourceFactory, location, \
routeParams) { scope.clientId = routeParams.id
scope.charges = [];
scope.chargesPerPage = 14;
scope.routeToCharge = function (chargeId) {
location.path('/viewclient/' + scope.clientId + '/charges/' + \
chargeId); };
scope.getClientChargeResultsPage = function (pageNumber) {
var items = resourceFactory.clientChargesResource.getCharges({
clientId: routeParams.id,
offset: ((pageNumber - 1) * scope.chargesPerPage),
limit: scope.chargesPerPage
}, function (data) {
scope.totalCharges= data.totalFilteredRecords;
scope.charges = data.pageItems;
});
}
scope.getClientChargeResultsPage(1);
}
});
mifosX.ng.application.controller('ClientChargesOverviewController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', \
mifosX.controllers.ClientChargesOverviewController]).run(function ($log) { \
$log.info("ClientChargesOverviewController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ClientController: function (scope, resourceFactory, location) {
scope.clients = [];
scope.actualClients = [];
scope.searchText = "";
scope.searchResults = [];
scope.showClosed = false;
scope.routeTo = function (id) {
location.path('/viewclient/' + id);
};
scope.clientsPerPage = 15;
scope.getResultsPage = function (pageNumber) {
if(scope.searchText){
var startPosition = (pageNumber - 1) * scope.clientsPerPage;
scope.clients = scope.actualClients.slice(startPosition, \
startPosition + scope.clientsPerPage); return;
}
var items = resourceFactory.clientResource.getAllClients({
offset: ((pageNumber - 1) * scope.clientsPerPage),
limit: scope.clientsPerPage
}, function (data) {
scope.clients = data.pageItems;
});
}
scope.initPage = function () {
var items = resourceFactory.clientResource.getAllClients({
offset: 0,
limit: scope.clientsPerPage
}, function (data) {
scope.totalClients = data.totalFilteredRecords;
scope.clients = data.pageItems;
});
}
scope.initPage();
scope.search = function () {
scope.actualClients = [];
scope.searchResults = [];
scope.filterText = "";
var searchString = scope.searchText;
searchString = searchString.replace(/(^"|"$)/g, '');
var exactMatch=false;
var n = searchString.localeCompare(scope.searchText);
if(n!=0)
{
exactMatch=true;
}
if(!scope.searchText){
scope.initPage();
} else {
resourceFactory.globalSearch.search({query: searchString , \
resource: "clients,clientIdentifiers",exactMatch: exactMatch}, function (data) { var \
arrayLength = data.length; for (var i = 0; i < arrayLength; i++) {
var result = data[i];
var client = {};
client.status = {};
client.subStatus = {};
client.status.value = result.entityStatus.value;
client.status.code = result.entityStatus.code;
if(result.entityType == 'CLIENT'){
client.displayName = result.entityName;
client.accountNo = result.entityAccountNo;
client.id = result.entityId;
client.externalId = result.entityExternalId;
client.officeName = result.parentName;
}else if (result.entityType == 'CLIENTIDENTIFIER'){
numberOfClients = numberOfClients + 1;
client.displayName = result.parentName;
client.id = result.parentId;
client.externalId = result.parentExternalId;
}
scope.actualClients.push(client);
}
var numberOfClients = scope.actualClients.length;
scope.totalClients = numberOfClients;
scope.clients = scope.actualClients.slice(0, \
scope.clientsPerPage); });
}
}
}
});
mifosX.ng.application.controller('ClientController', ['$scope', \
'ResourceFactory', '$location', mifosX.controllers.ClientController]).run(function \
($log) { $log.info("ClientController initialized");
});
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ClientDocumentController: function (scope, location, http, routeParams, \
API_VERSION, Upload, $rootScope) { scope.clientId = routeParams.clientId;
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.submit = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
scope.clientId + '/documents',
data: { name : scope.formData.name, description : \
scope.formData.description, file: scope.formData.file}, }).then(function (data) {
// to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
location.path('/viewclient/' + scope.clientId);
});
};
}
});
mifosX.ng.application.controller('ClientDocumentController', ['$scope', \
'$location', '$http', '$routeParams', 'API_VERSION', 'Upload', '$rootScope', \
mifosX.controllers.ClientDocumentController]).run(function ($log) { \
$log.info("ClientDocumentController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
ClientIdentifierController: function (scope, routeParams, location, \
resourceFactory) { scope.clientId = routeParams.clientId;
scope.formData = {};
scope.documenttypes = [];
scope.statusTypes = [{
id: 1,
label: 'Active'
}, {
id: 2,
label: 'Inactive',
}];
resourceFactory.clientIdenfierTemplateResource.get({clientId: \
routeParams.clientId}, function (data) { scope.documenttypes = \
data.allowedDocumentTypes;
scope.formData.documentTypeId = data.allowedDocumentTypes[0].id;
});
scope.submit = function () {
resourceFactory.clientIdenfierResource.save({clientId: \
scope.clientId}, this.formData, function (data) { location.path('/viewclient/' + \
data.clientId); });
};
}
});
mifosX.ng.application.controller('ClientIdentifierController', ['$scope', \
'$routeParams', '$location', 'ResourceFactory', \
mifosX.controllers.ClientIdentifierController]).run(function ($log) { \
$log.info("ClientIdentifierController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ClientScreenReportController: function (scope, resourceFactory, location, \
$http, API_VERSION, routeParams, $rootScope, $sce) { scope.clientId = \
routeParams.clientId;
resourceFactory.templateResource.get({entityId: 0, typeId: 0}, function \
(data) { scope.clientTemplateData = data;
});
scope.print = function (template) {
var templateWindow = window.open('', 'Screen Report', \
'height=400,width=600'); templateWindow.document.write('<html><head>');
templateWindow.document.write('</head><body>');
templateWindow.document.write(template);
templateWindow.document.write('</body></html>');
templateWindow.print();
templateWindow.close();
};
scope.getClientTemplate = function (templateId) {
scope.selectedTemplate = templateId;
$http({
method: 'POST',
url: $rootScope.hostUrl + API_VERSION + '/templates/' + \
templateId + '?clientId=' + routeParams.clientId, data: {}
}).then(function (data) {
scope.template = $sce.trustAsHtml(data.data);
});
};
}
});
mifosX.ng.application.controller('ClientScreenReportController', ['$scope', \
'ResourceFactory', '$location', '$http', 'API_VERSION', '$routeParams', '$rootScope', \
'$sce', mifosX.controllers.ClientScreenReportController]).run(function ($log) { \
$log.info("ClientScreenReportController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CreateClientController: function (scope, resourceFactory, location, http, \
dateFilter, API_VERSION, Upload, $rootScope, routeParams, WizardHandler) {
scope.offices = [];
scope.staffs = [];
scope.savingproducts = [];
scope.first = {};
scope.first.date = new Date();
scope.first.submitondate = new Date ();
scope.formData = {};
scope.formDat = {};
scope.clientNonPersonDetails = {};
scope.restrictDate = new Date();
scope.showSavingOptions = false;
scope.savings = {};
scope.savings.opensavingsproduct = false;
scope.forceOffice = null;
scope.showNonPersonOptions = false;
scope.clientPersonId = 1;
//address
scope.addressTypes=[];
scope.countryOptions=[];
scope.stateOptions=[];
scope.addressTypeId={};
entityname="ADDRESS";
scope.addressArray=[];
scope.formData.address=[];
//familymembers
scope.formData.familyMembers=[];
scope.familyArray=[];
scope.datatables = [];
scope.noOfTabs = 1;
scope.step = '-';
scope.formData.datatables = [];
scope.formDat.datatables = [];
scope.tf = "HH:mm";
scope.clientId = routeParams.clientId;
var requestParams = {staffInSelectedOfficeOnly:true};
if (routeParams.groupId) {
requestParams.groupId = routeParams.groupId;
}
if (routeParams.officeId) {
requestParams.officeId = routeParams.officeId;
}
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
scope.formData.officeId = scope.offices[0].id;
scope.savingproducts = data.savingProductOptions;
scope.genderOptions = data.genderOptions;
scope.clienttypeOptions = data.clientTypeOptions;
scope.clientClassificationOptions = data.clientClassificationOptions;
scope.clientNonPersonConstitutionOptions = \
data.clientNonPersonConstitutionOptions;
scope.clientNonPersonMainBusinessLineOptions = \
data.clientNonPersonMainBusinessLineOptions;
scope.clientLegalFormOptions = data.clientLegalFormOptions;
scope.datatables = data.datatables;
if (!_.isUndefined(scope.datatables) && scope.datatables.length > 0) \
{ scope.noOfTabs = scope.datatables.length + 1;
angular.forEach(scope.datatables, function (datatable, index) {
scope.updateColumnHeaders(datatable.columnHeaderData);
angular.forEach(datatable.columnHeaderData, function \
(colHeader, i) {
if (_.isEmpty(scope.formDat.datatables[index])) {
scope.formDat.datatables[index] = {data: {}};
}
if (_.isEmpty(scope.formData.datatables[index])) {
scope.formData.datatables[index] = {
registeredTableName: \
datatable.registeredTableName, data: {locale: scope.optlang.code}
};
}
if (datatable.columnHeaderData[i].columnDisplayType == \
'DATETIME') {
\
scope.formDat.datatables[index].data[datatable.columnHeaderData[i].columnName] = {}; \
} });
});
}
if (data.savingProductOptions.length > 0) {
scope.showSavingOptions = true;
}
if(routeParams.officeId) {
scope.formData.officeId = routeParams.officeId;
for(var i in data.officeOptions) {
if(data.officeOptions[i].id == routeParams.officeId) {
scope.forceOffice = data.officeOptions[i];
break;
}
}
}
if(routeParams.groupId) {
if(typeof data.staffId !== "undefined") {
scope.formData.staffId = data.staffId;
}
}
scope.enableAddress=data.isAddressEnabled;
if(scope.enableAddress===true)
{
scope.addressTypes=data.address.addressTypeIdOptions;
scope.countryOptions=data.address.countryIdOptions;
scope.stateOptions=data.address.stateProvinceIdOptions;
resourceFactory.addressFieldConfiguration.get({entity:entityname},function(data){
for(var i=0;i<data.length;i++)
{
data[i].field='scope.'+data[i].field;
eval(data[i].field+"="+data[i].is_enabled);
}
})
}
scope.relationshipIdOptions=data.familyMemberOptions.relationshipIdOptions;
scope.genderIdOptions=data.familyMemberOptions.genderIdOptions;
scope.maritalStatusIdOptions=data.familyMemberOptions.maritalStatusIdOptions;
scope.professionIdOptions=data.familyMemberOptions.professionIdOptions;
});
scope.updateColumnHeaders = function(columnHeaderData) {
var colName = columnHeaderData[0].columnName;
if (colName == 'id') {
columnHeaderData.splice(0, 1);
}
colName = columnHeaderData[0].columnName;
if (colName == 'client_id' || colName == 'office_id' || colName == \
'group_id' || colName == 'center_id' || colName == 'loan_id' || colName == \
'savings_account_id') { columnHeaderData.splice(0, 1);
}
};
// address
scope.addAddress=function()
{
scope.addressArray.push({});
}
scope.removeAddress=function(index)
{
scope.addressArray.splice(index,1);
}
// end of address
// family members
scope.addFamilyMember=function()
{
scope.familyArray.push({});
}
scope.removeFamilyMember=function(index)
{
scope.familyArray.splice(index,1);
}
// end of family members
scope.displayPersonOrNonPersonOptions = function (legalFormId) {
if(legalFormId == scope.clientPersonId || legalFormId == null) {
scope.showNonPersonOptions = false;
}else {
scope.showNonPersonOptions = true;
}
};
scope.changeOffice = function (officeId) {
resourceFactory.clientTemplateResource.get({staffInSelectedOfficeOnly:true, \
officeId: officeId }, function (data) {
scope.staffs = data.staffOptions;
scope.savingproducts = data.savingProductOptions;
});
};
scope.setChoice = function () {
if (this.formData.active) {
scope.choice = 1;
}
else if (!this.formData.active) {
scope.choice = 0;
}
};
if(routeParams.groupId) {
scope.cancel = '#/viewgroup/' + routeParams.groupId
scope.groupid = routeParams.groupId;
}else {
scope.cancel = "#/clients"
}
//return input type
//return input type
scope.fieldType = function (type) {
var fieldType = "";
if (type) {
if (type == 'CODELOOKUP' || type == 'CODEVALUE') {
fieldType = 'SELECT';
} else if (type == 'DATE') {
fieldType = 'DATE';
} else if (type == 'DATETIME') {
fieldType = 'DATETIME';
} else if (type == 'BOOLEAN') {
fieldType = 'BOOLEAN';
} else {
fieldType = 'TEXT';
}
}
return fieldType;
};
scope.dateTimeFormat = function (colHeaders) {
angular.forEach(colHeaders, function (colHeader, i) {
if (colHeaders[i].columnDisplayType == 'DATETIME') {
return scope.df + " " + scope.tf;
}
});
return scope.df;
};
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.locale = scope.optlang.code;
this.formData.active = this.formData.active || false;
this.formData.dateFormat = scope.df;
this.formData.activationDate = reqDate;
if (!_.isUndefined(scope.datatables) && scope.datatables.length > 0) \
{
angular.forEach(scope.datatables, function (datatable, index) {
scope.columnHeaders = datatable.columnHeaderData;
angular.forEach(scope.columnHeaders, function (colHeader, i) \
{ scope.dateFormat = scope.df + " " + scope.tf
if (scope.columnHeaders[i].columnDisplayType == 'DATE') {
if \
(!_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName])) \
{ scope.formData.datatables[index].data[scope.columnHeaders[i].columnName] = \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName], \
scope.dateFormat);
scope.formData.datatables[index].data.dateFormat \
= scope.dateFormat; }
} else if (scope.columnHeaders[i].columnDisplayType == \
'DATETIME') { if (!_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].date) \
&& !_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].time)) \
{ scope.formData.datatables[index].data[scope.columnHeaders[i].columnName] = \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].date, \
scope.df)
+ " " + \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].time, \
scope.tf);
scope.formData.datatables[index].data.dateFormat \
= scope.dateFormat; }
}
});
});
} else {
delete scope.formData.datatables;
}
if (routeParams.groupId) {
this.formData.groupId = routeParams.groupId;
}
if (routeParams.officeId) {
this.formData.officeId = routeParams.officeId;
}
if (scope.first.submitondate) {
reqDate = dateFilter(scope.first.submitondate, scope.df);
this.formData.submittedOnDate = reqDate;
}
if (scope.first.dateOfBirth) {
this.formData.dateOfBirth = dateFilter(scope.first.dateOfBirth, \
scope.df); }
if (this.formData.legalFormId == scope.clientPersonId || \
this.formData.legalFormId == null) { delete this.formData.fullname;
} else {
delete this.formData.firstname;
delete this.formData.middlename;
delete this.formData.lastname;
}
if(scope.first.incorpValidityTillDate) {
this.formData.clientNonPersonDetails.locale = scope.optlang.code;
this.formData.clientNonPersonDetails.dateFormat = scope.df;
this.formData.clientNonPersonDetails.incorpValidityTillDate = \
dateFilter(scope.first.incorpValidityTillDate, scope.df); }
if (!scope.savings.opensavingsproduct) {
this.formData.savingsProductId = null;
}
if(scope.enableAddress===true)
{
for(var i=0;i<scope.addressArray.length;i++)
{
var temp=new Object();
if(scope.addressArray[i].addressTypeId)
{
temp.addressTypeId=scope.addressArray[i].addressTypeId;
}
if(scope.addressArray[i].street)
{
temp.street=scope.addressArray[i].street;
}
if(scope.addressArray[i].addressLine1)
{
temp.addressLine1=scope.addressArray[i].addressLine1;
}
if(scope.addressArray[i].addressLine2)
{
temp.addressLine2=scope.addressArray[i].addressLine2;
}
if(scope.addressArray[i].addressLine3)
{
temp.addressLine3=scope.addressArray[i].addressLine3;
}
if(scope.addressArray[i].townVillage)
{
temp.townVlage=scope.addressArray[i].townVillage;
}
if(scope.addressArray[i].city)
{
temp.city=scope.addressArray[i].city;
}
if(scope.addressArray[i].countyDistrict)
{
temp.countyDistrict=scope.addressArray[i].countyDistrict;
}
if(scope.addressArray[i].countryId)
{
temp.countryId=scope.addressArray[i].countryId;
}
if(scope.addressArray[i].stateProvinceId)
{
\
temp.stateProvinceId=scope.addressArray[i].stateProvinceId; }
if(scope.addressArray[i].postalCode)
{
temp.postalCode=scope.addressArray[i].postalCode;
}
if(scope.addressArray[i].latitude)
{
temp.latitude=scope.addressArray[i].latitude;
}
if(scope.addressArray[i].longitude)
{
temp.longitude=scope.addressArray[i].longitude;
}
if(scope.addressArray[i].isActive)
{
temp.isActive=scope.addressArray[i].isActive;
}
scope.formData.address.push(temp);
}
}
// family array
for(var i=0;i<scope.familyArray.length;i++)
{
var temp=new Object();
if(scope.familyArray[i].relationshipId)
{
temp.relationshipId=scope.familyArray[i].relationshipId;
}
if(scope.familyArray[i].firstName)
{
temp.firstName=scope.familyArray[i].firstName;
}
if(scope.familyArray[i].middleName)
{
temp.middleName=scope.familyArray[i].middleName;
}
if(scope.familyArray[i].lastName)
{
temp.lastName=scope.familyArray[i].lastName;
}
if(scope.familyArray[i].qualification)
{
temp.qualification=scope.familyArray[i].qualification;
}
if(scope.familyArray[i].mobileNumber)
{
temp.mobileNumber=scope.familyArray[i].mobileNumber;
}
if(scope.familyArray[i].age)
{
temp.age=scope.familyArray[i].age;
}
if(scope.familyArray[i].isDependent)
{
temp.isDependent=scope.familyArray[i].isDependent;
}
if(scope.familyArray[i].genderId)
{
temp.genderId=scope.familyArray[i].genderId;
}
if(scope.familyArray[i].professionId)
{
temp.professionId=scope.familyArray[i].professionId;
}
if(scope.familyArray[i].maritalStatusId)
{
temp.maritalStatusId=scope.familyArray[i].maritalStatusId;
}
if(scope.familyArray[i].dateOfBirth)
{
temp.dateOfBirth=dateFilter(scope.familyArray[i].dateOfBirth, \
scope.df); }
temp.locale = scope.optlang.code;
temp.dateFormat = scope.df;
scope.formData.familyMembers.push(temp);
}
//
resourceFactory.clientResource.save(this.formData, function (data) {
location.path('/viewclient/' + data.clientId);
});
};
}
});
mifosX.ng.application.controller('CreateClientController', ['$scope', \
'ResourceFactory', '$location', '$http', 'dateFilter', 'API_VERSION', 'Upload', \
'$rootScope', '$routeParams', 'WizardHandler', \
mifosX.controllers.CreateClientController]).run(function ($log) { \
$log.info("CreateClientController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditClientController: function (scope, routeParams, resourceFactory, \
location, http, dateFilter, API_VERSION, Upload, $rootScope) { scope.offices = [];
scope.date = {};
scope.restrictDate = new Date();
scope.savingproducts = [];
scope.clientId = routeParams.id;
scope.showSavingOptions = 'false';
scope.opensavingsproduct = 'false';
scope.showNonPersonOptions = false;
scope.clientPersonId = 1;
resourceFactory.clientResource.get({clientId: routeParams.id, \
template:'true', staffInSelectedOfficeOnly:true}, function (data) { scope.offices = \
data.officeOptions; scope.staffs = data.staffOptions;
scope.savingproducts = data.savingProductOptions;
scope.genderOptions = data.genderOptions;
scope.clienttypeOptions = data.clientTypeOptions;
scope.clientClassificationOptions = data.clientClassificationOptions;
scope.clientNonPersonConstitutionOptions = \
data.clientNonPersonConstitutionOptions;
scope.clientNonPersonMainBusinessLineOptions = \
data.clientNonPersonMainBusinessLineOptions;
scope.clientLegalFormOptions = data.clientLegalFormOptions;
scope.officeId = data.officeId;
scope.formData = {
firstname: data.firstname,
lastname: data.lastname,
middlename: data.middlename,
active: data.active,
accountNo: data.accountNo,
staffId: data.staffId,
externalId: data.externalId,
isStaff:data.isStaff,
mobileNo: data.mobileNo,
savingsProductId: data.savingsProductId,
genderId: data.gender.id,
fullname: data.fullname,
clientNonPersonDetails : {
incorpNumber: data.clientNonPersonDetails.incorpNumber,
remarks: data.clientNonPersonDetails.remarks
}
};
if(data.gender){
scope.formData.genderId = data.gender.id;
}
if(data.clientType){
scope.formData.clientTypeId = data.clientType.id;
}
if(data.clientClassification){
scope.formData.clientClassificationId = \
data.clientClassification.id; }
if(data.legalForm){
scope.displayPersonOrNonPersonOptions(data.legalForm.id);
scope.formData.legalFormId = data.legalForm.id;
}
if(data.clientNonPersonDetails.constitution){
scope.formData.clientNonPersonDetails.constitutionId = \
data.clientNonPersonDetails.constitution.id; }
if(data.clientNonPersonDetails.mainBusinessLine){
scope.formData.clientNonPersonDetails.mainBusinessLineId = \
data.clientNonPersonDetails.mainBusinessLine.id; }
if (data.savingsProductId != null) {
scope.opensavingsproduct = 'true';
scope.showSavingOptions = 'true';
} else if (data.savingProductOptions.length > 0) {
scope.showSavingOptions = 'true';
}
if (data.dateOfBirth) {
var dobDate = dateFilter(data.dateOfBirth, scope.df);
scope.date.dateOfBirth = new Date(dobDate);
}
if (data.clientNonPersonDetails.incorpValidityTillDate) {
var incorpValidityTillDate = \
dateFilter(data.clientNonPersonDetails.incorpValidityTillDate, \
scope.df);
scope.date.incorpValidityTillDate = new \
Date(incorpValidityTillDate); }
var actDate = dateFilter(data.activationDate, scope.df);
scope.date.activationDate = new Date(actDate);
if (data.active) {
scope.choice = 1;
scope.showSavingOptions = 'false';
scope.opensavingsproduct = 'false';
}
if (data.timeline.submittedOnDate) {
var submittedOnDate = dateFilter(data.timeline.submittedOnDate, \
scope.df);
scope.date.submittedOnDate = new Date(submittedOnDate);
}
});
scope.displayPersonOrNonPersonOptions = function (legalFormId) {
if(legalFormId == scope.clientPersonId || legalFormId == null) {
scope.showNonPersonOptions = false;
}else {
scope.showNonPersonOptions = true;
}
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (scope.choice === 1) {
if (scope.date.activationDate) {
this.formData.activationDate = \
dateFilter(scope.date.activationDate, scope.df); }
}
if(scope.date.dateOfBirth){
this.formData.dateOfBirth = dateFilter(scope.date.dateOfBirth, \
scope.df); }
if(scope.date.submittedOnDate){
this.formData.submittedOnDate = \
dateFilter(scope.date.submittedOnDate, scope.df); }
if(scope.date.incorpValidityTillDate){
this.formData.clientNonPersonDetails.locale = scope.optlang.code;
this.formData.clientNonPersonDetails.dateFormat = scope.df;
this.formData.clientNonPersonDetails.incorpValidityTillDate = \
dateFilter(scope.date.incorpValidityTillDate, scope.df); }
if(this.formData.legalFormId == scope.clientPersonId || \
this.formData.legalFormId == null) { delete this.formData.fullname;
}else {
delete this.formData.firstname;
delete this.formData.middlename;
delete this.formData.lastname;
}
resourceFactory.clientResource.update({'clientId': routeParams.id}, \
this.formData, function (data) { location.path('/viewclient/' + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('EditClientController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', '$http', 'dateFilter', 'API_VERSION', \
'Upload', '$rootScope', mifosX.controllers.EditClientController]).run(function ($log) \
{ $log.info("EditClientController initialized");
});
}(mifosX.controllers || {}));
;/**
* Created by nikpa on 22-06-2017.
*/
(function (module) {
mifosX.controllers = _.extend(module, {
EditFamilyMemberController: function (scope, resourceFactory, \
routeParams,dateFilter, location) {
scope.formData={};
scope.date = {};
clientId=routeParams.clientId;
familyMemberId=routeParams.familyMemberId;
resourceFactory.familyMemberTemplate.get({clientId:clientId},function(data)
{
scope.relationshipIdOptions=data.relationshipIdOptions;
scope.genderIdOptions=data.genderIdOptions;
scope.maritalStatusIdOptions=data.maritalStatusIdOptions;
scope.professionIdOptions=data.professionIdOptions;
});
resourceFactory.familyMember.get({clientId:clientId,clientFamilyMemberId:familyMemberId},function(data)
{
scope.formData=data;
if (data.dateOfBirth) {
var dobDate = dateFilter(data.dateOfBirth, scope.df);
scope.date.dateOfBirth = new Date(dobDate);
}
});
scope.routeTo=function()
{
location.path('/viewclient/'+clientId);
}
scope.updateClientMember=function()
{
delete scope.formData.maritalStatus;
delete scope.formData.gender;
delete scope.formData.profession;
delete scope.formData.relationship;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if(scope.date.dateOfBirth){
this.formData.dateOfBirth = dateFilter(scope.date.dateOfBirth, \
scope.df); }
resourceFactory.familyMember.put({clientId:clientId,clientFamilyMemberId:familyMemberId},scope.formData,function(data)
{
location.path('/viewclient/'+clientId);
})
}
}
});
mifosX.ng.application.controller('EditFamilyMemberController', \
['$scope','ResourceFactory', '$routeParams','dateFilter', '$location', \
mifosX.controllers.EditFamilyMemberController]).run(function ($log) { \
$log.info("EditFamilyMemberController initialized"); });
}
(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
PayClientChargeController: function (scope, resourceFactory, location, \
routeParams, dateFilter) { scope.cancelRoute = routeParams.id;
scope.formData = {};
scope.paymentDate = new Date();
resourceFactory.clientChargesResource.get({clientId: routeParams.id, \
resourceType: routeParams.chargeid}, function (data) { scope.formData.amount = \
data.amountOutstanding; });
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (scope.paymentDate) {
this.formData.transactionDate = dateFilter(scope.paymentDate, \
scope.df); }
resourceFactory.clientChargesResource.save({clientId: routeParams.id \
, resourceType: routeParams.chargeid ,command: 'paycharge'}, this.formData, function \
(data) { location.path('/viewclient/' + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('PayClientChargeController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.PayClientChargeController]).run(function ($log) { \
$log.info("PayClientChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
SurveyController: function (scope, resourceFactory, location, routeParams, \
localStorageService, $uibModal) {
scope.clientId = routeParams.clientId;
scope.formData = {};
scope.surveyData = {};
scope.survey = {};
resourceFactory.surveyResource.getAll({isActive: true}, function (data) {
scope.surveys = data;
});
scope.surveySelected = function (surveyData) {
if(surveyData) {
scope.surveyData = surveyData;
function groupBy( array , f )
{
var groups = {};
array.forEach( function( o )
{
var group = JSON.stringify( f(o) );
groups[group] = groups[group] || [];
groups[group].push( o );
});
return Object.keys(groups).map( function( group )
{
return groups[group];
})
}
var result = groupBy(scope.surveyData.questionDatas, \
function(item) {
return [item.componentKey];
});
scope.componentGroups = result;
}
}
scope.submit = function () {
this.formData.userId = \
localStorageService.getFromLocalStorage('userData').userId; this.formData.clientId = \
routeParams.clientId; this.formData.surveyId = scope.surveyData.id;
this.formData.scorecardValues = [];
this.formData.surveyName = '';
this.formData.username = '';
this.formData.id = 0;
for(i=0; i < scope.surveyData.questionDatas.length; i++){
if(scope.surveyData.questionDatas[i].answer) {
var tmp = {};
tmp.questionId = scope.surveyData.questionDatas[i].id;
tmp.responseId = scope.surveyData.questionDatas[i].answer.id
tmp.value = scope.surveyData.questionDatas[i].answer.value
tmp.createdOn = new Date().getTime();
this.formData.scorecardValues.push(tmp);
}
}
resourceFactory.surveyScorecardResource.post({surveyId: \
scope.surveyData.id}, this.formData, function (data) { \
location.path('/clients/survey/' + scope.clientId); });
};
scope.isAnyResponse = function(){
for(i=0; i < scope.surveyData.questionDatas.length; i++){
if(scope.surveyData.questionDatas[i].answer) {
return false;
}
}
return true;
};
scope.cancel = function () {
if (scope.clientId) {
location.path('/clients/survey/' + scope.clientId);
} else {
location.path('/clients');
}
}
}
});
mifosX.ng.application.controller('SurveyController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'localStorageService','$uibModal', \
mifosX.controllers.SurveyController]).run(function ($log) { \
$log.info("SurveyController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
TransactionClientController: function (scope, resourceFactory, routeParams, \
location) {
scope.formData = {};
scope.clientId = routeParams.id;
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
scope.formData.destinationOfficeId = scope.offices[0].id;
});
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'proposeTransfer'}, this.formData, function (data) { \
location.path('/viewclient/' + routeParams.id); });
};
}
});
mifosX.ng.application.controller('TransactionClientController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.TransactionClientController]).run(function ($log) { \
$log.info("TransactionClientController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
UploadClientIdentifierDocumentController: function (scope, location, \
routeParams, API_VERSION, Upload, $rootScope) { scope.clientId = \
routeParams.clientId; scope.resourceId = routeParams.resourceId;
scope.uploadPic = function (file) {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/client_identifiers/' + \
scope.resourceId + '/documents', data: scope.formData,
file: file
}).then(function (data) {
// to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
location.path('/viewclient/' + scope.clientId);
});
};
}
});
mifosX.ng.application.controller('UploadClientIdentifierDocumentController', \
['$scope', '$location', '$routeParams', 'API_VERSION', 'Upload', '$rootScope', \
mifosX.controllers.UploadClientIdentifierDocumentController]).run(function ($log) { \
$log.info("UploadClientIdentifierDocumentController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewClientChargeController: function (scope, resourceFactory, location, \
routeParams, route) { scope.clientId = routeParams.clientId;
resourceFactory.clientChargesResource.get({clientId: \
routeParams.clientId, resourceType:routeParams.chargeId , associations:'all'}, \
function (data) { scope.charge = data;
});
scope.undoTransaction = function(transactionId){
resourceFactory.clientTransactionResource.undoTransaction({clientId: \
routeParams.clientId, transactionId:transactionId}, function (data) { \
route.reload(); });
}
scope.waiveCharge = function(chargeId){
resourceFactory.clientChargesResource.waive({clientId: \
routeParams.clientId, resourceType:routeParams.chargeId}, function (data) { \
route.reload(); });
}
scope.deleteCharge = function(){
resourceFactory.clientChargesResource.delete({clientId: \
routeParams.clientId, resourceType:routeParams.chargeId , associations:'all'}, \
function (data) { location.path('/viewclient/'+ scope.clientId);
});
}
}
});
mifosX.ng.application.controller('ViewClientChargeController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', '$route', \
mifosX.controllers.ViewClientChargeController]).run(function ($log) { \
$log.info("ViewClientChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewClientController: function (scope, routeParams, route, location, \
resourceFactory, http, $uibModal, API_VERSION, $rootScope, Upload) { scope.client = \
[]; scope.identitydocuments = [];
scope.buttons = [];
scope.clientdocuments = [];
scope.staffData = {};
scope.formData = {};
scope.openLoan = true;
scope.openSaving = true;
scope.openShares = true ;
scope.updateDefaultSavings = false;
scope.charges = [];
// address
scope.addresses=[];
scope.view={};
scope.view.data=[];
// scope.families=[];
var entityname="ADDRESS";
formdata={};
resourceFactory.clientTemplateResource.get(function(data)
{
scope.enableAddress=data.isAddressEnabled;
if(scope.enableAddress===true)
{
resourceFactory.addressFieldConfiguration.get({entity:entityname},function(data){
for(var i=0;i<data.length;i++)
{
data[i].field='scope.view.'+data[i].field;
eval(data[i].field+"="+data[i].is_enabled);
}
})
resourceFactory.clientAddress.get({clientId:routeParams.id},function(data)
{
scope.addresses=data;
})
}
/* resourceFactory.getAllFamilyMembers.get({clientId:routeParams.id},function(data)
{
scope.families=data;
})*/
});
scope.routeTo=function()
{
location.path('/address/'+ routeParams.id);
}
scope.ChangeAddressStatus=function(id,status,addressId)
{
formdata.isActive=!status
formdata.addressId=addressId
resourceFactory.clientAddress.put({clientId:id},formdata,function(data)
{
route.reload();
})
}
scope.routeToEdit=function(clientId,addressId)
{
location.path('/editAddress/'+clientId+'/'+addressId+'/'+ \
routeParams.id);
}
// end of address
// family members
scope.families=[];
resourceFactory.familyMembers.get({clientId:routeParams.id},function(data)
{
scope.families=data;
});
scope.deleteFamilyMember=function(clientFamilyMemberId)
{
resourceFactory.familyMember.delete({clientId:routeParams.id,clientFamilyMemberId:clientFamilyMemberId},function(data)
{
route.reload();
})
}
scope.editFamilyMember=function(clientFamilyMemberId)
{
location.path('/editfamilymember/'+routeParams.id+'/'+clientFamilyMemberId);
}
scope.routeToaddFamilyMember=function()
{
location.path('/addfamilymembers/'+ routeParams.id);
}
// end of family members
scope.routeToLoan = function (id) {
location.path('/viewloanaccount/' + id);
};
scope.routeToChargeOverview = function () {
location.path(scope.pathToChargeOverview());
};
scope.pathToChargeOverview =function (){
return ('/viewclient/'+ scope.client.id + '/chargeoverview');
}
scope.routeToCharge = function (chargeId) {
location.path('/viewclient/'+ scope.client.id + '/charges/' + \
chargeId); };
scope.routeToSaving = function (id, depositTypeCode) {
if (depositTypeCode === "depositAccountType.savingsDeposit") {
location.path('/viewsavingaccount/' + id);
} else if (depositTypeCode === "depositAccountType.fixedDeposit") {
location.path('/viewfixeddepositaccount/' + id);
} else if (depositTypeCode === "depositAccountType.recurringDeposit") \
{ location.path('/viewrecurringdepositaccount/' + id);
}
};
scope.routeToShareAccount = function(id) {
location.path('/viewshareaccount/'+id)
} ;
scope.haveFile = [];
resourceFactory.clientResource.get({clientId: routeParams.id}, function \
(data) { scope.client = data;
scope.isClosedClient = scope.client.status.value == 'Closed';
scope.staffData.staffId = data.staffId;
if (data.imagePresent) {
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/images?maxHeight=150' }).then(function (imageData) {
scope.image = imageData.data;
});
}
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents' }).then(function (docsData) {
var docId = -1;
for (var i = 0; i < docsData.data.length; ++i) {
if (docsData.data[i].name == 'clientSignature') {
docId = docsData.data[i].id;
scope.signature_url = $rootScope.hostUrl + API_VERSION + \
'/clients/' + routeParams.id + '/documents/' + docId + \
'/attachment?tenantIdentifier=' + $rootScope.tenantIdentifier; }
}
});
scope.navigateToSavingsOrDepositAccount = function (eventName, \
accountId, savingProductType) { switch(eventName) {
case "deposit":
if(savingProductType==100)
location.path('/savingaccount/' + accountId + \
'/deposit'); if(savingProductType==300)
location.path('/recurringdepositaccount/' + accountId \
+ '/deposit'); break;
case "withdraw":
if(savingProductType==100)
location.path('/savingaccount/' + accountId + \
'/withdrawal'); if(savingProductType==300)
location.path('/recurringdepositaccount/' + accountId \
+ '/withdrawal'); break;
}
}
var clientStatus = new mifosX.models.ClientStatus();
if (clientStatus.statusKnown(data.status.value)) {
scope.buttons = clientStatus.getStatus(data.status.value);
scope.savingsActionbuttons = [
{
name: "button.deposit",
type: "100",
icon: "fa fa-arrow-up",
taskPermissionName: "DEPOSIT_SAVINGSACCOUNT"
},
{
name: "button.withdraw",
type: "100",
icon: "fa fa-arrow-down",
taskPermissionName: "WITHDRAW_SAVINGSACCOUNT"
},
{
name: "button.deposit",
type: "300",
icon: "fa fa-arrow-up",
taskPermissionName: "DEPOSIT_RECURRINGDEPOSITACCOUNT"
},
{
name: "button.withdraw",
type: "300",
icon: "fa fa-arrow-down",
taskPermissionName: "WITHDRAW_RECURRINGDEPOSITACCOUNT"
}
];
}
if (data.status.value == "Pending" || data.status.value == "Active") \
{ if (data.staffId) {
}
else {
scope.buttons.push(clientStatus.getStatus("Assign Staff"));
}
}
scope.buttonsArray = {
options: [
{
name: "button.clientscreenreports"
}
]
};
scope.buttonsArray.singlebuttons = scope.buttons;
resourceFactory.runReportsResource.get({reportSource: \
'ClientSummary', genericResultSet: 'false', R_clientId: routeParams.id}, function \
(data) { scope.client.ClientSummary = data[0];
});
});
scope.deleteClient = function () {
$uibModal.open({
templateUrl: 'deleteClient.html',
controller: ClientDeleteCtrl
});
};
scope.uploadPic = function () {
$uibModal.open({
templateUrl: 'uploadpic.html',
controller: UploadPicCtrl
});
};
var UploadPicCtrl = function ($scope, $uibModalInstance) {
$scope.upload = function (file) {
if (file) {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/images', data: {},
file: file
}).then(function (imageData) {
// to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
$uibModalInstance.close('upload');
route.reload();
});
}
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.capturePic = function () {
$uibModal.open({
templateUrl: 'capturepic.html',
controller: CapturePicCtrl,
windowClass: 'modalwidth700'
});
};
var CapturePicCtrl = function ($scope, $uibModalInstance) {
$scope.picture = null;
$scope.error = null;
$scope.videoChannel = {
video: null,
videoWidth: 320,
videoHeight: 240
};
$scope.stream = null;
$scope.onVideoSuccess = function () {
$scope.error = null;
};
$scope.onStream = function(stream) {
$scope.stream = stream
}
$scope.onVideoError = function (err) {
if(typeof err != "undefined")
$scope.error = err.message + '(' + err.name + ')';
};
$scope.takeScreenshot = function () {
if($scope.videoChannel.video) {
var picCanvas = document.createElement('canvas');
var width = $scope.videoChannel.video.width;
var height = $scope.videoChannel.video.height;
picCanvas.width = width;
picCanvas.height = height;
var ctx = picCanvas.getContext("2d");
ctx.drawImage($scope.videoChannel.video, 0, 0, width, \
height);
var imageData = ctx.getImageData(0, 0, width, height);
\
document.querySelector('#clientSnapshot').getContext("2d").putImageData(imageData, 0, \
0); $scope.picture = picCanvas.toDataURL();
}
};
$scope.uploadscreenshot = function () {
if($scope.picture != null) {
http({
method: 'POST',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/images', data: $scope.picture
}).then(function (imageData) {
if (!scope.$$phase) {
scope.$apply();
}
$scope.stream.getVideoTracks()[0].stop();
$uibModalInstance.close('upload');
route.reload();
});
}
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
$scope.stream.getVideoTracks()[0].stop();
};
$scope.reset = function () {
$scope.picture = null;
}
};
scope.deletePic = function () {
$uibModal.open({
templateUrl: 'deletePic.html',
controller: DeletePicCtrl
});
};
var DeletePicCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
http({
method: 'DELETE',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/images', }).then(function (imageData) {
if (!scope.$$phase) {
scope.$apply();
}
$uibModalInstance.close('delete');
route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.uploadSig = function () {
$uibModal.open({
templateUrl: 'uploadsig.html',
controller: UploadSigCtrl
});
};
var UploadSigCtrl = function ($scope, $uibModalInstance) {
$scope.upload = function (file) {
if (file) {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents', data: {
name: 'clientSignature',
description: 'client signature'
},
file: file
}).then(function (imageData) {
// to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
$uibModalInstance.close('upload');
route.reload();
});
}
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.deleteSig = function () {
$uibModal.open({
templateUrl: 'deletesig.html',
controller: DeleteSigCtrl
});
};
var DeleteSigCtrl = function ($scope, $uibModalInstance) {
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents' }).then(function (docsData) {
$scope.docId = -1;
for (var i = 0; i < docsData.data.length; ++i) {
if (docsData.data[i].name == 'clientSignature') {
$scope.docId = docsData.data[i].id;
scope.signature_url = $rootScope.hostUrl + \
API_VERSION + '/clients/' + routeParams.id + '/documents/' + docId + \
'/attachment?tenantIdentifier=' + $rootScope.tenantIdentifier; }
}
});
$scope.delete = function (file) {
http({
method: 'DELETE',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents/' + $scope.docId }).then(function () {
if (!scope.$$phase) {
scope.$apply();
}
$uibModalInstance.close('upload');
route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.unassignStaffCenter = function () {
$uibModal.open({
templateUrl: 'clientunassignstaff.html',
controller: ClientUnassignCtrl
});
};
var ClientDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.clientResource.delete({clientId: routeParams.id}, \
{}, function (data) { $uibModalInstance.close('delete');
location.path('/clients');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
var ClientUnassignCtrl = function ($scope, $uibModalInstance) {
$scope.unassign = function () {
resourceFactory.clientResource.save({clientId: routeParams.id, \
command: 'unassignstaff'}, scope.staffData, function (data) { \
$uibModalInstance.close('unassign'); route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
resourceFactory.clientAccountResource.get({clientId: routeParams.id}, \
function (data) { scope.clientAccounts = data;
if (data.savingsAccounts) {
for (var i in data.savingsAccounts) {
if (data.savingsAccounts[i].status.value == "Active") {
scope.updateDefaultSavings = true;
break;
}
}
scope.totalAllSavingsAccountsBalanceBasedOnCurrency=[];
for (var i in data.savingsAccounts) {
if (!scope.isSavingClosed(data.savingsAccounts[i])) {
var isNewEntryMap = true;
for(var j in \
scope.totalAllSavingsAccountsBalanceBasedOnCurrency){
\
if(scope.totalAllSavingsAccountsBalanceBasedOnCurrency[j].code === \
data.savingsAccounts[i].currency.code){ isNewEntryMap = false;
var totalSavings = \
scope.totalAllSavingsAccountsBalanceBasedOnCurrency[j].totalSavings + \
data.savingsAccounts[i].accountBalance;
\
scope.totalAllSavingsAccountsBalanceBasedOnCurrency[j].totalSavings = totalSavings; \
} }
if(isNewEntryMap){
var map = {};
map.code = data.savingsAccounts[i].currency.code;
map.totalSavings = \
data.savingsAccounts[i].accountBalance;
\
scope.totalAllSavingsAccountsBalanceBasedOnCurrency.push(map); }
}
}
}
});
resourceFactory.clientChargesResource.getCharges({clientId: \
routeParams.id, pendingPayment:true}, function (data) { scope.charges = \
data.pageItems; });
scope.isClosed = function (loanaccount) {
if (loanaccount.status.code === "loanStatusType.closed.written.off" \
||
loanaccount.status.code === \
"loanStatusType.closed.obligations.met" ||
loanaccount.status.code === \
"loanStatusType.closed.reschedule.outstanding.amount" ||
loanaccount.status.code === "loanStatusType.withdrawn.by.client" \
||
loanaccount.status.code === "loanStatusType.rejected") {
return true;
} else {
return false;
}
};
scope.isSavingClosed = function (savingaccount) {
if (savingaccount.status.code === \
"savingsAccountStatusType.withdrawn.by.applicant" ||
savingaccount.status.code === "savingsAccountStatusType.closed" \
||
savingaccount.status.code === \
"savingsAccountStatusType.pre.mature.closure" ||
savingaccount.status.code === \
"savingsAccountStatusType.rejected") { return true;
} else {
return false;
}
};
scope.isShareClosed = function (shareAccount) {
if ( shareAccount.status.code === "shareAccountStatusType.closed" ||
shareAccount.status.code === "shareAccountStatusType.rejected") {
return true;
} else {
return false;
}
};
scope.setLoan = function () {
if (scope.openLoan) {
scope.openLoan = false
} else {
scope.openLoan = true;
}
};
scope.setSaving = function () {
if (scope.openSaving) {
scope.openSaving = false;
} else {
scope.openSaving = true;
}
};
scope.setShares = function () {
if (scope.openShares) {
scope.openShares = false;
} else {
scope.openShares = true;
}
};
resourceFactory.clientNotesResource.getAllNotes({clientId: \
routeParams.id}, function (data) { scope.clientNotes = data;
});
scope.getClientIdentityDocuments = function () {
resourceFactory.clientResource.getAllClientDocuments({clientId: \
routeParams.id, anotherresource: 'identifiers'}, function (data) { \
scope.identitydocuments = data;
for (var i = 0; i < scope.identitydocuments.length; i++) {
\
resourceFactory.clientIdentifierResource.get({clientIdentityId: \
scope.identitydocuments[i].id}, function (data) {
for (var j = 0; j < scope.identitydocuments.length; j++) \
{
if (data.length > 0 && scope.identitydocuments[j].id \
== data[0].parentEntityId) { for (var l in data) {
var loandocs = {};
loandocs = API_VERSION + '/' + \
data[l].parentEntityType + '/' + data[l].parentEntityId + '/documents/' + data[l].id \
+ '/attachment?tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = \
loandocs; }
scope.identitydocuments[j].documents = data;
}
}
});
}
});
};
resourceFactory.DataTablesResource.getAllDataTables({apptable: \
'm_client'}, function (data) { scope.clientdatatables = data;
});
scope.dataTableChange = function (clientdatatable) {
resourceFactory.DataTablesResource.getTableDetails({datatablename: \
clientdatatable.registeredTableName,
entityId: routeParams.id, genericResultSet: 'true'}, function \
(data) { scope.datatabledetails = data;
scope.datatabledetails.isData = data.data.length > 0 ? true : \
false;
scope.datatabledetails.isMultirow = \
data.columnHeaders[0].columnName == "id" ? true : false;
scope.showDataTableAddButton = !scope.datatabledetails.isData || \
scope.datatabledetails.isMultirow;
scope.showDataTableEditButton = scope.datatabledetails.isData && \
!scope.datatabledetails.isMultirow; scope.singleRow = [];
for (var i in data.columnHeaders) {
if (scope.datatabledetails.columnHeaders[i].columnCode) {
for (var j in \
scope.datatabledetails.columnHeaders[i].columnValues) { for (var k in data.data) {
if (data.data[k].row[i] == \
scope.datatabledetails.columnHeaders[i].columnValues[j].id) {
data.data[k].row[i] = \
scope.datatabledetails.columnHeaders[i].columnValues[j].value; }
}
}
}
}
if (scope.datatabledetails.isData) {
for (var i in data.columnHeaders) {
if (!scope.datatabledetails.isMultirow) {
var row = {};
row.key = data.columnHeaders[i].columnName;
row.value = data.data[0].row[i];
scope.singleRow.push(row);
}
}
}
});
};
scope.viewstandinginstruction = function () {
location.path('/liststandinginstructions/' + scope.client.officeId + \
'/' + scope.client.id); };
scope.createstandinginstruction = function () {
location.path('/createstandinginstruction/' + scope.client.officeId + \
'/' + scope.client.id + '/fromsavings'); };
scope.deleteAll = function (apptableName, entityId) {
resourceFactory.DataTablesResource.delete({datatablename: \
apptableName, entityId: entityId, genericResultSet: 'true'}, {}, function (data) { \
route.reload(); });
};
scope.getClientDocuments = function () {
resourceFactory.clientDocumentsResource.getAllClientDocuments({clientId: \
routeParams.id}, function (data) { for (var l in data) {
var loandocs = {};
loandocs = API_VERSION + '/' + data[l].parentEntityType + '/' \
+ data[l].parentEntityId + '/documents/' + data[l].id + \
'/attachment?tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = \
loandocs; if (data[l].fileName)
if (data[l].fileName.toLowerCase().indexOf('.jpg') != -1 \
|| data[l].fileName.toLowerCase().indexOf('.jpeg') != -1 || \
data[l].fileName.toLowerCase().indexOf('.png') != -1) data[l].fileIsImage = true;
if (data[l].type)
if (data[l].type.toLowerCase().indexOf('image') != -1)
data[l].fileIsImage = true;
}
scope.clientdocuments = data;
});
};
scope.deleteDocument = function (documentId, index) {
resourceFactory.clientDocumentsResource.delete({clientId: \
routeParams.id, documentId: documentId}, '', function (data) { \
scope.clientdocuments.splice(index, 1); });
};
scope.previewDocument = function (url, fileName) {
scope.preview = true;
scope.fileUrl = scope.hostUrl + url;
if(fileName.toLowerCase().indexOf('.png') != -1)
scope.fileType = 'image/png';
else if(fileName.toLowerCase().indexOf('.jpg') != -1)
scope.fileType = 'image/jpg';
else if(fileName.toLowerCase().indexOf('.jpeg') != -1)
scope.fileType = 'image/jpeg';
};
scope.viewDataTable = function (registeredTableName, data) {
if (scope.datatabledetails.isMultirow) {
location.path("/viewdatatableentry/" + registeredTableName + "/" \
+ scope.client.id + "/" + data.row[0]); } else {
location.path("/viewsingledatatableentry/" + registeredTableName \
+ "/" + scope.client.id); }
};
scope.downloadDocument = function (documentId) {
resourceFactory.clientDocumentsResource.get({clientId: \
routeParams.id, documentId: documentId}, '', function (data) { \
scope.clientdocuments.splice(index, 1); });
};
scope.isLoanNotClosed = function (loanaccount) {
if (loanaccount.status.code === "loanStatusType.closed.written.off" \
||
loanaccount.status.code === \
"loanStatusType.closed.obligations.met" ||
loanaccount.status.code === \
"loanStatusType.closed.reschedule.outstanding.amount" ||
loanaccount.status.code === "loanStatusType.withdrawn.by.client" \
||
loanaccount.status.code === "loanStatusType.rejected") {
return false;
} else {
return true;
}
};
scope.isSavingNotClosed = function (savingaccount) {
if (savingaccount.status.code === \
"savingsAccountStatusType.withdrawn.by.applicant" ||
savingaccount.status.code === "savingsAccountStatusType.closed" \
||
savingaccount.status.code === \
"savingsAccountStatusType.pre.mature.closure" ||
savingaccount.status.code === \
"savingsAccountStatusType.rejected") { return false;
} else {
return true;
}
};
scope.isShareNotClosed = function (shareAccount) {
if ( shareAccount.status.code === "shareAccountStatusType.closed" ||
shareAccount.status.code === "shareAccountStatusType.rejected") {
return false;
} else {
return true;
}
};
scope.saveNote = function () {
resourceFactory.clientResource.save({clientId: routeParams.id, \
anotherresource: 'notes'}, this.formData, function (data) { var today = new Date();
temp = { id: data.resourceId, note: scope.formData.note, \
createdByUsername: "test", createdOn: today }; scope.clientNotes.unshift(temp);
scope.formData.note = "";
scope.predicate = '-id';
});
}
scope.showEditNote = function(clientId, clientNote, index) {
$uibModal.open({
templateUrl: 'editNote.html',
controller: EditNoteCtrl,
resolve: {
items: function(){
return {
clientId: clientId,
clientNote: clientNote,
index: index
}
}
},
size: "lg"
});
}
scope.showDeleteNote = function(clientId, clientNote, index) {
$uibModal.open({
templateUrl: 'deleteNote.html',
controller: DeleteNoteCtrl,
resolve: {
items: function(){
return {
clientId: clientId,
clientNote: clientNote,
index: index
}
}
},
size: "lg"
});
}
var EditNoteCtrl = function ($scope, $uibModalInstance, items) {
scope.editData = {};
editData = {};
$scope.editNote = function (clientId, entityId, index, editData) {
resourceFactory.clientNotesResource.put({clientId: \
items.clientId, noteId: items.clientNote}, {note: this.editData.editNote}, \
function(data) {
scope.clientNotes[items.index].note = \
$scope.editData.editNote; scope.editData.editNote = "";
$uibModalInstance.close();
});
};
$scope.cancel = function (index) {
$uibModalInstance.dismiss('cancel');
};
};
var DeleteNoteCtrl = function ($scope, $uibModalInstance, items) {
$scope.deleteNote = function (clientId, entityId, index) {
resourceFactory.clientNotesResource.delete({clientId: \
items.clientId, noteId: items.clientNote}, '', function(data) { \
$uibModalInstance.close(); scope.clientNotes.splice(items.index, 1);
});
};
$scope.cancel = function (index) {
$uibModalInstance.dismiss('cancel');
};
};
scope.deleteClientIdentifierDocument = function (clientId, entityId, \
index) {
resourceFactory.clientIdenfierResource.delete({clientId: clientId, \
id: entityId}, '', function (data) { scope.identitydocuments.splice(index, 1);
});
};
scope.downloadClientIdentifierDocument = function (identifierId, \
documentId) { console.log(identifierId, documentId);
};
scope.waiveCharge = function(chargeId){
resourceFactory.clientChargesResource.waive({clientId: \
routeParams.id, resourceType:chargeId}, function (data) { route.reload();
});
}
scope.showSignature = function()
{
$uibModal.open({
templateUrl: 'clientSignature.html',
controller: ViewLargerClientSignature,
size: "lg"
});
};
scope.showWithoutSignature = function()
{
$uibModal.open({
templateUrl: 'clientWithoutSignature.html',
controller: ViewClientWithoutSignature,
size: "lg"
});
};
scope.showPicture = function () {
$uibModal.open({
templateUrl: 'photo-dialog.html',
controller: ViewLargerPicCtrl,
size: "lg"
});
};
var ViewClientWithoutSignature = function($scope,$uibModalInstance){
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.uploadSig = function () {
$uibModalInstance.dismiss('cancel');
scope.uploadSig();
};
};
var ViewLargerClientSignature = function($scope,$uibModalInstance){
var loadSignature = function(){
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents' }).then(function (docsData) {
$scope.docId = -1;
for (var i = 0; i < docsData.data.length; ++i) {
if (docsData.data[i].name == 'clientSignature') {
$scope.docId = docsData.data[i].id;
scope.signature_url = $rootScope.hostUrl + \
API_VERSION + '/clients/' + routeParams.id + '/documents/' + $scope.docId + \
'/attachment?tenantIdentifier=' + $rootScope.tenantIdentifier; }
}
if (scope.signature_url != null) {
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/documents/' + $scope.docId + '/attachment?tenantIdentifier=' + \
$rootScope.tenantIdentifier }).then(function (docsData) {
$scope.largeImage = scope.signature_url;
});
}
});
};
loadSignature();
$scope.deleteSig = function () {
$uibModalInstance.dismiss('cancel');
scope.deleteSig();
};
$scope.uploadSig = function () {
$uibModalInstance.dismiss('cancel');
scope.uploadSig();
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
var ViewLargerPicCtrl = function ($scope, $uibModalInstance) {
var loadImage = function () {
if (scope.client.imagePresent) {
http({
method: 'GET',
url: $rootScope.hostUrl + API_VERSION + '/clients/' + \
routeParams.id + '/images?maxWidth=860' }).then(function (imageData) {
$scope.largeImage = imageData.data;
});
}
};
loadImage();
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewClientController', ['$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', '$http', '$uibModal', \
'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.ViewClientController]).run(function ($log) { \
$log.info("ViewClientController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewClientSurveyController: function (scope, resourceFactory, location, \
routeParams) {
scope.clientId = routeParams.clientId;
scope.surveys = [];
resourceFactory.clientSurveyScorecardResource.get({clientId: \
scope.clientId}, function (data) { scope.constructSurvey(data);
});
scope.constructSurvey = function(data){
for(var i in data){
for(var j in data[i].scorecardValues){
var survey = \
{'surveyName':data[i].surveyName,'createdby':data[i].username,'date':data[i].scorecardValues[j].createdOn,'score':data[i].scorecardValues[j].value};
scope.surveys.push(survey);
}
}
};
scope.routeTo = function(){
location.path('/survey/'+scope.clientId);
};
}
});
mifosX.ng.application.controller('ViewClientSurveyController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', \
mifosX.controllers.ViewClientSurveyController]).run(function ($log) { \
$log.info("ViewClientSurveyController initialized"); });
}(mifosX.controllers || {}));
;'use strict';
/*global _ */
/*global mifosX */
(function (module) {
mifosX.controllers = _.extend(module, {
CollectionSheetController: function (scope, resourceFactory, location, \
routeParams, dateFilter, localStorageService, route, $timeout) { scope.offices = [];
scope.centers = [];
scope.groups = [];
scope.clientsAttendance = [];
scope.calendarId = '';
scope.formData = {};
scope.centerId = '';
scope.groupId = '';
scope.date = {};
scope.newGroupTotal = {};
scope.savingsGroupsTotal = [];
scope.date.transactionDate = new Date();
var centerOrGroupResource = '';
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
scope.productiveCollectionSheet = function () {
if (scope.officeId && scope.loanOfficerId ) {
for (var i = 0; i < scope.offices.length; i++) {
if (scope.offices[i].id === scope.officeId) {
scope.officeName = scope.offices[i].name;
}
}
scope.meetingDate = dateFilter(scope.date.transactionDate, \
scope.df);
location.path('/productivesheet/' + scope.officeId + '/' + \
scope.officeName + '/' + scope.meetingDate + '/' + scope.loanOfficerId); } else {
scope.collectionsheetform.office.$valid = true;
scope.collectionsheetform.office.$error.req = true;
scope.collectionsheetform.loanOfficer.$valid = true;
scope.collectionsheetform.loanOfficer.$error.req = true;
}
};
scope.officeSelected = function (officeId) {
scope.officeId = officeId;
if (officeId) {
resourceFactory.employeeResource.getAllEmployees({officeId: \
officeId}, function (data) { scope.loanOfficers = data;
});
resourceFactory.centerResource.getAllCenters({officeId: \
scope.officeId, orderBy: 'name', sortOrder: 'ASC', limit: -1}, function (data) { \
scope.centers = data; });
resourceFactory.groupResource.getAllGroups({officeId: \
scope.officeId, orderBy: 'name', sortOrder: 'ASC', limit: -1}, function (data) { \
scope.groups = data; });
}
};
if (localStorageService.getFromLocalStorage('Success') === 'true') {
scope.savesuccess = true;
localStorageService.removeFromLocalStorage('Success');
scope.val = true;
$timeout(function () {
scope.val = false;
}, 3000);
}
scope.loanOfficerSelected = function (loanOfficerId) {
if (loanOfficerId) {
scope.loanOfficerId = loanOfficerId;
resourceFactory.centerResource.getAllCenters({officeId: \
scope.officeId, staffId: loanOfficerId, orderBy: 'name', sortOrder: 'ASC', limit: \
-1}, function (data) { scope.centers = data;
});
resourceFactory.groupResource.getAllGroups({officeId: \
scope.officeId, staffId: loanOfficerId, orderBy: 'name', sortOrder: 'ASC', limit: \
-1}, function (data) { scope.groups = data;
});
} else {
scope.centers = '';
scope.groups = '';
}
};
scope.centerSelected = function (centerId) {
if (centerId) {
scope.collectionsheetdata = "";
resourceFactory.centerResource.get({'centerId': centerId, \
associations: 'groupMembers,collectionMeetingCalendar' }, function (data) { \
scope.centerdetails = data; if (data.groupMembers.length > 0) {
scope.groups = data.groupMembers;
}
if (data.collectionMeetingCalendar && \
data.collectionMeetingCalendar.recentEligibleMeetingDate) { if \
(!scope.date.transactionDate) {
scope.date.transactionDate = new \
Date(dateFilter(data.collectionMeetingCalendar.recentEligibleMeetingDate, scope.df)); \
} }
if (data.collectionMeetingCalendar) {
scope.calendarId = data.collectionMeetingCalendar.id;
}
centerOrGroupResource = "centerResource";
});
}
};
scope.groupSelected = function (groupId) {
if (groupId) {
scope.collectionsheetdata = "";
resourceFactory.groupResource.get({'groupId': groupId, \
associations: 'collectionMeetingCalendar'}, function (data) { scope.groupdetails = \
data.pageItems; if (data.collectionMeetingCalendar) {
scope.calendarId = data.collectionMeetingCalendar.id;
}
if (data.collectionMeetingCalendar && \
data.collectionMeetingCalendar.recentEligibleMeetingDate) { if \
(!scope.date.transactionDate) {
scope.date.transactionDate = new \
Date(dateFilter(data.collectionMeetingCalendar.recentEligibleMeetingDate, scope.df));
}
}
centerOrGroupResource = "groupResource";
});
} else if (scope.centerId) {
centerOrGroupResource = "centerResource";
}
};
scope.showPaymentDetailsFn = function () {
var paymentDetail = {};
scope.showPaymentDetails = true;
paymentDetail.paymentTypeId = "";
paymentDetail.accountNumber = "";
paymentDetail.checkNumber = "";
paymentDetail.routingCode = "";
paymentDetail.receiptNumber = "";
paymentDetail.bankNumber = "";
};
scope.previewCollectionSheet = function () {
scope.formData = {};
scope.formData.dateFormat = scope.df;
scope.formData.locale = scope.optlang.code;
scope.formData.calendarId = scope.calendarId;
scope.showPaymentDetails = false;
if (scope.date.transactionDate) {
scope.formData.transactionDate = \
dateFilter(scope.date.transactionDate, scope.df); }
if (centerOrGroupResource === "centerResource" && scope.calendarId \
!== "") {
resourceFactory.centerResource.save({'centerId': scope.centerId, \
command: 'generateCollectionSheet'}, scope.formData, function (data) { if \
(data.groups.length > 0) { scope.collectionsheetdata = data;
scope.clientsAttendanceArray(data.groups);
//scope.total(data);
scope.savingsgroups = data.groups;
scope.sumTotalDueCollection();
} else {
scope.noData = true;
$timeout(function () {
scope.noData = false;
}, 3000);
}
});
} else if (centerOrGroupResource === "groupResource" && \
scope.calendarId !== "") {
resourceFactory.groupResource.save({'groupId': scope.groupId, \
command: 'generateCollectionSheet'}, scope.formData, function (data) { if \
(data.groups.length > 0) { scope.collectionsheetdata = data;
scope.clientsAttendanceArray(data.groups);
//scope.total(data);
scope.savingsgroups = data.groups;
scope.sumTotalDueCollection();
} else {
scope.noData = true;
$timeout(function () {
scope.noData = false;
}, 3000);
}
});
} else {
resourceFactory.groupResource.save({'groupId': 0, command: \
'generateCollectionSheet'}, scope.formData, function (data) { \
scope.collectionsheetdata = data; });
}
};
/**
* Sum of loans and savings due for collection group by currency
*/
scope.sumTotalDueCollection = function () {
scope.totalDueCollection = [];
scope.sumGroupDueCollection();
scope.sumSavingsDueCollection();
scope.sumLoansTotal();
scope.sumLoansDueByCurrency();
scope.sumSavingsDueByCurrency();
};
scope.sumLoansDueByCurrency = function () {
_.each(scope.loansTotal, function (loan) {
var existing = _.findWhere(scope.totalDueCollection, \
{currencyCode: loan.currencyCode}); var dueAmount = loan.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
currencyCode: loan.currencyCode,
currencySymbol: loan.currencySymbol,
dueAmount: dueAmount
};
scope.totalDueCollection.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(dueAmount)) * 100) / 100; }
});
};
scope.sumSavingsDueByCurrency = function () {
_.each(scope.savingsTotal, function (saving) {
var existing = _.findWhere(scope.totalDueCollection, \
{currencyCode: saving.currencyCode}); var dueAmount = saving.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
currencyCode: saving.currencyCode,
currencySymbol: saving.currencySymbol,
dueAmount: dueAmount
};
scope.totalDueCollection.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(dueAmount)) * 100) / 100; }
});
};
/**
* Sum of loan dues and Savings dues group by group and product
*/
scope.sumGroupDueCollection = function () {
scope.savingsGroupsTotal = [];
scope.loanGroupsTotal = [];
_.each(scope.savingsgroups, function (group) {
_.each(group.clients, function (client) {
_.each(client.savings, function (saving) {
scope.sumGroupSavingsDueCollection(group, saving);
});
_.each(client.loans, function (loan) {
scope.sumGroupLoansDueCollection(group, loan);
});
});
}
);
};
/**
* Sum of savings dues group by group id and savings product id
* @param group
* @param saving
*/
scope.sumGroupSavingsDueCollection = function (group, saving) {
var existing = _.findWhere(scope.savingsGroupsTotal, {groupId: \
group.groupId, productId: saving.productId}); var dueAmount = saving.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
groupId: group.groupId,
productId: saving.productId,
dueAmount: dueAmount,
currencyCode: saving.currency.code,
currencySymbol: saving.currency.displaySymbol
};
scope.savingsGroupsTotal.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(dueAmount)) * 100) / 100; }
};
/**
* Sum of loans dues group by group id and loan product id
* @param group
* @param loan
*/
scope.sumGroupLoansDueCollection = function (group, loan) {
var existing = _.findWhere(scope.loanGroupsTotal, {groupId: \
group.groupId, productId: loan.productId}); //alert(_.isObject(existing));
var totalDue = scope.getLoanTotalDueAmount(loan);
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
groupId: group.groupId,
productId: loan.productId,
dueAmount: totalDue,
//chargesDue: loan['chargesDue'],
currencyCode: loan.currency.code,
currencySymbol: loan.currency.displaySymbol
};
scope.loanGroupsTotal.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(totalDue)) * 100) / 100; }
};
scope.getLoanTotalDueAmount = function(loan){
var principalInterestDue = loan.totalDue;
var chargesDue = loan.chargesDue;
if (isNaN(principalInterestDue)) {
principalInterestDue = parseInt(0);
}
if (isNaN(chargesDue)) {
chargesDue = parseInt(0);
}
return Math.ceil((Number(principalInterestDue) + Number(chargesDue)) \
* 100) / 100; };
/**
* Sum of savings dues across all groups group by savings product id
*/
scope.sumSavingsDueCollection = function () {
scope.savingsTotal = [];
_.each(scope.savingsGroupsTotal, function (group) {
var dueAmount = group.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
var existing = _.findWhere(scope.savingsTotal, {productId: \
group.productId});
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
productId: group.productId,
currencyCode: group.currencyCode,
currencySymbol: group.currencySymbol,
dueAmount: dueAmount
};
scope.savingsTotal.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(dueAmount)) * 100) / 100; }
});
};
/**
* Sum of loans dues across all groups group by loan product id
*/
scope.sumLoansTotal = function () {
scope.loansTotal = [];
_.each(scope.loanGroupsTotal, function (group) {
var dueAmount = group.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
var existing = _.findWhere(scope.loansTotal, {productId: \
group.productId});
if (existing === 'undefined' || !(_.isObject(existing))) {
var gp = {
productId: group.productId,
currencyCode: group.currencyCode,
currencySymbol: group.currencySymbol,
dueAmount: dueAmount
};
scope.loansTotal.push(gp);
} else {
existing.dueAmount = Math.ceil((Number(existing.dueAmount) + \
Number(dueAmount)) * 100) / 100; }
});
};
scope.clientsAttendanceArray = function (groups) {
var gl = groups.length;
for (var i = 0; i < gl; i++) {
scope.clients = groups[i].clients;
var cl = scope.clients.length;
for (var j = 0; j < cl; j++) {
scope.client = scope.clients[j];
if (scope.client.attendanceType && \
scope.client.attendanceType.id === 0) { scope.client.attendanceType.id = 1;
}
}
}
};
scope.constructBulkLoanAndSavingsRepaymentTransactions = function(){
scope.bulkRepaymentTransactions = [];
scope.bulkSavingsDueTransactions = [];
_.each(scope.savingsgroups, function (group) {
_.each(group.clients, function (client) {
_.each(client.savings, function (saving) {
var dueAmount = saving.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
var savingsTransaction = {
savingsId:saving.savingsId,
transactionAmount:dueAmount,
depositAccountType: \
saving.depositAccountType=='Saving \
Deposit'?100:(saving.depositAccountType=='Recurring Deposit'?300:400) };
if(savingsTransaction.transactionAmount>0){
\
scope.bulkSavingsDueTransactions.push(savingsTransaction); }
});
_.each(client.loans, function (loan) {
var totalDue = scope.getLoanTotalDueAmount(loan);
var loanTransaction = {
loanId:loan.loanId,
transactionAmount:totalDue
};
\
scope.bulkRepaymentTransactions.push(loanTransaction); });
});
}
);
};
scope.submit = function () {
scope.formData.calendarId = scope.calendarId;
scope.formData.dateFormat = scope.df;
scope.formData.locale = scope.optlang.code;
if (scope.date.transactionDate) {
scope.formData.transactionDate = \
dateFilter(scope.date.transactionDate, scope.df); }
scope.formData.actualDisbursementDate = \
this.formData.transactionDate;
_.each(scope.savingsgroups, function (group) {
_.each(group.clients, function (client) {
var clientAttendanceDetails = {
clientId: client.clientId,
attendanceType: client.attendanceType != \
undefined?client.attendanceType.id:null };
scope.clientsAttendance.push(clientAttendanceDetails);
});
});
scope.formData.clientsAttendance = scope.clientsAttendance;
if(scope.showPaymentDetails && scope.paymentDetail.paymentTypeId != \
""){
scope.formData.paymentTypeId = scope.paymentDetail.paymentTypeId;
scope.formData.accountNumber = scope.paymentDetail.accountNumber;
scope.formData.checkNumber = scope.paymentDetail.checkNumber;
scope.formData.routingCode =scope.paymentDetail.routingCode;
scope.formData.receiptNumber = scope.paymentDetail.receiptNumber;
scope.formData.bankNumber = scope.paymentDetail.bankNumber;
}
scope.formData.bulkDisbursementTransactions = [];
//construct loan repayment and savings due transactions
scope.constructBulkLoanAndSavingsRepaymentTransactions();
scope.formData.bulkRepaymentTransactions = \
scope.bulkRepaymentTransactions;
scope.formData.bulkSavingsDueTransactions = \
scope.bulkSavingsDueTransactions; if (centerOrGroupResource === "centerResource") {
resourceFactory.centerResource.save({'centerId': scope.centerId, \
command: 'saveCollectionSheet'}, scope.formData, function (data) {
localStorageService.addToLocalStorage('Success', true);
route.reload();
});
} else if (centerOrGroupResource === "groupResource") {
resourceFactory.groupResource.save({'groupId': scope.groupId, \
command: 'saveCollectionSheet'}, scope.formData, function (data) {
localStorageService.addToLocalStorage('Success', true);
route.reload();
});
}
};
}
})
;
mifosX.ng.application.controller('CollectionSheetController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
'localStorageService',
'$route', '$timeout', \
mifosX.controllers.CollectionSheetController]).run(function ($log) { \
$log.info("CollectionSheetController initialized"); });
}
(mifosX.controllers || {})
)
;
;'use strict';
/*global _ */
/*global mifosX */
(function (module) {
mifosX.controllers = _.extend(module, {
IndividualCollectionSheetController: function (scope, resourceFactory, \
location, routeParams, dateFilter, localStorageService, route, $timeout) { \
scope.offices = []; scope.centers = [];
scope.groups = [];
scope.clientsAttendance = [];
scope.calendarId = '';
scope.formData = {};
scope.centerId = '';
scope.groupId = '';
scope.date = {};
scope.newGroupTotal = {};
scope.savingsGroupsTotal = [];
scope.date.transactionDate = new Date();
var centerOrGroupResource = '';
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices = data;
});
scope.officeSelected = function (officeId) {
scope.officeId = officeId;
if (officeId) {
resourceFactory.employeeResource.getAllEmployees({officeId: \
officeId}, function (data) { scope.loanOfficers = data;
});
}
};
scope.showLoanPaymentDetails = function (parentindex, index) {
var client = scope.collectionsheetdata.clients[parentindex];
var loandetail = client.loans[index];
loandetail.showPaymentDetails = true;
loandetail.paymentTypeId = "";
loandetail.accountNumber = "";
loandetail.checkNumber = "";
loandetail.routingCode = "";
loandetail.receiptNumber = "";
loandetail.bankNumber = "";
};
scope.showSavingsPaymentDetails = function (parentindex, index) {
var client = scope.collectionsheetdata.clients[parentindex];
var savings = client.savings[index];
savings.showPaymentDetails = true;
savings.paymentTypeId = "";
savings.accountNumber = "";
savings.checkNumber = "";
savings.routingCode = "";
savings.receiptNumber = "";
savings.bankNumber = "";
};
scope.previewCollectionSheet = function () {
scope.formData = {};
scope.formData.dateFormat = scope.df;
scope.formData.locale = scope.optlang.code;
if (scope.date.transactionDate) {
scope.formData.transactionDate = \
dateFilter(scope.date.transactionDate, scope.df); }
scope.formData.staffId = scope.loanOfficerId;
scope.formData.officeId = scope.officeId;
resourceFactory.collectionSheetResource.save({command: \
'generateCollectionSheet'}, scope.formData, function (data) { if \
(data.clients.length > 0) { scope.collectionsheetdata = data;
scope.clients = data.clients;
} else {
scope.noData = true;
$timeout(function () {
scope.noData = false;
}, 3000);
}
});
};
if (localStorageService.getFromLocalStorage('Success') === 'true') {
scope.savesuccess = true;
localStorageService.removeFromLocalStorage('Success');
scope.val = true;
$timeout(function () {
scope.val = false;
}, 3000);
}
scope.getLoanTotalDueAmount = function (loan) {
var principalInterestDue = loan.totalDue;
var chargesDue = loan.chargesDue;
if (isNaN(principalInterestDue)) {
principalInterestDue = parseInt(0);
}
if (isNaN(chargesDue)) {
chargesDue = parseInt(0);
}
return Math.ceil((Number(principalInterestDue) + Number(chargesDue)) \
* 100) / 100; };
scope.constructBulkLoanAndSavingsRepaymentTransactions = function () {
scope.bulkRepaymentTransactions = [];
scope.bulkSavingsDueTransactions = [];
_.each(scope.clients, function (client) {
_.each(client.savings, function (saving) {
var dueAmount = saving.dueAmount;
if (isNaN(dueAmount)) {
dueAmount = parseInt(0);
}
var savingsTransaction = {
savingsId: saving.savingsId,
transactionAmount: dueAmount,
depositAccountType: \
saving.depositAccountType=='Saving \
Deposit'?100:(saving.depositAccountType=='Recurring Deposit'?300:400) };
if(saving.showPaymentDetails && saving.paymentTypeId != \
""){
savingsTransaction.paymentTypeId = \
saving.paymentTypeId;
savingsTransaction.accountNumber = \
saving.accountNumber;
savingsTransaction.checkNumber = saving.checkNumber;
savingsTransaction.routingCode =saving.routingCode;
savingsTransaction.receiptNumber = \
saving.receiptNumber;
savingsTransaction.bankNumber = saving.bankNumber;
}
if(savingsTransaction.transactionAmount>0){
\
scope.bulkSavingsDueTransactions.push(savingsTransaction); }
});
_.each(client.loans, function (loan) {
var totalDue = scope.getLoanTotalDueAmount(loan);
var loanTransaction = {
loanId: loan.loanId,
transactionAmount: totalDue
};
if(loan.showPaymentDetails && loan.paymentTypeId != ""){
loanTransaction.paymentTypeId = loan.paymentTypeId;
loanTransaction.accountNumber = loan.accountNumber;
loanTransaction.checkNumber = loan.checkNumber;
loanTransaction.routingCode =loan.routingCode;
loanTransaction.receiptNumber = loan.receiptNumber;
loanTransaction.bankNumber = loan.bankNumber;
}
scope.bulkRepaymentTransactions.push(loanTransaction);
});
}
);
};
scope.submit = function () {
var data = {};
data.dateFormat = scope.df;
data.locale = scope.optlang.code;
if (scope.date.transactionDate) {
data.transactionDate = dateFilter(scope.date.transactionDate, \
scope.df); }
data.actualDisbursementDate = this.formData.transactionDate;
data.bulkDisbursementTransactions = [];
//construct loan repayment and savings due transactions
scope.constructBulkLoanAndSavingsRepaymentTransactions();
data.bulkRepaymentTransactions = scope.bulkRepaymentTransactions;
data.bulkSavingsDueTransactions = scope.bulkSavingsDueTransactions;
resourceFactory.collectionSheetResource.save({command: \
'saveCollectionSheet'}, data, function (data) {
localStorageService.addToLocalStorage('Success', true);
route.reload();
});
};
}
})
;
mifosX.ng.application.controller('IndividualCollectionSheetController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
'localStorageService',
'$route', '$timeout', \
mifosX.controllers.IndividualCollectionSheetController]).run(function ($log) { \
$log.info("IndividualCollectionSheetController initialized"); });
}
(mifosX.controllers || {})
)
;
;(function (module) {
mifosX.controllers = _.extend(module, {
ProductiveCollectionSheetController: function (scope, routeParams, \
resourceFactory, dateFilter, location) { var params = {};
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
params.meetingDate = routeParams.meetingDate;
params.officeId = routeParams.officeId;
params.staffId = routeParams.staffId;
if (params.staffId === "undefined") {
params.staffId = null;
}
var centerIdArray = [];
scope.submitNextShow = true;
scope.submitShow = false;
scope.completedCenter = false;
scope.officeName = routeParams.officeName;
scope.meetingDate = routeParams.meetingDate;
var submittedStaffId = [];
scope.details = false;
scope.noData = true;
resourceFactory.centerResource.getAllMeetingFallCenters(params, function \
(data) { if (data[0]) {
scope.staffCenterData = data[0].meetingFallCenters;
for (var i = 0; i < scope.staffCenterData.length; i++) {
centerIdArray.push({id: scope.staffCenterData[i].id, \
calendarId: scope.staffCenterData[i].collectionMeetingCalendar.id}); }
scope.getAllGroupsByCenter(data[0].meetingFallCenters[0].id, \
data[0].meetingFallCenters[0].collectionMeetingCalendar.id); }
});
scope.detailsShow = function() {
if (scope.details) {
scope.details = false;
} else {
scope.details = true;
}
}
scope.getAllGroupsByCenter = function (centerId, calendarId) {
scope.submitNextShow = true;
scope.submitShow = false;
if (centerIdArray.length-1 === submittedStaffId.length || \
centerIdArray.length === 1) { scope.submitNextShow = false;
scope.submitShow = true;
}
scope.selectedTab = centerId;
scope.centerId = centerId;
scope.calendarId = calendarId;
scope.formData = {};
scope.formData.dateFormat = scope.df;
scope.formData.locale = scope.optlang.code;
scope.formData.calendarId = scope.calendarId;
scope.formData.transactionDate = routeParams.meetingDate;
for (var i = 0; i < submittedStaffId.length; i++) {
if (centerId == submittedStaffId[i].id) {
scope.submitNextShow = false;
scope.submitShow = false;
break;
}
}
resourceFactory.centerResource.save({'centerId': scope.centerId, \
command: 'generateCollectionSheet'}, scope.formData, function (data) { \
scope.collectionsheetdata = data; if(data.groups.length > 0){
scope.noData = false;
}
scope.clientsAttendanceArray(data.groups);
scope.total(data);
});
};
scope.bulkRepaymentTransactionAmountChange = function () {
scope.collectionData = scope.collectionsheetdata;
scope.total(scope.collectionData);
};
scope.clientsAttendanceArray = function (groups) {
var gl = groups.length;
for (var i = 0; i < gl; i++) {
scope.clients = groups[i].clients;
var cl = scope.clients.length;
for (var j = 0; j < cl; j++) {
scope.client = scope.clients[j];
if (scope.client.attendanceType.id === 0) {
scope.client.attendanceType.id = 1;
}
}
}
};
function deepCopy(obj) {
if (Object.prototype.toString.call(obj) === '[object Array]') {
var out = [], i = 0, len = obj.length;
for (; i < len; i++) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
if (typeof obj === 'object') {
var out = {}, i;
for (i in obj) {
out[i] = arguments.callee(obj[i]);
}
return out;
}
return obj;
}
scope.total = function (data) {
scope.bulkRepaymentTransactions = [];
scope.bulkDisbursementTransactions = [];
scope.groupTotal = [];
scope.loanProductArray = [];
scope.loanDueTotalCollections = [];
for (var i = 0; i < data.loanProducts.length; i++) {
loanProductTemp = {
productId: data.loanProducts[i].id,
transactionAmount: 0,
disbursementAmount: 0
}
scope.loanProductArray.push(loanProductTemp);
}
scope.groupArray = scope.collectionsheetdata.groups;
var gl = scope.groupArray.length;
for (var i = 0; i < gl; i++) {
var loanProductArrayDup = deepCopy(scope.loanProductArray);
var temp = {};
temp.groupId = scope.groupArray[i].groupId;
scope.clientArray = scope.groupArray[i].clients;
var cl = scope.clientArray.length;
for (var j = 0; j < cl; j++) {
scope.loanArray = scope.clientArray[j].loans;
var ll = scope.loanArray.length;
for (var k = 0; k < ll; k++) {
scope.loan = scope.loanArray[k];
if (scope.loan.totalDue > 0) {
scope.bulkRepaymentTransactions.push({
loanId: scope.loan.loanId,
transactionAmount: scope.loan.totalDue
});
}
for (var l = 0; l < loanProductArrayDup.length; l++) {
if (loanProductArrayDup[l].productId == \
scope.loan.productId) { if (scope.loan.chargesDue) {
loanProductArrayDup[l].transactionAmount = \
Number(loanProductArrayDup[l].transactionAmount + Number(scope.loan.totalDue) + \
Number(scope.loan.chargesDue));
loanProductArrayDup[l].transactionAmount = \
Math.ceil(loanProductArrayDup[l].transactionAmount * 100) / 100; } else {
loanProductArrayDup[l].transactionAmount = \
Number(loanProductArrayDup[l].transactionAmount + Number(scope.loan.totalDue)); }
}
}
}
}
temp.loanProductArrayDup = loanProductArrayDup;
scope.groupTotal.push(temp);
}
var loanProductArrayTotal = deepCopy(scope.loanProductArray);
for (var i = 0; i < scope.groupTotal.length; i++) {
var groupProductTotal = scope.groupTotal[i];
for (var j = 0; j < groupProductTotal.loanProductArrayDup.length; \
j++) {
var productObjectTotal = \
groupProductTotal.loanProductArrayDup[j];
for (var k = 0; k < loanProductArrayTotal.length; k++) {
var productArrayTotal = loanProductArrayTotal[k];
if (productObjectTotal.productId == \
productArrayTotal.productId) {
productArrayTotal.transactionAmount = \
productArrayTotal.transactionAmount + \
productObjectTotal.transactionAmount;
productArrayTotal.disbursementAmount = \
productArrayTotal.disbursementAmount + productObjectTotal.disbursementAmount; }
}
}
}
scope.grandTotal = loanProductArrayTotal;
}
scope.viewFullScreen = function () {
var element = document.getElementById("productive_sheet");
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
};
scope.submit = function () {
scope.formData.calendarId = scope.calendarId;
scope.formData.dateFormat = scope.df;
scope.formData.locale = scope.optlang.code;
scope.formData.transactionDate = dateFilter(routeParams.meetingDate, \
scope.df);
scope.formData.clientsAttendance = scope.clientsAttendance;
scope.formData.bulkDisbursementTransactions = [];
scope.formData.bulkRepaymentTransactions = \
scope.bulkRepaymentTransactions;
resourceFactory.centerResource.save({'centerId': scope.centerId, \
command: 'saveCollectionSheet'}, scope.formData, function (data) { for (var i = 0; i \
< centerIdArray.length; i++) {
if (scope.centerId === centerIdArray[i].id && \
centerIdArray.length >= 1) { scope.staffCenterData[i].submitted = true;
submittedStaffId.push({id: scope.staffCenterData[i].id});
}
}
if (centerIdArray.length === submittedStaffId.length) {
location.path('/entercollectionsheet');
}
if (centerIdArray.length-1 === submittedStaffId.length) {
scope.submitNextShow = false;
scope.submitShow = true;
}
for (var i = 0; i < centerIdArray.length; i++) {
if (!scope.staffCenterData[i].submitted) {
\
scope.getAllGroupsByCenter(deepCopy(scope.staffCenterData[i].id), \
deepCopy(scope.staffCenterData[i].collectionMeetingCalendar.id)); break;
}
}
});
};
}
});
mifosX.ng.application.controller('ProductiveCollectionSheetController', \
['$scope', '$routeParams', 'ResourceFactory', 'dateFilter', '$location', \
mifosX.controllers.ProductiveCollectionSheetController]).run(function ($log) { \
$log.info("ProductiveCollectionSheetController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddressFormController: function ($scope, resourceFactory, routeParams, \
location) {
$scope.formData={};
$scope.addressTypes=[];
$scope.countryOptions=[];
$scope.stateOptions=[];
$scope.addressTypeId={};
entityname="ADDRESS";
$scope.editable=false;
clientId=routeParams.id;
resourceFactory.clientaddressFields.get(function(data){
$scope.addressTypes=data.addressTypeIdOptions;
$scope.countryOptions=data.countryIdOptions;
$scope.stateOptions=data.stateProvinceIdOptions;
}
)
resourceFactory.addressFieldConfiguration.get({entity:entityname},function(data){
for(var i=0;i<data.length;i++)
{
data[i].field='$scope.'+data[i].field;
eval(data[i].field+"="+data[i].is_enabled);
}
})
$scope.routeTo=function()
{
location.path('/viewclient/'+clientId);
}
$scope.isEditRequired=function(addType)
{
resourceFactory.clientAddress.get({type:addType,clientId:routeParams.id,status:true},function(data)
{
if(data[0]) // index is added just to sense whether it is \
empty or contains data {
$scope.editable=true;
}
else
{
$scope.editable=false;
}
})
}
$scope.updateaddress=function()
{
$scope.formData.locale="en";
resourceFactory.clientAddress.put({'clientId': \
routeParams.id,'type':$scope.addressTypeId},$scope.formData,function (data) {
location.path('/viewclient/'+routeParams.id);
});
}
$scope.submit = function () {
resourceFactory.clientAddress.save({'clientId': \
routeParams.id,'type':$scope.addressTypeId},$scope.formData,function (data) {
location.path('/viewclient/'+clientId);
});
};
}
});
mifosX.ng.application.controller('AddressFormController', \
['$scope','ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.AddressFormController]).run(function ($log) { \
$log.info("AddressFormController initialized"); });
}
(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
EditAddressController: function ($scope, resourceFactory, routeParams, \
location) {
$scope.formData={};
$scope.addressTypes=[];
$scope.countryOptions=[];
$scope.stateOptions=[];
$scope.addressTypeId={};
$scope.clients={};
$scope.addressType={};
entityname="ADDRESS";
$scope.addStatus="";
$scope.editable=false;
clientId=routeParams.clientId;
addresstypid=routeParams.addrType;
isActive={};
var addressId=routeParams.addrId;
resourceFactory.clientaddressFields.get(function(data){
$scope.addressTypes=data.addressTypeIdOptions;
$scope.countryOptions=data.countryIdOptions;
$scope.stateOptions=data.stateProvinceIdOptions;
}
)
resourceFactory.addressFieldConfiguration.get({entity:entityname},function(data){
for(var i=0;i<data.length;i++)
{
data[i].field='$scope.'+data[i].field;
eval(data[i].field+"="+data[i].is_enabled);
}
})
$scope.routeTo=function()
{
location.path('/viewclient/'+clientId);
}
resourceFactory.clientAddress.get({type:addresstypid,clientId:clientId},function(data)
{
$scope.editable=true;
for(var i=0;i<data.length;i++)
{
if(data[i].addressId==addressId)
{
if(data[i].street&&$scope.street)
{
$scope.formData.street=data[i].street;
}
if(data[i].addressLine1&&$scope.addressLine1)
{
$scope.formData.addressLine1=data[i].addressLine1;
}
if(data[i].addressLine2&&$scope.addressLine2)
{
$scope.formData.addressLine2=data[i].addressLine2;
}
if(data[i].addressLine3&&$scope.addressLine3)
{
$scope.formData.addressLine3=data[i].addressLine3;
}
if(data[i].townVillage&&$scope.townVillage)
{
$scope.formData.townVillage=data[i].townVillage;
}
if(data[i].city&&$scope.city)
{
$scope.formData.city=data[i].city;
}
if(data[i].countyDistrict&&$scope.countyDistrict)
{
\
$scope.formData.countyDistrict=data[i].countyDistrict; }
if(data[i].stateProvinceId&&$scope.stateProvinceId)
{
\
$scope.formData.stateProvinceId=data[i].stateProvinceId; }
if(data[i].countryId&&$scope.countryId)
{
$scope.formData.countryId=data[i].countryId;
}
if(data[i].postalCode&&$scope.postalCode)
{
$scope.formData.postalCode=data[i].postalCode;
}
if(data[i].latitude&&$scope.latitue)
{
$scope.formData.latitude=data[i].latitude;
}
if(data[i].longitude&&$scope.longitude)
{
$scope.formData.longitude=data[i].longitude;
}
if(data[i].isActive&&$scope.isActive)
{
isActive=data[i].isActive;
}
}
}
});
$scope.updateaddress=function()
{
$scope.formData.locale="en";
$scope.formData.addressId=addressId;
resourceFactory.clientAddress.put({'clientId': \
clientId},$scope.formData,function (data) {
location.path('/viewclient/'+clientId);
});
}
}
});
mifosX.ng.application.controller('EditAddressController', \
['$scope','ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.EditAddressController]).run(function ($log) { \
$log.info("EditAddressController initialized"); });
}
(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
EditConfigurationController: function (scope, resourceFactory, routeParams, \
location) {
scope.configId = routeParams.configId;
resourceFactory.configurationResource.get({id: scope.configId}, function \
(data) { scope.formData = {value: data.value};
});
scope.cancel = function () {
location.path('/global');
};
scope.submit = function () {
resourceFactory.configurationResource.update({resourceType: \
'configurations', id: scope.configId}, this.formData, function (data) { \
location.path('/global'); });
};
}
});
mifosX.ng.application.controller('EditConfigurationController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.EditConfigurationController]).run(function ($log) { \
$log.info("EditConfigurationController initialized"); });
}(mifosX.controllers || {}));
;/**
* Created by 27 on 04-08-2015.
*/
(function (module) {
mifosX.controllers = _.extend(module, {
EditExternalServicesConfigurationController: function ($scope, \
resourceFactory, $routeParams, location) { $scope.formData = [];
$scope.names = [];
$scope.externalServicesType = $routeParams.externalServicesType;
//$scope.name = $routeParams.name;
var nvObject = {};
resourceFactory.externalServicesResource.get({id: \
$scope.externalServicesType}, function (data) { for (var i in data) {
if(data[i] != null && data[i].name != null) {
data[i].name.replace(/ /g, '');
if (!angular.equals(data[i].name, "")) {
nvObject[data[i].name] = data[i].value;
$scope.names.push(data[i].name);
}
}
}
$scope.formData = nvObject;
});
$scope.cancel = function () {
location.path('/externalservices/'+ $scope.externalServicesType);
};
$scope.submit = function () {
//scope.formData1 = { scope.name : scope.formData.value};
resourceFactory.externalServicesResource.put({id: \
$scope.externalServicesType}, this.formData, function (data) { \
location.path('/externalservices' ); });
};
}
});
mifosX.ng.application.controller('EditExternalServicesConfigurationController', \
['$scope', 'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.EditExternalServicesConfigurationController]).run(function ($log) \
{
$log.info("EditExternalServicesConfigurationController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditTwoFactorConfigController: function (scope, resourceFactory, \
$routeParams, location) { var configs = [];
configs['sms'] = ['otp-delivery-sms-enable', 'otp-delivery-sms-provider', \
'otp-delivery-sms-text'];
configs['email'] = ['otp-delivery-email-enable', \
'otp-delivery-email-subject', 'otp-delivery-email-body'];
configs['token'] = ['otp-token-length', \
'access-token-live-time-extended', 'otp-token-live-time', 'access-token-live-time'];
var boolConfigs = ['otp-delivery-sms-enable', \
'otp-delivery-email-enable'];
var multiLineConfigs = ['otp-delivery-sms-text', \
'otp-delivery-email-body'];
scope.configs = [];
scope.configType = $routeParams.configType;
scope.disabledTwoFactor = false;
resourceFactory.twoFactorConfigResource.getAllConfigs(function (data) {
for (var i in data.toJSON()) {
if(configs[scope.configType].indexOf(i) > -1) {
scope.configs.push({
name: i,
value: data[i].toString(),
type: getConfigType(i)
});
}
}
}, function () {
scope.disabledTwoFactor = true;
});
scope.cancel = function () {
location.path('/twofactorconfig');
};
scope.submit = function () {
var formData = {};
for(var i = 0; i < scope.configs.length; i++) {
var config = scope.configs[i];
formData[config.name] = config.value;
}
resourceFactory.twoFactorConfigResource.put(formData, function (data) \
{ location.path('/twofactorconfig');
});
};
var getConfigType = function (name) {
if(boolConfigs.indexOf(name) > -1)
return 'BOOLEAN';
if(multiLineConfigs.indexOf(name) > -1) {
return 'MULTILINE';
}
return 'TEXT';
};
}
});
mifosX.ng.application.controller('EditTwoFactorConfigController', ['$scope', \
'ResourceFactory', '$routeParams', '$location',
mifosX.controllers.EditTwoFactorConfigController]).run(function ($log) {
$log.info("EditTwoFactorConfigController initialized");
});
}(mifosX.controllers || {}));
;/**
* Created by 27 on 03-08-2015.
*/
(function (module) {
mifosX.controllers = _.extend(module, {
ExternalServicesController: function (scope, resourceFactory, location, \
route) { scope.S3Configs = [];
scope.SMTPConfigs = [];
scope.notification = [];
resourceFactory.externalServicesS3Resource.get(function (data) {
for (var i in data) {
if(data[i] != null && data[i].name != null) {
data[i].name.replace(/ /g, '');
if (!angular.equals(data[i].name, "")) {
data[i].showEditvalue = true;
scope.S3Configs.push(data[i])
}
}
}
});
resourceFactory.externalServicesSMTPResource.get(function (data) {
for (var i in data) {
//console.log(data[0]);
if(data[i].name != "") {
data[i].showEditvalue = true;
scope.SMTPConfigs.push(data[i])
}
}
});
resourceFactory.externalServicesNotificationResource.get(function (data) \
{ for (var i in data) {
if(data[i] != null && data[i].name != null) {
data[i].name.replace(/ /g, '');
if (!angular.equals(data[i].name, "")) {
data[i].showEditvalue = true;
scope.notification.push(data[i])
}
}
}
});
}
});
mifosX.ng.application.controller('ExternalServicesController', ['$scope', \
'ResourceFactory', '$location', '$route',
mifosX.controllers.ExternalServicesController]).run(function ($log){
$log.info("ExternalServicesController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
GlobalConfigurationController: function (scope, resourceFactory, location, \
route) { scope.configs = [];
scope.GlobalsPerPage = 15;
resourceFactory.configurationResource.get(function (data) {
for (var i in data.globalConfiguration) {
data.globalConfiguration[i].showEditvalue = true;
scope.configs.push(data.globalConfiguration[i])
}
resourceFactory.cacheResource.get(function (data) {
for (var i in data) {
if (data[i].cacheType && data[i].cacheType.id == 2) {
var cache = {};
cache.name = 'Is Cache Enabled';
cache.enabled = data[i].enabled;
cache.showEditvalue = false;
scope.configs.push(cache);
}
}
});
});
if (!scope.searchCriteria.config) {
scope.searchCriteria.config = null;
scope.saveSC();
}
scope.filterText = scope.searchCriteria.config || '';
scope.onFilter = function () {
scope.searchCriteria.config = scope.filterText;
scope.saveSC();
};
scope.enable = function (id, name) {
if (name == 'Is Cache Enabled') {
var temp = {};
temp.cacheType = 2;
resourceFactory.cacheResource.update(temp, function (data) {
route.reload();
});
}
else {
var temp = {'enabled': 'true'};
resourceFactory.configurationResource.update({'id': id}, temp, \
function (data) { route.reload();
});
}
};
scope.disable = function (id, name) {
if (name == 'Is Cache Enabled') {
var temp = {};
temp.cacheType = 1;
resourceFactory.cacheResource.update(temp, function (data) {
route.reload();
});
}
else {
var temp = {'enabled': 'false'};
resourceFactory.configurationResource.update({'id': id}, temp, \
function (data) { route.reload();
});
}
};
}
});
mifosX.ng.application.controller('GlobalConfigurationController', ['$scope', \
'ResourceFactory', '$location', '$route', \
mifosX.controllers.GlobalConfigurationController]).run(function ($log) { \
$log.info("GlobalConfigurationController initialized"); });
}(mifosX.controllers || {}));;/**
* Created by 27 on 05-08-2015.
*/
(function (module) {
mifosX.controllers = _.extend(module, {
ViewExternalServicesController: function ($scope, resourceFactory, \
$routeParams, location) { $scope.Configs = [];
$scope.externalServicesType = $routeParams.externalServicesType;
//$scope.name = $routeParams.name;
resourceFactory.externalServicesResource.get({id: \
$scope.externalServicesType}, function (data) { for (var i in data) {
if(data[i] != null && data[i].name != null) {
data[i].name.replace(/ /g, '');
if (!angular.equals(data[i].name, "")) {
$scope.Configs.push(data[i]);
}
}
}
});
$scope.cancel = function () {
location.path('/externalservices');
};
}
});
mifosX.ng.application.controller('ViewExternalServicesController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.ViewExternalServicesController]).run(function ($log) { \
$log.info("ViewExternalServicesController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewTwoFactorConfigController: function (scope, resourceFactory) {
var smsConfigs = ['otp-delivery-sms-enable', 'otp-delivery-sms-provider', \
'otp-delivery-sms-text'];
var emailConfigs = ['otp-delivery-email-enable', \
'otp-delivery-email-subject', 'otp-delivery-email-body'];
var tokenConfigs = ['otp-token-length', \
'access-token-live-time-extended', 'otp-token-live-time', 'access-token-live-time']; \
scope.configurations = []; scope.smsConfig = [];
scope.emailConfig = [];
scope.tokenConfig = [];
scope.tabs = {};
scope.disabledTwoFactor = false;
resourceFactory.twoFactorConfigResource.getAllConfigs(function (data) {
for(var i = 0; i < smsConfigs.length; i++) {
scope.smsConfig.push({name: smsConfigs[i], value: \
data[smsConfigs[i]]}); }
for(i = 0; i < emailConfigs.length; i++) {
scope.emailConfig.push({name: emailConfigs[i], value: \
data[emailConfigs[i]]}); }
for(i = 0; i < tokenConfigs.length; i++) {
scope.tokenConfig.push({name: tokenConfigs[i], value: \
data[tokenConfigs[i]]}); }
scope.tabs['sms'] = scope.smsConfig;
scope.tabs['email'] = scope.emailConfig;
scope.tabs['token'] = scope.tokenConfig;
for (var i in data.toJSON()) {
scope.configurations.push({name: i, value: data[i]});
}
}, function () {
scope.disabledTwoFactor = true;
});
}
});
mifosX.ng.application.controller('ViewTwoFactorConfigController', ['$scope', \
'ResourceFactory',
mifosX.controllers.ViewTwoFactorConfigController]).run(function ($log) {
$log.info("ViewTwoFactorConfigController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddNewFixedDepositChargeController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.offices = [];
scope.cancelRoute = routeParams.id;
scope.date = {};
resourceFactory.savingsChargeResource.get({accountId: routeParams.id, \
resourceType: 'template'}, function (data) { scope.chargeOptions = \
data.chargeOptions; });
scope.chargeSelected = function (id) {
resourceFactory.chargeResource.get({chargeId: id, template: 'true'}, \
function (data) {
scope.chargeCalculationType = data.chargeCalculationType.id;
scope.chargeTimeType = data.chargeTimeType.id;
scope.chargeDetails = data;
scope.formData.amount = data.amount;
scope.withDrawCharge = data.chargeTimeType.value === "Withdrawal \
Fee" ? true : false; scope.formData.feeInterval = data.feeInterval;
if (data.chargeTimeType.value === "Annual Fee" || \
data.chargeTimeType.value === "Monthly Fee") { scope.chargeTimeTypeAnnualOrMonth = \
true; }
});
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
if (scope.withDrawCharge !== true) {
if (scope.chargeTimeTypeAnnualOrMonth === true) {
this.formData.monthDayFormat = "dd MMMM";
if (scope.date.due) {
this.formData.feeOnMonthDay = dateFilter(scope.date.due, \
'dd MMMM'); } else {
this.formData.feeOnMonthDay = "";
}
} else {
this.formData.dateFormat = scope.df;
if (scope.date.specificduedate) {
this.formData.dueDate = \
dateFilter(scope.date.specificduedate, scope.df); } else {
this.formData.dueDate = "";
}
}
}
resourceFactory.savingsChargeResource.save({accountId: \
routeParams.id}, this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('AddNewFixedDepositChargeController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.AddNewFixedDepositChargeController]).run(function ($log) { \
$log.info("AddNewFixedDepositChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportFixedDepositAccountsController: function (scope, resourceFactory, \
location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/fixeddepositaccounts/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"fixeddepositaccounts"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/fixeddepositaccounts/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportFixedDepositAccountsController', \
['$scope', 'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportFixedDepositAccountsController]).run(function ($log) { \
$log.info("BulkImportFixedDepositAccountsController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportFixedDepositTransactionsController: function (scope, \
resourceFactory, location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/fixeddepositaccounts/transaction/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices=data;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
scope.first.queryParams += 'officeId=' + \
scope.formData.officeId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"fixeddeposittransactions"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/fixeddepositaccounts/transaction/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportFixedDepositTransactionsController', \
['$scope', 'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportFixedDepositTransactionsController]).run(function ($log) \
{
$log.info("BulkImportFixedDepositTransactionsController initialized");
});
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CreateFixedDepositAccountController: function (scope, resourceFactory, \
location, routeParams, dateFilter,$uibModal) { scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
scope.restrictDate = new Date();
scope.clientId = routeParams.clientId;
scope.groupId = routeParams.groupId;
if (routeParams.centerEntity) {
scope.centerEntity = true;
}
//interest rate chart details
scope.chart = {};
scope.fromDate = {}; //required for date formatting
scope.endDate = {};//required for date formatting
scope.charges = [];
scope.inparams = {};
if (scope.clientId) {
scope.inparams.clientId = scope.clientId
}
;
if (scope.groupId) {
scope.inparams.groupId = scope.groupId
}
;
if (scope.centerId) {
scope.inparams.centerId = scope.centerId
}
;
resourceFactory.fixedDepositAccountTemplateResource.get(scope.inparams, \
function (data) { scope.products = data.productOptions;
scope.chargeOptions = data.chargeOptions;
scope.clientName = data.clientName;
scope.groupName = data.groupName;
scope.savingsAccounts = data.savingsAccounts;
});
scope.changeProduct = function () {
scope.inparams.productId = scope.formData.productId;
resourceFactory.fixedDepositAccountTemplateResource.get(scope.inparams, \
function (data) {
scope.data = data;
scope.charges = data.charges;
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value === "Annual Fee" && \
scope.charges[i].feeOnMonthDay) { scope.charges[i].feeOnMonthDay.push('2013');
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df)); }
}
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate;
scope.formData.minRequiredOpeningBalance = \
data.minRequiredOpeningBalance;
scope.formData.lockinPeriodFrequency = \
data.lockinPeriodFrequency; scope.formData.withHoldTax = data.withHoldTax;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = \
data.lockinPeriodFrequencyType.id;
if (data.withdrawalFeeType) scope.formData.withdrawalFeeType = \
data.withdrawalFeeType.id;
if (data.interestFreePeriodApplicable) \
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
if (data.preClosurePenalApplicable) \
scope.formData.preClosurePenalApplicable = data.preClosurePenalApplicable;
scope.chart = data.accountChart;
scope.chartSlabs = scope.chart.chartSlabs;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
var interestFreePeriodFrequencyTypeId = \
(_.isNull(data.interestFreePeriodFrequencyType) || \
_.isUndefined(data.interestFreePeriodFrequencyType)) ? '' : \
data.interestFreePeriodFrequencyType.id; var preClosurePenalInterestOnTypeId = \
(_.isNull(data.preClosurePenalInterestOnType) || \
_.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
scope.formData.interestFreeFromPeriod = \
data.interestFreeFromPeriod;
scope.formData.interestFreeToPeriod = data.interestFreeToPeriod;
scope.formData.interestFreePeriodFrequencyTypeId = \
interestFreePeriodFrequencyTypeId;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId; scope.formData.transferInterestToSavings = 'false';
});
};
scope.addCharge = function (chargeId) {
scope.errorchargeevent = false;
if (chargeId) {
resourceFactory.chargeResource.get({chargeId: chargeId, template: \
'true'}, function (data) { data.chargeId = data.id;
if (data.chargeTimeType.value == "Annual Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
} else if (data.chargeTimeType.value == "Monthly Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
}
scope.charges.push(data);
scope.chargeId = undefined;
});
} else {
scope.errorchargeevent = true;
scope.labelchargeerror = "selectcharge";
}
}
scope.deleteCharge = function (index) {
scope.charges.splice(index, 1);
}
scope.submit = function () {
if (scope.date) {
this.formData.submittedOnDate = \
dateFilter(scope.date.submittedOnDate, scope.df); }
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.monthDayFormat = "dd MMM";
this.formData.charges = [];
if (scope.clientId) this.formData.clientId = scope.clientId;
if (scope.groupId) this.formData.groupId = scope.groupId;
if (scope.centerId) this.formData.centerId = scope.centerId;
if (scope.charges.length > 0) {
for (var i in scope.charges) {
var chargeData = { chargeId: scope.charges[i].chargeId, \
amount: scope.charges[i].amount};
if(scope.charges[i].chargeTimeType.value == 'Annual Fee' || \
scope.charges[i].chargeTimeType.value == 'Monthly Fee'){
chargeData.feeOnMonthDay = \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM'); }
if (scope.charges[i].chargeTimeType.value == 'Specified due \
date' || \
scope.charges[i].chargeTimeType.code=='chargeTimeType.weeklyFee') {
chargeData.dueDate = dateFilter(scope.charges[i].dueDate, \
scope.df); }
if (scope.charges[i].chargeTimeType.value == 'Monthly Fee' || \
scope.charges[i].chargeTimeType.code=='chargeTimeType.weeklyFee') {
chargeData.feeInterval = scope.charges[i].feeInterval;
}
this.formData.charges.push(chargeData);
}
}
this.formData.charts = [];//declare charts array
this.formData.charts.push(copyChartData(scope.chart));//add chart \
details this.formData = removeEmptyValues(this.formData);
resourceFactory.fixedDepositAccountResource.save(this.formData, \
function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
};
scope.cancel = function () {
if (scope.clientId) {
location.path('/viewclient/' + scope.clientId);
} else if (scope.centerEntity) {
location.path('/viewcenter/' + scope.groupId);
} else {
location.path('/viewgroup/' + scope.groupId);
}
}
/**
* Add a new row with default values for entering chart details
*/
scope.addNewRow = function () {
var fromPeriod = '';
var amountRangeFrom = '';
var periodType = '';
if (_.isNull(scope.chart.chartSlabs) || \
_.isUndefined(scope.chart.chartSlabs)) { scope.chart.chartSlabs = [];
} else {
var lastChartSlab = {};
if (scope.chart.chartSlabs.length > 0) {
lastChartSlab = \
angular.copy(scope.chart.chartSlabs[scope.chart.chartSlabs.length - 1]); }
if (!(_.isNull(lastChartSlab) || _.isUndefined(lastChartSlab))) {
fromPeriod = _.isNull(lastChartSlab) ? '' : \
parseInt(lastChartSlab.toPeriod) + 1;
amountRangeFrom = _.isNull(lastChartSlab) ? '' : \
parseFloat(lastChartSlab.amountRangeTo) + 1;
periodType = angular.copy(lastChartSlab.periodType);
}
}
var chartSlab = {
"periodType": periodType,
"fromPeriod": fromPeriod,
"amountRangeFrom": amountRangeFrom
};
scope.chart.chartSlabs.push(chartSlab);
}
/**
* create new chart data object
*/
copyChartData = function () {
var newChartData = {
id: scope.chart.id,
name: scope.chart.name,
description: scope.chart.description,
fromDate: dateFilter(scope.fromDate.date, scope.df),
endDate: dateFilter(scope.endDate.date, scope.df),
isPrimaryGroupingByAmount:scope.chart.isPrimaryGroupingByAmount,
//savingsProductId: scope.productId,
dateFormat: scope.df,
locale: scope.optlang.code,
chartSlabs: angular.copy(copyChartSlabs(scope.chart.chartSlabs)),
isActiveChart: 'true'
}
//remove empty values
_.each(newChartData, function (v, k) {
if (!v)
delete newChartData[k];
});
return newChartData;
}
/**
* copy all chart details to a new Array
* @param chartSlabs
* @returns {Array}
*/
copyChartSlabs = function (chartSlabs) {
var detailsArray = [];
_.each(chartSlabs, function (chartSlab) {
var chartSlabData = copyChartSlab(chartSlab);
detailsArray.push(chartSlabData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param chartSlab
*
*/
copyChartSlab = function (chartSlab) {
var newChartSlabData = {
id: chartSlab.id,
description: chartSlab.description,
fromPeriod: chartSlab.fromPeriod,
toPeriod: chartSlab.toPeriod,
amountRangeFrom: chartSlab.amountRangeFrom,
amountRangeTo: chartSlab.amountRangeTo,
annualInterestRate: chartSlab.annualInterestRate,
locale: scope.optlang.code,
incentives:angular.copy(copyIncentives(chartSlab.incentives))
}
if(chartSlab.periodType != undefined) {
newChartSlabData.periodType = chartSlab.periodType.id;
}
//remove empty values
_.each(newChartSlabData, function (v, k) {
if (!v && v != 0)
delete newChartSlabData[k];
});
return newChartSlabData;
}
removeEmptyValues = function (objArray) {
_.each(objArray, function (v, k) {
//alert(k + ':' + v);
if (_.isNull(v) || _.isUndefined(v) || v === '') {
//alert('remove' + k + ':' + v);
delete objArray[k];
}
});
return objArray;
}
/**
* Remove chart details row
*/
scope.removeRow = function (index) {
scope.chart.chartSlabs.splice(index, 1);
}
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
data: function () {
return scope.chart;
},
chartSlab: function () {
return scope.chart.chartSlabs[index];
}
}
});
}
/**
* copy all chart details to a new Array
* @param incentiveDatas
* @returns {Array}
*/
copyIncentives = function (incentives) {
var detailsArray = [];
_.each(incentives, function (incentive) {
var incentiveData = copyIncentive(incentive);
detailsArray.push(incentiveData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param incentiveData
*
*/
copyIncentive = function (incentiveData) {
var newIncentiveDataData = {
id: incentiveData.id,
"entityType":incentiveData.entityType,
"attributeName":incentiveData.attributeName.id,
"conditionType":incentiveData.conditionType.id,
"attributeValue":incentiveData.attributeValue,
"incentiveType":incentiveData.incentiveType.id,
"amount":incentiveData.amount
}
return newIncentiveDataData;
}
var IncentiveCtrl = function ($scope, $uibModalInstance, data,chartSlab) \
{ $scope.data = data;
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.addNewRow = function () {
var incentive = {
"entityType":"2",
"attributeName":"",
"conditionType":"",
"attributeValue":"",
"incentiveType":"",
"amount":""
};
$scope.chartSlab.incentives.push(incentive);
}
/**
* Remove chart details row
*/
$scope.removeRow = function (index) {
$scope.chartSlab.incentives.splice(index, 1);
}
};
}
});
mifosX.ng.application.controller('CreateFixedDepositAccountController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter','$uibModal', \
mifosX.controllers.CreateFixedDepositAccountController]).run(function ($log) { \
$log.info("CreateFixedDepositAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditDepositAccountController: function (scope, resourceFactory, location, \
routeParams, dateFilter,$uibModal) { scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
scope.accountId = routeParams.id;
scope.charges = [];
scope.restrictDate = new Date();
//interest rate chart details
scope.chart = {};
scope.fromDate = {}; //required for date formatting
scope.endDate = {};//required for date formatting
resourceFactory.fixedDepositAccountResource.get({accountId: \
scope.accountId, template: 'true', associations: 'charges, linkedAccount'}, function \
(data) { scope.data = data;
scope.charges = data.charges || [];
if (scope.charges) {
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value == 'Annual Fee') {
scope.charges[i].feeOnMonthDay.push(2013);
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df));
} else if (scope.charges[i].chargeTimeType.value == "Monthly \
Fee") { scope.charges[i].feeOnMonthDay.push(2013);
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df));
} else if (scope.charges[i].chargeTimeType.value == \
'Specified due date') {
scope.charges[i].dueDate = new \
Date(dateFilter(scope.charges[i].dueDate, scope.df)); }
}
}
if (data.clientId) {
scope.formData.clientId = data.clientId;
scope.clientName = data.clientName;
}
if (data.groupId) {
scope.formData.groupId = data.groupId;
scope.groupName = data.groupName;
}
scope.formData.productId = data.depositProductId;
scope.products = data.productOptions;
scope.savingsAccounts = data.savingsAccounts;
if (data.linkedAccount) {
scope.formData.linkAccountId = data.linkedAccount.id;
}
if (data.fieldOfficerId != 0)scope.formData.fieldOfficerId = \
data.fieldOfficerId; if (data.timeline) {
var submittedOnDate = dateFilter(data.timeline.submittedOnDate, \
scope.df);
scope.formData.submittedOnDate = new Date(submittedOnDate);
}
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate; scope.formData.depositAmount = data.depositAmount;
scope.formData.depositPeriod = data.depositPeriod;
scope.formData.lockinPeriodFrequency = data.lockinPeriodFrequency;
scope.formData.withHoldTax = data.withHoldTax;
/* FIX-ME: uncomment annualFeeAmount when datepicker avialable, \
because it depends on the date field 'annualFeeOnMonthDay'*/ \
//scope.formData.annualFeeAmount = data.annualFeeAmount;
//scope.formData.withdrawalFeeAmount = data.withdrawalFeeAmount;
//scope.formData.withdrawalFeeForTransfers = \
data.withdrawalFeeForTransfers;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = \
data.lockinPeriodFrequencyType.id;
//if (data.withdrawalFeeType) scope.formData.withdrawalFeeType = \
data.withdrawalFeeType.id;
scope.chart = data.accountChart;
scope.chartSlabs = scope.chart.chartSlabs;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
var depositPeriodFrequencyId = (_.isNull(data.depositPeriodFrequency) \
|| _.isUndefined(data.depositPeriodFrequency)) ? '' : data.depositPeriodFrequency.id; \
var interestFreePeriodFrequencyTypeId = \
(_.isNull(data.interestFreePeriodFrequencyType) || \
_.isUndefined(data.interestFreePeriodFrequencyType)) ? '' : \
data.interestFreePeriodFrequencyType.id; var preClosurePenalInterestOnTypeId = \
(_.isNull(data.preClosurePenalInterestOnType) || \
_.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.depositPeriodFrequencyId = depositPeriodFrequencyId;
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
scope.formData.interestFreeFromPeriod = data.interestFreeFromPeriod;
scope.formData.interestFreeToPeriod = data.interestFreeToPeriod;
scope.formData.interestFreePeriodFrequencyTypeId = \
interestFreePeriodFrequencyTypeId;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId; if(data.transferInterestToSavings) {
scope.formData.transferInterestToSavings = 'true';
}else{
scope.formData.transferInterestToSavings = 'false';
}
});
scope.changeProduct = function () {
var inparams = {productId: scope.formData.productId};
if (scope.formData.clientId) inparams.clientId = \
scope.formData.clientId;
if (scope.formData.groupId) inparams.groupId = \
scope.formData.groupId;
resourceFactory.savingsTemplateResource.get(inparams, function (data) \
{
scope.data = data;
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate; scope.formData.depositAmount = data.depositAmount;
scope.formData.depositPeriod = data.depositPeriod;
scope.formData.lockinPeriodFrequency = \
data.lockinPeriodFrequency; scope.formData.withHoldTax = data.withHoldTax;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = \
data.lockinPeriodFrequencyType.id;
//if (data.withdrawalFeeType) scope.formData.withdrawalFeeType = \
data.withdrawalFeeType.id;
scope.chart = data.accountChart;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
var depositPeriodFrequencyId = \
(_.isNull(data.depositPeriodFrequency) || _.isUndefined(data.depositPeriodFrequency)) \
? '' : data.depositPeriodFrequency.id; var interestFreePeriodFrequencyTypeId = \
(_.isNull(data.interestFreePeriodFrequencyType) || \
_.isUndefined(data.interestFreePeriodFrequencyType)) ? '' : \
data.interestFreePeriodFrequencyType.id; var preClosurePenalInterestOnTypeId = \
(_.isNull(data.preClosurePenalInterestOnType) || \
_.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.depositPeriodFrequencyId = \
depositPeriodFrequencyId;
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
scope.formData.interestFreeFromPeriod = \
data.interestFreeFromPeriod;
scope.formData.interestFreeToPeriod = data.interestFreeToPeriod;
scope.formData.interestFreePeriodFrequencyTypeId = \
interestFreePeriodFrequencyTypeId;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId; scope.linkAccountId = data.linkAccountId;
});
}
scope.addCharge = function (chargeId) {
scope.errorchargeevent = false;
if (chargeId) {
resourceFactory.chargeResource.get({chargeId: chargeId, template: \
'true'}, function (data) { data.chargeId = data.id;
if (data.chargeTimeType.value == "Annual Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
} else if (data.chargeTimeType.value == "Monthly Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
}
delete data.id;
scope.charges.push(data);
scope.chargeId = undefined;
});
} else {
scope.errorchargeevent = true;
scope.labelchargeerror = "selectcharge";
}
}
scope.deleteCharge = function (index) {
scope.charges.splice(index, 1);
}
scope.cancel = function () {
location.path('/viewsavingaccount/' + scope.accountId);
}
scope.submit = function () {
if (this.formData.submittedOnDate) this.formData.submittedOnDate = \
dateFilter(this.formData.submittedOnDate, scope.df); this.formData.locale = \
scope.optlang.code; this.formData.dateFormat = scope.df;
this.formData.monthDayFormat = "dd MMM";
scope.formData.charges = [];
if (scope.charges.length > 0) {
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value == 'Annual Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM')});
} else if (scope.charges[i].chargeTimeType.value == \
'Specified due date') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
dueDate: dateFilter(scope.charges[i].dueDate, \
scope.df)});
} else if (scope.charges[i].chargeTimeType.value == 'Monthly \
Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM'), feeInterval: \
scope.charges[i].feeInterval}); } else {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount}); }
}
}
this.formData.charts = [];//declare charts array
this.formData.charts.push(copyChartData(scope.chart));//add chart \
details this.formData = removeEmptyValues(this.formData);
resourceFactory.fixedDepositAccountResource.update({'accountId': \
scope.accountId}, this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
};
/**
* Add a new row with default values for entering chart details
*/
scope.addNewRow = function () {
var fromPeriod = '';
var amountRangeFrom = '';
var periodType = '';
if (_.isNull(scope.chart.chartSlabs) || \
_.isUndefined(scope.chart.chartSlabs)) { scope.chart.chartSlabs = [];
} else {
var lastChartSlab = {};
if (scope.chart.chartSlabs.length > 0) {
lastChartSlab = \
angular.copy(scope.chart.chartSlabs[scope.chart.chartSlabs.length - 1]); }
if (!(_.isNull(lastChartSlab) || _.isUndefined(lastChartSlab))) {
fromPeriod = _.isNull(lastChartSlab) ? '' : \
parseInt(lastChartSlab.toPeriod) + 1;
amountRangeFrom = _.isNull(lastChartSlab) ? '' : \
parseFloat(lastChartSlab.amountRangeTo) + 1;
periodType = angular.copy(lastChartSlab.periodType);
}
}
var chartSlab = {
"periodType": periodType,
"fromPeriod": fromPeriod,
"amountRangeFrom": amountRangeFrom
};
scope.chart.chartSlabs.push(chartSlab);
}
/**
* create new chart data object
*/
copyChartData = function () {
var newChartData = {
id: scope.chart.id,
name: scope.chart.name,
description: scope.chart.description,
fromDate: dateFilter(scope.fromDate.date, scope.df),
endDate: dateFilter(scope.endDate.date, scope.df),
isPrimaryGroupingByAmount:scope.chart.isPrimaryGroupingByAmount,
//savingsProductId: scope.productId,
dateFormat: scope.df,
locale: scope.optlang.code,
chartSlabs: angular.copy(copyChartSlabs(scope.chart.chartSlabs)),
isActiveChart: 'true'
}
//remove empty values
_.each(newChartData, function (v, k) {
if (!v)
delete newChartData[k];
});
return newChartData;
}
/**
* copy all chart details to a new Array
* @param chartSlabs
* @returns {Array}
*/
copyChartSlabs = function (chartSlabs) {
var detailsArray = [];
_.each(chartSlabs, function (chartSlab) {
var chartSlabData = copyChartSlab(chartSlab);
detailsArray.push(chartSlabData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param chartSlab
*
*/
copyChartSlab = function (chartSlab) {
var newChartSlabData = {
id: chartSlab.id,
description: chartSlab.description,
fromPeriod: chartSlab.fromPeriod,
toPeriod: chartSlab.toPeriod,
amountRangeFrom: chartSlab.amountRangeFrom,
amountRangeTo: chartSlab.amountRangeTo,
annualInterestRate: chartSlab.annualInterestRate,
locale: scope.optlang.code,
incentives:angular.copy(copyIncentives(chartSlab.incentives))
}
if(chartSlab.periodType != undefined) {
newChartSlabData.periodType = chartSlab.periodType.id;
}
//remove empty values
_.each(newChartSlabData, function (v, k) {
if (!v && v != 0)
delete newChartSlabData[k];
});
return newChartSlabData;
}
removeEmptyValues = function (objArray) {
_.each(objArray, function (v, k) {
//alert(k + ':' + v);
if ((_.isNull(v) || _.isUndefined(v) || v === '') && (k != \
'linkAccountId')) { //alert('remove' + k + ':' + v);
delete objArray[k];
}
});
return objArray;
}
/**
* Remove chart details row
*/
scope.removeRow = function (index) {
scope.chart.chartSlabs.splice(index, 1);
}
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
data: function () {
return scope.chart;
},
chartSlab: function () {
return scope.chart.chartSlabs[index];
}
}
});
}
/**
* copy all chart details to a new Array
* @param incentiveDatas
* @returns {Array}
*/
copyIncentives = function (incentives) {
var detailsArray = [];
_.each(incentives, function (incentive) {
var incentiveData = copyIncentive(incentive);
detailsArray.push(incentiveData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param incentiveData
*
*/
copyIncentive = function (incentiveData) {
var newIncentiveDataData = {
id: incentiveData.id,
"entityType":incentiveData.entityType,
"attributeName":incentiveData.attributeName.id,
"conditionType":incentiveData.conditionType.id,
"attributeValue":incentiveData.attributeValue,
"incentiveType":incentiveData.incentiveType.id,
"amount":incentiveData.amount
}
return newIncentiveDataData;
}
var IncentiveCtrl = function ($scope, $uibModalInstance, data,chartSlab) \
{ $scope.data = data;
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.addNewRow = function () {
var incentive = {
"entityType":"2",
"attributeName":"",
"conditionType":"",
"attributeValue":"",
"incentiveType":"",
"amount":""
};
$scope.chartSlab.incentives.push(incentive);
}
/**
* Remove chart details row
*/
$scope.removeRow = function (index) {
$scope.chartSlab.incentives.splice(index, 1);
}
};
}
});
mifosX.ng.application.controller('EditDepositAccountController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter','$uibModal', \
mifosX.controllers.EditDepositAccountController]).run(function ($log) { \
$log.info("EditDepositAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
FixedDepositAccountActionsController: function (scope, resourceFactory, \
location, routeParams, dateFilter) {
scope.action = routeParams.action || "";
scope.accountId = routeParams.id;
scope.savingAccountId = routeParams.id;
scope.formData = {};
scope.restrictDate = new Date();
// Transaction UI Related
scope.isAccountClose = false;
scope.showPaymentDetails = false;
scope.paymentTypes = [];
scope.activationChargeAmount = 0;
scope.totalAmountIncludingActivationCharge = 0;
scope.depositAmount = 0;
if(scope.action=='activate'){
resourceFactory.fixedDepositAccountResource.get({accountId: \
scope.savingAccountId, associations:'charges'}, function (data) {
scope.totalAmountIncludingActivationCharge = \
data.depositAmount+parseFloat(data.activationCharge); scope.depositAmount = \
data.depositAmount;
scope.activationChargeAmount = data.activationCharge;
});
}
switch (scope.action) {
case "approve":
scope.title = 'label.heading.approvefixeddepositaccount';
scope.labelName = 'label.input.savingaccountapprovedOnDate';
scope.modelName = 'approvedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Approve application';
break;
case "reject":
scope.title = 'label.heading.rejectfixeddepositaccount';
scope.labelName = 'label.input.rejectedon';
scope.modelName = 'rejectedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Reject application';
break;
case "withdrawnByApplicant":
scope.title = 'label.heading.withdrawnfixeddepositaccount';
scope.labelName = 'label.input.withdrawnon';
scope.modelName = 'withdrawnOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Withdrawn by applicant';
break;
case "undoapproval":
scope.title = 'label.heading.undoapprovefixeddepositaccount';
scope.showDateField = false;
scope.showNoteField = true;
scope.actionName = 'Undo Approve application';
break;
case "activate":
scope.title = 'label.heading.activatefixeddepositaccount';
scope.labelName = 'label.input.activatedon';
scope.modelName = 'activatedOnDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.actionName = 'Approve application';
break;
/*case "deposit":
resourceFactory.savingsTrxnsTemplateResource.get({savingsId:scope.accountId, \
command:'deposit'}, function (data) { scope.paymentTypes=data.paymentTypeOptions;
});
scope.title = 'label.heading.depositmoneytosavingaccount';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
break;
case "withdrawal":
resourceFactory.savingsTrxnsTemplateResource.get({savingsId:scope.accountId, \
command:'withdrawal'}, function (data) { scope.paymentTypes=data.paymentTypeOptions;
});
scope.title = 'label.heading.withdrawmoneyfromsavingaccount';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
break;
case "applyAnnualFees":
resourceFactory.savingsResource.get({accountId : routeParams.id, \
resourceType : 'charges', chargeId : routeParams.chargeId}, function (data) {
scope.formData.amount = data.amount;
if (data.dueDate) {
var dueDate = dateFilter(data.dueDate, scope.df);
scope.formData.dueDate = new Date(dueDate);
}
});
scope.title = 'label.heading.savingaccountapplyannualFee';
scope.labelName = 'label.input.annualfeetransactiondate';
scope.modelName = 'dueDate';
scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
scope.showNoteField = false;
break;*/
case "close":
resourceFactory.fixedDepositAccountResource.get({accountId: \
routeParams.id, resourceType: 'template', command: 'close'}, function (data) {
scope.maturityAmount = data.maturityAmount;
scope.onAccountClosureOptions = \
data.onAccountClosureOptions; scope.savingsAccounts = data.savingsAccounts;
scope.paymentTypes = data.paymentTypeOptions;
scope.currency = data.currency;
});
scope.title = 'label.heading.closefixeddepositaccount';
scope.labelName = 'label.input.closedon';
scope.modelName = 'closedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.isAccountClose = true;
break;
case "prematureClose":
scope.title = 'label.heading.prematureclosefixeddepositaccount';
scope.labelName = 'label.input.preMatureCloseOnDate';
scope.modelName = 'closedOnDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.retrievePreMatureAmount = true;
break;
case "modifytransaction":
resourceFactory.fixedDepositTrxnsResource.get({savingsId: \
scope.accountId, transactionId: routeParams.transactionId, template: 'true'}, \
function (data) {
scope.title = \
'label.heading.editfixeddepositaccounttransaction';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.formData[scope.modelName] = new Date(data.date) || \
new Date(); scope.paymentTypes = data.paymentTypeOptions;
scope.formData.transactionAmount = data.amount;
if (data.paymentDetailData) {
if (data.paymentDetailData.paymentType) {
scope.formData.paymentTypeId = \
data.paymentDetailData.paymentType.id; }
scope.formData.accountNumber = \
data.paymentDetailData.accountNumber;
scope.formData.checkNumber = \
data.paymentDetailData.checkNumber;
scope.formData.routingCode = \
data.paymentDetailData.routingCode;
scope.formData.receiptNumber = \
data.paymentDetailData.receiptNumber;
scope.formData.bankNumber = \
data.paymentDetailData.bankNumber; }
});
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
scope.showPaymentType = true;
scope.showAmount = true;
break;
case "editsavingcharge":
resourceFactory.savingsResource.get({accountId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, function (data) {
scope.formData.amount = data.amount;
if (data.feeOnMonthDay) {
scope.dateArray = [];
scope.dateArray.push(2013)
for (var i in data.feeOnMonthDay) {
scope.dateArray.push(data.feeOnMonthDay[i]);
}
var feeOnMonthDay = dateFilter(scope.dateArray, \
scope.df);
scope.formData.feeOnMonthDayFullDate = new \
Date(feeOnMonthDay);
scope.labelName = \
'label.heading.savingaccounttransactionDate'; scope.modelName = \
'feeOnMonthDayFullDate'; scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
} else {
scope.labelName = 'label.amount';
scope.modelName = 'amount';
scope.showDateField = false;
scope.showAnnualAmountField = false;
scope.showAmountField = true;
}
});
break;
case "deletesavingcharge":
scope.showDelete = true;
break;
case "paycharge":
scope.formData.dueDate = new Date();
resourceFactory.savingsResource.get({accountId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId, command: 'paycharge'}, \
function (data) { scope.formData.amount = data.amountOutstanding;
});
scope.labelName = 'label.amount';
scope.showAmountField = true;
scope.paymentDatefield = true;
scope.modelName = 'dueDate';
break;
case "waive":
scope.waiveCharge = true;
break;
}
scope.cancel = function () {
location.path('/viewfixeddepositaccount/' + routeParams.id);
};
scope.submit = function () {
var params = {command: scope.action};
if (scope.action != "undoapproval") {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
}
if (scope.action == "deposit" || scope.action == "withdrawal" || \
scope.action == "modifytransaction") { if (scope.action == "withdrawal") {
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
} else if (scope.action == "deposit") {
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
}
if (scope.action == "modifytransaction") {
params.command = 'modify';
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
params.transactionId = routeParams.transactionId;
}
params.savingsId = scope.accountId;
resourceFactory.fixedDepositTrxnsResource.save(params, \
this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
} else if (scope.action == "editsavingcharge") {
if (this.formData.feeOnMonthDayFullDate) {
this.formData.feeOnMonthDay = \
dateFilter(this.formData.feeOnMonthDayFullDate, scope.df); \
this.formData.monthDayFormat = "dd MMM";
this.formData.feeOnMonthDay = \
this.formData.feeOnMonthDay.substring(0, this.formData.feeOnMonthDay.length - 5); \
delete this.formData.feeOnMonthDayFullDate; }
resourceFactory.savingsResource.update({accountId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + \
data.savingsId); });
} else if (scope.action == "deletesavingcharge") {
resourceFactory.savingsResource.delete({accountId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + \
data.savingsId); });
} else if (scope.action == "paycharge" || scope.action == "waive") {
params = {accountId: routeParams.id, resourceType: 'charges', \
chargeId: routeParams.chargeId, command: scope.action}; if (this.formData.dueDate) {
this.formData.dueDate = dateFilter(this.formData.dueDate, \
scope.df); }
resourceFactory.savingsResource.save(params, this.formData, \
function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
} else {
params.accountId = scope.accountId;
if (scope.action == "approve") {
if (this.formData.approvedOnDate) {
this.formData.approvedOnDate = \
dateFilter(this.formData.approvedOnDate, scope.df); }
} else if (scope.action == "withdrawnByApplicant") {
if (this.formData.withdrawnOnDate) {
this.formData.withdrawnOnDate = \
dateFilter(this.formData.withdrawnOnDate, scope.df); }
} else if (scope.action == "reject") {
if (this.formData.rejectedOnDate) {
this.formData.rejectedOnDate = \
dateFilter(this.formData.rejectedOnDate, scope.df); }
} else if (scope.action == "activate") {
if (this.formData.activatedOnDate) {
this.formData.activatedOnDate = \
dateFilter(this.formData.activatedOnDate, scope.df); }
/*} else if (scope.action == "applyAnnualFees" || \
scope.action == "paycharge" || scope.action == "waivecharge") {
params = {accountId : routeParams.id, resourceType : \
'charges', chargeId : routeParams.chargeId, command : 'paycharge'}; if \
(this.formData.dueDate) {
this.formData.dueDate = \
dateFilter(this.formData.dueDate,scope.df); }*/
} else if (scope.action === "close") {
if (this.formData.closedOnDate) {
this.formData.closedOnDate = \
dateFilter(this.formData.closedOnDate, scope.df); }
} else if (scope.action === "prematureClose") {
if (this.formData.closedOnDate) {
this.formData.closedOnDate = \
dateFilter(this.formData.closedOnDate, scope.df); }
if (scope.retrievePreMatureAmount) {
params = {accountId: routeParams.id, command: \
'calculatePrematureAmount'};
resourceFactory.fixedDepositAccountResource.save(params, \
this.formData, function (data) {
scope.maturityAmount = data.maturityAmount;
scope.onAccountClosureOptions = \
data.onAccountClosureOptions;
scope.savingsAccounts = data.savingsAccounts;
scope.paymentTypes = data.paymentTypeOptions;
scope.currency = data.currency;
});
scope.isAccountClose = true;
scope.showNoteField = true;
scope.retrievePreMatureAmount = false;
return;
}
}
resourceFactory.fixedDepositAccountResource.save(params, \
this.formData, function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
}
};
}
});
mifosX.ng.application.controller('FixedDepositAccountActionsController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.FixedDepositAccountActionsController]).run(function ($log) { \
$log.info("FixedDepositAccountActionsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewFixedDepositAccountDetailsController: function (scope, routeParams, \
resourceFactory, paginatorService, location, route, dateFilter,$uibModal) { \
scope.isDebit = function (savingsTransactionType) {
return savingsTransactionType.withdrawal == true || \
savingsTransactionType.feeDeduction == true || savingsTransactionType.withholdTax == \
true; };
/***
* we are using orderBy(https://docs.angularjs.org/api/ng/filter/orderBy) \
filter to sort fields in ui
* api returns dates in array format[yyyy, mm, dd], converting the array \
of dates to date object
* @param dateFieldName
*/
scope.convertDateArrayToObject = function(dateFieldName){
for(var i in scope.savingaccountdetails.transactions){
scope.savingaccountdetails.transactions[i][dateFieldName] = new \
Date(scope.savingaccountdetails.transactions[i].date); }
};
scope.clickEvent = function (eventName, accountId) {
eventName = eventName || "";
switch (eventName) {
case "modifyapplication":
location.path('/editfixeddepositaccount/' + accountId);
break;
case "approve":
location.path('/fixeddepositaccount/' + accountId + \
'/approve'); break;
case "reject":
location.path('/fixeddepositaccount/' + accountId + \
'/reject'); break;
case "withdrawnbyclient":
location.path('/fixeddepositaccount/' + accountId + \
'/withdrawnByApplicant'); break;
case "delete":
\
resourceFactory.fixedDepositAccountResource.delete({accountId: accountId}, {}, \
function (data) {
var destination = '/viewgroup/' + data.groupId;
if (data.clientId) destination = '/viewclient/' + \
data.clientId; location.path(destination);
});
break;
case "undoapproval":
location.path('/fixeddepositaccount/' + accountId + \
'/undoapproval'); break;
case "activate":
location.path('/fixeddepositaccount/' + accountId + \
'/activate'); break;
case "addcharge":
location.path('/fixeddepositaccount/' + accountId + \
'/charges'); break;
case "calculateInterest":
resourceFactory.fixedDepositAccountResource.save({accountId: \
accountId, command: 'calculateInterest'}, {}, function (data) { route.reload();
});
break;
case "postInterest":
resourceFactory.fixedDepositAccountResource.save({accountId: \
accountId, command: 'postInterest'}, {}, function (data) { route.reload();
});
break;
/* case "applyAnnualFees":
location.path('/savingaccountcharge/' + accountId + \
'/applyAnnualFees/' + scope.annualChargeId); break;
case "transferFunds":
if (scope.savingaccountdetails.clientId) {
location.path('/accounttransfers/fromsavings/'+accountId);
}
break;*/
case "close":
location.path('/fixeddepositaccount/' + accountId + \
'/close'); break;
case "prematureClose":
location.path('/fixeddepositaccount/' + accountId + \
'/prematureClose'); break;
case "enableWithHoldTax":
var changes = {
withHoldTax:true
};
resourceFactory.savingsResource.update({accountId: accountId, \
command: 'updateWithHoldTax'}, changes, function (data) { route.reload();
});
break;
case "disableWithHoldTax":
var changes = {
withHoldTax:false
};
resourceFactory.savingsResource.update({accountId: accountId, \
command: 'updateWithHoldTax'}, changes, function (data) { route.reload();
});
break;
}
};
scope.routeTo = function (accountId, transactionId, accountTransfer, \
transferId) { if (accountTransfer) {
location.path('/viewaccounttransfers/' + transferId);
} else {
location.path('/viewfixeddepositaccounttrxn/' + accountId + '/' + \
transactionId); }
};
resourceFactory.fixedDepositAccountResource.get({accountId: \
routeParams.id, associations: 'all'}, function (data) { scope.savingaccountdetails = \
data; scope.savingaccountdetails.availableBalance = \
scope.savingaccountdetails.enforceMinRequiredBalance?(scope.savingaccountdetails.summary.accountBalance \
- scope.savingaccountdetails.minRequiredOpeningBalance):scope.savingaccountdetails.summary.accountBalance;
scope.convertDateArrayToObject('date');
scope.chartSlabs = \
scope.savingaccountdetails.accountChart.chartSlabs; scope.status = \
data.status.value; scope.heading = (!scope.savingaccountdetails.status.rejected && \
!scope.savingaccountdetails.status.submittedAndPendingApproval)?'label.heading.interestchart':'label.heading.summary';
if (scope.status == "Submitted and pending approval" || scope.status \
== "Active" || scope.status == "Approved") { scope.choice = true;
}
scope.chargeAction = data.status.value == "Submitted and pending \
approval" ? true : false; if (scope.savingaccountdetails.charges) {
scope.charges = scope.savingaccountdetails.charges;
scope.chargeTableShow = true;
} else {
scope.chargeTableShow = false;
}
if (data.status.value == "Submitted and pending approval") {
scope.buttons = { singlebuttons: [
{
name: "button.modifyapplication",
icon: "fa fa-pencil "
},
{
name: "button.approve",
icon: "fa fa-check"
}
],
options: [
{
name: "button.reject"
},
{
name: "button.withdrawnbyclient"
},
{
name: "button.addcharge"
},
{
name: "button.delete"
}
]
};
}
if (data.status.value == "Approved") {
scope.buttons = { singlebuttons: [
{
name: "button.undoapproval",
icon: "fa fa-undo"
},
{
name: "button.activate",
icon: "fa fa-ok-sign"
}
]
};
}
if (data.status.value == "Active") {
scope.buttons = { singlebuttons: [
{
name: "button.prematureClose",
icon: "fa fa-arrow-left"
},
{
name: "button.calculateInterest",
icon: "fa fa-table"
}
],
options: [
{
name: "button.postInterest"
},
{
name: "button.addcharge"
}
]
};
if(data.taxGroup){
if(data.withHoldTax){
scope.buttons.options.push({
name: "button.disableWithHoldTax",
taskPermissionName:"UPDATEWITHHOLDTAX_SAVINGSACCOUNT"
});
}else{
scope.buttons.options.push({
name: "button.enableWithHoldTax",
taskPermissionName:"UPDATEWITHHOLDTAX_SAVINGSACCOUNT"
});
}
}
/*if (data.clientId) {
scope.buttons.options.push({
name:"button.transferFunds"
});
}*/
}else if (data.status.value == "Matured") {
scope.buttons = { singlebuttons: [
{
name: "button.close",
icon: "fa fa-arrow-right"
},
{
name: "button.calculateInterest",
icon: "fa fa-table"
}
],
options: [
{
name: "button.postInterest"
},
{
name: "button.addcharge"
}
]
};
/*if (data.clientId) {
scope.buttons.options.push({
name:"button.transferFunds"
});
}*/
}
resourceFactory.standingInstructionTemplateResource.get({fromClientId: \
scope.savingaccountdetails.clientId,fromAccountType: 2,fromAccountId: \
routeParams.id},function (response) { scope.standinginstruction = response;
scope.searchTransaction();
});
});
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.fromAccountId = routeParams.id;
params.fromAccountType = 2;
params.clientId = scope.savingaccountdetails.clientId;
params.clientName = scope.savingaccountdetails.clientName;
params.dateFormat = scope.df;
resourceFactory.standingInstructionResource.search(params, callback);
};
scope.searchTransaction = function () {
scope.displayResults = true;
scope.instructions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
};
scope.deletestandinginstruction = function (id) {
$uibModal.open({
templateUrl: 'delInstruction.html',
controller: DelInstructionCtrl,
resolve: {
ids: function () {
return id;
}
}
});
};
var DelInstructionCtrl = function ($scope, $uibModalInstance, ids) {
$scope.delete = function () {
resourceFactory.standingInstructionResource.cancel({standingInstructionId: \
ids}, function (data) { scope.searchTransaction();
$uibModalInstance.close('delete');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
resourceFactory.DataTablesResource.getAllDataTables({apptable: \
'm_savings_account'}, function (data) { scope.savingdatatables = data;
});
scope.dataTableChange = function (datatable) {
resourceFactory.DataTablesResource.getTableDetails({datatablename: \
datatable.registeredTableName,
entityId: routeParams.id, genericResultSet: 'true'}, function \
(data) { scope.datatabledetails = data;
scope.datatabledetails.isData = data.data.length > 0 ? true : \
false;
scope.datatabledetails.isMultirow = \
data.columnHeaders[0].columnName == "id" ? true : false; scope.singleRow = [];
for (var i in data.columnHeaders) {
if (scope.datatabledetails.columnHeaders[i].columnCode) {
for (var j in \
scope.datatabledetails.columnHeaders[i].columnValues) { for (var k in data.data) {
if (data.data[k].row[i] == \
scope.datatabledetails.columnHeaders[i].columnValues[j].id) {
data.data[k].row[i] = \
scope.datatabledetails.columnHeaders[i].columnValues[j].value; }
}
}
}
}
if (scope.datatabledetails.isData) {
for (var i in data.columnHeaders) {
if (!scope.datatabledetails.isMultirow) {
var row = {};
row.key = data.columnHeaders[i].columnName;
row.value = data.data[0].row[i];
scope.singleRow.push(row);
}
}
}
});
};
scope.deleteAll = function (apptableName, entityId) {
resourceFactory.DataTablesResource.delete({datatablename: \
apptableName, entityId: entityId, genericResultSet: 'true'}, {}, function (data) { \
route.reload(); });
};
scope.modifyTransaction = function (accountId, transactionId) {
location.path('/fixeddepositaccount/' + accountId + \
'/modifytransaction?transactionId=' + transactionId); };
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
chartSlab: function () {
return \
scope.savingaccountdetails.accountChart.chartSlabs[index]; }
}
});
};
var IncentiveCtrl = function ($scope, $uibModalInstance, chartSlab) {
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ViewFixedDepositAccountDetailsController', \
['$scope', '$routeParams', 'ResourceFactory', 'PaginatorService', '$location', \
'$route', 'dateFilter','$uibModal', \
mifosX.controllers.ViewFixedDepositAccountDetailsController]).run(function ($log) { \
$log.info("ViewFixedDepositAccountDetailsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewFixedDepositTransactionController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.flag = false;
resourceFactory.fixedDepositTrxnsResource.get({savingsId: \
routeParams.accountId, transactionId: routeParams.transactionId}, function (data) { \
scope.transaction = data;
if (scope.transaction.transactionType.value == 'Transfer' || \
scope.transaction.reversed == 'true') { scope.flag = true;
}
});
scope.undoTransaction = function (accountId, transactionId) {
var params = {savingsId: accountId, transactionId: transactionId, \
command: 'undo'};
var formData = {dateFormat: scope.df, locale: scope.optlang.code, \
transactionAmount: 0};
formData.transactionDate = dateFilter(new Date(), scope.df);
resourceFactory.fixedDepositTrxnsResource.save(params, formData, \
function (data) {
location.path('/viewfixeddepositaccount/' + data.savingsId);
});
};
}
});
mifosX.ng.application.controller('ViewFixedDepositTransactionController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.ViewFixedDepositTransactionController]).run(function ($log) { \
$log.info("ViewFixedDepositTransactionController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddNewRecurringDepositChargeController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.offices = [];
scope.cancelRoute = routeParams.id;
scope.date = {};
resourceFactory.savingsChargeResource.get({accountId: routeParams.id, \
resourceType: 'template'}, function (data) { scope.chargeOptions = \
data.chargeOptions; });
scope.chargeSelected = function (id) {
resourceFactory.chargeResource.get({chargeId: id, template: 'true'}, \
function (data) {
scope.chargeCalculationType = data.chargeCalculationType.id;
scope.chargeTimeType = data.chargeTimeType.id;
scope.chargeDetails = data;
scope.formData.amount = data.amount;
scope.withDrawCharge = data.chargeTimeType.value === "Withdrawal \
Fee" ? true : false; scope.formData.feeInterval = data.feeInterval;
if (data.chargeTimeType.value === "Annual Fee" || \
data.chargeTimeType.value === "Monthly Fee") { scope.chargeTimeTypeAnnualOrMonth = \
true; }
});
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
if (scope.withDrawCharge !== true) {
if (scope.chargeTimeTypeAnnualOrMonth === true) {
this.formData.monthDayFormat = "dd MMMM";
if (scope.date.due) {
this.formData.feeOnMonthDay = dateFilter(scope.date.due, \
'dd MMMM'); } else {
this.formData.feeOnMonthDay = "";
}
} else {
this.formData.dateFormat = scope.df;
if (scope.date.specificduedate) {
this.formData.dueDate = \
dateFilter(scope.date.specificduedate, scope.df); } else {
this.formData.dueDate = "";
}
}
}
resourceFactory.savingsChargeResource.save({accountId: \
routeParams.id}, this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('AddNewRecurringDepositChargeController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.AddNewRecurringDepositChargeController]).run(function ($log) { \
$log.info("AddNewRecurringDepositChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportRecurringDepositController: function (scope, resourceFactory, \
location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/recurringdepositaccounts/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"recurringdeposits"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/recurringdepositaccounts/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportRecurringDepositController', \
['$scope', 'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportRecurringDepositController]).run(function ($log) { \
$log.info("BulkImportRecurringDepositController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportRecurringDepositTransactionsController: function (scope, \
resourceFactory, location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/recurringdepositaccounts/transactions/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
scope.first.queryParams += 'officeId=' + \
scope.formData.officeId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"recurringdepositstransactions"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/recurringdepositaccounts/transactions/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportRecurringDepositTransactionsController', \
['$scope', 'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportRecurringDepositTransactionsController]).run(function \
($log) {
$log.info("BulkImportRecurringDepositTransactionsController initialized");
});
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CreateRecurringDepositAccountController: function (scope, resourceFactory, \
location, routeParams, dateFilter,$uibModal) { scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
scope.restrictDate = new Date();
scope.clientId = routeParams.clientId;
scope.groupId = routeParams.groupId;
if (routeParams.centerEntity) {
scope.centerEntity = true;
}
//interest rate chart details
scope.chart = {};
scope.fromDate = {}; //required for date formatting
scope.endDate = {};//required for date formatting
//scope.formData.expectedFirstDepositOnDate = {};
scope.charges = [];
scope.inparams = {};
if (scope.clientId) {
scope.inparams.clientId = scope.clientId
}
;
if (scope.groupId) {
scope.inparams.groupId = scope.groupId
}
;
if (scope.centerId) {
scope.inparams.centerId = scope.centerId
}
;
resourceFactory.recurringDepositAccountTemplateResource.get(scope.inparams, \
function (data) { scope.products = data.productOptions;
scope.chargeOptions = data.chargeOptions;
scope.clientName = data.clientName;
scope.groupName = data.groupName;
});
scope.changeProduct = function () {
scope.inparams.productId = scope.formData.productId;
resourceFactory.recurringDepositAccountTemplateResource.get(scope.inparams, \
function (data) {
scope.data = data;
scope.charges = data.charges;
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value === "Annual Fee" && \
scope.charges[i].feeOnMonthDay) { scope.charges[i].feeOnMonthDay.push('2013');
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df)); }
}
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate;
scope.formData.lockinPeriodFrequency = \
data.lockinPeriodFrequency; scope.formData.withHoldTax = data.withHoldTax;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = \
data.lockinPeriodFrequencyType.id;
if (data.withdrawalFeeType) scope.formData.withdrawalFeeType = \
data.withdrawalFeeType.id;
if (data.interestFreePeriodApplicable) \
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
if (data.preClosurePenalApplicable) \
scope.formData.preClosurePenalApplicable = data.preClosurePenalApplicable;
scope.chart = data.accountChart;
scope.chartSlabs = scope.chart.chartSlabs;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
var preClosurePenalInterestOnTypeId = \
(_.isNull(data.preClosurePenalInterestOnType) || \
_.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId;
scope.formData.isMandatoryDeposit = data.isMandatoryDeposit;
scope.formData.allowWithdrawal = data.allowWithdrawal;
//alert(data.allowWithdrawal + '='+ data.isMandatoryDeposit + \
'='+data.adjustAdvanceTowardsFuturePayments);
scope.formData.adjustAdvanceTowardsFuturePayments = \
data.adjustAdvanceTowardsFuturePayments; });
};
scope.addCharge = function (chargeId) {
scope.errorchargeevent = false;
if (chargeId) {
resourceFactory.chargeResource.get({chargeId: chargeId, template: \
'true'}, function (data) { data.chargeId = data.id;
if (data.chargeTimeType.value == "Annual Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
} else if (data.chargeTimeType.value == "Monthly Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
}
scope.charges.push(data);
scope.chargeId = undefined;
});
} else {
scope.errorchargeevent = true;
scope.labelchargeerror = "selectcharge";
}
}
scope.deleteCharge = function (index) {
scope.charges.splice(index, 1);
}
scope.submit = function () {
if (scope.date) {
this.formData.submittedOnDate = \
dateFilter(scope.date.submittedOnDate, scope.df); }
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.monthDayFormat = "dd MMM";
this.formData.charges = [];
if (scope.clientId) this.formData.clientId = scope.clientId;
if (scope.groupId) this.formData.groupId = scope.groupId;
if (scope.centerId) this.formData.centerId = scope.centerId;
if (scope.charges.length > 0) {
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value == 'Annual Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM')});
} else if (scope.charges[i].chargeTimeType.value == \
'Specified due date') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
dueDate: dateFilter(scope.charges[i].dueDate, \
scope.df)});
} else if (scope.charges[i].chargeTimeType.value == 'Monthly \
Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM'), feeInterval: \
scope.charges[i].feeInterval}); } else {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount}); }
}
}
this.formData.charts = [];//declare charts array
this.formData.charts.push(copyChartData(scope.chart));//add chart \
details this.formData = removeEmptyValues(this.formData);
this.formData.isCalendarInherited = \
(_.isNull(this.formData.isCalendarInherited) || \
_.isUndefined(this.formData.isCalendarInherited)) ? false : \
this.formData.isCalendarInherited;
if (scope.formData.expectedFirstDepositOnDate) {
this.formData.expectedFirstDepositOnDate = \
dateFilter(scope.formData.expectedFirstDepositOnDate, scope.df); }
resourceFactory.recurringDepositAccountResource.save(this.formData, \
function (data) {
location.path('/viewrecurringdepositaccount/' + data.savingsId);
});
};
scope.cancel = function () {
if (scope.clientId) {
location.path('/viewclient/' + scope.clientId);
} else if (scope.centerEntity) {
location.path('/viewcenter/' + scope.groupId);
} else {
location.path('/viewgroup/' + scope.groupId);
}
}
/**
* Add a new row with default values for entering chart details
*/
scope.addNewRow = function () {
var fromPeriod = '';
var amountRangeFrom = '';
var periodType = '';
if (_.isNull(scope.chart.chartSlabs) || \
_.isUndefined(scope.chart.chartSlabs)) { scope.chart.chartSlabs = [];
} else {
var lastChartSlab = {};
if (scope.chart.chartSlabs.length > 0) {
lastChartSlab = \
angular.copy(scope.chart.chartSlabs[scope.chart.chartSlabs.length - 1]); }
if (!(_.isNull(lastChartSlab) || _.isUndefined(lastChartSlab))) {
fromPeriod = _.isNull(lastChartSlab) ? '' : \
parseInt(lastChartSlab.toPeriod) + 1;
amountRangeFrom = _.isNull(lastChartSlab) ? '' : \
parseFloat(lastChartSlab.amountRangeTo) + 1;
periodType = angular.copy(lastChartSlab.periodType);
}
}
var chartSlab = {
"periodType": periodType,
"fromPeriod": fromPeriod,
"amountRangeFrom": amountRangeFrom,
"incentives":[]
};
scope.chart.chartSlabs.push(chartSlab);
}
/**
* create new chart data object
*/
copyChartData = function () {
var newChartData = {
id: scope.chart.id,
name: scope.chart.name,
description: scope.chart.description,
fromDate: dateFilter(scope.fromDate.date, scope.df),
endDate: dateFilter(scope.endDate.date, scope.df),
isPrimaryGroupingByAmount:scope.chart.isPrimaryGroupingByAmount,
//savingsProductId: scope.productId,
dateFormat: scope.df,
locale: scope.optlang.code,
chartSlabs: angular.copy(copyChartSlabs(scope.chart.chartSlabs)),
isActiveChart: 'true'
}
//remove empty values
_.each(newChartData, function (v, k) {
if (!v)
delete newChartData[k];
});
return newChartData;
}
/**
* copy all chart details to a new Array
* @param chartSlabs
* @returns {Array}
*/
copyChartSlabs = function (chartSlabs) {
var detailsArray = [];
_.each(chartSlabs, function (chartSlab) {
var chartSlabData = copyChartSlab(chartSlab);
detailsArray.push(chartSlabData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param chartSlab
*
*/
copyChartSlab = function (chartSlab) {
var newChartSlabData = {
id: chartSlab.id,
description: chartSlab.description,
fromPeriod: chartSlab.fromPeriod,
toPeriod: chartSlab.toPeriod,
amountRangeFrom: chartSlab.amountRangeFrom,
amountRangeTo: chartSlab.amountRangeTo,
annualInterestRate: chartSlab.annualInterestRate,
locale: scope.optlang.code,
incentives:angular.copy(copyIncentives(chartSlab.incentives))
}
if(chartSlab.periodType != undefined) {
newChartSlabData.periodType = chartSlab.periodType.id;
}
//remove empty values
_.each(newChartSlabData, function (v, k) {
if (!v && v != 0)
delete newChartSlabData[k];
});
return newChartSlabData;
}
removeEmptyValues = function (objArray) {
_.each(objArray, function (v, k) {
//alert(k + ':' + v);
if (_.isNull(v) || _.isUndefined(v) || v === '') {
//alert('remove' + k + ':' + v);
delete objArray[k];
}
});
return objArray;
}
/**
* Remove chart details row
*/
scope.removeRow = function (index) {
scope.chart.chartSlabs.splice(index, 1);
}
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
data: function () {
return scope.chart;
},
chartSlab: function () {
return scope.chart.chartSlabs[index];
}
}
});
}
/**
* copy all chart details to a new Array
* @param incentiveDatas
* @returns {Array}
*/
copyIncentives = function (incentives) {
var detailsArray = [];
_.each(incentives, function (incentive) {
var incentiveData = copyIncentive(incentive);
detailsArray.push(incentiveData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param incentiveData
*
*/
copyIncentive = function (incentiveData) {
var newIncentiveDataData = {
id: incentiveData.id,
"entityType":incentiveData.entityType,
"attributeName":incentiveData.attributeName.id,
"conditionType":incentiveData.conditionType.id,
"attributeValue":incentiveData.attributeValue,
"incentiveType":incentiveData.incentiveType.id,
"amount":incentiveData.amount
}
return newIncentiveDataData;
}
var IncentiveCtrl = function ($scope, $uibModalInstance, data,chartSlab) \
{ $scope.data = data;
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.addNewRow = function () {
var incentive = {
"entityType":"2",
"attributeName":"",
"conditionType":"",
"attributeValue":"",
"incentiveType":"",
"amount":""
};
$scope.chartSlab.incentives.push(incentive);
}
/**
* Remove chart details row
*/
$scope.removeRow = function (index) {
$scope.chartSlab.incentives.splice(index, 1);
}
};
}
});
mifosX.ng.application.controller('CreateRecurringDepositAccountController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter','$uibModal', \
mifosX.controllers.CreateRecurringDepositAccountController]).run(function ($log) { \
$log.info("CreateRecurringDepositAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditRecurringDepositAccountController: function (scope, resourceFactory, \
location, routeParams, dateFilter,$uibModal) { scope.products = [];
scope.fieldOfficers = [];
scope.formData = {};
scope.accountId = routeParams.id;
scope.charges = [];
scope.restrictDate = new Date();
scope.formData.expectedFirstDepositOnDate = {};
//interest rate chart details
scope.chart = {};
scope.fromDate = {}; //required for date formatting
scope.endDate = {};//required for date formatting
resourceFactory.recurringDepositAccountResource.get({accountId: \
scope.accountId, template: 'true', associations: 'charges'}, function (data) { \
scope.data = data; scope.charges = data.charges || [];
if (scope.charges) {
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value == 'Annual Fee') {
scope.charges[i].feeOnMonthDay.push(2013);
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df));
} else if (scope.charges[i].chargeTimeType.value == "Monthly \
Fee") { scope.charges[i].feeOnMonthDay.push(2013);
scope.charges[i].feeOnMonthDay = new \
Date(dateFilter(scope.charges[i].feeOnMonthDay, scope.df));
} else if (scope.charges[i].chargeTimeType.value == \
'Specified due date') {
scope.charges[i].dueDate = new \
Date(dateFilter(scope.charges[i].dueDate, scope.df)); }
}
}
if (data.clientId) {
scope.formData.clientId = data.clientId;
scope.clientName = data.clientName;
}
if (data.groupId) {
scope.formData.groupId = data.groupId;
scope.groupName = data.groupName;
}
scope.formData.productId = data.depositProductId;
scope.products = data.productOptions;
if (data.fieldOfficerId != 0)scope.formData.fieldOfficerId = \
data.fieldOfficerId; if (data.timeline) {
var submittedOnDate = dateFilter(data.timeline.submittedOnDate, \
scope.df);
scope.formData.submittedOnDate = new Date(submittedOnDate);
}
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate;
scope.formData.mandatoryRecommendedDepositAmount = \
data.mandatoryRecommendedDepositAmount; scope.formData.depositPeriod = \
data.depositPeriod;
scope.formData.recurringDepositFrequency = \
data.recurringDepositFrequency;
scope.formData.lockinPeriodFrequency = data.lockinPeriodFrequency;
var depositPeriodFrequencyId = (_.isNull(data.depositPeriodFrequency) \
|| _.isUndefined(data.depositPeriodFrequency)) ? '' : \
data.depositPeriodFrequency.id;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = data.lockinPeriodFrequencyType.id;
scope.chart = data.accountChart;
scope.chartSlabs = scope.chart.chartSlabs;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
if (data.expectedFirstDepositOnDate) {
var expectedFirstDepositOnDate = \
dateFilter(data.expectedFirstDepositOnDate, scope.df);
scope.formData.expectedFirstDepositOnDate = new \
Date(expectedFirstDepositOnDate); }
var depositPeriodFrequencyId = (_.isNull(data.depositPeriodFrequency) \
|| _.isUndefined(data.depositPeriodFrequency)) ? '' : data.depositPeriodFrequency.id; \
var preClosurePenalInterestOnTypeId = (_.isNull(data.preClosurePenalInterestOnType) \
|| _.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.depositPeriodFrequencyId = depositPeriodFrequencyId;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId;
scope.formData.isMandatoryDeposit = data.isMandatoryDeposit;
scope.formData.allowWithdrawal = data.allowWithdrawal;
scope.formData.adjustAdvanceTowardsFuturePayments = \
data.adjustAdvanceTowardsFuturePayments;
scope.formData.isCalendarInherited = data.isCalendarInherited;
scope.formData.recurringFrequency = data.recurringFrequency;
scope.formData.recurringFrequencyType = \
data.recurringFrequencyType.id; scope.formData.withHoldTax = data.withHoldTax;
});
scope.changeProduct = function () {
var inparams = {productId: scope.formData.productId};
if (scope.formData.clientId) inparams.clientId = \
scope.formData.clientId;
if (scope.formData.groupId) inparams.groupId = \
scope.formData.groupId;
resourceFactory.recurringDepositAccountTemplateResource.get(inparams, \
function (data) {
scope.data = data;
scope.fieldOfficers = data.fieldOfficerOptions;
scope.formData.nominalAnnualInterestRate = \
data.nominalAnnualInterestRate;
scope.formData.mandatoryRecommendedDepositAmount = \
data.mandatoryRecommendedDepositAmount; scope.formData.depositPeriod = \
data.depositPeriod;
scope.formData.recurringDepositFrequency = \
data.recurringDepositFrequency;
scope.formData.lockinPeriodFrequency = \
data.lockinPeriodFrequency; scope.formData.withHoldTax = data.withHoldTax;
/* FIX-ME: uncomment annualFeeAmount when datepicker avialable, \
because it depends on the date field 'annualFeeOnMonthDay'*/
//scope.formData.annualFeeAmount = data.annualFeeAmount;
//scope.formData.withdrawalFeeAmount = data.withdrawalFeeAmount;
//scope.formData.withdrawalFeeForTransfers = \
data.withdrawalFeeForTransfers;
if (data.interestCompoundingPeriodType) \
scope.formData.interestCompoundingPeriodType = \
data.interestCompoundingPeriodType.id;
if (data.interestPostingPeriodType) \
scope.formData.interestPostingPeriodType = \
data.interestPostingPeriodType.id;
if (data.interestCalculationType) \
scope.formData.interestCalculationType = \
data.interestCalculationType.id;
if (data.interestCalculationDaysInYearType) \
scope.formData.interestCalculationDaysInYearType = \
data.interestCalculationDaysInYearType.id;
if (data.lockinPeriodFrequencyType) \
scope.formData.lockinPeriodFrequencyType = \
data.lockinPeriodFrequencyType.id;
//if (data.withdrawalFeeType) scope.formData.withdrawalFeeType = \
data.withdrawalFeeType.id;
scope.chart = data.accountChart;
//format chart date values
if (scope.chart.fromDate) {
var fromDate = dateFilter(scope.chart.fromDate, scope.df);
scope.fromDate.date = new Date(fromDate);
}
if (scope.chart.endDate) {
var endDate = dateFilter(scope.chart.endDate, scope.df);
scope.endDate.date = new Date(endDate);
}
var depositPeriodFrequencyId = \
(_.isNull(data.depositPeriodFrequency) || _.isUndefined(data.depositPeriodFrequency)) \
? '' : data.depositPeriodFrequency.id; var preClosurePenalInterestOnTypeId = \
(_.isNull(data.preClosurePenalInterestOnType) || \
_.isUndefined(data.preClosurePenalInterestOnType)) ? '' : \
data.preClosurePenalInterestOnType.id;
var minDepositTermTypeId = (_.isNull(data.minDepositTermType) || \
_.isUndefined(data.minDepositTermType)) ? '' : \
data.minDepositTermType.id;
var maxDepositTermTypeId = (_.isNull(data.maxDepositTermType) || \
_.isUndefined(data.maxDepositTermType)) ? '' : data.maxDepositTermType.id; var \
inMultiplesOfDepositTermTypeId = (_.isNull(data.inMultiplesOfDepositTermType) || \
_.isUndefined(data.inMultiplesOfDepositTermType)) ? '' : \
data.inMultiplesOfDepositTermType.id;
scope.formData.depositPeriodFrequencyId = \
depositPeriodFrequencyId;
scope.formData.interestFreePeriodApplicable = \
data.interestFreePeriodApplicable;
scope.formData.interestFreeFromPeriod = \
data.interestFreeFromPeriod;
scope.formData.interestFreeToPeriod = data.interestFreeToPeriod;
scope.formData.interestFreePeriodFrequencyTypeId = \
interestFreePeriodFrequencyTypeId;
scope.formData.preClosurePenalApplicable = \
data.preClosurePenalApplicable;
scope.formData.preClosurePenalInterest = \
data.preClosurePenalInterest;
scope.formData.preClosurePenalInterestOnTypeId = \
preClosurePenalInterestOnTypeId; scope.formData.minDepositTerm = \
data.minDepositTerm; scope.formData.maxDepositTerm = data.maxDepositTerm;
scope.formData.minDepositTermTypeId = minDepositTermTypeId;
scope.formData.maxDepositTermTypeId = maxDepositTermTypeId;
scope.formData.inMultiplesOfDepositTerm = \
data.inMultiplesOfDepositTerm;
scope.formData.inMultiplesOfDepositTermTypeId = \
inMultiplesOfDepositTermTypeId;
scope.formData.isMandatoryDeposit = data.isMandatoryDeposit;
scope.formData.allowWithdrawal = data.allowWithdrawal;
scope.formData.adjustAdvanceTowardsFuturePayments = \
data.adjustAdvanceTowardsFuturePayments;
scope.formData.isCalendarInherited = data.isCalendarInherited;
});
}
scope.addCharge = function (chargeId) {
scope.errorchargeevent = false;
if (chargeId) {
resourceFactory.chargeResource.get({chargeId: chargeId, template: \
'true'}, function (data) { data.chargeId = data.id;
if (data.chargeTimeType.value == "Annual Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
} else if (data.chargeTimeType.value == "Monthly Fee") {
if (data.feeOnMonthDay) {
data.feeOnMonthDay.push(2013);
data.feeOnMonthDay = new \
Date(dateFilter(data.feeOnMonthDay, scope.df)); }
}
delete data.id;
scope.charges.push(data);
scope.chargeId = undefined;
});
} else {
scope.errorchargeevent = true;
scope.labelchargeerror = "selectcharge";
}
}
scope.deleteCharge = function (index) {
scope.charges.splice(index, 1);
}
scope.cancel = function () {
location.path('/viewsavingaccount/' + scope.accountId);
}
scope.submit = function () {
if (this.formData.submittedOnDate) this.formData.submittedOnDate = \
dateFilter(this.formData.submittedOnDate, scope.df); if \
(this.formData.expectedFirstDepositOnDate) this.formData.expectedFirstDepositOnDate \
= dateFilter(this.formData.expectedFirstDepositOnDate, scope.df); \
this.formData.locale = scope.optlang.code; this.formData.dateFormat = scope.df;
this.formData.monthDayFormat = "dd MMM";
scope.formData.charges = [];
if (scope.charges.length > 0) {
for (var i in scope.charges) {
if (scope.charges[i].chargeTimeType.value == 'Annual Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM')});
} else if (scope.charges[i].chargeTimeType.value == \
'Specified due date') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
dueDate: dateFilter(scope.charges[i].dueDate, \
scope.df)});
} else if (scope.charges[i].chargeTimeType.value == 'Monthly \
Fee') {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount,
feeOnMonthDay: \
dateFilter(scope.charges[i].feeOnMonthDay, 'dd MMMM'), feeInterval: \
scope.charges[i].feeInterval}); } else {
this.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amount}); }
}
}
this.formData.charts = [];//declare charts array
this.formData.charts.push(copyChartData(scope.chart));//add chart \
details this.formData = removeEmptyValues(this.formData);
resourceFactory.recurringDepositAccountResource.update({'accountId': \
scope.accountId}, this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + data.savingsId);
});
};
/**
* Add a new row with default values for entering chart details
*/
scope.addNewRow = function () {
var fromPeriod = '';
var amountRangeFrom = '';
var periodType = '';
if (_.isNull(scope.chart.chartSlabs) || \
_.isUndefined(scope.chart.chartSlabs)) { scope.chart.chartSlabs = [];
} else {
var lastChartSlab = {};
if (scope.chart.chartSlabs.length > 0) {
lastChartSlab = \
angular.copy(scope.chart.chartSlabs[scope.chart.chartSlabs.length - 1]); }
if (!(_.isNull(lastChartSlab) || _.isUndefined(lastChartSlab))) {
fromPeriod = _.isNull(lastChartSlab) ? '' : \
parseInt(lastChartSlab.toPeriod) + 1;
amountRangeFrom = _.isNull(lastChartSlab) ? '' : \
parseFloat(lastChartSlab.amountRangeTo) + 1;
periodType = angular.copy(lastChartSlab.periodType);
}
}
var chartSlab = {
"periodType": periodType,
"fromPeriod": fromPeriod,
"amountRangeFrom": amountRangeFrom
};
scope.chart.chartSlabs.push(chartSlab);
}
/**
* create new chart data object
*/
copyChartData = function () {
var newChartData = {
id: scope.chart.id,
name: scope.chart.name,
description: scope.chart.description,
fromDate: dateFilter(scope.fromDate.date, scope.df),
endDate: dateFilter(scope.endDate.date, scope.df),
isPrimaryGroupingByAmount:scope.chart.isPrimaryGroupingByAmount,
//savingsProductId: scope.productId,
dateFormat: scope.df,
locale: scope.optlang.code,
chartSlabs: angular.copy(copyChartSlabs(scope.chart.chartSlabs)),
isActiveChart: 'true'
}
//remove empty values
_.each(newChartData, function (v, k) {
if (!v)
delete newChartData[k];
});
return newChartData;
}
/**
* copy all chart details to a new Array
* @param chartSlabs
* @returns {Array}
*/
copyChartSlabs = function (chartSlabs) {
var detailsArray = [];
_.each(chartSlabs, function (chartSlab) {
var chartSlabData = copyChartSlab(chartSlab);
detailsArray.push(chartSlabData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param chartSlab
*
*/
copyChartSlab = function (chartSlab) {
var newChartSlabData = {
id: chartSlab.id,
description: chartSlab.description,
fromPeriod: chartSlab.fromPeriod,
toPeriod: chartSlab.toPeriod,
amountRangeFrom: chartSlab.amountRangeFrom,
amountRangeTo: chartSlab.amountRangeTo,
annualInterestRate: chartSlab.annualInterestRate,
locale: scope.optlang.code,
incentives:angular.copy(copyIncentives(chartSlab.incentives))
}
if(chartSlab.periodType != undefined) {
newChartSlabData.periodType = chartSlab.periodType.id;
}
//remove empty values
_.each(newChartSlabData, function (v, k) {
if (!v && v != 0)
delete newChartSlabData[k];
});
return newChartSlabData;
}
removeEmptyValues = function (objArray) {
_.each(objArray, function (v, k) {
//alert(k + ':' + v);
if (_.isNull(v) || _.isUndefined(v) || v === '') {
//alert('remove' + k + ':' + v);
delete objArray[k];
}
});
return objArray;
}
/**
* Remove chart details row
*/
scope.removeRow = function (index) {
scope.chart.chartSlabs.splice(index, 1);
}
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
data: function () {
return scope.chart;
},
chartSlab: function () {
return scope.chart.chartSlabs[index];
}
}
});
}
/**
* copy all chart details to a new Array
* @param incentiveDatas
* @returns {Array}
*/
copyIncentives = function (incentives) {
var detailsArray = [];
_.each(incentives, function (incentive) {
var incentiveData = copyIncentive(incentive);
detailsArray.push(incentiveData);
});
return detailsArray;
}
/**
* create new chart detail object data from chartSlab
* @param incentiveData
*
*/
copyIncentive = function (incentiveData) {
var newIncentiveDataData = {
id: incentiveData.id,
"entityType":incentiveData.entityType,
"attributeName":incentiveData.attributeName.id,
"conditionType":incentiveData.conditionType.id,
"attributeValue":incentiveData.attributeValue,
"incentiveType":incentiveData.incentiveType.id,
"amount":incentiveData.amount
}
return newIncentiveDataData;
}
var IncentiveCtrl = function ($scope, $uibModalInstance, data,chartSlab) \
{ $scope.data = data;
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
$scope.addNewRow = function () {
var incentive = {
"entityType":"2",
"attributeName":"",
"conditionType":"",
"attributeValue":"",
"incentiveType":"",
"amount":""
};
$scope.chartSlab.incentives.push(incentive);
}
/**
* Remove chart details row
*/
$scope.removeRow = function (index) {
$scope.chartSlab.incentives.splice(index, 1);
}
};
}
});
mifosX.ng.application.controller('EditRecurringDepositAccountController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter','$uibModal', \
mifosX.controllers.EditRecurringDepositAccountController]).run(function ($log) { \
$log.info("EditRecurringDepositAccountController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
RecurringDepositAccountActionsController: function (scope, resourceFactory, \
location, routeParams, dateFilter) {
scope.action = routeParams.action || "";
scope.accountId = routeParams.id;
scope.savingAccountId = routeParams.id;
scope.formData = {};
scope.restrictDate = new Date();
// Transaction UI Related
scope.isAccountClose = false;
scope.showPaymentDetails = false;
scope.paymentTypes = [];
switch (scope.action) {
case "approve":
scope.title = 'label.heading.approverecurringdepositaccount';
scope.labelName = 'label.input.savingaccountapprovedOnDate';
scope.modelName = 'approvedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Approve application';
break;
case "reject":
scope.title = 'label.heading.rejectrecurringdepositaccount';
scope.labelName = 'label.input.rejectedon';
scope.modelName = 'rejectedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Reject application';
break;
case "withdrawnByApplicant":
scope.title = 'label.heading.withdrawnrecurringdepositaccount';
scope.labelName = 'label.input.withdrawnon';
scope.modelName = 'withdrawnOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.actionName = 'Withdrawn by applicant';
break;
case "undoapproval":
scope.title = 'label.heading.undoapproverecurringdepositaccount';
scope.showDateField = false;
scope.showNoteField = true;
scope.actionName = 'Undo Approve application';
break;
case "activate":
scope.title = 'label.heading.activaterecurringdepositaccount';
scope.labelName = 'label.input.activatedon';
scope.modelName = 'activatedOnDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.actionName = 'Approve application';
break;
case "deposit":
resourceFactory.recurringDepositTrxnsTemplateResource.get({savingsId: \
scope.accountId, command: 'deposit'}, function (data) { scope.amount = data.amount;
scope.formData.transactionAmount = data.amount;
if(data.outstandingChargeAmount && \
data.outstandingChargeAmount > 0){
scope.outstandingChargeAmount = \
data.outstandingChargeAmount;
scope.formData.transactionAmount = \
scope.formData.transactionAmount + scope.outstandingChargeAmount; }
scope.paymentTypes = data.paymentTypeOptions;
scope.formData.transactionDate=new Date(dateFilter(data.date, \
scope.df)); });
scope.title = 'label.heading.depositmoneytorecurringaccount';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
scope.showPaymentType=true;
scope.showAmount=true;
break;
case "withdrawal":
resourceFactory.recurringDepositTrxnsTemplateResource.get({savingsId: \
scope.accountId, command: 'withdrawal'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; scope.formData.transactionAmount = data.amount;
scope.formData.transactionDate=new Date(dateFilter(data.date, \
scope.df)); });
scope.title = 'label.heading.withdrawmoneyfromsavingaccount';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
scope.showPaymentType=true;
scope.showAmount=true;
break;
case "applyAnnualFees":
resourceFactory.savingsResource.get({accountId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, function (data) {
scope.formData.amount = data.amount;
if (data.dueDate) {
var dueDate = dateFilter(data.dueDate, scope.df);
scope.formData.dueDate = new Date(dueDate);
}
});
scope.title = 'label.heading.savingaccountapplyannualFee';
scope.labelName = 'label.input.annualfeetransactiondate';
scope.modelName = 'dueDate';
scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
scope.showNoteField = false;
break;
case "close":
resourceFactory.recurringDepositAccountResource.get({accountId: \
routeParams.id, resourceType: 'template', command: 'close'}, function (data) {
scope.maturityAmount = data.maturityAmount;
scope.onAccountClosureOptions = \
data.onAccountClosureOptions; scope.savingsAccounts = data.savingsAccounts;
scope.paymentTypes = data.paymentTypeOptions;
scope.currency = data.currency;
if(data.maturityAmount){
scope.title = \
'label.heading.closerecurringdepositaccount'; } else{
scope.title = \
'label.heading.closeopenrecurringdepositaccount'; }
});
scope.labelName = 'label.input.closedon';
scope.modelName = 'closedOnDate';
scope.showDateField = true;
scope.showNoteField = true;
scope.isAccountClose = true;
scope.showPaymentType=true;
break;
case "prematureClose":
scope.title = \
'label.heading.prematurecloserecurringdepositaccount'; scope.labelName = \
'label.input.closedon'; scope.modelName = 'closedOnDate';
scope.showDateField = true;
scope.showNoteField = false;
scope.retrievePreMatureAmount = true;
scope.showPaymentType=false;
break;
case "modifytransaction":
resourceFactory.recurringDepositTrxnsResource.get({savingsId: \
scope.accountId, transactionId: routeParams.transactionId, template: 'true'}, \
function (data) {
scope.title = \
'label.heading.editrecurringdepositaccounttransaction';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.formData[scope.modelName] = new Date(data.date) || \
new Date(); scope.paymentTypes = data.paymentTypeOptions;
scope.formData.transactionAmount = data.amount;
if (data.paymentDetailData) {
if (data.paymentDetailData.paymentType) {
scope.formData.paymentTypeId = \
data.paymentDetailData.paymentType.id; }
scope.formData.accountNumber = \
data.paymentDetailData.accountNumber;
scope.formData.checkNumber = \
data.paymentDetailData.checkNumber;
scope.formData.routingCode = \
data.paymentDetailData.routingCode;
scope.formData.receiptNumber = \
data.paymentDetailData.receiptNumber;
scope.formData.bankNumber = \
data.paymentDetailData.bankNumber; }
});
scope.showDateField = true;
scope.showNoteField = false;
scope.isTransaction = true;
scope.showPaymentDetails = false;
scope.showPaymentType=true;
scope.showAmount=true;
break;
case "editsavingcharge":
resourceFactory.savingsResource.get({accountId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, function (data) {
scope.formData.amount = data.amount;
if (data.feeOnMonthDay) {
scope.dateArray = [];
scope.dateArray.push(2013)
for (var i in data.feeOnMonthDay) {
scope.dateArray.push(data.feeOnMonthDay[i]);
}
var feeOnMonthDay = dateFilter(scope.dateArray, \
scope.df);
scope.formData.feeOnMonthDayFullDate = new \
Date(feeOnMonthDay);
scope.labelName = \
'label.heading.savingaccounttransactionDate'; scope.modelName = \
'feeOnMonthDayFullDate'; scope.showDateField = true;
scope.showAnnualAmountField = true;
scope.showAmountField = false;
} else {
scope.labelName = 'label.amount';
scope.modelName = 'amount';
scope.showDateField = false;
scope.showAnnualAmountField = false;
scope.showAmountField = true;
}
});
break;
case "deletesavingcharge":
scope.showDelete = true;
break;
case "paycharge":
scope.formData.dueDate = new Date();
resourceFactory.savingsResource.get({accountId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId, command: 'paycharge'}, \
function (data) { scope.formData.amount = data.amountOutstanding;
});
scope.labelName = 'label.amount';
scope.showAmountField = true;
scope.paymentDatefield = true;
scope.modelName = 'dueDate';
break;
case "waive":
scope.waiveCharge = true;
break;
}
scope.cancel = function () {
location.path('/viewrecurringdepositaccount/' + routeParams.id);
};
scope.submit = function () {
var params = {command: scope.action};
if (scope.action != "undoapproval") {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
}
if (scope.action == "deposit" || scope.action == "modifytransaction" \
|| scope.action == "withdrawal") { if (scope.action == "deposit") {
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
params.command = 'deposit';
} else if (scope.action == "withdrawal") {
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
params.command = 'withdrawal';
}
if (scope.action == "modifytransaction") {
params.command = 'modify';
if (this.formData.transactionDate) {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); }
params.transactionId = routeParams.transactionId;
}
params.savingsId = scope.accountId;
resourceFactory.recurringDepositTrxnsResource.save(params, \
this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + \
data.savingsId); });
} else if (scope.action == "editsavingcharge") {
if (this.formData.feeOnMonthDayFullDate) {
this.formData.feeOnMonthDay = \
dateFilter(this.formData.feeOnMonthDayFullDate, scope.df); \
this.formData.monthDayFormat = "dd MMM";
this.formData.feeOnMonthDay = \
this.formData.feeOnMonthDay.substring(0, this.formData.feeOnMonthDay.length - 5); \
delete this.formData.feeOnMonthDayFullDate; }
resourceFactory.savingsResource.update({accountId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + \
data.savingsId); });
} else if (scope.action == "deletesavingcharge") {
resourceFactory.savingsResource.delete({accountId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + \
data.savingsId); });
} else if (scope.action == "paycharge" || scope.action == "waive") {
params = {accountId: routeParams.id, resourceType: 'charges', \
chargeId: routeParams.chargeId, command: scope.action}; if (this.formData.dueDate) {
this.formData.dueDate = dateFilter(this.formData.dueDate, \
scope.df); }
resourceFactory.savingsResource.save(params, this.formData, \
function (data) {
location.path('/viewrecurringdepositaccount/' + \
data.savingsId); });
} else {
params.accountId = scope.accountId;
if (scope.action == "approve") {
if (this.formData.approvedOnDate) {
this.formData.approvedOnDate = \
dateFilter(this.formData.approvedOnDate, scope.df); }
} else if (scope.action == "withdrawnByApplicant") {
if (this.formData.withdrawnOnDate) {
this.formData.withdrawnOnDate = \
dateFilter(this.formData.withdrawnOnDate, scope.df); }
} else if (scope.action == "reject") {
if (this.formData.rejectedOnDate) {
this.formData.rejectedOnDate = \
dateFilter(this.formData.rejectedOnDate, scope.df); }
} else if (scope.action == "activate") {
if (this.formData.activatedOnDate) {
this.formData.activatedOnDate = \
dateFilter(this.formData.activatedOnDate, scope.df); }
/*} else if (scope.action == "applyAnnualFees" || \
scope.action == "paycharge" || scope.action == "waivecharge") {
params = {accountId : routeParams.id, resourceType : \
'charges', chargeId : routeParams.chargeId, command : 'paycharge'}; if \
(this.formData.dueDate) {
this.formData.dueDate = \
dateFilter(this.formData.dueDate,scope.df); }*/
} else if (scope.action === "close") {
if (this.formData.closedOnDate) {
this.formData.closedOnDate = \
dateFilter(this.formData.closedOnDate, scope.df); }
} else if (scope.action === "prematureClose") {
if (this.formData.closedOnDate) {
this.formData.closedOnDate = \
dateFilter(this.formData.closedOnDate, scope.df); }
if (scope.retrievePreMatureAmount) {
params = {accountId: routeParams.id, command: \
'calculatePrematureAmount'};
\
resourceFactory.recurringDepositAccountResource.save(params, this.formData, function \
(data) {
scope.maturityAmount = data.maturityAmount;
scope.onAccountClosureOptions = \
data.onAccountClosureOptions;
scope.savingsAccounts = data.savingsAccounts;
scope.paymentTypes = data.paymentTypeOptions;
scope.currency = data.currency;
});
scope.isAccountClose = true;
scope.showNoteField = true;
scope.retrievePreMatureAmount = false;
scope.showPaymentType=true;
return;
}
}
resourceFactory.recurringDepositAccountResource.save(params, \
this.formData, function (data) {
location.path('/viewrecurringdepositaccount/' + \
data.savingsId); });
}
};
}
});
mifosX.ng.application.controller('RecurringDepositAccountActionsController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.RecurringDepositAccountActionsController]).run(function ($log) { \
$log.info("RecurringDepositAccountActionsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewRecurringDepositAccountDetailsController: function (scope, routeParams, \
resourceFactory, paginatorService, location, route, dateFilter,$uibModal) { \
scope.isDebit = function (savingsTransactionType) {
return savingsTransactionType.withdrawal == true || \
savingsTransactionType.feeDeduction == true || savingsTransactionType.withholdTax == \
true; };
/***
* we are using orderBy(https://docs.angularjs.org/api/ng/filter/orderBy) \
filter to sort fields in ui
* api returns dates in array format[yyyy, mm, dd], converting the array \
of dates to date object
* @param dateFieldName
*/
scope.convertDateArrayToObject = function(dateFieldName){
for(var i in scope.savingaccountdetails.transactions){
scope.savingaccountdetails.transactions[i][dateFieldName] = new \
Date(scope.savingaccountdetails.transactions[i].date); }
};
scope.clickEvent = function (eventName, accountId) {
eventName = eventName || "";
switch (eventName) {
case "modifyapplication":
location.path('/editrecurringdepositaccount/' + accountId);
break;
case "approve":
location.path('/recurringdepositaccount/' + accountId + \
'/approve'); break;
case "reject":
location.path('/recurringdepositaccount/' + accountId + \
'/reject'); break;
case "withdrawnbyclient":
location.path('/recurringdepositaccount/' + accountId + \
'/withdrawnByApplicant'); break;
case "delete":
\
resourceFactory.recurringDepositAccountResource.delete({accountId: accountId}, {}, \
function (data) {
var destination = '/viewgroup/' + data.groupId;
if (data.clientId) destination = '/viewclient/' + \
data.clientId; location.path(destination);
});
break;
case "undoapproval":
location.path('/recurringdepositaccount/' + accountId + \
'/undoapproval'); break;
case "activate":
location.path('/recurringdepositaccount/' + accountId + \
'/activate'); break;
case "deposit":
location.path('/recurringdepositaccount/' + accountId + \
'/deposit'); break;
case "withdraw":
location.path('/recurringdepositaccount/' + accountId + \
'/withdrawal'); break;
case "addcharge":
location.path('/recurringdepositaccount/' + accountId + \
'/charges'); break;
case "calculateInterest":
\
resourceFactory.recurringDepositAccountResource.save({accountId: accountId, command: \
'calculateInterest'}, {}, function (data) { route.reload();
});
break;
case "postInterest":
\
resourceFactory.recurringDepositAccountResource.save({accountId: accountId, command: \
'postInterest'}, {}, function (data) { route.reload();
});
break;
/*case "applyAnnualFees":
location.path('/savingaccountcharge/' + accountId + \
'/applyAnnualFees/' + scope.annualChargeId); break;
case "transferFunds":
if (scope.savingaccountdetails.clientId) {
location.path('/accounttransfers/fromsavings/' + \
accountId); }
break;*/
case "close":
location.path('/recurringdepositaccount/' + accountId + \
'/close'); break;
case "prematureClose":
location.path('/recurringdepositaccount/' + accountId + \
'/prematureClose'); break;
case "enableWithHoldTax":
var changes = {
withHoldTax:true
};
resourceFactory.savingsResource.update({accountId: accountId, \
command: 'updateWithHoldTax'}, changes, function (data) { route.reload();
});
break;
case "disableWithHoldTax":
var changes = {
withHoldTax:false
};
resourceFactory.savingsResource.update({accountId: accountId, \
command: 'updateWithHoldTax'}, changes, function (data) { route.reload();
});
break;
}
};
resourceFactory.recurringDepositAccountResource.get({accountId: \
routeParams.id, associations: 'all'}, function (data) { scope.savingaccountdetails = \
data; scope.savingaccountdetails.availableBalance = \
scope.savingaccountdetails.enforceMinRequiredBalance?(scope.savingaccountdetails.summary.accountBalance \
- scope.savingaccountdetails.minRequiredOpeningBalance):scope.savingaccountdetails.summary.accountBalance;
scope.convertDateArrayToObject('date');
scope.chartSlabs = \
scope.savingaccountdetails.accountChart.chartSlabs; scope.isprematureAllowed = \
data.maturityDate != null; scope.status = data.status.value;
scope.heading = (!scope.savingaccountdetails.status.rejected && \
!scope.savingaccountdetails.status.submittedAndPendingApproval)?'label.heading.interestchart':'label.heading.summary';
if (scope.status == "Submitted and pending approval" || scope.status \
== "Active" || scope.status == "Approved") { scope.choice = true;
}
scope.chargeAction = data.status.value == "Submitted and pending \
approval" ? true : false; if (scope.savingaccountdetails.charges) {
scope.charges = scope.savingaccountdetails.charges;
scope.chargeTableShow = true;
} else {
scope.chargeTableShow = false;
}
if (data.status.value == "Submitted and pending approval") {
scope.buttons = { singlebuttons: [
{
name: "button.modifyapplication",
icon: "fa fa-pencil "
},
{
name: "button.approve",
icon: "fa fa-check"
}
],
options: [
{
name: "button.reject"
},
{
name: "button.withdrawnbyclient"
},
{
name: "button.addcharge"
},
{
name: "button.delete"
}
]
};
}
if (data.status.value == "Approved") {
scope.buttons = { singlebuttons: [
{
name: "button.undoapproval",
icon: "fa fa-undo"
},
{
name: "button.activate",
icon: "fa fa-check"
}
]
};
}
if (data.status.value == "Active") {
scope.buttons = { singlebuttons: [
{
name: "button.deposit",
icon: "fa fa-arrow-right"
},
{
name: "button.prematureClose",
icon: "fa fa-arrow-left"
},
{
name: "button.calculateInterest",
icon: "fa fa-table"
}
],
options: [
{
name: "button.postInterest"
},
{
name: "button.addcharge"
}
]
};
if (data.allowWithdrawal == true) {
scope.buttons.options.push({
name: "button.withdraw"
});
}
if (data.charges) {
for (var i in scope.charges) {
if (scope.charges[i].name == "Annual fee - INR") {
scope.buttons.options.push({
name: "button.applyAnnualFees"
});
scope.annualChargeId = scope.charges[i].id;
}
}
}
if(!scope.isprematureAllowed){
scope.buttons.singlebuttons[1] = {
name: "button.close",
icon: "fa fa-arrow-right"
};
}
if(data.taxGroup){
if(data.withHoldTax){
scope.buttons.options.push({
name: "button.disableWithHoldTax",
taskPermissionName:"UPDATEWITHHOLDTAX_SAVINGSACCOUNT"
});
}else{
scope.buttons.options.push({
name: "button.enableWithHoldTax",
taskPermissionName:"UPDATEWITHHOLDTAX_SAVINGSACCOUNT"
});
}
}
}
if (data.status.value == "Matured") {
scope.buttons = { singlebuttons: [
{
name: "button.close",
icon: "fa fa-arrow-right"
},
{
name: "button.calculateInterest",
icon: "fa fa-table"
},
{
name: "button.postInterest",
icon: "fa fa-table"
}
],
options: [
{
name: "button.addcharge"
}
]
};
if (data.clientId) {
scope.buttons.options.push({
name: "button.transferFunds"
});
}
if (data.charges) {
for (var i in scope.charges) {
if (scope.charges[i].name == "Annual fee - INR") {
scope.buttons.options.push({
name: "button.applyAnnualFees"
});
scope.annualChargeId = scope.charges[i].id;
}
}
}
}
/*var annualdueDate = [];
annualdueDate = data.annualFee.feeOnMonthDay;
annualdueDate.push(2013);
scope.annualdueDate = new Date(annualdueDate);*/
resourceFactory.standingInstructionTemplateResource.get({fromClientId: \
scope.savingaccountdetails.clientId,fromAccountType: 2,fromAccountId: \
routeParams.id},function (response) { scope.standinginstruction = response;
scope.searchTransaction();
});
});
var fetchFunction = function (offset, limit, callback) {
var params = {};
params.offset = offset;
params.limit = limit;
params.locale = scope.optlang.code;
params.fromAccountId = routeParams.id;
params.fromAccountType = 2;
params.clientId = scope.savingaccountdetails.clientId;
params.clientName = scope.savingaccountdetails.clientName;
params.dateFormat = scope.df;
resourceFactory.standingInstructionResource.search(params, callback);
};
scope.searchTransaction = function () {
scope.displayResults = true;
scope.instructions = paginatorService.paginate(fetchFunction, 14);
scope.isCollapsed = false;
};
scope.deletestandinginstruction = function (id) {
$uibModal.open({
templateUrl: 'delInstruction.html',
controller: DelInstructionCtrl,
resolve: {
ids: function () {
return id;
}
}
});
};
var DelInstructionCtrl = function ($scope, $uibModalInstance, ids) {
$scope.delete = function () {
resourceFactory.standingInstructionResource.cancel({standingInstructionId: \
ids}, function (data) { scope.searchTransaction();
$uibModalInstance.close('delete');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
resourceFactory.DataTablesResource.getAllDataTables({apptable: \
'm_savings_account'}, function (data) { scope.savingdatatables = data;
});
scope.routeTo = function (accountId, transactionId, accountTransfer, \
transferId) { if (accountTransfer) {
location.path('/viewaccounttransfers/' + transferId);
} else {
location.path('/viewrecurringdepositaccounttrxn/' + accountId + \
'/' + transactionId); }
};
scope.dataTableChange = function (datatable) {
resourceFactory.DataTablesResource.getTableDetails({datatablename: \
datatable.registeredTableName,
entityId: routeParams.id, genericResultSet: 'true'}, function \
(data) { scope.datatabledetails = data;
scope.datatabledetails.isData = data.data.length > 0 ? true : \
false;
scope.datatabledetails.isMultirow = \
data.columnHeaders[0].columnName == "id" ? true : false; scope.singleRow = [];
for (var i in data.columnHeaders) {
if (scope.datatabledetails.columnHeaders[i].columnCode) {
for (var j in \
scope.datatabledetails.columnHeaders[i].columnValues) { for (var k in data.data) {
if (data.data[k].row[i] == \
scope.datatabledetails.columnHeaders[i].columnValues[j].id) {
data.data[k].row[i] = \
scope.datatabledetails.columnHeaders[i].columnValues[j].value; }
}
}
}
}
if (scope.datatabledetails.isData) {
for (var i in data.columnHeaders) {
if (!scope.datatabledetails.isMultirow) {
var row = {};
row.key = data.columnHeaders[i].columnName;
row.value = data.data[0].row[i];
scope.singleRow.push(row);
}
}
}
});
};
scope.deleteAll = function (apptableName, entityId) {
resourceFactory.DataTablesResource.delete({datatablename: \
apptableName, entityId: entityId, genericResultSet: 'true'}, {}, function (data) { \
route.reload(); });
};
scope.modifyTransaction = function (accountId, transactionId) {
location.path('/recurringdepositaccount/' + accountId + \
'/modifytransaction?transactionId=' + transactionId); };
scope.incentives = function(index){
$uibModal.open({
templateUrl: 'incentive.html',
controller: IncentiveCtrl,
resolve: {
chartSlab: function () {
return \
scope.savingaccountdetails.accountChart.chartSlabs[index]; }
}
});
};
var IncentiveCtrl = function ($scope, $uibModalInstance, chartSlab) {
$scope.chartSlab = chartSlab;
_.each($scope.chartSlab.incentives, function (incentive) {
if(!incentive.attributeValueDesc){
incentive.attributeValueDesc = incentive.attributeValue;
}
});
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.transactionSort = {
column: 'date',
descending: true
};
scope.changeTransactionSort = function(column) {
var sort = scope.transactionSort;
if (sort.column == column) {
sort.descending = !sort.descending;
} else {
sort.column = column;
sort.descending = true;
}
};
}
});
mifosX.ng.application.controller('ViewRecurringDepositAccountDetailsController', \
['$scope', '$routeParams', 'ResourceFactory', 'PaginatorService', '$location', \
'$route', 'dateFilter','$uibModal', \
mifosX.controllers.ViewRecurringDepositAccountDetailsController]).run(function ($log) \
{
$log.info("ViewRecurringDepositAccountDetailsController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewRecurringDepositTransactionController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.flag = false;
resourceFactory.recurringDepositTrxnsResource.get({savingsId: \
routeParams.accountId, transactionId: routeParams.transactionId}, function (data) { \
scope.transaction = data;
if (scope.transaction.transactionType.value == 'Transfer' || \
scope.transaction.reversed == 'true') { scope.flag = true;
}
});
scope.undoTransaction = function (accountId, transactionId) {
var params = {savingsId: accountId, transactionId: transactionId, \
command: 'undo'};
var formData = {dateFormat: scope.df, locale: scope.optlang.code, \
transactionAmount: 0};
formData.transactionDate = dateFilter(new Date(), scope.df);
resourceFactory.recurringDepositTrxnsResource.save(params, formData, \
function (data) {
location.path('/viewrecurringdepositaccount/' + data.savingsId);
});
};
}
});
mifosX.ng.application.controller('ViewRecurringDepositTransactionController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.ViewRecurringDepositTransactionController]).run(function \
($log) {
$log.info("ViewRecurringDepositTransactionController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddRoleController: function (scope, routeParams, location, resourceFactory) {
scope.formData = {};
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'all', template: 'true'}, function (data) { scope.group = data;
scope.clients = data.clientMembers;
scope.roles = data.availableRoles;
scope.formData.clientId = data.clientMembers[0].id;
scope.formData.role = data.availableRoles[0].id;
});
scope.addrole = function () {
resourceFactory.groupResource.save({groupId: routeParams.id, command: \
'assignRole'}, this.formData, function (data) { location.path('/viewgroup/' + \
data.groupId); });
};
}
});
mifosX.ng.application.controller('AddRoleController', ['$scope', '$routeParams', \
'$location', 'ResourceFactory', mifosX.controllers.AddRoleController]).run(function \
($log) { $log.info("AddRoleController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AssignStaffController: function (scope, resourceFactory, location, \
routeParams) { scope.group = [];
scope.staff = [];
scope.formData = {};
resourceFactory.assignStaffResource.get({groupOrCenter: \
routeParams.entityType, groupOrCenterId: routeParams.id, template: \
'true',staffInSelectedOfficeOnly:true}, function (data) { scope.group = data;
scope.staffs = data.staffOptions;
scope.formData.staffId = data.staffOptions[0].id;
});
scope.assignStaff = function () {
if (routeParams.entityType == "groups") {
scope.r = "viewgroup/";
}
else if (routeParams.entityType == "centers") {
scope.r = "viewcenter/";
}
resourceFactory.assignStaffResource.save({groupOrCenterId: \
routeParams.id, command: 'assignStaff'}, this.formData, function (data) { \
location.path(scope.r + data.groupId); });
};
}
});
mifosX.ng.application.controller('AssignStaffController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', \
mifosX.controllers.AssignStaffController]).run(function ($log) { \
$log.info("AssignStaffController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AttachMeetingController: function (scope, resourceFactory, location, \
routeParams, dateFilter) {
resourceFactory.attachMeetingResource.get({groupOrCenter: \
routeParams.entityType, groupOrCenterId: routeParams.id, templateSource: \
'template'}, function (data) { scope.entityType = routeParams.entityType;
scope.groupOrCenterId = routeParams.id;
scope.groupCenterData = data;
scope.restrictDate = new Date();
scope.first = {};
scope.periodValue = "day(s)";
scope.repeatsOptions = [
{id: 1, value: "daily"},
{id: 2, value: "weekly"},
{id: 3, value: "monthly"},
{id: 4, value: "yearly"}
];
scope.repeatsEveryOptions = ["1", "2", "3"];
//to display default in select boxes
scope.formData = {
repeating: 'true',
frequency: scope.repeatsOptions[0].id,
interval: '1'
}
});
scope.selectedPeriod = function (period) {
if (period == 1) {
scope.repeatsEveryOptions = ["1", "2", "3"];
scope.periodValue = "day(s)"
}
if (period == 2) {
scope.repeatsEveryOptions = ["1", "2", "3","4","5"];
scope.formData.repeatsOnDay = '1';
scope.periodValue = "week(s)";
scope.repeatsOnOptions = [
{name: "MON", value: "1"},
{name: "TUE", value: "2"},
{name: "WED", value: "3"},
{name: "THU", value: "4"},
{name: "FRI", value: "5"},
{name: "SAT", value: "6"},
{name: "SUN", value: "7"}
]
}
if (period == 3) {
scope.periodValue = "month(s)";
scope.repeatsEveryOptions = ["1", "2", "3", "4", "5", "6", "7", \
"8", "9", "10", "11"]; }
if (period == 4) {
scope.periodValue = "year(s)";
scope.repeatsEveryOptions = ["1", "2", "3"];
}
}
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.startDate = reqDate;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.typeId = "1";
if (routeParams.entityType == "groups") {
this.formData.title = "groups_" + routeParams.id + \
"_CollectionMeeting"; scope.r = "viewgroup/";
}
else if (routeParams.entityType == "centers") {
this.formData.title = "centers_" + routeParams.id + \
"_CollectionMeeting"; scope.r = "viewcenter/";
}
resourceFactory.attachMeetingResource.save({groupOrCenter: \
routeParams.entityType, groupOrCenterId: routeParams.id}, this.formData, function \
(data) { location.path(scope.r + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('AttachMeetingController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.AttachMeetingController]).run(function ($log) { \
$log.info("AttachMeetingController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportGroupController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + '/groups/downloadtemplate' + \
'?tenantIdentifier=' + $rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: "groups"}, \
function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/groups/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportGroupController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportGroupController]).run(function ($log) { \
$log.info("BulkImportGroupController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
CloseGroupController: function (scope, routeParams, route, location, \
resourceFactory, dateFilter) { scope.group = [];
scope.template = [];
scope.first = {};
scope.first.date = new Date();
scope.restrictDate = new Date();
scope.formData = {};
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'all'}, function (data) { scope.group = data;
});
resourceFactory.groupTemplateResource.get({command: 'close'}, function \
(data) { scope.template = data;
if(data.closureReasons[0]) {
scope.formData.closureReasonId = data.closureReasons[0].id;
}
});
scope.closeGroup = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.closureDate = reqDate;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.groupResource.save({groupId: routeParams.id, command: \
'close'}, this.formData, function (data) { location.path('/viewgroup/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('CloseGroupController', ['$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', 'dateFilter', \
mifosX.controllers.CloseGroupController]).run(function ($log) { \
$log.info("CloseGroupController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
CreateGroupController: function ($q, scope, resourceFactory, location, \
dateFilter, routeParams, WizardHandler) { scope.offices = [];
scope.staffs = [];
scope.data = {};
scope.choice = 0;
scope.first = {};
scope.first.submitondate = new Date();
scope.first.date = new Date();
scope.restrictDate = new Date();
scope.addedClients = [];
scope.available = [];
scope.added = [];
scope.formData = {};
scope.formDat = {};
scope.formData.clientMembers = [];
scope.forceOffice = null;
scope.datatables = [];
scope.noOfTabs = 1;
scope.step = '-';
scope.formData.datatables = [];
scope.formDat.datatables = [];
scope.tf = "HH:mm";
scope.clientData = {};
var requestParams = {orderBy: 'name', sortOrder: 'ASC', \
staffInSelectedOfficeOnly: true}; if (routeParams.centerId) {
requestParams.centerId = routeParams.centerId;
}
resourceFactory.groupTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
scope.datatables = data.datatables;
if (!_.isUndefined(scope.datatables) && scope.datatables.length > 0) \
{ scope.noOfTabs = scope.datatables.length + 1;
angular.forEach(scope.datatables, function (datatable, index) {
scope.updateColumnHeaders(datatable.columnHeaderData);
angular.forEach(datatable.columnHeaderData, function \
(colHeader, i) {
if (_.isEmpty(scope.formDat.datatables[index])) {
scope.formDat.datatables[index] = {data: {}};
}
if (_.isEmpty(scope.formData.datatables[index])) {
scope.formData.datatables[index] = {
registeredTableName: \
datatable.registeredTableName, data: {locale: scope.optlang.code}
};
}
if (datatable.columnHeaderData[i].columnDisplayType == \
'DATETIME') {
\
scope.formDat.datatables[index].data[datatable.columnHeaderData[i].columnName] = {}; \
} });
});
}
if(routeParams.officeId) {
scope.formData.officeId = routeParams.officeId;
for(var i in data.officeOptions) {
if(data.officeOptions[i].id == routeParams.officeId) {
scope.forceOffice = data.officeOptions[i];
break;
}
}
}
if(routeParams.groupId) {
if(typeof data.staffId !== "undefined") {
scope.formData.staffId = data.staffId;
}
}
});
scope.updateColumnHeaders = function(columnHeaderData) {
var colName = columnHeaderData[0].columnName;
if (colName == 'id') {
columnHeaderData.splice(0, 1);
}
colName = columnHeaderData[0].columnName;
if (colName == 'client_id' || colName == 'office_id' || colName == \
'group_id' || colName == 'center_id' || colName == 'loan_id' || colName == \
'savings_account_id') { columnHeaderData.splice(0, 1);
}
};
scope.clientOptions = function(value){
var deferred = $q.defer();
resourceFactory.clientResource.getAllClientsWithoutLimit({displayName: \
value, orderBy : 'displayName', officeId : scope.formData.officeId, sortOrder : \
'ASC', orphansOnly : true}, function (data) { deferred.resolve(data.pageItems);
});
return deferred.promise;
};
scope.viewClient = function (item) {
scope.client = item;
};
scope.add = function () {
if(scope.clientData.available != ""){
var temp = {};
temp.id = scope.clientData.available.id;
temp.displayName = scope.clientData.available.displayName;
scope.addedClients.push(temp);
}
};
scope.sub = function (id) {
for (var i = 0; i < scope.addedClients.length; i++) {
if (scope.addedClients[i].id == id) {
scope.addedClients.splice(i, 1);
break;
}
}
};
scope.changeOffice = function (officeId) {
scope.addedClients = [];
scope.clientData.available = [];
resourceFactory.groupTemplateResource.get({staffInSelectedOfficeOnly: \
false, officeId: officeId,staffInSelectedOfficeOnly:true }, function (data) {
scope.staffs = data.staffOptions;
});
};
scope.setChoice = function () {
if (this.formData.active) {
scope.choice = 1;
}
else if (!this.formData.active) {
scope.choice = 0;
}
};
if(routeParams.centerId) {
scope.cancel = '#/viewcenter/' + routeParams.centerId
scope.centerid = routeParams.centerId;
}else {
scope.cancel = "#/groups"
}
//return input type
scope.fieldType = function (type) {
var fieldType = "";
if (type) {
if (type == 'CODELOOKUP' || type == 'CODEVALUE') {
fieldType = 'SELECT';
} else if (type == 'DATE') {
fieldType = 'DATE';
} else if (type == 'DATETIME') {
fieldType = 'DATETIME';
} else if (type == 'BOOLEAN') {
fieldType = 'BOOLEAN';
} else {
fieldType = 'TEXT';
}
}
return fieldType;
};
scope.submit = function () {
// if (WizardHandler.wizard().getCurrentStep() != scope.noOfTabs) {
// WizardHandler.wizard().next();
// return;
// }
for (var i in scope.addedClients) {
scope.formData.clientMembers[i] = scope.addedClients[i].id;
}
if (this.formData.active) {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.activationDate = reqDate;
}
if (routeParams.centerId) {
this.formData.centerId = routeParams.centerId;
}
if (routeParams.officeId) {
this.formData.officeId = routeParams.officeId;
}
if (scope.first.submitondate) {
reqDat = dateFilter(scope.first.submitondate, scope.df);
this.formData.submittedOnDate = reqDat;
}
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.active = this.formData.active || false;
if (!_.isUndefined(scope.datatables) && scope.datatables.length > 0) \
{
angular.forEach(scope.datatables, function (datatable, index) {
scope.columnHeaders = datatable.columnHeaderData;
angular.forEach(scope.columnHeaders, function (colHeader, i) \
{ scope.dateFormat = scope.df + " " + scope.tf
if (scope.columnHeaders[i].columnDisplayType == 'DATE') {
if \
(!_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName])) \
{ scope.formData.datatables[index].data[scope.columnHeaders[i].columnName] = \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName], \
scope.dateFormat);
scope.formData.datatables[index].data.dateFormat \
= scope.dateFormat; }
} else if (scope.columnHeaders[i].columnDisplayType == \
'DATETIME') { if (!_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].date) \
&& !_.isUndefined(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].time)) \
{ scope.formData.datatables[index].data[scope.columnHeaders[i].columnName] = \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].date, \
scope.df)
+ " " + \
dateFilter(scope.formDat.datatables[index].data[scope.columnHeaders[i].columnName].time, \
scope.tf);
scope.formData.datatables[index].data.dateFormat \
= scope.dateFormat; }
}
});
});
} else {
delete scope.formData.datatables;
}
resourceFactory.groupResource.save(this.formData, function (data) {
location.path('/viewgroup/' + data.resourceId);
});
};
}
});
mifosX.ng.application.controller('CreateGroupController', ['$q', '$scope', \
'ResourceFactory', '$location', 'dateFilter', '$routeParams', 'WizardHandler', \
mifosX.controllers.CreateGroupController]).run(function ($log) { \
$log.info("CreateGroupController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditGroupController: function (scope, resourceFactory, location, routeParams, \
dateFilter) { scope.first = {};
scope.managecode = routeParams.managecode;
scope.restrictDate = new Date();
scope.entityformData = {};
scope.entityformData.datatables={};
scope.submittedDatatables = [];
var submitStatus = [];
scope.RequestEntities = function(entity,status){
resourceFactory.entityDatatableChecksResource.getAll({limit:-1},function \
(response) {
scope.entityDatatableChecks = _.filter(response.pageItems , \
function(datatable){
var AllTables = (datatable.entity == entity && \
datatable.status.value == status); return AllTables;
});
scope.entityDatatableChecks = \
_.pluck(scope.entityDatatableChecks,'datatableName'); scope.datatables = [];
var k=0;
_.each(scope.entityDatatableChecks,function(entitytable) {
\
resourceFactory.DataTablesResource.getTableDetails({datatablename:entitytable,entityId: \
routeParams.id, genericResultSet: 'true'}, function (data) { \
data.registeredTableName = entitytable;
var colName = data.columnHeaders[0].columnName;
if (colName == 'id') {
data.columnHeaders.splice(0, 1);
}
colName = data.columnHeaders[0].columnName;
if (colName == 'client_id' || colName == 'office_id' || \
colName == 'group_id' || colName == 'center_id' || colName == 'loan_id' || colName == \
'savings_account_id') { data.columnHeaders.splice(0, 1);
scope.isCenter = (colName == 'center_id') ? true : \
false; }
data.noData = (data.data.length == 0);
if(data.noData){
scope.datatables.push(data);
scope.entityformData.datatables[k] = {data:{}};
submitStatus[k] = "save";
_.each(data.columnHeaders,function(Header){
\
scope.entityformData.datatables[k].data[Header.columnName] = ""; });
k++;
scope.isEntityDatatables = true;
}
});
});
});
};
function asyncLoop(iterations, func, callback) {
var index = 0;
var done = false;
var loop = {
next: function() {
if (done) {
return;
}
if (index < iterations) {
index++;
func(loop);
} else {
done = true;
callback();
}
},
iteration: function() {
return index - 1;
},
break: function() {
done = true;
}
};
loop.next();
return loop;
}
scope.fieldType = function (type) {
var fieldType = "";
if (type) {
if (type == 'CODELOOKUP' || type == 'CODEVALUE') {
fieldType = 'SELECT';
} else if (type == 'DATE') {
fieldType = 'DATE';
} else if (type == 'DATETIME') {
fieldType = 'DATETIME';
} else if (type == 'BOOLEAN') {
fieldType = 'BOOLEAN';
} else {
fieldType = 'TEXT';
}
}
return fieldType;
};
scope.RequestEntities('m_group','ACTIVATE');
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'clientMembers', template: 'true',staffInSelectedOfficeOnly:true}, function (data) { \
scope.editGroup = data; scope.formData = {
name: data.name,
externalId: data.externalId,
staffId: data.staffId
};
if (data.activationDate) {
var actDate = dateFilter(data.activationDate, scope.df);
scope.first.date = new Date(actDate);
}
});
resourceFactory.groupResource.get({groupId: routeParams.id}, function \
(data) { if (data.timeline.submittedOnDate) {
scope.mindate = new Date(data.timeline.submittedOnDate);
}
});
scope.updateGroup = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.activationDate = reqDate;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.groupResource.update({groupId: routeParams.id}, \
this.formData, function (data) { location.path('/viewgroup/' + routeParams.id);
});
};
scope.submitDatatable = function(){
if(scope.datatables) {
asyncLoop(Object.keys(scope.entityformData.datatables).length,function(loop){
var cnt = loop.iteration();
var formData = scope.entityformData.datatables[cnt];
formData.registeredTableName = \
scope.datatables[cnt].registeredTableName;
var params = {
datatablename: formData.registeredTableName,
entityId: routeParams.id,
genericResultSet: 'true'
};
angular.extend(formData.data,{dateFormat: scope.df, locale: \
scope.optlang.code});
_.each(formData.data, function (columnHeader) {
if (columnHeader.dateType) {
columnHeader = dateFilter(columnHeader.dateType.date, \
params.dateFormat); }
else if (columnHeader.dateTimeType) {
columnHeader = \
dateFilter(columnHeader.columnName.date, scope.df) + " " + \
dateFilter(columnHeader.columnName.time, scope.tf); }
});
var action = submitStatus[cnt];
resourceFactory.DataTablesResource[action](params, \
formData.data, function (data) {
submitStatus[cnt] = "update";
\
scope.submittedDatatables.push(scope.datatables[cnt].registeredTableName); \
loop.next();
},function(){
\
rootScope.errorDetails[0].push({datatable:scope.datatables[cnt].registeredTableName});
loop.break();
});
},function(){
scope.activate();
});
}
else{
scope.activate();
}
};
scope.activate = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
var newActivation = new Object();
newActivation.activationDate = reqDate;
newActivation.locale = scope.optlang.code;
newActivation.dateFormat = scope.df;
resourceFactory.groupResource.save({groupId: routeParams.id, command: \
'activate'}, newActivation, function (data) { location.path('/viewgroup/' + \
routeParams.id); });
};
}
});
mifosX.ng.application.controller('EditGroupController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.EditGroupController]).run(function ($log) { \
$log.info("EditGroupController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditMeetingBasedOnMeetingDatesController: function (scope, resourceFactory, \
location, routeParams, dateFilter) { scope.formData = {};
scope.formData.presentMeetingDate = {};
scope.formData.newMeetingDate = {};
resourceFactory.attachMeetingResource.get({groupOrCenter: \
routeParams.entityType, groupOrCenterId: routeParams.groupOrCenterId,
templateSource: routeParams.calendarId, template: 'true'}, function \
(data) { scope.entityType = routeParams.entityType;
scope.groupOrCenterId = routeParams.groupOrCenterId;
scope.calendarData = data;
scope.restrictDate = new Date();
scope.formData = {};
scope.presentmeetingdates = [];
for(var i in data.nextTenRecurringDates){
scope.presentmeetingdates.push(dateFilter(new \
Date(data.nextTenRecurringDates[i]), scope.df)); }
});
scope.submit = function () {
this.formData.reschedulebasedOnMeetingDates = true;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.presentMeetingDate = \
dateFilter(this.formData.presentMeetingDate, scope.df);
this.formData.newMeetingDate = \
dateFilter(this.formData.newMeetingDate, scope.df);
resourceFactory.attachMeetingResource.update({groupOrCenter: \
routeParams.entityType,
groupOrCenterId: routeParams.groupOrCenterId, templateSource: \
routeParams.calendarId}, this.formData, function (data) { var destURI = "";
if (routeParams.entityType == "groups") {
destURI = "viewgroup/" + routeParams.groupOrCenterId;
}
else if (routeParams.entityType == "centers") {
destURI = "viewcenter/" + routeParams.groupOrCenterId;
}
location.path(destURI);
});
};
}
});
mifosX.ng.application.controller('EditMeetingBasedOnMeetingDatesController', \
['$scope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.EditMeetingBasedOnMeetingDatesController]).run(function ($log) { \
$log.info("EditMeetingBasedOnMeetingDatesController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditMeetingController: function (scope, resourceFactory, location, \
routeParams, dateFilter) { scope.formData = {};
resourceFactory.attachMeetingResource.get({groupOrCenter: \
routeParams.entityType, groupOrCenterId: routeParams.groupOrCenterId,
templateSource: routeParams.calendarId, template: 'true'}, function \
(data) { scope.entityType = routeParams.entityType;
scope.calendarId = routeParams.calendarId;
scope.groupOrCenterId = routeParams.groupOrCenterId;
scope.calendarData = data;
scope.restrictDate = new Date();
scope.first = {date: new Date(data.startDate)};
scope.repeatsOptions = [
{id: 1, value: "daily"},
{id: 2, value: "weekly"},
{id: 3, value: "monthly"},
{id: 4, value: "yearly"}
];
scope.repeatsEveryOptions = [1, 2, 3];
scope.selectedPeriod(scope.calendarData.frequency.id);
//to display default in select boxes
scope.formData = {
repeating: scope.calendarData.repeating,
frequency: scope.calendarData.frequency.id,
interval: Math.abs(scope.calendarData.interval)
}
for(var i in scope.repeatsEveryOptions){
if (scope.formData.interval == scope.repeatsEveryOptions[i]){
scope.formData.interval = scope.repeatsEveryOptions[i];
}
}
//update interval option
for (var i in scope.repeatsEveryOptions) {
if (scope.repeatsEveryOptions[i] == scope.calendarData.interval) \
{
scope.formData.interval = scope.repeatsEveryOptions[i];
}
}
//update radio button option
if (scope.formData.frequency == 2) {
scope.formData.repeatsOnDay = scope.calendarData.repeatsOnDay.id;
}
});
scope.selectedPeriod = function (period) {
if (period == 1) {
scope.repeatsEveryOptions = ["1", "2", "3"];
scope.periodValue = "day(s)"
}
if (period == 2) {
scope.repeatsEveryOptions = ["1", "2", "3","4","5"];
scope.formData.repeatsOnDay = '1';
scope.periodValue = "week(s)";
scope.repeatsOnOptions = [
{name: "MON", value: "1"},
{name: "TUE", value: "2"},
{name: "WED", value: "3"},
{name: "THU", value: "4"},
{name: "FRI", value: "5"},
{name: "SAT", value: "6"},
{name: "SUN", value: "7"}
]
}
if (period == 3) {
scope.periodValue = "month(s)";
scope.repeatsEveryOptions = ["1", "2", "3", "4", "5", "6", "7", \
"8", "9", "10", "11"]; }
if (period == 4) {
scope.periodValue = "year(s)";
scope.repeatsEveryOptions = ["1", "2", "3"];
}
}
scope.submit = function () {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.startDate = reqDate;
this.formData.title = scope.calendarData.title;
this.formData.locale = scope.optlang.code;
this.formData.repeating = true;
this.formData.dateFormat = scope.df;
this.formData.typeId = "1";
if (this.formData.interval < 0) {
scope.formData.interval = Math.abs(this.formData.interval);
}
resourceFactory.attachMeetingResource.update({groupOrCenter: \
routeParams.entityType,
groupOrCenterId: routeParams.groupOrCenterId, templateSource: \
routeParams.calendarId}, this.formData, function (data) { var destURI = "";
if (routeParams.entityType == "groups") {
destURI = "viewgroup/" + routeParams.groupOrCenterId;
}
else if (routeParams.entityType == "centers") {
destURI = "viewcenter/" + routeParams.groupOrCenterId;
}
location.path(destURI);
});
};
}
});
mifosX.ng.application.controller('EditMeetingController', ['$scope', \
'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.EditMeetingController]).run(function ($log) { \
$log.info("EditMeetingController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
GroupAttendanceController: function (scope, resourceFactory, routeParams, \
location, dateFilter) { scope.group = [];
scope.first = {};
scope.first.date = new Date();
scope.formData = {};
scope.clientId = routeParams.clientId;
scope.groupId = routeParams.groupId;
resourceFactory.groupResource.get({groupId: routeParams.groupId, \
associations: 'all'}, function (data) { scope.group = data;
scope.meeting = data.collectionMeetingCalendar;
scope.groupName = scope.group.name;
});
resourceFactory.groupMeetingResource.getMeetingInfo({groupId: \
routeParams.groupId, templateSource: 'template', calenderId: routeParams.calendarId}, \
function (data) { scope.clients = data.clients;
scope.attendanceOptions = data.attendanceTypeOptions;
/*the following code help to display default attendance type is \
'present'*/ for (var i = 0; i < scope.clients.length; i++) {
scope.clients[i].attendanceType = \
data.attendanceTypeOptions[0].id; }
});
scope.attendanceUpdate = function (id) {
var reqDate = dateFilter(scope.first.date, scope.df);
this.formData.clientsAttendance = [];
for (var i = 0; i < scope.clients.length; i++) {
this.formData.clientsAttendance[i] = {clientId: \
scope.clients[i].id, attendanceType: scope.clients[i].attendanceType}; }
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.calendarId = id;
this.formData.meetingDate = reqDate;
resourceFactory.groupMeetingResource.save({groupId: \
routeParams.groupId, calenderId: routeParams.calendarId}, this.formData, function \
(data) { location.path('/viewgroup/' + routeParams.groupId);
});
};
}
});
mifosX.ng.application.controller('GroupAttendanceController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.GroupAttendanceController]).run(function ($log) { \
$log.info("GroupAttendanceController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
GroupController: function (scope, resourceFactory, location) {
scope.groups = [];
scope.actualGroups = [];
scope.searchText = "";
scope.searchResults = [];
scope.showClosed = false;
scope.routeTo = function (id) {
location.path('/viewgroup/' + id);
};
if (!scope.searchCriteria.groups) {
scope.searchCriteria.groups = null;
scope.saveSC();
}
scope.filterText = scope.searchCriteria.groups || '';
scope.onFilter = function () {
scope.searchCriteria.groups = scope.filterText;
scope.saveSC();
};
scope.groupsPerPage = 15;
scope.getResultsPage = function (pageNumber) {
if(scope.searchText){
var startPosition = (pageNumber - 1) * scope.groupsPerPage;
scope.groups = scope.actualGroups.slice(startPosition, \
startPosition + scope.groupsPerPage); return;
}
var items = resourceFactory.groupResource.get({
offset: ((pageNumber - 1) * scope.groupsPerPage),
limit: scope.groupsPerPage,
paged: 'true',
orderBy: 'name',
sortOrder: 'ASC'
}, function (data) {
scope.groups = data.pageItems;
});
}
scope.initPage = function () {
var items = resourceFactory.groupResource.get({
offset: 0,
limit: scope.groupsPerPage,
paged: 'true',
orderBy: 'name',
sortOrder: 'ASC'
}, function (data) {
scope.totalGroups = data.totalFilteredRecords;
scope.groups = data.pageItems;
});
}
scope.initPage();
scope.search = function () {
scope.actualGroups = [];
scope.searchResults = [];
scope.filterText = "";
var searchString = scope.searchText;
searchString = searchString.replace(/(^"|"$)/g, '');
var exactMatch=false;
var n = searchString.localeCompare(scope.searchText);
if(n!=0)
{
exactMatch=true;
}
if(!scope.searchText){
scope.initPage();
} else {
resourceFactory.globalSearch.search({query: searchString, \
resource: "groups",exactMatch: exactMatch}, function (data) { var arrayLength = \
data.length; for (var i = 0; i < arrayLength; i++) {
var result = data[i];
var group = {};
group.status = {};
group.subStatus = {};
if(result.entityType == 'GROUP') {
group.name = result.entityName;
group.id = result.entityId;
group.accountNo = result.entityAccountNo;
group.officeName = result.parentName;
group.status.value = result.entityStatus.value;
group.status.code = result.entityStatus.code;
group.externalId = result.entityExternalId;
scope.actualGroups.push(group);
}
}
var numberOfGroups = scope.actualGroups.length;
scope.totalGroups = numberOfGroups;
scope.groups = scope.actualGroups.slice(0, \
scope.groupsPerPage); });
}
}
}
});
mifosX.ng.application.controller('GroupController', ['$scope', 'ResourceFactory', \
'$location', mifosX.controllers.GroupController]).run(function ($log) { \
$log.info("GroupController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
MemberManageController: function ($q, scope, routeParams, route, location, \
resourceFactory, $uibModal) { scope.group = [];
scope.indexOfClientToBeDeleted = "";
scope.allMembers = [];
scope.viewClient = function (item) {
scope.client = item;
};
scope.clientOptions = function(value){
var deferred = $q.defer();
resourceFactory.clientResource.getAllClientsWithoutLimit({displayName: \
value, orderBy : 'displayName', officeId : scope.group.officeId, sortOrder : 'ASC', \
orphansOnly : true}, function (data) { deferred.resolve(data.pageItems);
});
return deferred.promise;
};
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'clientMembers', template: 'true'}, function (data) { scope.group = data;
if(data.clientMembers) {
scope.allMembers = data.clientMembers;
}
});
scope.add = function () {
if(scope.available != ""){
scope.associate = {};
scope.associate.clientMembers = [];
scope.associate.clientMembers[0] = scope.available.id;
resourceFactory.groupResource.save({groupId: routeParams.id, \
command: 'associateClients'}, scope.associate, function (data) { var temp = {};
temp.id = scope.available.id;
temp.displayName = scope.available.displayName;
scope.allMembers.push(temp);
scope.available = "";
});
}
};
scope.remove = function (index,id) {
scope.indexOfClientToBeDeleted = index;
$uibModal.open({
templateUrl: 'delete.html',
controller: MemberDeleteCtrl
});
scope.disassociate = {};
scope.disassociate.clientMembers = [];
scope.disassociate.clientMembers.push(id);
};
var MemberDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.groupResource.save({groupId: routeParams.id, \
command: 'disassociateClients'}, scope.disassociate, function (data) \
{
scope.allMembers.splice(scope.indexOfClientToBeDeleted, 1);
$uibModalInstance.close('activate');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('MemberManageController', ['$q','$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', '$uibModal', \
mifosX.controllers.MemberManageController]).run(function ($log) { \
$log.info("MemberManageController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
TransferClientsController: function ($q, scope, routeParams, route, location, \
resourceFactory) { scope.group = [];
scope.tempData = [];
scope.selectedClients = [];
scope.selectedMembers = [];
scope.formData = {};
scope.destinationGroup = "";
scope.groupId = routeParams.id;
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'clientMembers'}, function (data) { scope.data = data;
scope.allMembers = data.clientMembers;
});
scope.groups = function(value){
var deferred = $q.defer();
resourceFactory.groupResource.getAllGroups({name : value, orderBy : \
'name', officeId : scope.data.officeId, sortOrder : 'ASC'}, function(data){
scope.group = _.reject(data, function (group) {
return group.id == routeParams.id;
});
deferred.resolve(scope.group);
});
return deferred.promise;
};
scope.addClient = function () {
for (var i in this.availableClients) {
for (var j in scope.allMembers) {
if (scope.allMembers[j].id == this.availableClients) {
var temp = {};
temp.id = this.allMembers[j].id;
temp.displayName = this.allMembers[j].displayName;
temp.accountNo = this.allMembers[j].accountNo;
scope.selectedMembers.push(temp);
scope.allMembers.splice(j, 1);
}
}
}
};
scope.removeClient = function () {
for (var i in this.selectedClients) {
for (var j in scope.selectedMembers) {
if (scope.selectedMembers[j].id == this.selectedClients) {
var temp = {};
temp.id = this.selectedMembers[j].id;
temp.displayName = this.selectedMembers[j].displayName;
temp.accountNo = this.selectedMembers[j].accountNo;
scope.allMembers.push(temp);
scope.selectedMembers.splice(j, 1);
}
}
}
};
scope.viewgroup = function (group) {
resourceFactory.groupResource.get({groupId: group.id}, function \
(data) { scope.groupdata = data;
});
scope.view = 1;
};
scope.transfer = function () {
this.formData.locale = scope.optlang.code;
this.formData.clients = [];
this.formData.destinationGroupId = scope.destinationGroup.id;
var temp = new Object();
for (var i = 0; i < scope.selectedMembers.length; i++) {
temp = {id: this.selectedMembers[i].id};
this.formData.clients.push(temp);
}
this.formData.inheritDestinationGroupLoanOfficer = \
this.formData.inheritDestinationGroupLoanOfficer || false;
resourceFactory.groupResource.save({groupId: routeParams.id, command: \
'transferClients'}, this.formData, function (data) { location.path('/viewgroup/' + \
data.resourceId); });
};
scope.displayNameAndId = function (member){
return ( member.accountNo + " " + member.displayName );
};
}
});
mifosX.ng.application.controller('TransferClientsController', ['$q', '$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory',
mifosX.controllers.TransferClientsController]).run(function ($log) {
$log.info("TransferClientsController initialized");
});
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ViewGroupController: function (scope, routeParams, route, location, \
resourceFactory, dateFilter, $uibModal) { scope.group = [];
scope.template = [];
scope.formData = {};
scope.choice = 0;
scope.staffData = {};
scope.openLoan = true;
scope.openSaving = true;
scope.editMeeting = false;
scope.isGroupMembersAvailable = false;
scope.routeToLoan = function (id) {
location.path('/viewloanaccount/' + id);
};
scope.routeToSaving = function (id) {
location.path('/viewsavingaccount/' + id);
};
scope.routeToMem = function (id) {
location.path('/viewclient/' + id);
};
resourceFactory.groupResource.get({groupId: routeParams.id, associations: \
'all'}, function (data) { scope.group = data;
if(scope.group.clientMembers){
scope.isGroupMembersAvailable = \
(scope.group.clientMembers.length>0); }
scope.isClosedGroup = scope.group.status.value == 'Closed';
scope.staffData.staffId = data.staffId;
if(data.collectionMeetingCalendar) {
scope.entityId = data.id;
scope.entityType = \
data.collectionMeetingCalendar.entityType.value;
if(scope.entityType == "GROUPS" && data.hierarchy == "."+ data.id \
+ "." ){ scope.editMeeting = true;
}
}
});
resourceFactory.runReportsResource.get({reportSource: \
'GroupSummaryCounts', genericResultSet: 'false', R_groupId: routeParams.id}, function \
(data) { scope.summary = data[0];
});
resourceFactory.groupAccountResource.get({groupId: routeParams.id}, \
function (data) { scope.groupAccounts = data;
});
resourceFactory.groupNotesResource.getAllNotes({groupId: routeParams.id}, \
function (data) { scope.groupNotes = data;
});
scope.delrole = function (id) {
resourceFactory.groupResource.save({groupId: routeParams.id, command: \
'unassignRole', roleId: id}, {}, function (data) {
resourceFactory.groupResource.get({groupId: routeParams.id}, \
function (data) { route.reload();
});
});
};
scope.deleteGroup = function () {
$uibModal.open({
templateUrl: 'deletegroup.html',
controller: GroupDeleteCtrl
});
};
scope.unassignStaffGroup = function () {
$uibModal.open({
templateUrl: 'groupunassignstaff.html',
controller: GroupUnassignCtrl
});
};
var GroupUnassignCtrl = function ($scope, $uibModalInstance) {
$scope.unassign = function () {
resourceFactory.groupResource.save({groupId: routeParams.id, \
command: 'unassignstaff'}, scope.staffData, function (data) { \
$uibModalInstance.close('unassign'); route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
var GroupDeleteCtrl = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.groupResource.delete({groupId: routeParams.id}, \
{}, function (data) { $uibModalInstance.close('delete');
location.path('/groups');
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.cancel = function (id) {
resourceFactory.groupResource.get({groupId: id}, function (data) {
route.reload();
});
};
scope.viewDataTable = function (registeredTableName,data){
if (scope.datatabledetails.isMultirow) {
location.path("/viewdatatableentry/"+registeredTableName+"/"+scope.group.id+"/"+data.row[0]);
}else{
location.path("/viewsingledatatableentry/"+registeredTableName+"/"+scope.group.id);
}
};
scope.saveNote = function () {
resourceFactory.groupResource.save({groupId: routeParams.id, \
anotherresource: 'notes'}, this.formData, function (data) { var today = new Date();
temp = { id: data.resourceId, note: scope.formData.note, \
createdByUsername: "test", createdOn: today }; scope.groupNotes.push(temp);
scope.formData.note = "";
scope.predicate = '-id';
});
};
scope.isLoanClosed = function (loanaccount) {
if (loanaccount.status.code === "loanStatusType.closed.written.off" \
||
loanaccount.status.code === \
"loanStatusType.closed.obligations.met" ||
loanaccount.status.code === \
"loanStatusType.closed.reschedule.outstanding.amount" ||
loanaccount.status.code === "loanStatusType.withdrawn.by.client" \
||
loanaccount.status.code === "loanStatusType.rejected") {
return true;
} else {
return false;
}
};
scope.setLoan = function () {
if (scope.openLoan) {
scope.openLoan = false
} else {
scope.openLoan = true;
}
};
scope.setSaving = function () {
if (scope.openSaving) {
scope.openSaving = false;
} else {
scope.openSaving = true;
}
};
scope.isSavingClosed = function (savingaccount) {
if (savingaccount.status.code === \
"savingsAccountStatusType.withdrawn.by.applicant" ||
savingaccount.status.code === "savingsAccountStatusType.closed" \
||
savingaccount.status.code === \
"savingsAccountStatusType.rejected") { return true;
} else {
return false;
}
};
scope.isLoanNotClosed = function (loanaccount) {
if (loanaccount.status.code === "loanStatusType.closed.written.off" \
||
loanaccount.status.code === \
"loanStatusType.closed.obligations.met" ||
loanaccount.status.code === \
"loanStatusType.closed.reschedule.outstanding.amount" ||
loanaccount.status.code === "loanStatusType.withdrawn.by.client" \
||
loanaccount.status.code === "loanStatusType.rejected") {
return false;
} else {
return true;
}
};
scope.isSavingNotClosed = function (savingaccount) {
if (savingaccount.status.code === \
"savingsAccountStatusType.withdrawn.by.applicant" ||
savingaccount.status.code === "savingsAccountStatusType.closed" \
||
savingaccount.status.code === \
"savingsAccountStatusType.rejected") { return false;
} else {
return true;
}
};
scope.isActiveMember = function (status) {
if (status == 'clientStatusType.active') {
return true;
} else {
return false;
}
};
resourceFactory.DataTablesResource.getAllDataTables({apptable: \
'm_group'}, function (data) { scope.groupdatatables = data;
});
scope.dataTableChange = function (datatable) {
resourceFactory.DataTablesResource.getTableDetails({datatablename: \
datatable.registeredTableName, entityId: routeParams.id, genericResultSet: 'true'}, \
function (data) { scope.datatabledetails = data;
scope.datatabledetails.isData = data.data.length > 0 ? true : \
false;
scope.datatabledetails.isMultirow = \
data.columnHeaders[0].columnName == "id" ? true : false;
scope.showDataTableAddButton = !scope.datatabledetails.isData || \
scope.datatabledetails.isMultirow;
scope.showDataTableEditButton = scope.datatabledetails.isData && \
!scope.datatabledetails.isMultirow; scope.singleRow = [];
for (var i in data.columnHeaders) {
if (scope.datatabledetails.columnHeaders[i].columnCode) {
for (var j in \
scope.datatabledetails.columnHeaders[i].columnValues) { for (var k in data.data) {
if (data.data[k].row[i] == \
scope.datatabledetails.columnHeaders[i].columnValues[j].id) {
data.data[k].row[i] = \
scope.datatabledetails.columnHeaders[i].columnValues[j].value; }
}
}
}
}
if (scope.datatabledetails.isData) {
for (var i in data.columnHeaders) {
if (!scope.datatabledetails.isMultirow) {
var row = {};
row.key = data.columnHeaders[i].columnName;
row.value = data.data[0].row[i];
scope.singleRow.push(row);
}
}
}
});
};
scope.deleteAll = function (apptableName, entityId) {
resourceFactory.DataTablesResource.delete({datatablename: \
apptableName, entityId: entityId, genericResultSet: 'true'}, {}, function (data) { \
route.reload(); });
};
}
});
mifosX.ng.application.controller('ViewGroupController', ['$scope', \
'$routeParams', '$route', '$location', 'ResourceFactory', 'dateFilter', '$uibModal', \
mifosX.controllers.ViewGroupController]).run(function ($log) { \
$log.info("ViewGroupController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddLoanChargeController: function (scope, resourceFactory, routeParams, \
location, dateFilter) {
scope.charges = [];
scope.formData = {};
scope.isCollapsed = true;
scope.loanId = routeParams.id;
resourceFactory.loanChargeTemplateResource.get({loanId: scope.loanId}, \
function (data) { scope.charges = data.chargeOptions;
});
scope.selectCharge = function(chargeId){
for(var i in scope.charges){
if(scope.charges[i].id == chargeId){
scope.isCollapsed = false;
scope.chargeData = scope.charges[i];
scope.formData.amount = scope.charges[i].amount;
}
}
};
scope.cancel = function () {
location.path('/viewloanaccount/' + scope.loanId);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
if (this.formData.dueDate) {
this.formData.dueDate = dateFilter(this.formData.dueDate, \
scope.df); }
;
resourceFactory.loanResource.save({resourceType: 'charges', loanId: \
scope.loanId}, this.formData, function (data) { location.path('/viewloanaccount/' + \
data.loanId); });
};
}
});
mifosX.ng.application.controller('AddLoanChargeController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.AddLoanChargeController]).run(function ($log) { \
$log.info("AddLoanChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AddLoanCollateralController: function (scope, resourceFactory, routeParams, \
location) {
scope.collateralTypes = [];
scope.formData = {};
scope.loanId = routeParams.id;
resourceFactory.loanCollateralTemplateResource.get({loanId: \
scope.loanId}, function (data) { scope.collateralTypes = \
data.allowedCollateralTypes;
scope.formData.collateralTypeId = data.allowedCollateralTypes[0].id;
});
scope.cancel = function () {
location.path('/viewloanaccount/' + scope.loanId);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
resourceFactory.loanResource.save({resourceType: 'collaterals', \
loanId: scope.loanId}, this.formData, function (data) {
location.path('/loan/' + data.loanId + '/viewcollateral/' + \
data.resourceId); });
};
}
});
mifosX.ng.application.controller('AddLoanCollateralController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.AddLoanCollateralController]).run(function ($log) { \
$log.info("AddLoanCollateralController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
AdjustRepaymentSchedule: function (scope, routeParams, resourceFactory, \
location, route, http, $uibModal, dateFilter, API_VERSION, $sce, $rootScope) { \
scope.formData = {}; scope.enablePrincipal = false ;
scope.enableInstallment = false ;
scope.newinstallments = [] ;
scope.deletedinstallments = [] ;
scope.modifiedinstallments = [] ;
scope.days = [] ;
scope.months = [] ;
var i = 0 ;
//load days in this days array
for(i = 0 ; i < 31; i++) {
scope.days.push(i+1) ;
}
//load months in this months array
for(i = 0 ; i < 12; i++) {
scope.months.push(i+1) ;
}
loadData() ;
function loadData() {
scope.newinstallments.splice(0, scope.newinstallments.length) ;
scope.deletedinstallments.splice(0, scope.deletedinstallments.length) \
;
scope.modifiedinstallments.splice(0, \
scope.modifiedinstallments.length) ; \
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.accountId, associations: 'repaymentSchedule', exclude: 'guarantors'}, \
function (data) { scope.loandetails = data;
scope.decimals = data.currency.decimalPlaces;
var length = scope.loandetails.repaymentSchedule.periods.length ;
var i = 0 ;
while(i < scope.loandetails.repaymentSchedule.periods.length) {
if(scope.loandetails.repaymentSchedule.periods[i].period) {
var date = new \
Date(scope.loandetails.repaymentSchedule.periods[i].dueDate) ;
scope.loandetails.repaymentSchedule.periods[i].dueDate = \
date ;
\
scope.loandetails.repaymentSchedule.periods[i].originalDueDate = \
scope.loandetails.repaymentSchedule.periods[i].dueDate ;
\
scope.loandetails.repaymentSchedule.periods[i].oroginalPrincipalDue = \
scope.loandetails.repaymentSchedule.periods[i].principalDue ; \
scope.loandetails.repaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod \
= scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod; \
scope.loandetails.repaymentSchedule.periods[i].formattedDueDate = \
dateFilter(scope.loandetails.repaymentSchedule.periods[i].dueDate, scope.df); i++ ;
}else {
scope.loandetails.repaymentSchedule.periods.splice(i, 1) \
; }
}
if(scope.loandetails.interestType.code == 'interestType.flat') {
scope.enablePrincipal = true ;
scope.enableInstallment = false ;
}else if(scope.loandetails.interestType.code == \
'interestType.declining.balance') {
if(scope.loandetails.amortizationType.code == \
'amortizationType.equal.principal') { scope.enablePrincipal = true ;
}else if(scope.loandetails.amortizationType.code == \
'amortizationType.equal.installments') { scope.enableInstallment = true ;
}
}else { //invalid case. don't allow anything to be modified
scope.enablePrincipal = false ;
scope.enableInstallment = false ;
}
});
}
scope.pattern = function () {
$uibModal.open({
templateUrl: 'pattern.html',
controller: patternController,
resolve: {
periods: function () {
return scope.loandetails.repaymentSchedule.periods;
},
enablePrincipal: function () {
return scope.enablePrincipal;
},
enableInstallment: function () {
return scope.enableInstallment;
},
months: function () {
return scope.months ;
},
days: function () {
return scope.days ;
}
}
});
};
var patternController = function ($scope, $uibModalInstance, periods, \
enablePrincipal, enableInstallment, months, days) { $scope.periods = periods ;
$scope.enablePrincipal = enablePrincipal;
$scope.enableInstallment = enableInstallment ;
$scope.months = months ;
$scope.days = days ;
$scope.adjustmentData = {} ;
$scope.invaliddaterangeerror = false ;
$scope.submit = function () {
var t1 = $scope.adjustmentData.fromDate.getTime() ;
var t2 = $scope.adjustmentData.fromDate.getTime() ;
if($scope.adjustmentData.toDate) {
t2 = $scope.adjustmentData.toDate.getTime() ;
if(t1 > t2) {
$scope.invaliddaterangeerror = true ;
return ;
}
}
$scope.invaliddaterangeerror = false ;
$uibModalInstance.close($scope.adjustmentData);
for(var i in scope.loandetails.repaymentSchedule.periods) {
\
if(scope.loandetails.repaymentSchedule.periods[i].dueDate.getTime()>= \
t1 &&
\
scope.loandetails.repaymentSchedule.periods[i].dueDate.getTime()<= \
t2) {
if($scope.enableInstallment && \
$scope.adjustmentData.totalInstallmentAmountForPeriod) { \
scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod = \
$scope.adjustmentData.totalInstallmentAmountForPeriod ;
}else if($scope.enablePrincipal && \
$scope.adjustmentData.principalDue){
\
scope.loandetails.repaymentSchedule.periods[i].principalDue = \
$scope.adjustmentData.principalDue ; }
if($scope.adjustmentData.month || \
$scope.adjustmentData.day) {
var tempDate = new \
Date(scope.loandetails.repaymentSchedule.periods[i].dueDate) ; \
if($scope.adjustmentData.month) {
\
tempDate.setMonth(parseInt($scope.adjustmentData.month)+scope.loandetails.repaymentSchedule.periods[i].dueDate.getMonth()) \
; }
if($scope.adjustmentData.day) {
var uiday = parseInt($scope.adjustmentData.day) ;
var day = numberOfDays(tempDate.getFullYear(), \
tempDate.getMonth()+1, uiday) ; tempDate.setDate(day) ;
}
\
scope.loandetails.repaymentSchedule.periods[i].dueDate = new Date(tempDate) ; \
scope.loandetails.repaymentSchedule.periods[i].formattedDueDate = \
dateFilter(scope.loandetails.repaymentSchedule.periods[i].dueDate, scope.df); }
}
}
};
function numberOfDays(year, month, day) {
var d = new Date(year, month, 0);
console.log(year, month) ;
console.log(d.getDate(), day) ;
if(d.getDate() < day) {
return d.getDate() ;
}else {
return day ;
}
}
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.addInstallment = function (index) {
var installment = {} ;
scope.loandetails.repaymentSchedule.periods.splice(index+1, 0, \
installment); scope.newinstallments.push(installment) ;
} ;
scope.deleteInstallment = function (index) {
if(scope.loandetails.repaymentSchedule.periods[index].period) {
var deleted = {} ;
deleted.dueDate = dateFilter( \
scope.loandetails.repaymentSchedule.periods[index].dueDate , scope.df); \
scope.deletedinstallments.push(deleted) ; }else {
var i = 0 ;
var length = scope.newinstallments.length ;
for(i = 0 ; i < length; i++) {
if(scope.newinstallments[i] == \
scope.loandetails.repaymentSchedule.periods[index]) { \
scope.newinstallments.splice(i, 1) ; break ;
}
}
}
scope.loandetails.repaymentSchedule.periods.splice(index, 1);
} ;
function getNewInstallments() {
var tempArray = [] ;
for (var i in scope.newinstallments) {
tempArray.push({}) ;
tempArray[i].dueDate = dateFilter( \
scope.newinstallments[i].dueDate, scope.df); if(scope.enablePrincipal) {
tempArray[i].principal = \
scope.newinstallments[i].principalDue; }
if(scope.enableInstallment) {
tempArray[i].installmentAmount = \
scope.newinstallments[i].totalInstallmentAmountForPeriod; }
}
return tempArray ;
} ;
function constructRequestData() {
var exceptions = {} ;
var modified = getUpdatedInstallments() ;
if(modified.length > 0) {
exceptions.modifiedinstallments = modified ;
}
var newinstalls = getNewInstallments() ;
if(newinstalls.length > 0) {
exceptions.newinstallments = newinstalls ;
}
if(scope.deletedinstallments.length > 0) {
exceptions.deletedinstallments = scope.deletedinstallments ;
}
return exceptions ;
}
function getUpdatedInstallments() {
var modified = [] ;
var modifiedIndex = 0 ;
scope.modifiedinstallments.splice(0, \
scope.modifiedinstallments.length);
for(var i in scope.loandetails.repaymentSchedule.periods) {
if(scope.loandetails.repaymentSchedule.periods[i].period) {
var dateModified = \
scope.loandetails.repaymentSchedule.periods[i].originalDueDate.getTime() != \
scope.loandetails.repaymentSchedule.periods[i].dueDate.getTime() ;
\
if(!scope.loandetails.repaymentSchedule.periods[i].principalDue) {
\
scope.loandetails.repaymentSchedule.periods[i].principalDue = 0 ; }
var principalModified = \
scope.loandetails.repaymentSchedule.periods[i].oroginalPrincipalDue != \
scope.loandetails.repaymentSchedule.periods[i].principalDue ;
\
if(!scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod) \
{
\
scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod = 0 ; \
} var installmentModified = \
scope.loandetails.repaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod \
!= scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod ;
if(dateModified || principalModified || installmentModified) \
{ var modifiedInstallment = {} ;
scope.modifiedinstallments.push({}) ;
modifiedInstallment.dueDate = \
dateFilter(scope.loandetails.repaymentSchedule.periods[i].originalDueDate, \
scope.df);
scope.modifiedinstallments[modifiedIndex].dueDate = \
scope.loandetails.repaymentSchedule.periods[i].originalDueDate ;
if(dateModified) {
modifiedInstallment.modifiedDueDate = \
dateFilter(scope.loandetails.repaymentSchedule.periods[i].dueDate, \
scope.df);
\
scope.modifiedinstallments[modifiedIndex].modifiedDueDate = \
scope.loandetails.repaymentSchedule.periods[i].dueDate ; }
if(scope.enablePrincipal && principalModified) {
modifiedInstallment.principal = \
scope.loandetails.repaymentSchedule.periods[i].principalDue ; \
scope.modifiedinstallments[modifiedIndex].oroginalPrincipalDue = \
scope.loandetails.repaymentSchedule.periods[i].oroginalPrincipalDue ;
scope.modifiedinstallments[modifiedIndex].principal = \
scope.loandetails.repaymentSchedule.periods[i].principalDue ; }
if(scope.enableInstallment && installmentModified) {
modifiedInstallment.installmentAmount = \
scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod ; \
scope.modifiedinstallments[modifiedIndex].originaltotalInstallmentAmountForPeriod = \
scope.loandetails.repaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod \
; scope.modifiedinstallments[modifiedIndex].installmentAmount = \
scope.loandetails.repaymentSchedule.periods[i].totalInstallmentAmountForPeriod ; }
modified.push(modifiedInstallment) ;
modifiedIndex++ ;
}
}
}
return modified ;
};
scope.resetToOriginalSchedule = function () {
$uibModal.open({
templateUrl: 'resetschedule.html',
controller: resetToOriginalSchedule
});
};
var resetToOriginalSchedule = function ($scope, $uibModalInstance) {
$scope.delete = function () {
resourceFactory.variableinstallments.deleteVariations({loanId: \
routeParams.accountId}, function (data) { $uibModalInstance.close("Close");
loadData() ;
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
function validateBeforesendingdata() {
var emptyData = false ;
for(var i in scope.loandetails.repaymentSchedule.periods) {
if(!scope.loandetails.repaymentSchedule.periods[i].dueDate){
emptyData = true ;
break ;
}
}
return emptyData ;
}
scope.validate = function () {
if(validateBeforesendingdata()) return true ;
scope.formData.exceptions = constructRequestData() ;
if(!scope.formData.exceptions.modifiedinstallments &&
!scope.formData.exceptions.newinstallments &&
!scope.formData.exceptions.deletedinstallments) {
return ;
}
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
resourceFactory.variableinstallments.validate({loanId: \
routeParams.accountId}, scope.formData, function (data) { var validRepaymentSchedule \
= data ; for (var i in validRepaymentSchedule.periods) {
var index = -1 ;
var date = new \
Date(validRepaymentSchedule.periods[i].dueDate) ; for(var j in \
scope.modifiedinstallments) { if((scope.modifiedinstallments[j].dueDate &&
scope.modifiedinstallments[j].dueDate.getTime() == \
date.getTime())) { index = j ;
break ;
}
if(scope.modifiedinstallments[j].modifiedDueDate &&
\
scope.modifiedinstallments[j].modifiedDueDate.getTime() == date.getTime()) { index = \
j ; break ;
}
}
validRepaymentSchedule.periods[i].dueDate = date ;
if(index > -1) {
if(scope.modifiedinstallments[index].modifiedDueDate) {
validRepaymentSchedule.periods[i].originalDueDate = \
scope.modifiedinstallments[index].dueDate ; }else {
validRepaymentSchedule.periods[i].originalDueDate = \
validRepaymentSchedule.periods[i].dueDate ; }
if(scope.modifiedinstallments[index].principal) {
\
validRepaymentSchedule.periods[i].oroginalPrincipalDue = \
scope.modifiedinstallments[index].oroginalPrincipalDue ; }else {
\
validRepaymentSchedule.periods[i].oroginalPrincipalDue = \
validRepaymentSchedule.periods[i].principalDue ; }
if(scope.modifiedinstallments[index].installmentAmount) {
\
validRepaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod = \
scope.modifiedinstallments[index].originaltotalInstallmentAmountForPeriod ; }else {
\
validRepaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod = \
validRepaymentSchedule.periods[i].totalInstallmentAmountForPeriod ; }
validRepaymentSchedule.periods[i].formattedDueDate = \
dateFilter(validRepaymentSchedule.periods[i].dueDate, scope.df); }else {
validRepaymentSchedule.periods[i].originalDueDate = \
validRepaymentSchedule.periods[i].dueDate ;
validRepaymentSchedule.periods[i].oroginalPrincipalDue = \
validRepaymentSchedule.periods[i].principalDue ; \
validRepaymentSchedule.periods[i].originaltotalInstallmentAmountForPeriod = \
validRepaymentSchedule.periods[i].totalInstallmentAmountForPeriod ;
validRepaymentSchedule.periods[i].formattedDueDate = \
dateFilter(validRepaymentSchedule.periods[i].dueDate, scope.df); }
}
scope.loandetails.repaymentSchedule = data;
});
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
scope.formData.exceptions = constructRequestData() ;
resourceFactory.variableinstallments.addVariations({loanId: \
routeParams.accountId}, scope.formData, function (data) { \
location.path('/viewloanaccount/' + data.loanId); });
};
}
});
mifosX.ng.application.controller('AdjustRepaymentSchedule', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', '$route', '$http', '$uibModal', \
'dateFilter', 'API_VERSION', '$sce', '$rootScope', \
mifosX.controllers.AdjustRepaymentSchedule]).run(function ($log) { \
$log.info("AdjustRepaymentSchedule initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ApproveLoanRescheduleRequestController: function (scope, resourceFactory, \
routeParams, location, dateFilter) { scope.formData = {};
scope.loanId = routeParams.loanId;
scope.requestId = routeParams.requestId;
scope.cancel = function () {
location.path('/loans/' + scope.loanId + \
'/viewreschedulerequest/'+scope.requestId); };
scope.approve = function(){
this.formData.dateFormat = scope.df;
this.formData.locale = scope.optlang.code;
this.formData.approvedOnDate = \
dateFilter(this.formData.approvedOnDate, scope.df);
resourceFactory.loanRescheduleResource.approve({scheduleId:scope.requestId},this.formData,function \
(data) { location.path('/viewloanaccount/' + scope.loanId);
});
};
}
});
mifosX.ng.application.controller('ApproveLoanRescheduleRequestController', \
['$scope', 'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.ApproveLoanRescheduleRequestController]).run(function ($log) { \
$log.info("ApproveLoanRescheduleRequestController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
AssignLoanOfficerController: function (scope, resourceFactory, routeParams, \
location, dateFilter) {
scope.loanOfficers = [];
scope.formData = {};
scope.loanId = routeParams.id;
var fields = "id,loanOfficerId,loanOfficerOptions";
scope.formData.assignmentDate = new Date();
scope.restrictDate = new Date();
resourceFactory.loanResource.get({loanId: scope.loanId, template: true, \
fields: fields, staffInSelectedOfficeOnly:true}, function (data) { if \
(data.loanOfficerOptions) { scope.loanOfficers = data.loanOfficerOptions;
scope.formData.toLoanOfficerId = data.loanOfficerOptions[0].id;
}
scope.data = data;
});
scope.cancel = function () {
location.path('/viewloanaccount/' + scope.loanId);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.fromLoanOfficerId = scope.data.loanOfficerId || "";
this.formData.assignmentDate = \
dateFilter(this.formData.assignmentDate, scope.df);
resourceFactory.loanResource.save({command: 'assignloanofficer', \
loanId: scope.loanId}, this.formData, function (data) { \
location.path('/viewloanaccount/' + data.loanId); });
};
}
});
mifosX.ng.application.controller('AssignLoanOfficerController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.AssignLoanOfficerController]).run(function ($log) { \
$log.info("AssignLoanOfficerController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportGuarantorController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/loans/1/guarantors/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
resourceFactory.officeResource.getAllOffices(function (data) {
scope.offices=data;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
scope.first.queryParams += 'officeId=' + \
scope.formData.officeId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: "guarantors"}, \
function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/loans/1/guarantors/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportGuarantorController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportGuarantorController]).run(function ($log) { \
$log.info("BulkImportGuarantorController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportLoanAccountsController: function (scope, resourceFactory, location, \
API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + '/loans/downloadtemplate' + \
'?tenantIdentifier=' + $rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
scope.first.queryParams += '&officeId=' + \
scope.formData.officeId; }else {
resourceFactory.clientTemplateResource.get({
staffInSelectedOfficeOnly: true, officeId: \
scope.formData.officeId }, function (data) {
scope.staffs = data.staffOptions;
});
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.changeStaff = function() {
if(scope.formData.staffId) {
if (scope.first.queryParams.indexOf("staffId")==-1) {
scope.first.queryParams = scope.first.queryParams + \
'&staffId=' + scope.formData.staffId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&staffId=\d+/i,"&staffId="+ \
scope.formData.staffId); }
} else {
if(scope.formData.officeId)
scope.first.queryParams = '&' + 'officeId=' + \
scope.formData.officeId; else
scope.first.queryParams = '&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: "loans"}, \
function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/loans/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportLoanAccountsController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportLoanAccountsController]).run(function ($log) { \
$log.info("BulkImportLoanAccountsController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
BulkImportLoanRepaymentController: function (scope, resourceFactory, \
location, API_VERSION, $rootScope, Upload) {
scope.first = {};
scope.first.templateUrl = API_VERSION + \
'/loans/repayments/downloadtemplate' + '?tenantIdentifier=' + \
$rootScope.tenantIdentifier
+ '&locale=' + scope.optlang.code + '&dateFormat=' + scope.df;
scope.formData = {};
var requestParams = {staffInSelectedOfficeOnly:true};
resourceFactory.clientTemplateResource.get(requestParams, function (data) \
{ scope.offices = data.officeOptions;
scope.staffs = data.staffOptions;
});
scope.first.queryParams = '&';
scope.changeOffice = function () {
if(scope.formData.officeId) {
if(scope.first.queryParams.indexOf("officeId")==-1) {
scope.first.queryParams += 'officeId=' + \
scope.formData.officeId; }else {
\
scope.first.queryParams=scope.first.queryParams.replace(/&officeId=\d+/i,"&officeId="+ \
scope.formData.officeId); }
} else {
scope.first.queryParams ='&';
}
};
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.refreshImportTable=function () {
resourceFactory.importResource.getImports({entityType: \
"loantransactions"}, function (data) {
for (var l in data) {
var importdocs = {};
importdocs = API_VERSION + \
'/imports/downloadOutputTemplate?importDocumentId='+ data[l].importId \
+'&tenantIdentifier=' + $rootScope.tenantIdentifier; data[l].docUrl = importdocs;
}
scope.imports = data;
});
};
scope.upload = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + \
'/loans/repayments/uploadtemplate',
data: {file: \
scope.formData.file,locale:scope.optlang.code,dateFormat:scope.df}, }).then(function \
(data) { // to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
});
};
}
});
mifosX.ng.application.controller('BulkImportLoanRepaymentController', ['$scope', \
'ResourceFactory', '$location', 'API_VERSION', '$rootScope', 'Upload', \
mifosX.controllers.BulkImportLoanRepaymentController]).run(function ($log) { \
$log.info("BulkImportLoanRepaymentController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
EditGuarantorController: function (scope, resourceFactory, routeParams, \
location, dateFilter) { scope.template = {};
scope.clientview = false;
scope.date = {};
scope.restrictDate = new Date();
resourceFactory.guarantorResource.get({ loanId: routeParams.loanId, \
templateResource: routeParams.id, template: true}, function (data) { scope.template \
= data; scope.formData = {
firstname: data.firstname,
lastname: data.lastname,
city: data.city,
zip: data.zip,
mobile: data.mobileNumber,
residence: data.housePhoneNumber,
addressLine1: data.addressLine1,
addressLine2:data.addressLine2
}
if (data.clientRelationshipType) {
scope.formData.relationshipType = data.clientRelationshipType.id;
}
if (data.dob) {
scope.date.first = new Date(dateFilter(data.dob, scope.df));
}
});
scope.submit = function () {
var guarantor = {};
var reqDate = dateFilter(scope.date.first, scope.df);
guarantor.addressLine1 = this.formData.addressLine1;
guarantor.addressLine2 = this.formData.addressLine2;
guarantor.city = this.formData.city;
guarantor.dob = reqDate;
guarantor.zip = this.formData.zip;
guarantor.dateFormat = scope.df;
guarantor.locale = scope.optlang.code;
guarantor.firstname = this.formData.firstname;
guarantor.lastname = this.formData.lastname;
guarantor.mobileNumber = this.formData.mobile;
guarantor.housePhoneNumber = this.formData.residence;
guarantor.clientRelationshipTypeId = this.formData.relationshipType;
guarantor.guarantorTypeId = 3;
resourceFactory.guarantorResource.update({ loanId: \
routeParams.loanId, templateResource: routeParams.id}, guarantor, function (data) { \
location.path('listguarantors/' + routeParams.loanId); });
};
}
});
mifosX.ng.application.controller('EditGuarantorController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.EditGuarantorController]).run(function ($log) { \
$log.info("EditGuarantorController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditLoanAccAppController: function (scope, routeParams, resourceFactory, \
location, dateFilter, uiConfigService) {
scope.previewRepayment = false;
scope.formData = {};
scope.chargeFormData = {}; //For charges
scope.collateralFormData = {}; //For collaterals
scope.collaterals = [];
scope.restrictDate = new Date();
scope.date = {};
resourceFactory.loanResource.get({loanId: routeParams.id, template: true, \
associations: 'charges,collateral,meeting,multiDisburseDetails',staffInSelectedOfficeOnly:true}, \
function (data) { scope.loanaccountinfo = data;
resourceFactory.loanResource.get({resourceType: 'template', \
templateType: 'collateral', productId: data.loanProductId, fields: \
'id,loanCollateralOptions'}, function (data) {
scope.collateralOptions = data.loanCollateralOptions || [];
});
if (data.clientId) {
scope.clientId = data.clientId;
scope.clientName = data.clientName;
scope.formData.clientId = scope.clientId;
}
if (data.group) {
scope.groupId = data.group.id;
scope.groupName = data.group.name;
scope.formData.groupId = scope.groupId;
}
if (scope.clientId && scope.groupId) {
scope.templateType = 'jlg';
}
else if (scope.groupId) {
scope.templateType = 'group';
}
else if (scope.clientId) {
scope.templateType = 'individual';
}
scope.formData.loanOfficerId = data.loanOfficerId;
scope.formData.loanPurposeId = data.loanPurposeId;
scope.formData.externalId = data.externalId;
//update collaterals
if (scope.loanaccountinfo.collateral) {
for (var i in scope.loanaccountinfo.collateral) {
scope.collaterals.push({type: \
scope.loanaccountinfo.collateral[i].type.id, name: \
scope.loanaccountinfo.collateral[i].type.name, value: \
scope.loanaccountinfo.collateral[i].value, description: \
scope.loanaccountinfo.collateral[i].description}); }
}
scope.previewClientLoanAccInfo();
});
scope.loanProductChange = function (loanProductId) {
var inparams = { resourceType: 'template', productId: loanProductId, \
templateType: scope.templateType }; if (scope.clientId) {
inparams.clientId = scope.clientId;
}
if (scope.groupId) {
inparams.groupId = scope.groupId;
}
inparams.staffInSelectedOfficeOnly = true;
resourceFactory.loanResource.get(inparams, function (data) {
scope.loanaccountinfo = data;
scope.collaterals = [];
scope.previewClientLoanAccInfo();
});
resourceFactory.loanResource.get({resourceType: 'template', \
templateType: 'collateral', productId: loanProductId, fields: \
'id,loanCollateralOptions'}, function (data) {
scope.collateralOptions = data.loanCollateralOptions || [];
});
}
scope.previewClientLoanAccInfo = function () {
scope.previewRepayment = false;
for (var i in scope.loanaccountinfo.charges) {
if (scope.loanaccountinfo.charges[i].dueDate) {
if(scope.loanaccountinfo.charges[i].chargeTimeType.value == \
"Disbursement" ||
scope.loanaccountinfo.charges[i].chargeTimeType.value == \
"Tranche Disbursement"){
scope.loanaccountinfo.charges[i].dueDate = null;
}else{
scope.loanaccountinfo.charges[i].dueDate = new \
Date(scope.loanaccountinfo.charges[i].dueDate); }
}
}
scope.charges = scope.loanaccountinfo.charges || [];
scope.formData.disbursementData = \
scope.loanaccountinfo.disbursementDetails || []; if \
(scope.formData.disbursementData.length > 0) { for (var i in \
scope.formData.disbursementData) {
scope.formData.disbursementData[i].expectedDisbursementDate = \
new Date(scope.formData.disbursementData[i].expectedDisbursementDate); }
}
if (scope.loanaccountinfo.timeline.submittedOnDate) {
scope.formData.submittedOnDate = new \
Date(scope.loanaccountinfo.timeline.submittedOnDate); }
if (scope.loanaccountinfo.timeline.expectedDisbursementDate) {
scope.formData.expectedDisbursementDate = new \
Date(scope.loanaccountinfo.timeline.expectedDisbursementDate); }
if (scope.loanaccountinfo.interestChargedFromDate) {
scope.formData.interestChargedFromDate = new \
Date(scope.loanaccountinfo.interestChargedFromDate); }
if (scope.loanaccountinfo.expectedFirstRepaymentOnDate) {
scope.formData.repaymentsStartingFromDate = new \
Date(scope.loanaccountinfo.expectedFirstRepaymentOnDate); }
scope.multiDisburseLoan = scope.loanaccountinfo.multiDisburseLoan;
scope.formData.productId = scope.loanaccountinfo.loanProductId;
scope.formData.fundId = scope.loanaccountinfo.fundId;
scope.formData.principal = scope.loanaccountinfo.principal;
scope.formData.loanTermFrequency = \
scope.loanaccountinfo.termFrequency;
scope.formData.loanTermFrequencyType = \
scope.loanaccountinfo.termPeriodFrequencyType.id;
scope.formData.numberOfRepayments = \
scope.loanaccountinfo.numberOfRepayments;
scope.formData.repaymentEvery = scope.loanaccountinfo.repaymentEvery;
scope.formData.repaymentFrequencyType = \
scope.loanaccountinfo.repaymentFrequencyType.id;
if (scope.loanaccountinfo.repaymentFrequencyNthDayType != null){
scope.formData.repaymentFrequencyNthDayType = \
scope.loanaccountinfo.repaymentFrequencyNthDayType.id; }
if(scope.loanaccountinfo.repaymentFrequencyDayOfWeekType != null){
scope.formData.repaymentFrequencyDayOfWeekType = \
scope.loanaccountinfo.repaymentFrequencyDayOfWeekType.id }
scope.formData.interestRatePerPeriod = \
scope.loanaccountinfo.interestRatePerPeriod;
scope.formData.interestRateFrequencyType = \
scope.loanaccountinfo.interestRateFrequencyType.id;
scope.formData.amortizationType = \
scope.loanaccountinfo.amortizationType.id;
scope.formData.interestType = scope.loanaccountinfo.interestType.id;
scope.formData.isEqualAmortization = \
scope.loanaccountinfo.isEqualAmortization;
scope.formData.interestCalculationPeriodType = \
scope.loanaccountinfo.interestCalculationPeriodType.id;
scope.formData.allowPartialPeriodInterestCalcualtion = \
scope.loanaccountinfo.allowPartialPeriodInterestCalcualtion;
scope.formData.inArrearsTolerance = \
scope.loanaccountinfo.inArrearsTolerance;
scope.formData.graceOnPrincipalPayment = \
scope.loanaccountinfo.graceOnPrincipalPayment;
scope.formData.graceOnInterestPayment = \
scope.loanaccountinfo.graceOnInterestPayment;
scope.formData.graceOnArrearsAgeing = \
scope.loanaccountinfo.graceOnArrearsAgeing;
scope.formData.transactionProcessingStrategyId = \
scope.loanaccountinfo.transactionProcessingStrategyId;
scope.formData.graceOnInterestCharged = \
scope.loanaccountinfo.graceOnInterestCharged;
scope.formData.syncDisbursementWithMeeting = \
scope.loanaccountinfo.syncDisbursementWithMeeting;
scope.formData.fixedEmiAmount = scope.loanaccountinfo.fixedEmiAmount;
scope.formData.maxOutstandingLoanBalance = \
scope.loanaccountinfo.maxOutstandingLoanBalance;
scope.formData.createStandingInstructionAtDisbursement = \
scope.loanaccountinfo.createStandingInstructionAtDisbursement; \
scope.formData.isTopup = scope.loanaccountinfo.isTopup;
scope.formData.loanIdToClose = scope.loanaccountinfo.closureLoanId;
if (scope.loanaccountinfo.meeting) {
scope.formData.syncRepaymentsWithMeeting = true;
}
if (scope.loanaccountinfo.linkedAccount) {
scope.formData.linkAccountId = \
scope.loanaccountinfo.linkedAccount.id; }
if (scope.loanaccountinfo.isInterestRecalculationEnabled && \
scope.loanaccountinfo.interestRecalculationData.recalculationRestFrequencyDate) \
{
scope.date.recalculationRestFrequencyDate = new \
Date(scope.loanaccountinfo.interestRecalculationData.recalculationRestFrequencyDate); \
}
if (scope.loanaccountinfo.isInterestRecalculationEnabled && \
scope.loanaccountinfo.interestRecalculationData.recalculationCompoundingFrequencyDate) \
{ scope.date.recalculationCompoundingFrequencyDate = new \
Date(scope.loanaccountinfo.interestRecalculationData.recalculationCompoundingFrequencyDate);
}
scope.formData.interestRateDifferential = \
scope.loanaccountinfo.interestRateDifferential ;
scope.formData.isFloatingInterestRate = \
scope.loanaccountinfo.isFloatingInterestRate ; }
scope.addCharge = function () {
if (scope.chargeFormData.chargeId) {
resourceFactory.chargeResource.get({chargeId: \
this.chargeFormData.chargeId, template: 'true'}, function (data) { data.chargeId = \
data.id; data.id = null;
data.amountOrPercentage = data.amount;
scope.charges.push(data);
scope.chargeFormData.chargeId = undefined;
});
}
}
scope.deleteCharge = function (index) {
scope.charges.splice(index, 1);
}
scope.addTranches = function () {
scope.formData.disbursementData.push({
});
};
scope.deleteTranches = function (index) {
scope.formData.disbursementData.splice(index, 1);
}
scope.syncRepaymentsWithMeetingchange = function () {
if (!scope.formData.syncRepaymentsWithMeeting) {
scope.formData.syncDisbursementWithMeeting = false;
}
};
scope.syncDisbursementWithMeetingchange = function () {
if (scope.formData.syncDisbursementWithMeeting) {
scope.formData.syncRepaymentsWithMeeting = true;
}
};
scope.addCollateral = function () {
if (scope.collateralFormData.collateralIdTemplate && \
scope.collateralFormData.collateralValueTemplate) { scope.collaterals.push({type: \
scope.collateralFormData.collateralIdTemplate.id, name: \
scope.collateralFormData.collateralIdTemplate.name, value: \
scope.collateralFormData.collateralValueTemplate, description: \
scope.collateralFormData.collateralDescriptionTemplate});
scope.collateralFormData.collateralIdTemplate = undefined;
scope.collateralFormData.collateralValueTemplate = undefined;
scope.collateralFormData.collateralDescriptionTemplate = \
undefined; }
};
scope.deleteCollateral = function (index) {
scope.collaterals.splice(index, 1);
};
scope.previewRepayments = function () {
// Make sure charges and collaterals are empty before initializing.
delete scope.formData.charges;
delete scope.formData.collateral;
if (scope.charges.length > 0) {
scope.formData.charges = [];
for (var i in scope.charges) {
scope.formData.charges.push({ chargeId: \
scope.charges[i].chargeId, amount: scope.charges[i].amountOrPercentage, dueDate: \
dateFilter(scope.charges[i].dueDate, scope.df) }); }
}
if (scope.formData.disbursementData.length > 0) {
for (var i in scope.formData.disbursementData) {
scope.formData.disbursementData[i].expectedDisbursementDate = \
dateFilter(scope.formData.disbursementData[i].expectedDisbursementDate, scope.df); \
} }
if (scope.collaterals.length > 0) {
scope.formData.collateral = [];
for (var i in scope.collaterals) {
scope.formData.collateral.push({type: \
scope.collaterals[i].type, value: scope.collaterals[i].value, description: \
scope.collaterals[i].description}); }
}
if (this.formData.syncRepaymentsWithMeeting) {
if(scope.loanaccountinfo.calendarOptions){
this.formData.calendarId = \
scope.loanaccountinfo.calendarOptions[0].id; }
scope.syncRepaymentsWithMeeting = \
this.formData.syncRepaymentsWithMeeting; }
delete this.formData.syncRepaymentsWithMeeting;
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.loanType = scope.templateType;
this.formData.expectedDisbursementDate = \
dateFilter(this.formData.expectedDisbursementDate, scope.df);
this.formData.submittedOnDate = \
dateFilter(this.formData.submittedOnDate, scope.df);
this.formData.interestChargedFromDate = \
dateFilter(this.formData.interestChargedFromDate, scope.df);
this.formData.repaymentsStartingFromDate = \
dateFilter(this.formData.repaymentsStartingFromDate, scope.df);
if(!scope.loanaccountinfo.isLoanProductLinkedToFloatingRate) {
delete this.formData.interestRateDifferential ;
delete this.formData.isFloatingInterestRate ;
}
resourceFactory.loanResource.save({command: 'calculateLoanSchedule'}, \
this.formData, function (data) { scope.repaymentscheduleinfo = data;
scope.previewRepayment = true;
scope.formData.syncRepaymentsWithMeeting = \
scope.syncRepaymentsWithMeeting; });
}
uiConfigService.appendConfigToScope(scope);
scope.submit = function () {
// Make sure charges and collaterals are empty before initializing.
delete scope.formData.charges;
delete scope.formData.collateral;
if (scope.formData.disbursementData.length > 0) {
for (var i in scope.formData.disbursementData) {
scope.formData.disbursementData[i].expectedDisbursementDate = \
dateFilter(scope.formData.disbursementData[i].expectedDisbursementDate, scope.df); }
}
scope.formData.charges = [];
if (scope.charges.length > 0) {
for (var i in scope.charges) {
scope.formData.charges.push({id: scope.charges[i].id, \
chargeId: scope.charges[i].chargeId, amount: scope.charges[i].amountOrPercentage, \
dueDate: dateFilter(scope.charges[i].dueDate, scope.df) }); }
}
scope.formData.collateral = [];
if (scope.collaterals.length > 0) {
for (var i in scope.collaterals) {
scope.formData.collateral.push({type: \
scope.collaterals[i].type, value: scope.collaterals[i].value, description: \
scope.collaterals[i].description}); }
;
}
if (this.formData.syncRepaymentsWithMeeting) {
if(scope.loanaccountinfo.calendarOptions){
this.formData.calendarId = \
scope.loanaccountinfo.calendarOptions[0].id; }
}
delete this.formData.syncRepaymentsWithMeeting;
delete this.formData.interestRateFrequencyType;
if(!scope.loanaccountinfo.isLoanProductLinkedToFloatingRate) {
delete this.formData.interestRateDifferential ;
delete this.formData.isFloatingInterestRate ;
}
this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
this.formData.loanType = scope.templateType;
this.formData.expectedDisbursementDate = \
dateFilter(this.formData.expectedDisbursementDate, scope.df);
this.formData.submittedOnDate = \
dateFilter(this.formData.submittedOnDate, scope.df);
this.formData.interestChargedFromDate = \
dateFilter(this.formData.interestChargedFromDate, scope.df);
this.formData.repaymentsStartingFromDate = \
dateFilter(this.formData.repaymentsStartingFromDate, scope.df);
this.formData.createStandingInstructionAtDisbursement = \
scope.formData.createStandingInstructionAtDisbursement; if \
(scope.date.recalculationRestFrequencyDate) {
var restFrequencyDate = \
dateFilter(scope.date.recalculationRestFrequencyDate, scope.df);
scope.formData.recalculationRestFrequencyDate = \
restFrequencyDate; }
if (scope.date.recalculationCompoundingFrequencyDate) {
var restFrequencyDate = \
dateFilter(scope.date.recalculationCompoundingFrequencyDate, \
scope.df);
scope.formData.recalculationCompoundingFrequencyDate = \
restFrequencyDate; }
if(this.formData.interestCalculationPeriodType == 0){
this.formData.allowPartialPeriodInterestCalcualtion = false;
}
resourceFactory.loanResource.put({loanId: routeParams.id}, \
this.formData, function (data) { location.path('/viewloanaccount/' + data.loanId);
});
};
scope.cancel = function () {
location.path('/viewloanaccount/' + routeParams.id);
}
}
});
mifosX.ng.application.controller('EditLoanAccAppController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', 'dateFilter', 'UIConfigService', \
mifosX.controllers.EditLoanAccAppController]).run(function ($log) { \
$log.info("EditLoanAccAppController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditLoanChargeController: function (scope, resourceFactory, routeParams, \
location) {
scope.loanId = routeParams.loanId;
scope.chargeId = routeParams.id;
resourceFactory.loanResource.get({ resourceType: 'charges', loanId: \
scope.loanId, resourceId: scope.chargeId, template: true }, function (data) { \
scope.formData = {amount: data.amount}; });
scope.cancel = function () {
location.path('/viewloanaccount/' + scope.loanId);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
resourceFactory.loanResource.put({resourceType: 'charges', \
resourceId: scope.chargeId, loanId: scope.loanId}, this.formData, function (data) { \
location.path('/viewloanaccount/' + data.loanId); });
};
}
});
mifosX.ng.application.controller('EditLoanChargeController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.EditLoanChargeController]).run(function ($log) { \
$log.info("EditLoanChargeController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
EditLoanCollateralController: function (scope, resourceFactory, routeParams, \
location) {
scope.loanId = routeParams.loanId;
scope.collateralId = routeParams.id;
resourceFactory.loanResource.get({ resourceType: 'collaterals', loanId: \
scope.loanId, resourceId: scope.collateralId, template: true }, \
function (data) {
scope.formData = {collateralTypeId: data.type.id, value: data.value, \
description: data.description}; scope.collateralTypes = data.allowedCollateralTypes;
});
scope.cancel = function () {
location.path('/viewloanaccount/' + scope.loanId);
};
scope.submit = function () {
this.formData.locale = scope.optlang.code;
resourceFactory.loanResource.put({resourceType: 'collaterals', \
resourceId: scope.collateralId, loanId: scope.loanId}, this.formData, function (data) \
{ location.path('/viewloanaccount/' + data.loanId);
});
};
}
});
mifosX.ng.application.controller('EditLoanCollateralController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', \
mifosX.controllers.EditLoanCollateralController]).run(function ($log) { \
$log.info("EditLoanCollateralController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
GuarantorController: function (scope, resourceFactory, routeParams, location, \
dateFilter) { scope.template = {};
scope.clientview = false;
scope.temp = true;
scope.date = {};
scope.formData = {};
scope.restrictDate = new Date();
resourceFactory.guarantorResource.get({ loanId: routeParams.id, \
templateResource: 'template'}, function (data) { scope.template = data;
scope.loanId = routeParams.id;
});
resourceFactory.clientResource.getAllClientsWithoutLimit(function (data) \
{ scope.clients = data.pageItems;
});
scope.viewClient = function (item) {
scope.clientview = true;
scope.client = item;
scope.changeEvent();
};
scope.checkClient = function () {
if (!scope.temp) {
scope.clientview = false;
}
};
scope.changeEvent = function () {
resourceFactory.guarantorAccountResource.get({ loanId: \
routeParams.id, clientId: scope.client.id}, function (data) { scope.accounts = \
data.accountLinkingOptions; });
}
scope.submit = function () {
var guarantor = {};
var reqDate = dateFilter(scope.date.first, scope.df);
if (scope.temp == true) {
guarantor.guarantorTypeId = \
scope.template.guarantorTypeOptions[0].id; guarantor.locale = scope.optlang.code;
if (this.formData) {
guarantor.clientRelationshipTypeId = \
this.formData.relationship; }
if (scope.client) {
guarantor.entityId = scope.client.id;
guarantor.savingsId = this.formData.savingsId;
guarantor.amount = this.formData.amount;
}
}
else if (this.formData) {
guarantor.addressLine1 = this.formData.addressLine1;
guarantor.addressLine2 = this.formData.addressLine2;
guarantor.city = this.formData.city;
guarantor.dob = reqDate;
guarantor.zip = this.formData.zip;
guarantor.dateFormat = scope.df;
guarantor.locale = scope.optlang.code;
guarantor.firstname = this.formData.firstname;
guarantor.lastname = this.formData.lastname;
guarantor.mobileNumber = this.formData.mobile;
guarantor.housePhoneNumber = this.formData.residence;
guarantor.guarantorTypeId = \
scope.template.guarantorTypeOptions[2].id;
guarantor.clientRelationshipTypeId = \
this.formData.relationshipType; }
resourceFactory.guarantorResource.save({ loanId: routeParams.id}, \
guarantor, function (data) { location.path('viewloanaccount/' + routeParams.id);
});
};
}
});
mifosX.ng.application.controller('GuarantorController', ['$scope', \
'ResourceFactory', '$routeParams', '$location', 'dateFilter', \
mifosX.controllers.GuarantorController]).run(function ($log) { \
$log.info("GuarantorController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
ListGuarantorController: function (scope, routeParams, resourceFactory, \
location, route, http, $uibModal, dateFilter, API_VERSION, $sce, $rootScope) {
scope.modified = 0;
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'guarantors'}, function (data) { scope.loandetails = \
data; scope.guarantorDetails = data.guarantors;
scope.status = data.status.value;
scope.decimals = data.currency.decimalPlaces;
scope.changedDetail = [];
scope.hideDeletedGuarantors=true;
scope.hideWithDrawnGuarantors=true;
scope.isHideDeletedGuarantorsCheckboxChecked = true;
scope.updateCheckBoxStatus = function (){
scope.isHideDeletedGuarantorsCheckboxChecked = \
!scope.isHideDeletedGuarantorsCheckboxChecked; };
});
scope.showDetails = function (parentindex, index) {
scope.guarantorData = scope.guarantorDetails[parentindex];
if (index == null) {
scope.guarantorFundDetail = null;
} else {
scope.guarantorFundDetail = \
scope.guarantorData.guarantorFundingDetails[index]; }
$uibModal.open({
templateUrl: 'viewguarantor.html',
controller: GuarantorViewCtrl,
resolve: {
guarantorFundDetail: function () {
return scope.guarantorFundDetail;
},
guarantorData: function () {
return scope.guarantorData;
}
}
});
};
var GuarantorViewCtrl = function ($scope, $uibModalInstance, \
guarantorData, guarantorFundDetail) { $scope.guarantorFundDetail = \
guarantorFundDetail; $scope.guarantorData = guarantorData;
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
scope.deleteGuarantor = function (id,fundId) {
scope.guarantorId = id;
scope.guarantorFundId = fundId;
$uibModal.open({
templateUrl: 'deleteguarantor.html',
controller: GuarantorDeleteCtrl,
resolve: {
id: function () {
return scope.guarantorId;
},
fundId: function () {
return scope.guarantorFundId;
}
}
});
};
var GuarantorDeleteCtrl = function ($scope, $uibModalInstance, id, \
fundId) { $scope.delete = function () {
resourceFactory.guarantorResource.delete({loanId: routeParams.id, \
templateResource: id,guarantorFundingId:fundId}, {}, function (data) { \
$uibModalInstance.close('delete'); route.reload();
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
};
}
});
mifosX.ng.application.controller('ListGuarantorController', ['$scope', \
'$routeParams', 'ResourceFactory', '$location', '$route', '$http', '$uibModal', \
'dateFilter', 'API_VERSION', '$sce', '$rootScope', \
mifosX.controllers.ListGuarantorController]).run(function ($log) { \
$log.info("ListGuarantorController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
LoanAccountActionsController: function (scope, rootScope, resourceFactory, \
location, routeParams, dateFilter) {
scope.action = routeParams.action || "";
scope.accountId = routeParams.id;
scope.formData = {};
scope.entityformData = {datatables:{}};
scope.showDateField = true;
scope.showNoteField = true;
scope.showAmountField = false;
scope.restrictDate = new Date();
// Transaction UI Related
scope.isTransaction = false;
scope.showPaymentDetails = false;
scope.paymentTypes = [];
scope.form = {};
scope.form.expectedDisbursementDate = [];
scope.disbursementDetails = [];
scope.showTrancheAmountTotal = 0;
scope.processDate = false;
scope.submittedDatatables = [];
var submitStatus = [];
rootScope.RequestEntities = function(entity,status,productId){
resourceFactory.entityDatatableChecksResource.getAll({limit:-1},function \
(response) {
scope.entityDatatableChecks = _.filter(response.pageItems , \
function(datatable){
var specificProduct = (datatable.entity == entity && \
datatable.status.value == status && datatable.productId == \
productId);
var AllProducts = (datatable.entity == entity && \
datatable.status.value == status);
return (datatable.productId?specificProduct:AllProducts);
});
scope.entityDatatableChecks = \
_.pluck(scope.entityDatatableChecks,'datatableName'); scope.datatables = [];
var k=0;
_.each(scope.entityDatatableChecks,function(entitytable) {
\
resourceFactory.DataTablesResource.getTableDetails({datatablename:entitytable,entityId: \
routeParams.id, genericResultSet: 'true'}, function (data) { \
data.registeredTableName = entitytable;
var colName = data.columnHeaders[0].columnName;
if (colName == 'id') {
data.columnHeaders.splice(0, 1);
}
colName = data.columnHeaders[0].columnName;
if (colName == 'client_id' || colName == 'office_id' || \
colName == 'group_id' || colName == 'center_id' || colName == 'loan_id' || colName == \
'savings_account_id') { data.columnHeaders.splice(0, 1);
scope.isCenter = (colName == 'center_id') ? true : \
false; }
data.noData = (data.data.length == 0);
if(data.noData){
scope.datatables.push(data);
scope.entityformData.datatables[k] = {data:{}};
submitStatus[k] = "save";
_.each(data.columnHeaders,function(Header){
\
scope.entityformData.datatables[k].data[Header.columnName] = ""; });
k++;
scope.isEntityDatatables = true;
}
});
});
});
};
scope.fetchEntities = function(entity,status,productId){
if(!productId){
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id}, function (data) { scope.productId = data.loanProductId;
rootScope.RequestEntities(entity,status,scope.productId);
});
}
else{
rootScope.RequestEntities(entity,status,productId);
}
};
//Stack overflow
function asyncLoop(iterations, func, callback) {
var index = 0;
var done = false;
var loop = {
next: function() {
if (done) {
return;
}
if (index < iterations) {
index++;
func(loop);
} else {
done = true;
callback();
}
},
iteration: function() {
return index - 1;
},
break: function() {
done = true;
}
};
loop.next();
return loop;
}
switch (scope.action) {
case "approve":
scope.taskPermissionName = 'APPROVE_LOAN';
resourceFactory.loanTemplateResource.get({loanId: \
scope.accountId, templateType: 'approval'}, function (data) {
scope.title = 'label.heading.approveloanaccount';
scope.labelName = 'label.input.approvedondate';
scope.modelName = 'approvedOnDate';
scope.formData[scope.modelName] = new Date();
scope.showApprovalAmount = true;
scope.formData.approvedLoanAmount = data.approvalAmount;
});
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'multiDisburseDetails'}, function \
(data) {
scope.form.expectedDisbursementDate = new \
Date(data.timeline.expectedDisbursementDate); scope.productId = data.loanProductId;
if(data.disbursementDetails != ""){
scope.disbursementDetails = data.disbursementDetails;
scope.approveTranches = true;
}
for(var i in data.disbursementDetails){
scope.disbursementDetails[i].expectedDisbursementDate = \
new Date(data.disbursementDetails[i].expectedDisbursementDate);
scope.disbursementDetails[i].principal = \
data.disbursementDetails[i].principal;
scope.showTrancheAmountTotal += \
Number(data.disbursementDetails[i].principal) ; }
scope.fetchEntities('m_loan','APPROVE',scope.productId);
});
break;
case "reject":
scope.title = 'label.heading.rejectloanaccount';
scope.labelName = 'label.input.rejectedondate';
scope.modelName = 'rejectedOnDate';
scope.formData[scope.modelName] = new Date();
scope.taskPermissionName = 'REJECT_LOAN';
scope.fetchEntities('m_loan','REJECTED');
break;
case "withdrawnByApplicant":
scope.title = 'label.heading.withdrawloanaccount';
scope.labelName = 'label.input.withdrawnondate';
scope.modelName = 'withdrawnOnDate';
scope.formData[scope.modelName] = new Date();
scope.taskPermissionName = 'WITHDRAW_LOAN';
scope.fetchEntities('m_loan','WITHDRAWN');
break;
case "undoapproval":
scope.title = 'label.heading.undoapproveloanaccount';
scope.showDateField = false;
scope.taskPermissionName = 'APPROVALUNDO_LOAN';
break;
case "undodisbursal":
scope.title = 'label.heading.undodisburseloanaccount';
scope.showDateField = false;
scope.taskPermissionName = 'DISBURSALUNDO_LOAN';
break;
case "disburse":
scope.modelName = 'actualDisbursementDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'disburse'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; if (data.paymentTypeOptions.length > 0) {
scope.formData.paymentTypeId = \
data.paymentTypeOptions[0].id; }
scope.formData.transactionAmount = data.amount;
scope.formData[scope.modelName] = new Date();
if (data.fixedEmiAmount) {
scope.formData.fixedEmiAmount = data.fixedEmiAmount;
scope.showEMIAmountField = true;
}
});
scope.title = 'label.heading.disburseloanaccount';
scope.labelName = 'label.input.disbursedondate';
scope.isTransaction = true;
scope.showAmountField = true;
scope.taskPermissionName = 'DISBURSE_LOAN';
scope.fetchEntities('m_loan','DISBURSE');
break;
case "disbursetosavings":
scope.modelName = 'actualDisbursementDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'disburseToSavings'}, function (data) { \
scope.formData.transactionAmount = data.amount; scope.formData[scope.modelName] = \
new Date(); if (data.fixedEmiAmount) {
scope.formData.fixedEmiAmount = data.fixedEmiAmount;
scope.showEMIAmountField = true;
}
});
scope.title = 'label.heading.disburseloanaccount';
scope.labelName = 'label.input.disbursedondate';
scope.isTransaction = false;
scope.showAmountField = true;
scope.taskPermissionName = 'DISBURSETOSAVINGS_LOAN';
break;
case "repayment":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'repayment'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; if (data.paymentTypeOptions.length > 0) {
scope.formData.paymentTypeId = \
data.paymentTypeOptions[0].id; }
scope.formData.transactionAmount = data.amount;
scope.formData[scope.modelName] = new Date(data.date) || new \
Date(); if(data.penaltyChargesPortion>0){
scope.showPenaltyPortionDisplay = true;
}
});
scope.title = 'label.heading.loanrepayments';
scope.labelName = 'label.input.transactiondate';
scope.isTransaction = true;
scope.showAmountField = true;
scope.taskPermissionName = 'REPAYMENT_LOAN';
break;
case "prepayloan":
scope.modelName = 'transactionDate';
scope.formData.transactionDate = new Date();
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'prepayLoan'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; if (data.paymentTypeOptions.length > 0) {
scope.formData.paymentTypeId = \
data.paymentTypeOptions[0].id; }
scope.formData.transactionAmount = data.amount;
if(data.penaltyChargesPortion>0){
scope.showPenaltyPortionDisplay = true;
}
scope.principalPortion = data.principalPortion;
scope.interestPortion = data.interestPortion;
scope.feeChargesPortion = data.feeChargesPortion;
scope.processDate = true;
});
scope.title = 'label.heading.prepayloan';
scope.labelName = 'label.input.transactiondate';
scope.isTransaction = true;
scope.showAmountField = true;
scope.taskPermissionName = 'REPAYMENT_LOAN';
scope.action = 'repayment';
break;
case "waiveinterest":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'waiveinterest'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; scope.formData.transactionAmount = data.amount;
scope.formData[scope.modelName] = new Date(data.date) || new \
Date(); });
scope.title = 'label.heading.loanwaiveinterest';
scope.labelName = 'label.input.interestwaivedon';
scope.showAmountField = true;
scope.taskPermissionName = 'WAIVEINTERESTPORTION_LOAN';
break;
case "writeoff":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'writeoff'}, function (data) {
scope.formData[scope.modelName] = new Date(data.date) || new \
Date(); scope.writeOffAmount = data.amount;
scope.isLoanWriteOff = true;
});
scope.title = 'label.heading.writeoffloanaccount';
scope.labelName = 'label.input.writeoffondate';
scope.taskPermissionName = 'WRITEOFF_LOAN';
scope.fetchEntities('m_loan','WRITE_OFF');
break;
case "close-rescheduled":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'close-rescheduled'}, function (data) {
scope.formData[scope.modelName] = new Date(data.date) || new \
Date(); });
scope.title = 'label.heading.closeloanaccountasrescheduled';
scope.labelName = 'label.input.closedondate';
scope.taskPermissionName = 'CLOSEASRESCHEDULED_LOAN';
break;
case "close":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'close'}, function (data) {
scope.formData[scope.modelName] = new Date(data.date) || new \
Date(); });
scope.title = 'label.heading.closeloanaccount';
scope.labelName = 'label.input.closedondate';
scope.taskPermissionName = 'CLOSE_LOAN';
break;
case "unassignloanofficer":
scope.title = 'label.heading.unassignloanofficer';
scope.labelName = 'label.input.loanofficerunassigneddate';
scope.modelName = 'unassignedDate';
scope.showNoteField = false;
scope.formData[scope.modelName] = new Date();
scope.taskPermissionName = 'REMOVELOANOFFICER_LOAN';
break;
case "modifytransaction":
resourceFactory.loanTrxnsResource.get({loanId: scope.accountId, \
transactionId: routeParams.transactionId, template: 'true'}, function (data) {
scope.title = 'label.heading.editloanaccounttransaction';
scope.labelName = 'label.input.transactiondate';
scope.modelName = 'transactionDate';
scope.paymentTypes = data.paymentTypeOptions || [];
scope.formData.transactionAmount = data.amount;
scope.formData[scope.modelName] = new Date(data.date) || \
new Date(); if (data.paymentDetailData) {
if (data.paymentDetailData.paymentType) {
scope.formData.paymentTypeId = \
data.paymentDetailData.paymentType.id; }
scope.formData.accountNumber = \
data.paymentDetailData.accountNumber;
scope.formData.checkNumber = \
data.paymentDetailData.checkNumber;
scope.formData.routingCode = \
data.paymentDetailData.routingCode;
scope.formData.receiptNumber = \
data.paymentDetailData.receiptNumber;
scope.formData.bankNumber = \
data.paymentDetailData.bankNumber; }
});
scope.showDateField = true;
scope.showNoteField = false;
scope.showAmountField = true;
scope.isTransaction = true;
scope.showPaymentDetails = false;
scope.taskPermissionName = 'ADJUST_LOAN';
break;
case "deleteloancharge":
scope.showDelete = true;
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'DELETE_LOANCHARGE';
break;
case "recoverguarantee":
scope.showDelete = true;
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'RECOVERGUARANTEES_LOAN';
break;
case "waivecharge":
resourceFactory.LoanAccountResource.get({loanId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, function \
(data) {
if (data.chargeTimeType.value !== "Specified due date" && \
data.installmentChargeData) {
scope.installmentCharges = data.installmentChargeData;
scope.formData.installmentNumber = \
data.installmentChargeData[0].installmentNumber; scope.installmentchargeField = \
true; } else {
scope.installmentchargeField = false;
scope.showwaiveforspecicficduedate = true;
}
});
scope.title = 'label.heading.waiveloancharge';
scope.labelName = 'label.input.installment';
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'WAIVE_LOANCHARGE';
break;
case "paycharge":
resourceFactory.LoanAccountResource.get({loanId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId, command: 'pay'}, function \
(data) { if (data.dueDate) {
scope.formData.transactionDate = new Date(data.dueDate);
}
if (data.chargeTimeType.value === "Instalment Fee" && \
data.installmentChargeData) {
scope.installmentCharges = data.installmentChargeData;
scope.formData.installmentNumber = \
data.installmentChargeData[0].installmentNumber; scope.installmentchargeField = \
true; }
});
scope.title = 'label.heading.payloancharge';
scope.showNoteField = false;
scope.showDateField = false;
scope.paymentDatefield = true;
scope.taskPermissionName = 'PAY_LOANCHARGE';
break;
case "editcharge":
resourceFactory.LoanAccountResource.get({loanId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, function (data) { if \
(data.amountOrPercentage) { scope.showEditChargeAmount = true;
scope.formData.amount = data.amountOrPercentage;
if (data.dueDate) {
scope.formData.dueDate = new Date(data.dueDate);
scope.showEditChargeDueDate = true;
}
}
});
scope.title = 'label.heading.editcharge';
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'UPDATE_LOANCHARGE';
break;
case "editdisbursedate":
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'multiDisburseDetails'}, function (data) { \
scope.showEditDisburseDate = true;
scope.formData.approvedLoanAmount = data.approvedPrincipal;
scope.form.expectedDisbursementDate = new \
Date(data.timeline.expectedDisbursementDate); for(var i in \
data.disbursementDetails){
if(routeParams.disbursementId == \
data.disbursementDetails[i].id){
scope.formData.updatedExpectedDisbursementDate = new \
Date(data.disbursementDetails[i].expectedDisbursementDate);
scope.formData.updatedPrincipal = \
data.disbursementDetails[i].principal; scope.id = data.disbursementDetails[i].id;
}
}
});
scope.title = 'label.heading.editdisbursedate';
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'UPDATE_DISBURSEMENTDETAIL';
break;
case "recoverypayment":
scope.modelName = 'transactionDate';
resourceFactory.loanTrxnsTemplateResource.get({loanId: \
scope.accountId, command: 'recoverypayment'}, function (data) { scope.paymentTypes = \
data.paymentTypeOptions; if (data.paymentTypeOptions.length > 0) {
scope.formData.paymentTypeId = \
data.paymentTypeOptions[0].id; }
scope.formData.transactionAmount = data.amount;
scope.formData[scope.modelName] = new Date();
});
scope.title = 'label.heading.recoverypayment';
scope.labelName = 'label.input.transactiondate';
scope.isTransaction = true;
scope.showAmountField = true;
scope.taskPermissionName = 'RECOVERYPAYMENT_LOAN';
break;
case "adddisbursedetails":
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'multiDisburseDetails'}, function (data) { \
scope.addDisburseDetails = true;
scope.formData.approvedLoanAmount = data.approvedPrincipal;
scope.form.expectedDisbursementDate = new \
Date(data.timeline.expectedDisbursementDate);
if(data.disbursementDetails != ""){
scope.disbursementDetails = data.disbursementDetails;
}
if (scope.disbursementDetails.length > 0) {
for (var i in scope.disbursementDetails) {
scope.disbursementDetails[i].expectedDisbursementDate \
= new Date(scope.disbursementDetails[i].expectedDisbursementDate); }
}
scope.disbursementDetails.push({
});
});
scope.title = 'label.heading.adddisbursedetails';
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'UPDATE_DISBURSEMENTDETAIL';
break;
case "deletedisbursedetails":
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'multiDisburseDetails'}, function (data) { \
scope.deleteDisburseDetails = true;
scope.formData.approvedLoanAmount = data.approvedPrincipal;
scope.form.expectedDisbursementDate = new \
Date(data.timeline.expectedDisbursementDate); if(data.disbursementDetails != ""){
scope.disbursementDetails = data.disbursementDetails;
}
if (scope.disbursementDetails.length > 0) {
for (var i in scope.disbursementDetails) {
scope.disbursementDetails[i].expectedDisbursementDate \
= new Date(scope.disbursementDetails[i].expectedDisbursementDate); }
}
});
scope.title = 'label.heading.deletedisbursedetails';
scope.showNoteField = false;
scope.showDateField = false;
scope.taskPermissionName = 'UPDATE_DISBURSEMENTDETAIL';
break;
}
scope.cancel = function () {
location.path('/viewloanaccount/' + routeParams.id);
};
scope.addTrancheAmounts = function(){
scope.showTrancheAmountTotal = 0;
for(var i in scope.disbursementDetails ){
scope.showTrancheAmountTotal += \
Number(scope.disbursementDetails[i].principal); }
};
scope.deleteTranches = function (index) {
scope.disbursementDetails.splice(index, 1);
};
scope.addTranches = function () {
scope.disbursementDetails.push({
});
};
scope.submit = function () {
scope.processDate = false;
var params = {command: scope.action};
if(scope.action == "recoverguarantee"){
params.command = "recoverGuarantees";
}
if(scope.action == "approve"){
this.formData.expectedDisbursementDate = \
dateFilter(scope.form.expectedDisbursementDate, scope.df); \
if(scope.disbursementDetails != null) { this.formData.disbursementData = [];
for (var i in scope.disbursementDetails) {
this.formData.disbursementData.push({
id: scope.disbursementDetails[i].id,
principal: scope.disbursementDetails[i].principal,
expectedDisbursementDate: \
dateFilter(scope.disbursementDetails[i].expectedDisbursementDate, \
scope.df),
loanChargeId : \
scope.disbursementDetails[i].loanChargeId });
}
console.log("DISBURSEMENT DATA", \
this.formData.expectedDisbursementDate); }
if(scope.formData.approvedLoanAmount == null){
scope.formData.approvedLoanAmount = \
scope.showTrancheAmountTotal; }
}
if (this.formData[scope.modelName]) {
this.formData[scope.modelName] = \
dateFilter(this.formData[scope.modelName], scope.df); }
if (scope.action != "undoapproval" && scope.action != "undodisbursal" \
|| scope.action === "paycharge") { this.formData.locale = scope.optlang.code;
this.formData.dateFormat = scope.df;
}
if (scope.action == "repayment" || scope.action == "waiveinterest" || \
scope.action == "writeoff" || scope.action == "close-rescheduled"
|| scope.action == "close" || scope.action == "modifytransaction" \
|| scope.action == "recoverypayment" || scope.action == "prepayloan") { if \
(scope.action == "modifytransaction") { params.command = 'modify';
params.transactionId = routeParams.transactionId;
}
params.loanId = scope.accountId;
resourceFactory.loanTrxnsResource.save(params, this.formData, \
function (data) { location.path('/viewloanaccount/' + data.loanId);
});
} else if (scope.action == "deleteloancharge") {
resourceFactory.LoanAccountResource.delete({loanId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) { location.path('/viewloanaccount/' + data.loanId);
});
} else if (scope.action === "waivecharge") {
resourceFactory.LoanAccountResource.save({loanId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId, 'command': 'waive'}, \
this.formData, function (data) { location.path('/viewloanaccount/' + data.loanId);
});
} else if (scope.action === "paycharge") {
this.formData.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); \
resourceFactory.LoanAccountResource.save({loanId: routeParams.id, resourceType: \
'charges', chargeId: routeParams.chargeId, 'command': 'pay'}, this.formData, function \
(data) { location.path('/viewloanaccount/' + data.loanId);
});
} else if (scope.action === "editcharge") {
this.formData.dueDate = dateFilter(this.formData.dueDate, \
scope.df); resourceFactory.LoanAccountResource.update({loanId: routeParams.id, \
resourceType: 'charges', chargeId: routeParams.chargeId}, this.formData, function \
(data) { location.path('/viewloanaccount/' + data.loanId);
});
} else if (scope.action === "editdisbursedate") {
this.formData.expectedDisbursementDate = \
dateFilter(this.formData.expectedDisbursementDate, scope.df); for(var i in \
scope.disbursementDetails){ if(scope.disbursementDetails[i].id == scope.id){
scope.disbursementDetails[i].principal = \
scope.formData.updatedPrincipal;
scope.disbursementDetails[i].expectedDisbursementDate = \
dateFilter(scope.formData.updatedExpectedDisbursementDate, scope.df); }
}
this.formData.disbursementData = [];
this.formData.updatedExpectedDisbursementDate = \
dateFilter(scope.formData.updatedExpectedDisbursementDate, scope.df);
this.formData.expectedDisbursementDate = \
dateFilter(scope.form.expectedDisbursementDate, scope.df);
for (var i in scope.disbursementDetails) {
this.formData.disbursementData.push({
id: scope.disbursementDetails[i].id,
principal: scope.disbursementDetails[i].principal,
expectedDisbursementDate: \
dateFilter(scope.disbursementDetails[i].expectedDisbursementDate, \
scope.df),
loanChargeId : scope.disbursementDetails[i].loanChargeId
});
}
resourceFactory.LoanEditDisburseResource.update({loanId: \
routeParams.id, disbursementId: routeParams.disbursementId}, this.formData, function \
(data) { location.path('/viewloanaccount/' + data.loanId);
});
}else if(scope.action === "adddisbursedetails" || scope.action === \
"deletedisbursedetails") { this.formData.disbursementData = [];
for (var i in scope.disbursementDetails) {
this.formData.disbursementData.push({
id:scope.disbursementDetails[i].id,
principal: scope.disbursementDetails[i].principal,
expectedDisbursementDate: \
dateFilter(scope.disbursementDetails[i].expectedDisbursementDate, \
scope.df),
loanChargeId : \
scope.disbursementDetails[i].loanChargeId });
}
this.formData.expectedDisbursementDate = \
dateFilter(scope.form.expectedDisbursementDate, scope.df);
resourceFactory.LoanAddTranchesResource.update({loanId: \
routeParams.id}, this.formData, function (data) { location.path('/viewloanaccount/' \
+ data.loanId); });
}
else if (scope.action == "deleteloancharge") {
resourceFactory.LoanAccountResource.delete({loanId: \
routeParams.id, resourceType: 'charges', chargeId: routeParams.chargeId}, \
this.formData, function (data) { location.path('/viewloanaccount/' + data.loanId);
});
} else {
params.loanId = scope.accountId;
resourceFactory.LoanAccountResource.save(params, this.formData, \
function (data) {
location.path('/viewloanaccount/' + data.loanId);
});
}
};
scope.submitDatatable = function(){
if(scope.datatables) {
asyncLoop(Object.keys(scope.entityformData.datatables).length,function(loop){
var cnt = loop.iteration();
var formData = scope.entityformData.datatables[cnt];
formData.registeredTableName = \
scope.datatables[cnt].registeredTableName;
var params = {
datatablename: formData.registeredTableName,
entityId: routeParams.id,
genericResultSet: 'true'
};
angular.extend(formData.data,{dateFormat: scope.df, \
locale: scope.optlang.code});
_.each(formData.data, function (columnHeader) {
if (columnHeader.dateType) {
columnHeader = \
dateFilter(columnHeader.dateType.date, params.dateFormat); }
else if (columnHeader.dateTimeType) {
columnHeader = \
dateFilter(columnHeader.columnName.date, scope.df) + " " + \
dateFilter(columnHeader.columnName.time, scope.tf); }
});
var action = submitStatus[cnt];
resourceFactory.DataTablesResource[action](params, \
formData.data, function (data) {
submitStatus[cnt] = "update";
\
scope.submittedDatatables.push(scope.datatables[cnt].registeredTableName); \
loop.next();
},function(){
\
rootScope.errorDetails[0].push({datatable:scope.datatables[cnt].registeredTableName});
loop.break();
});
},function(){
scope.submit();
});
}
else{
scope.submit();
}
};
scope.$watch('formData.transactionDate',function(){
scope.onDateChange();
});
scope.fieldType = function (type) {
var fieldType = "";
if (type) {
if (type == 'CODELOOKUP' || type == 'CODEVALUE') {
fieldType = 'SELECT';
} else if (type == 'DATE') {
fieldType = 'DATE';
} else if (type == 'DATETIME') {
fieldType = 'DATETIME';
} else if (type == 'BOOLEAN') {
fieldType = 'BOOLEAN';
} else {
fieldType = 'TEXT';
}
}
return fieldType;
};
scope.onDateChange = function(){
if(scope.processDate) {
var params = {};
params.locale = scope.optlang.code;
params.dateFormat = scope.df;
params.transactionDate = \
dateFilter(this.formData.transactionDate, scope.df); params.loanId = \
scope.accountId; params.command = 'prepayLoan';
resourceFactory.loanTrxnsTemplateResource.get(params, function \
(data) { scope.formData.transactionAmount = data.amount;
if (data.penaltyChargesPortion > 0) {
scope.showPenaltyPortionDisplay = true;
}
scope.principalPortion = data.principalPortion;
scope.interestPortion = data.interestPortion;
});
}
};
}
});
mifosX.ng.application.controller('LoanAccountActionsController', \
['$scope','$rootScope', 'ResourceFactory', '$location', '$routeParams', 'dateFilter', \
mifosX.controllers.LoanAccountActionsController]).run(function ($log) { \
$log.info("LoanAccountActionsController initialized"); });
}(mifosX.controllers || {}));
;(function (module) {
mifosX.controllers = _.extend(module, {
LoanDocumentController: function (scope, location, http, routeParams, \
API_VERSION, Upload, $rootScope) { scope.loanId = routeParams.loanId;
scope.onFileSelect = function (files) {
scope.formData.file = files[0];
};
scope.submit = function () {
Upload.upload({
url: $rootScope.hostUrl + API_VERSION + '/loans/' + scope.loanId \
+ '/documents',
data: { name : scope.formData.name, description : \
scope.formData.description, file: scope.formData.file}, }).then(function (data) {
// to fix IE not refreshing the model
if (!scope.$$phase) {
scope.$apply();
}
location.path('/viewloanaccount/' + scope.loanId);
});
};
}
});
mifosX.ng.application.controller('LoanDocumentController', ['$scope', \
'$location', '$http', '$routeParams', 'API_VERSION', 'Upload', '$rootScope', \
mifosX.controllers.LoanDocumentController]).run(function ($log) { \
$log.info("LoanDocumentController initialized"); });
}(mifosX.controllers || {}));;(function (module) {
mifosX.controllers = _.extend(module, {
LoanForeclosureController: function (scope, routeParams, resourceFactory, \
location, route, http, $uibModal, dateFilter, $filter) { scope.accountId = \
routeParams.id; scope.formData = {};
scope.formData.loanId = scope.accountId;
scope.taskTypeName = 'Foreclosure';
scope.subTaskTypeName = 'Foreclosure';
scope.formData.transactionDate = new Date();
scope.restrictDate = new Date();
resourceFactory.LoanAccountResource.getLoanAccountDetails({loanId: \
routeParams.id, associations: 'all'}, function (data) { scope.loandetails = data;
});
scope.$watch('formData.transactionDate',function(){
scope.retrieveLoanForeclosureTemplate();
});
scope.retrieveLoanForeclosureTemplate = function() {
resourceFactory.loanTrxnsTemplateResource.get({
loanId: routeParams.id,
command: 'foreclosure',
transactionDate: dateFilter(this.formData.transactionDate, \
scope.df), dateFormat: scope.df,
locale: scope.optlang.code
}, function (data) {
scope.foreclosuredata = data;
scope.formData.outstandingPrincipalPortion = \
scope.foreclosuredata.principalPortion;
scope.formData.outstandingInterestPortion = \
scope.foreclosuredata.interestPortion; if \
(scope.foreclosuredata.unrecognizedIncomePortion) {
scope.formData.interestAccruedAfterDeath = \
scope.foreclosuredata.unrecognizedIncomePortion; }
scope.formData.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic