///
///
///
///
(function (window) {
if (!ts.progresshistory)
ts.progresshistory = {};
ts.progresshistory.index = {
hasAddPermission: false,
hasModifyPermission: false,
hasDeletePermission: false,
hasOverridePermission: false,
studentEid: null,
studentName: null,
studentNumber: null,
program: null,
period: null,
programEnrollmentId: null,
progressHistoryId: null,
validator: null,
init: function () {
// set properties
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.hasOverridePermission = $('#HasOverridePermission').length && $('#HasOverridePermission').val().toLowerCase() == "true";
if (prospectStudentSearch) {
prospectStudentSearch.on('selectionChanged', this.loadStudent);
}
ts.profileheaderinfo.getheaderforpersoneid('fullName', this.studentEid);
if (this.studentEid) {
// register events
this.registerEvents();
}
},
registerEvents: function () {
var scope = this;
$('#findForm').submit(function () {
scope.search(true);
return false;
});
$('#ddlPrograms').change(function () {
scope.search(true);
});
$('#ddlSapStatuses').change(function () {
scope.search(true);
});
$('#ddlAcademicStatuses').change(function () {
scope.search(true);
});
$('.studentHistoryGlyph').live('click', function (e) {
if ($(e.target).is('a')) return;
e.stopImmediatePropagation();
scope.progressHistoryId = $(this).attr('ts-id');
scope.studentName = $(this).attr('ts-name');
scope.studentNumber = $(this).attr('ts-number');
scope.program = $(this).attr('ts-program');
scope.period = $(this).attr('ts-period');
var id = ts.win.modal({
url: '/Academics/StudentProgressHistoryDetails/Get/' + $(this).attr('ts-id'),
data: { name: scope.studentName, program: scope.program, period: scope.period, hasOverridePermission: scope.hasOverridePermission },
id: 'formStudentProgressHistoryDetails',
title: 'Student Progress History Details',
binder: function () {
scope.validate();
$('#appealRequested').datepicker();
$('#decisionDate').datepicker();
$('#cancelDetails').live('click', function (e) {
ts.win.closeModal(id);
});
}
});
});
$('#saveDetails').live('click', function (e) {
if (scope.hasModifyPermission || scope.hasOverridePermission) {
scope.save(id);
} else {
ts.msg.sendInfo("You don't have the proper permissions for this action");
}
});
$('#printAppeal').live('click', function () {
scope.print(scope.progressHistoryId, scope.studentName, scope.studentNumber, scope.program, scope.period);
});
$('#recalculateProgressHistory').click(function (e) {
if (scope.hasModifyPermission || scope.hasOverridePermission) {
if (confirm('Are you sure you want to recalculate all the student evaluation?')) {
scope.recalculate();
}
} else {
ts.msg.sendInfo("You don't have the proper permissions for this action");
}
});
$('#recalculateRecord').live('click', function (e) {
if (scope.hasModifyPermission || scope.hasOverridePermission) {
if (confirm('Are you sure you want to recalculate the selected record?')) {
scope.recalculate($(this).attr('ts-id'));
}
}
else {
ts.msg.sendInfo("You don't have the proper permissions for this action");
}
});
$('#exportProgressHistory').click(function () {
if (scope.studentEid) {
ts.msg.sendInfo('exporting data');
var url = "/Academics/StudentProgressHistory/Export/Student/" + scope.studentEid;
location.href = url;
}
});
$('#refreshProgressHistory').click(function () {
if (scope.studentEid) {
ts.msg.sendInfo('Refreshing ..');
var url = '/Academics/StudentProgressHistory/' + scope.studentEid;
location.href = url;
}
});
//sorting
$('#Period').live('click', function () {
scope.setSorting('Period');
});
$('#Program').live('click', function () {
scope.setSorting('Program');
});
$('#SAPStatus').live('click', function () {
scope.setSorting('SAPStatus');
});
$('#AcademicStatus').live('click', function () {
scope.setSorting('AcademicStatus');
});
$('#EvaluatedDate').live('click', function () {
scope.setSorting('EvaluatedDate');
});
$('#AppealStatus').live('click', function () {
scope.setSorting('AppealStatus');
});
},
formData: function(form, name, value) {
var $data = $('').attr({
type: 'hidden',
name: name,
value: value
});
form.append($data);
},
print: function (progressHistoryId, name, number, program, period) {
var scope = this;
ts.msg.sendInfo('Printing ..');
ts.ajax.send({
url: '/Academics/StudentProgressHistory/AppealPrint/Id/' + progressHistoryId,
data: { name: name, number: number, program: program, period: period },
type: 'GET',
successHandler: function (result) {
ts.ajax.handleResult(result);
if (result.State == 0) {
var $form = $('
', { action: "/Setup/Institution/Prints/PrintContentTracking/", method: 'POST' });
ts.progresshistory.index.formData($form, 'Content', result.HtmlResult);
ts.progresshistory.index.formData($form, 'PrintType', 'PDF');
ts.progresshistory.index.formData($form, 'RecipientId', result.Subject);
ts.progresshistory.index.formData($form, 'Subject', 'Print Tracking');
$form.appendTo("body");
$form.submit();
}
else {
ts.msg.sendError(result.Messages[0].Message);
}
},
errorHandler: function (result) {
ts.msg.sendError('An error occurred while print student progress history appeal.');
ts.msg.sendMsg('sysWarning', 'unknown error ts.progresshistory.index.print ajax: ' + result.responseText);
}
});
},
recalculate: function (id) {
var scope = this;
if (scope.studentEid) {
ts.msg.sendInfo('Recalculating ..');
var url = "/Academics/StudentProgressHistory/Recalculate/" + scope.studentEid + "/" + id;
if (!id) {
url = "/Academics/StudentProgressHistory/Recalculate/" + scope.studentEid;
}
ts.ajax.send({
url: url,
type: 'POST',
successHandler: function (result) {
ts.ajax.handleResult(result);
if (result.State == 0) {
ts.msg.sendInfo('Recalculation has started');
} else {
ts.msg.sendError(result.Messages[0].Message);
}
},
errorHandler: function (result) {
ts.msg.sendError('An error occurred while saving student progress history record.');
ts.msg.sendMsg('sysWarning', 'unknown error ts.progresshistory.index.save ajax: ' + result.responseText);
}
});
}
},
search: function (resetSort) {
if (resetSort) {
$('#selectedSortColumn').val('Period');
$('#IsAscending').val('false');
}
ts.msg.sendInfo('Searching for records...');
ts.list.applyFilter('studenthistory', function (config) {
ts.msg.sendInfo('Found ' + config.totalRecordCount + ' records that match your search');
});
},
setSorting: function (column) {
var scope = this;
$('#selectedSortColumn').val(column);
if ($('#IsAscending').val() == "true")
$('#IsAscending').val("false");
else
$('#IsAscending').val("true");
if (($('.studentHistoryGlyph').length != 0))
scope.search(false);
},
save: function (id) {
if ($('#formStudentProgressHistoryDetails').valid()) {
ts.ajax.send({
url: '/Academics/StudentProgressHistoryDetails/Save',
data: $('#formStudentProgressHistoryDetails').serialize(),
type: 'POST',
successHandler: function (result) {
ts.ajax.handleResult(result);
if (result.State == 0) {
ts.win.closeModal(id);
var url = '/Academics/StudentProgressHistory/' + ts.progresshistory.index.studentEid;
location.href = url;
} else {
ts.msg.sendError(result.Messages[0].Message);
}
},
errorHandler: function (result) {
ts.msg.sendError('An error occurred while saving student progress history record.');
ts.msg.sendMsg('sysWarning', 'unknown error ts.progresshistory.index.save ajax: ' + result.responseText);
}
});
}
},
validate: function () {
$.validator.addMethod("customRequired", function (value, element) {
var required = $('#appealRequested').val() != "" || $('#txtNotes').val() != "" || $('#decisionDate').val() != "";
return !required || value != "";
});
$("#formStudentProgressHistoryDetails").validate({});
$('#ddlAppealOutcome').rules("add", {
customRequired: true,
messages: {
'customRequired': 'Required'
}
});
ts.progresshistory.index.validator = $("#formStudentProgressHistoryDetails").validate();
$('#txtNotes').live('change', function () {
ts.progresshistory.index.validator.form();
});
$('#decisionDate').live('change', function () {
ts.progresshistory.index.validator.form();
});
$('#appealRequested').live('change', function () {
ts.progresshistory.index.validator.form();
});
},
loadStudent: function (studentEid, studentName) {
var url = '/Academics/StudentProgressHistory/' + studentEid;
location.href = url;
}
};
$(document).ready(function () {
ts.progresshistory.index.init();
});
})(window);