///
///
///
///
(function (window) {
if (!ts.awardedcredit)
ts.awardedcredit = {};
ts.awardedcredit.form = {
hasAddPermission: false,
hasModifyPermission: false,
hasDeletePermission: false,
hasDegreeAuditTabPermissions: false,
studentId: null,
studentEid: null,
programEnrollmentId: null,
init: function () {
// set properties
this.studentId = $("#studentId").val();
this.studentEid = $("#StudentEid").val();
this.programEnrollmentId = $("#SelectedProgramEnrollmentId").val();
this.hasAddPermission = $('#HasAddPermission').length && $('#HasAddPermission').val().toLowerCase() == "true";
this.hasModifyPermission = $('#HasModifyPermission').length && $('#HasModifyPermission').val().toLowerCase() == "true";
this.hasDeletePermission = $('#HasDeletePermission').length && $('#HasDeletePermission').val().toLowerCase() == "true";
this.hasDegreeAuditTabPermissions = $('#HasDegreeAuditTabPermissions').length && $('#HasDegreeAuditTabPermissions').val().toLowerCase() == "true";
if (prospectStudentSearch) {
prospectStudentSearch.on('selectionChanged', this.loadStudent);
}
ts.profileheaderinfo.getheaderforpersoneid("studentInfo", this.studentEid);
if (this.studentId) {
// register events
this.registerEvents();
}
},
registerEvents: function () {
var scope = this;
scope.loadTransferCredit();
scope.loadCreditsByExamination();
scope.loadDegreeAudit();
$('#SelectedProgramEnrollmentId').change(function () {
scope.loadProgramEnrollment();
});
$('#mainPanel #sliderPanel').resize(function (e) {
ts.studentplacement.form.resizePanels();
});
if (scope.hasAddPermission || scope.hasModifyPermission) {
$('#AwardedCreditSaveLink').live("click", function (e) {
// if there isnt any transfer credit records and there is at least one credit by examination record
var callCreditByExam = $('#creditsByExaminationGridContainer .tsrow').length > 0;
if ($('div[id*=creditTransferGridContainer] .tsrow').length == 0 && callCreditByExam)
ts.awardedcredit.creditsbyexamination.saveCreditsByExamination(ts.awardedcredit.credittransfergrid.studentEid, ts.awardedcredit.credittransfergrid.programEnrollmentId);
else if (($('div[id*=creditTransferGridContainer] .tsrow').length > 0))
ts.awardedcredit.credittransfergrid.saveCreditTransfers(ts.awardedcredit.credittransfergrid.studentEid, ts.awardedcredit.credittransfergrid.programEnrollmentId, callCreditByExam);
else
ts.msg.sendInfo('There must be at least one credit transfer Or one credit by examination record for saving');
});
}
},
loadHeader: function () {
var scope = this;
ts.ajax.send({
url: '/Enrollment/AwardedCredit/' + scope.studentEid + '/' + scope.programEnrollmentId + '/Header',
errorHandler: function (data) {
ts.msg.sendError('An error occurred while loading Summary information.');
ts.msg.sendMsg('sysWarning', 'unknown error loadHeader: ' + data.responseText);
},
successHandler: function (data) {
ts.msg.sendInfo(' Summary information loaded.');
$('div#pageSummary').html(data);
}
});
},
resizePanels: function () {
var width = $('#sliderPanel').width() - 20;
var count = $('.childSliderPanel').length;
$('.childSliderPanel').width(width);
$('#sliderOuterPanel').width((width + 10) * (count + 1));
},
disabler: function (parent, child, off) {
if (off) {
$(parent + " " + child).attr("disabled", "disabled");
} else {
$(parent + " " + child).removeAttr('disabled');
}
},
loadStudent: function (studentEid, studentName) {
var url = '/Enrollment/AwardedCredit/' + studentEid;
location.href = url;
},
loadTransferCredit: function () {
var scope = this;
if (scope.programEnrollmentId) {
var isCredits = $('#IsCreditBasedProgram').val();
var url = String.format('/Enrollment/AwardedCredit/{0}/{1}/transfercredit/{2}', scope.studentId, scope.programEnrollmentId, isCredits);
ts.msg.sendInfo('Loading Transfer Credit information.');
ts.ajax.send({
url: url,
errorHandler: function (data) {
ts.msg.sendError('An error occurred while loading Transfer Credit information.');
ts.msg.sendMsg('sysWarning', 'unknown error Transfer Credit: ' + data.responseText);
},
successHandler: function (data) {
ts.msg.sendInfo('Transfer Credit loaded.');
$('div#transferCreditTabPanel').html(data);
var awardedcreditForm = ts.awardedcredit.form;
ts.awardedcredit.transfercredit.init(awardedcreditForm.studentId, awardedcreditForm.programEnrollmentId, awardedcreditForm.hasAddPermission, awardedcreditForm.hasModifyPermission, awardedcreditForm.hasDeletePermission);
}
});
} else {
$('div#transferCreditTabPanel').text('Program enrollment is needed, before you can award credits.');
}
},
loadCreditsByExamination: function () {
var scope = this;
if (scope.programEnrollmentId) {
var isCredits = $('#IsCreditBasedProgram').val();
var url = String.format('/Enrollment/AwardedCredit/{0}/{1}/creditsbyexamination/{2}', scope.studentId, scope.programEnrollmentId, isCredits);
ts.msg.sendInfo('Loading Credits By Examination information.');
ts.ajax.send({
url: url,
errorHandler: function (data) {
ts.msg.sendError('An error occurred while loading Credits by Examination information.');
ts.msg.sendMsg('sysWarning', 'unknown error Credits by Examination: ' + data.responseText);
},
successHandler: function (data) {
ts.msg.sendInfo('Credits by Examination loaded.');
$('div#creditsbyExaminationTabPanel').html(data);
var awardedcreditForm = ts.awardedcredit.form;
ts.awardedcredit.creditsbyexamination.init(awardedcreditForm.studentId, awardedcreditForm.programEnrollmentId, awardedcreditForm.hasAddPermission, awardedcreditForm.hasModifyPermission, awardedcreditForm.hasDeletePermission);
}
});
} else {
$('div#creditsbyExaminationTabPanel').text('Program enrollment is needed, before you can award credits by examination.');
}
},
loadDegreeAudit: function () {
var scope = this;
if (scope.hasDegreeAuditTabPermissions) {
if (scope.programEnrollmentId) {
var url = String.format('/Enrollment/AwardedCredit/{0}/{1}/DegreeAudit', scope.studentId, scope.programEnrollmentId);
ts.msg.sendInfo('Loading Degree Audit information.');
ts.ajax.send({
url: url,
errorHandler: function (data) {
ts.msg.sendError('An error occurred while loading Degree Audit Data.');
ts.msg.sendMsg('sysWarning', 'unknown error Transfer Credit: ' + data.responseText);
},
successHandler: function (data) {
ts.msg.sendInfo('Degree Audit Data loaded.');
$('div#degreeAuditTabPanel').html(data.HtmlResult);
}
});
} else {
$('div#transferCreditTabPanel').text('Program enrollment is needed, before you can award credits.');
}
}
},
loadProgramEnrollment: function () {
this.programEnrollmentId = $("#SelectedProgramEnrollmentId").val();
var url = '/Enrollment/AwardedCredit/' + this.studentId + '/' + this.programEnrollmentId;
location.href = url;
}
};
$(document).ready(function () {
var awardedcreditForm = ts.awardedcredit.form;
// init student placement form, register events, set studentId and permissions, load data
awardedcreditForm.init();
});
$(window).load(function () {
resizePanelseAfterSearchIsLoaded = function () {
if ($("#searchPanel").length > 0) {
ts.awardedcredit.form.resizePanels();
}
else {
window.setTimeout('resizePanelseAfterSearchIsLoaded()', 100);
}
};
resizePanelseAfterSearchIsLoaded();
});
})(window);