<html>
<head>
<title></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../WebResources/new_jQueryv1.9.1"></script>
<link href="../WebResources/bam_Bootstrap_min_css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="canvasjs.com/.../script>
<script src="../WebResources/new_bootstrap3.3.2.min.js"></script>
<link href="new_bootstrapmultiselect.css" type="text/css" rel="stylesheet">
<script src="new_bootstrapmultiselect.js"></script>
<link href="../WebResources/new_ReceivePaymentDashboardsCss" type="text/css" rel="stylesheet">
<script>
$(document).ready(function () {
debugger;
$('select.multiple').multiselect('refresh');
function toggleIcon(e) {
$(e.target)
.prev('.panel-heading')
.find(".more-less")
.toggleClass('glyphicon-plus glyphicon-minus');
}
$('.panel-group').on('hidden.bs.collapse', toggleIcon);
$('.panel-group').on('shown.bs.collapse', toggleIcon);
$('#search').on('click', SearchData);
});
var PaymentType;
function ShowData(type) {
debugger;
PaymentType=type;
//var _StudentIdColl = $('#tablemobel tr td input[type="radio"] checked');
var _StudentId = "B5E5201A-43A5-E911-A95E-000D3AF06091";//_StudentIdColl[0].value;
var FeeSummaryFetch = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"><entity name="new_feesummary"><attribute name="new_feesummaryid"/><attribute name="new_name"/><attribute name="new_feepaymentfor"/><attribute name="new_studentsession"/><attribute name="new_student"/><attribute name="new_accessamount"/><attribute name="new_enrollmentno"/><attribute name="new_advancepayment"/><attribute name="new_remainingamount"/><attribute name="new_totalfees1"/><attribute name="new_amountpaid" /><attribute name="new_amountpaid"/><attribute name="new_totalnetpayment"/><filter type="and"><condition attribute="new_student" operator="eq" value="' + _StudentId + '"/></filter><order attribute="new_name" descending="false"/><filter type="and"><condition attribute="new_remainingamount" operator="gt" value="0"/></filter><link-entity name="new_feepaymentnew" from="new_feesummary" to="new_feesummaryid" link-type="inner" alias="ac"/><link-entity name="sis_registration" from="sis_registrationid" to="sis_registrationid" link-type="inner" alias="re"><attribute name="sis_fathersname"/><attribute name="sis_dateofbirth"/><attribute name="new_admissionno"/></link-entity></entity></fetch>';
var ResultFeeSummary = getFetch("new_feesummarie", FeeSummaryFetch);
$('#accordion').html('');
if (ResultFeeSummary.value.length > 0) {
var studentName = ResultFeeSummary.value[0].new_name;
var Dob = ResultFeeSummary.value[0].re_x002e_sis_dateofbirth;
var fathername = ResultFeeSummary.value[0].re_x002e_sis_fathersname;
var admissionNumber = ResultFeeSummary.value[0].re_x002e_new_admissionno;
$('#studentnamediv').html(studentName);
$('#fathername').html(fathername);
$('#dob').html(Dob);
$('#enrollmentId').html(admissionNumber);
var totalFee = 0;
var RemainingFee = 0;
var depositFee = 0;
for (var i = 0; i < ResultFeeSummary.value.length; i++) {
totalFee += ResultFeeSummary.value[i].new_totalnetpayment;
RemainingFee += ResultFeeSummary.value[i].new_remainingamount;
depositFee += ResultFeeSummary.value[i].new_amountpaid;
}
var fetchAccessAmountOrAdvancePayment = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="new_feesummary"><attribute name="new_feesummaryid"/><attribute name="new_name"/><attribute name="createdon"/><attribute name="new_accessamount"/><attribute name="new_advancepayment"/><order attribute="new_name" descending="false"/><filter type="and"><filter type="or"><condition attribute="new_advancepayment" operator="gt" value="0"/><condition attribute="new_accessamount" operator="gt" value="0"/></filter><condition attribute="new_student" operator="eq" value="' + _StudentId + '"/></filter></entity></fetch>';
var ResultextraAmount = getFetch("new_feesummarie", fetchAccessAmountOrAdvancePayment);
var extraAmount = 0;
for (var i = 0; i < ResultextraAmount.value.length; i++) {
extraAmount += ResultextraAmount.value[i].hasOwnProperty("new_accessamount") ? ResultextraAmount.value[i].new_accessamount : 0;
extraAmount += ResultextraAmount.value[i].hasOwnProperty("new_advancepayment") ? ResultextraAmount.value[i].new_advancepayment : 0;
}
$('#totalFee').html(totalFee);
$('#AdvanceFee').html(extraAmount);
$('#remainingFee').html(RemainingFee);
$('#DepositFee').html(depositFee);
var FetchFeeHead = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="new_feeitempaymentnew"><attribute name="new_feeitempaymentnewid"/><attribute name="new_name"/><attribute name="new_feemaster"/><attribute name="new_feepaymentnew"/><attribute name="new_totalamountpaid" /><attribute name="new_amountleft"/><attribute name="new_amount"/><attribute name="new_feesummary"/><link-entity name="new_feepaymentnew" from="new_feepaymentnewid" to="new_feepaymentnew" link-type="inner" alias="ag"><attribute name="new_installmentnumber1"/><order attribute="new_installmentnumber1"/><link-entity name="new_feesummary" from="new_feesummaryid" to="new_feesummary" link-type="inner" alias="ai"><filter type="and"><condition attribute="new_student" operator="eq" value="' + _StudentId + '"/></filter></link-entity></link-entity></entity></fetch>';
var ResultFeeHead = getFetch("new_feeitempaymentnew", FetchFeeHead);
for (var i = 0; i < ResultFeeSummary.value.length; i++) {
var FeePaymentColl = ResultFeeHead.value.filter(function (item) { return item._new_feesummary_value == ResultFeeSummary.value[i].new_feesummaryid });
var FeePayment = FeePaymentColl[0];
var FilterHead = ResultFeeHead.value.filter(function (item) { return item._new_feesummary_value == ResultFeeSummary.value[i].new_feesummaryid && item._new_feepaymentnew_value == FeePayment._new_feepaymentnew_value });
var FeeType = ResultFeeSummary.value[i].new_feepaymentfor == 1 ? "Academic Fee" : ResultFeeSummary.value[i].new_feepaymentfor == 2 ? "Hoslel Fee" : "";
var _HTML = '<div class="panel panel-default">';
_HTML += '<div class="panel-heading" role="tab" id="' + ResultFeeSummary.value[i].new_feesummaryid + '">';
_HTML += '<h4 class="panel-title">';
_HTML += '<a role="button" data-toggle="collapse" data-parent="#accordion" href="#' + ResultFeeSummary.value[i].new_feesummaryid + i + '" aria-expanded="true" aria-controls="' + ResultFeeSummary.value[i].new_feesummaryid + 'i">';
_HTML += ' <i class="more-less glyphicon glyphicon-plus"></i>';
_HTML += '<label>' + FeeType + '</label>';
_HTML += ' </a>';
_HTML += ' </h4>';
_HTML += ' </div>';
_HTML += ' <div id="' + ResultFeeSummary.value[i].new_feesummaryid + i + '" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">';
_HTML += ' <div class="panel-body">';
_HTML += ' <div class="table-responsive">';
_HTML += ' <table class="table table-bordered"><thead>';
var _table = '<tr><th><input type="checkbox" id="checkbox' + i + '" onchange="CheckAll(this)"></th><th>Sr. No.</th><th>Fee Head</th><th>Total Fee</th><th>Left Fee</th><th>Pay Amount</th><th></th></tr></thead><tbody>';
for (var j = 0; j < FilterHead.length; j++) {
_table += '<tr><td><input type="checkbox" id="' + FilterHead[j].new_feeitempaymentnewid + '" class="checkbox' + i + '"></td><td>' + j + 1 + '</td><td>' + FilterHead[j]["_new_feemaster_value@OData.Community.Display.V1.FormattedValue"] + '</td><td>' + FilterHead[j].new_amount + '</td><td>' + FilterHead[j].new_amountleft + '</td><td><input type="text" class="headFee" onclick="headPay(this)" disabled=true></td></tr>';
}
_HTML += _table + '</tbody></table>';
_HTML += ' </div>';
_HTML += ' </div>';
_HTML += ' </div>';
_HTML += '</div>';
$('#accordion').append(_HTML);
}
$("ul li a label input[type='checkbox']").on('change', OnSelect);
$('th input[type="checkbox"]').on('change', UnableDisable);
}
}
function UnableDisable() {
var eleColl = $('td input[type="checkbox"]');
$.each(eleColl, function (i, ele) {
if ($(ele).prop('checked')) {
$(ele).parent().parent().find('input[type="text"]').prop('disabled', false);
}
else {
$(ele).parent().parent().find('input[type="text"]').prop('disabled', true);
}
});
}
function SearchData() {
var EnrollMentId = $('#enrollmetnId').val();
var StudentName = $('#studentname').val();
var result = '';
if (EnrollMentId != "") {
var fetchById = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"><entity name="new_student"><attribute name="new_studentname"/><attribute name="new_contact"/><attribute name="new_coursesession"/><attribute name="new_studentid" /><attribute name="new_course1"/><attribute name="new_studenti"/><attribute name="new_studentid"/><order attribute="new_studentname" descending="false"/><filter type="and"><condition attribute="new_studenti" operator="eq" value="2019B151009"/></filter><link-entity name="new_feesummary" from="new_student" to="new_studentid" link-type="inner" alias="aj"><link-entity name="new_coursestreamdivisionsession" from="new_coursestreamdivisionsessionid" to="new_division" link-type="inner" alias="ak"><filter type="and"><condition attribute="new_sessionstatus" operator="eq" value="1"/></filter></link-entity></link-entity>><link-entity name="sis_registration" from="sis_registrationid" to="sis_registrationid" visible="false" link-type="outer" alias="reg"><attribute name="sis_fathersname"/><attribute name="sis_dateofbirth"/></link-entity></entity></fetch>';
result = getFetch("new_student", fetchById);
}
else {
if (StudentName != "") {
var fetchByName = '<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true"><entity name="new_student"><attribute name="new_studentname"/><attribute name="new_contact"/><attribute name="new_coursesession"/><attribute name="new_studentid" /><attribute name="new_course1"/><attribute name="new_studenti"/><attribute name="new_studentid"/><order attribute="new_studentname" descending="false"/><filter type="and"><condition attribute="new_contactname" operator="like" value="%Test%"/></filter><link-entity name="new_feesummary" from="new_student" to="new_studentid" link-type="inner" alias="aj"><link-entity name="new_coursestreamdivisionsession" from="new_coursestreamdivisionsessionid" to="new_division" link-type="inner" alias="ak"><filter type="and"><condition attribute="new_sessionstatus" operator="eq" value="1"/></filter></link-entity></link-entity>><link-entity name="sis_registration" from="sis_registrationid" to="sis_registrationid" visible="false" link-type="outer" alias="reg"><attribute name="sis_fathersname"/><attribute name="sis_dateofbirth"/></link-entity></entity></fetch>';
result = getFetch("new_student", fetchByName);
}
else {
alert("Please provide enrollment id or student name");
return;
}
}
var _html = '<tr><th></th><th>Student Name</th><th>Father Name</th><th>Enrollment Id</th><th>DoB</th></tr>';
for (var i = 0; i < result.value.length; i++) {
_html += "<tr><td><input type='radio' id='" + result.value[i].new_studentid + "' name='student'></td><td>" + result.value[i]["_new_contact_value@OData.Community.Display.V1.FormattedValue"] + "</td><td>" + result.value[i].reg_x002e_sis_fathersname + "</td><td>" + result.value[i].new_studentname + "</td></tr>";
}
$('#tablemobel').html(_html);
}
function OnSelect() {
var SelectOption = $('#paymentMode').val();
var html = "<tr><th>Payment Mode</th><th>Amount</th><th>Cheque/DD No.</th><th>Cheque/DD Date</th><th>Bank</th><th>Branch</th></tr>";
if (SelectOption != null) {
for (var i = 0; i < SelectOption.length; i++) {
if (SelectOption[i] == 1) {
html += "<tr><td mode='1'>Cash</td><td><input 'text'></td><td></td><td></td><td></td><td></td></tr>";
}
if (SelectOption[i] == 2) {
html += "<tr><td mode='2'>Cheque</td><td><input 'text'></td><td><input type='text'></td><td><input type='date'></td><td><input type='text'></td><td><input type='text'></td></tr>";
}
if (SelectOption[i] == 3) {
html += "<tr><td mode='3'>Demand Draft</td><td><input 'text'></td><td><input type='text'></td><td><input type='date'></td><td></td><td></td></tr>";
}
}
}
$('#paymentModeTable').html(html);
}
function CheckAll(ele) {
var Id = ele.id;
if ($(ele).prop('checked')) {
$('.' + Id).prop('checked', true);
}
else {
$('.' + Id).prop('checked', false);
}
UnableDisable();
}
/////////////// Validation //////////
function DoValidate() {
debugger;
var SelectOption = $('#paymentMode').val();
$('#paymentModeTable').find('tr');
if (SelectOption == null) {
alert("Please select payment Mode");
return;
} else {
var AdvanceAmount = Number($('#AdvanceFee').html());
//////////////////////////////////// Update Fee Head /////////////
for (var i = 0; i < $('#accordion div div.panel-heading').length; i++) {
var FeeStructureId = $('#accordion div .panel-heading')[i].id;
var element = $('#accordion div div.panel-heading');
var TotalAmount = 0;
for (var j = 0; j < $(element[i]).parent().find('table tbody tr').length; j++) {
var _checkbox = $($(element[i]).parent().find('table tbody tr')[j]).find('td input[type="checkbox"]');
if (_checkbox.prop('checked'))
{
TotalAmount = '';
}
}
}
}
}
function checkOverAllFeeHeadWise(ele) {
var maxRemainVal = Number($('#remainingFee').html());
var totalAmount = 0;
for (var i = 0; i < $('input.headFee').length; i++) {
totalAmount += Number($('input.headFee')[i].val());
}
if (totalAmount > maxRemainVal) {
alert("Amount should not be grater than remaining amount");
}
}
function headPay(ele) {
if (headPay.val() == "") {
alert("Please Enter Amount");
}
var leftAmount = Number($(ele).parent().prev('td').html());
if (leftAmount < Number(ele.value)) {
alert("Amount should not be grater than left amount");
$(ele).val('');
}
checkOverAllFeeHeadWise(ele);
}
function getFetch(entity, fetchXML) {
var req = new XMLHttpRequest();
req.open("GET", window.parent.Xrm.Page.context.getClientUrl() + "/api/data/v8.2/" + entity + "s?fetchXml=" + fetchXML + "", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.send();
if (req.status === 200) {
return results = JSON.parse(req.response);
} else {
window.parent.Xrm.Utility.alertDialog(req.statusText);
}
}
</script>
<meta>
</head>
<body dir="LTR" onfocusout="parent.setEmailRange();" lang="en-US" style="overflow-wrap: break-word;">
<div class="body_background">
<div class="row grid-margin flex-grow">
<div class="col-md-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<div class="col-md-12">
<h4 class="card-title">Search</h4>
</div>
<div class="row">
<div class="col-md-11">
<div class="col-md-6">
<div class="form-group">
<label>Enrollment No</label>
<input type="text" id="enrollmetnId" class="form-control">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Student Name</label>
<input type="text" class="form-control" id="studentname">
</div>
</div>
</div>
<div class="col-md-1">
<div class="form-group">
<label> </label>
<button type="button" id="search" class="btn btn-dark btn-rounded pull-right" data-toggle="modal" data-target="#myModal">Search</button>
</div>
</div>
<div class="clearfix"></div>
<div class=" text-right " style="margin-bottom:15px; margin-top:20px">
</div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="col-md-6 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<div class="col-md-12">
<h4 class="card-title">Student Information</h4>
</div>
<div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-primary shadow py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2 pull-left">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Student Name</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" id="studentnamediv"></div>
</div>
<div class="col-auto pull-right">
<img src="../webresources/new_graduate-student-avatar">
</div>
</div>
</div>
</div>
</div><div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-success shadow py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2 pull-left">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">Fater Name</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" id="fathername"></div>
</div>
<div class="col-auto pull-right">
<img src="../webresources/new_father">
</div>
</div>
</div>
</div>
</div><div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-info shadow py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2 pull-left">
<div class="text-xs font-weight-bold text-info text-uppercase mb-1">Date of Birth</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" id="dob"></div>
</div>
<div class="col-auto pull-right">
<img src="../webresources/new_cake">
</div>
</div>
</div>
</div>
</div><div class="col-xl-3 col-md-6 mb-4">
<div class="card border-left-warning shadow py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2 pull-left">
<div class="text-xs font-weight-bold text-warning text-uppercase mb-1">Student Enrollment</div>
<div class="h5 mb-0 font-weight-bold text-gray-800" id="enrollmentId"></div>
</div>
<div class="col-auto pull-right">
<img src="../webresources/new_forms">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 stretch-card">
<!--- activity status card-->
<div class="card">
<div class="card-body">
<h4 class="card-title">Fee Information</h4>
<div class="card-inner-wrapper">
<div class="row ">
<div class="col-md-3 stretch-card">
<div class="card card-inner">
<div class="card-body">
<img src="../webresources/new_totalfee">
<p class="status">
Total Fee
</p>
<p class="count" id="totalFee">
</p>
</div>
</div>
</div>
<div class="col-md-3 stretch-card">
<div class="card card-inner">
<div class="card-body">
<img src="../webresources/new_advancepay">
<p class="status">
Advance Fee
</p>
<p class="count" id="AdvanceFee">
</p>
</div>
</div>
</div>
<div class="col-md-3 stretch-card">
<div class="card card-inner">
<div class="card-body">
<img src="../webresources/new_totalfee">
<p class="status">
Remaining Fee
</p>
<p class="count" id="remainingFee">
</p>
</div>
</div>
</div>
<div class="col-md-3 stretch-card">
<div class="card card-inner">
<div class="card-body">
<img src="../webresources/new_paidfee">
<p class="status">
Total Fee Deposit
</p>
<p class="count" id="DepositFee">
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!--- activity status card ends-->
</div>
<div class="col-lg-12 grid-margin stretch-card">
<div class="card">-
<div class="card-body">
<h4 class="card-title">Fee Payment</h4>
<!--<p class="card-description">Use class <code>.accordion</code> for Basic Accordion</p>-->
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
</div><!-- panel-group -->
</div>
</div>
</div>
<div class="col-lg-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<h4 class="card-title pull-left">Mode Of Payment</h4>
<div class="col-md-8 pull-right" style="padding-right:0px">
<div class="col-md-10 mltselect">
<select id="paymentMode" class="form-control pull-right multiple" multiple=""><option value="1">Cash</option><option value="2">Cheque</option><option value="3">Demand Draft</option></select>
</div>
<!--<div class="col-md-2" style="padding-right:0px">
<button type="button" class="btn btn-dark btn-rounded pull-right">submit</button>
</div>-->
</div>
<div class="clearfix"></div>
<!--<p class="card-description">Use class <code>.accordion</code> for Basic Accordion</p>-->
<div class="panel-group" role="tablist" aria-multiselectable="true">
<div class="table-responsive">
<table class="table table-bordered" id="paymentModeTable"></table>
</div>
<button type="button" class="btn btn-primary pull-right" onclick="DoValidate()">Pay</button>
</div><!-- panel-group -->
</div>
</div>
</div>
</div>
</div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Student Names</h4>
</div>
<div class="modal-body">
<table class="table table-bordered" id="tablemobel"></table>
</div>
<div class="modal-footer">
<!--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>-->
<button class="btn btn-primary" data-dismiss="modal" onclick="ShowData(1)">Quick pay</button>
<button class="btn btn-defaule" data-dismiss="modal" onclick="ShowData(2)">Pay</button>
<button class="btn btn-defaule" data-dismiss="modal">View</button>
</div>
</div>
</div>
</div>
</body>
</html>