From 9e8d4e0d1df9752643a395a6bd545e9f74140936 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Thu, 25 Jan 2018 17:47:31 +0530 Subject: [PATCH] course details changes done --- Apollo/assets/js/controllers/courseCtrl.js | 97 +++++++++++++--------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/Apollo/assets/js/controllers/courseCtrl.js b/Apollo/assets/js/controllers/courseCtrl.js index c77c5f1f..f795ca35 100755 --- a/Apollo/assets/js/controllers/courseCtrl.js +++ b/Apollo/assets/js/controllers/courseCtrl.js @@ -18,7 +18,10 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab "transferAmount":"", "degreeAmount":"", "migrationAmount":"", - "otherAmount":"" + "otherAmount":"", + "specilization1":"", + "specilization2":"", + }; $rootScope.myModel1 = { "ListName": "", @@ -125,7 +128,8 @@ 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 { + } + else { if(semYearModel.program=='Y001' && semYearModel.programName!="" || semYearModel.FeesAmount!=""){ $scope.addMoreItems.push({ @@ -137,45 +141,55 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab }); } - $scope.ldloading1 = {}; + if(regularModel.FeesAmount=='' && lateralModel.FeesAmount=='' && $scope.addMoreItems.length==0){ + swal("Failed!", 'Please Enter Single/Sem-Year Fees ', "error"); - $scope.ldloading1[loading.replace('-', '_')] = true; + } + else{ + $scope.ldloading1 = {}; + + $scope.ldloading1[loading.replace('-', '_')] = true; + + + var addCourse = { + method: 'POST', + url: apiPoint.url + 'addCourseDetails/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + courseID: myModel.courseCode, + 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, + regularFeesAmounts:regularModel, + lateralFeesAmounts:lateralModel, + semFeesAmounts:$scope.addMoreItems, + createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID, + specilization1:myModel.specilization1, + specilization2:myModel.specilization2 + } + }; + $http(addCourse).then(function (response) { + if (response.data.status==200 && response.data.courseStatus) { + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Success!", response.data.message, "success"); + $state.go($state.current, {}, {reload: true}); + } else { + $scope.addMoreItems.splice($scope.addMoreItems.length-1); + $scope.ldloading1[loading.replace('-', '_')] = false; + swal("Failed!", response.data.message, "error"); + } + }); + } - var addCourse = { - method: 'POST', - url: apiPoint.url + 'addCourseDetails/', - headers: { - 'Content-Type': 'application/json' - }, - data: { - courseID: myModel.courseCode, - 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, - regularFeesAmounts:regularModel, - lateralFeesAmounts:lateralModel, - semFeesAmounts:$scope.addMoreItems, - createdBy: JSON.parse(localStorage.getItem('localObj')).localUserID - } - }; - $http(addCourse).then(function (response) { - if (response.data.status==200 && response.data.courseStatus) { - $scope.ldloading1[loading.replace('-', '_')] = false; - swal("Success!", response.data.message, "success"); - $state.go($state.current, {}, {reload: true}); - } else { - $scope.addMoreItems.splice($scope.addMoreItems.length-1); - $scope.ldloading1[loading.replace('-', '_')] = false; - swal("Failed!", response.data.message, "error"); - } - }); } @@ -243,7 +257,10 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab lateralFeesAmounts:lateral, semFeesAmounts:$rootScope.updateMoreItems, status: myModel.IsActive, - updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID + updatedBy: JSON.parse(localStorage.getItem('localObj')).localUserID, + specilization1:myModel.Specilization1, + specilization2:myModel.Specilization2, + existCourseID:myModel.CourseID } }; $http(update).then(function (response) { @@ -258,7 +275,7 @@ app.controller('courseCtrl', ["$scope","$rootScope","toaster", "$filter", "ngTab } else { $scope.ldloading[loading.replace('-', '_')] = false; - $rootScope.init(); + // $rootScope.init(); swal("Failed!", response.data.message, "error"); } });