changes in course

This commit is contained in:
gandhimathi 2017-11-28 19:57:56 +05:30
parent 66a6f96b9f
commit cc9685f39e

View File

@ -9,18 +9,37 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
"courseCode": "",
"courseName": "",
"universityName":"",
"switchsetting": true
"switchsetting": true,
"ListName": "",
"programListName":"",
"semYear":"",
"feesAmount":"",
"provFess":"",
"transferAmount":"",
"degreeAmount":"",
"migrationAmount":"",
"otherAmount":""
};
$rootScope.myModel1 = {
"ListName": "",
"programListName":""
};
/*
* edit branch details
* edit course details
* created by kms
* */
$scope.editId = -1;
$scope.setEditId = function (pid) {
$rootScope.setEditId = function (pid,p) {
// find index for fees type drop down list
for(var i in $scope.feesDetails) {
if($scope.feesDetails[i].ListCode==p.FeesType){
$rootScope.myModel1.ListName=$scope.feesDetails[i];
}
}
$scope.editId = pid;
$scope.viewId = -1;
};
/*
@ -28,7 +47,7 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
* created by kms
* */
$scope.cancel = function () {
$scope.init();
$rootScope.init();
$scope.editId = -1;
};
@ -45,7 +64,8 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
* created by kms
* */
$scope.courseForm = {
submit: function (form, myModel,loading) {
submit: function (form, myModel,loading,addMoreItems) {
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -62,6 +82,27 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
angular.element('.ng-invalid[name=' + firstError + ']').focus();
// swal("The form cannot be submitted because it contains validation errors!", "Errors are marked with a red, dashed border!", "error");
} else {
if(myModel.programListName=='P001'){
$scope.addMoreItems.push({
program: myModel.programListName,
FeesName: 'Regular',
FeesAmount: myModel.feesAmount
});
}
else if(myModel.programListName=='P002'){
$scope.addMoreItems.push({
program: myModel.programListName,
FeesName: 'Lateral Entry',
FeesAmount: myModel.feesAmount
});
}
else if(myModel.programListName=='Y001'){
$scope.addMoreItems.push({
program: myModel.programListName,
FeesName: myModel.semYear,
FeesAmount: myModel.feesAmount
});
}
$scope.ldloading1 = {};
@ -76,9 +117,16 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
},
data: {
courseID: myModel.courseCode,
courseName: myModel.courseName,
courseName: myModel.courseName,
universityName: myModel.universityName,
feesType:myModel.ListName.ListCode,
status: myModel.switchsetting,
provFess:myModel.provFess,
transferAmount:myModel.transferAmount,
degreeAmount:myModel.degreeAmount,
migrationAmount:myModel.migrationAmount,
otherAmount:myModel.otherAmount,
feesAmounts:$scope.addMoreItems,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
}
};
@ -97,7 +145,9 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
}
},
reset: function (form) {
$scope.addMoreItems = [];
$scope.myModel.ListName=$scope.feesDetails[0];
$scope.myModel.programListName=$scope.myModel.ListName.programType[0].ListCode;
$scope.myModel = angular.copy($scope.master);
form.$setPristine(true);
}
@ -107,7 +157,7 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
* created by kms
* */
$scope.updateCourse = function (myModel, form, loading) {
console.log(form);
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -138,8 +188,14 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
data: {
courseCode: myModel.CourseID,
courseName: myModel.CourseName,
provFess:myModel.PC,
transferAmount:myModel.TC,
degreeAmount:myModel.DC,
migrationAmount:myModel.MC,
otherAmount:myModel.OtherFees,
feesAmounts:myModel.feesStructures,
status: myModel.IsActive,
createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID
updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID
}
};
$http(update).then(function (response) {
@ -147,7 +203,7 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
$scope.ldloading[loading.replace('-', '_')] = false;
swal("Success!", response.data.message, "success");
$scope.editId = -1;
$scope.init();
$rootScope.init();
} else {
$scope.ldloading[loading.replace('-', '_')] = false;
@ -166,7 +222,7 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
$scope.emptyData='';
$rootScope.init = function () {
$scope.loader='';
var getBranch = {
method: 'POST',
url: apiPoint.url + 'getCourseDetails/',
@ -184,7 +240,9 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
$scope.data = response.data.details;
$scope.university=response.data.universityDetails;
$scope.feesDetails=response.data.feesDetails;
$scope.myModel.ListName=$scope.feesDetails[0];
$scope.myModel.programListName=$scope.myModel.ListName.programType[0].ListCode;
} else {
@ -196,6 +254,51 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab
});
};
/*
* get fees type drop down
* created by kms
* */
$scope.getFeesProgram = function () {
$scope.myModel.programListName=$scope.myModel.ListName.programType[0].ListCode;
$scope.addMoreItems = [];
}
/*
* get add more fees item array
* created by kms
* */
$scope.addMoreItems = [];
$rootScope.addMoreFeesItems = function (model,form) {
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
for (field in form) {
if (field[0] != '$') {
if (firstError === null && !form[field].$valid) {
firstError = form[field].$stop_name;
}
if (form[field].$pristine) {
form[field].$dirty = true;
}
}
}
angular.element('.ng-invalid[name=' + firstError + ']').focus();
} else {
$scope.addMoreItems.push({
program: model.programListName,
FeesName: model.semYear,
FeesAmount: model.feesAmount
});
$scope.myModel.semYear="";
$scope.myModel.feesAmount="";
}
}