$scope.year_selected = false; $scope.isstaff = ''; $scope.issection = ''; $scope.selected_branch_id = ''; $scope.selected_academic_id = ''; $scope.selected_course_parent_id = ''; $scope.selected_course_id = ''; $scope.selected_year = ''; $scope.selected_semister = 0; $scope.selected_section_id = 0; $scope.section_object = []; $scope.courses_object = []; $scope.total_semisters = 0; $scope.semisters = []; $scope.have_semisters = false; $scope.academic_years = []; $scope.parent_courses = []; $scope.sections = []; $scope.courses = []; $scope.parent_selected = false; $scope.years = []; $scope.result_data = []; $scope.reffrance_detail = ''; @if(isset($user_slug)) $scope.pre_selected_branch_id = ''; $scope.pre_selected_academic_id = ''; $scope.pre_selected_course_parent_id = ''; $scope.pre_selected_course_id = ''; $scope.pre_selected_year = 1; $scope.pre_selected_semister = 0; @endif $scope.resetYears = function(){ $scope.years = []; $scope.selected_year = null; $scope.current_year = null; $scope.result_data = []; $scope.resetSemisters(); } $scope.resetSemisters = function(){ $scope.total_semisters = 0; $scope.semisters = []; $scope.have_semisters = false; $scope.current_semister = ''; $scope.result_data=[]; } $scope.resetCourses = function(){ $scope.selected_course_id = ''; $scope.courses = []; $scope.resetYears(); } $scope.resetSection = function(){ $scope.selected_section_id = ''; $scope.sections = []; $scope.resetYears(); } $scope.resetParentCourses = function(){ $scope.parent_courses = []; $scope.selected_course_parent_id = ''; $scope.course_parent_id = ''; $scope.resetCourses(); } $scope.resetAcademicYears = function(){ $scope.academic_years = []; $scope.selected_academic_id = ''; $scope.academic_id = ''; $scope.resetParentCourses(); } $scope.resetFields = function(){ $scope.selected_branch_id = ''; $scope.resetAcademicYears(); } $scope.getAcademicYears = function(branch_id) { if(branch_id=='') return; $scope.resetFields(); $scope.selected_branch_id = branch_id; route = '{{URL_ACADEMICS_COURSES_GET_ACADEMIC_YEARS}}'; data= { _method: 'post', '_token':httpPreConfig.getToken(), 'branch_id': branch_id }; httpPreConfig.webServiceCallPost(route, data).then(function(result){ $scope.academic_years = result.data; if($scope.pre_selected_academic_id) { index = httpPreConfig.findIndexInData( $scope.academic_years,'id', $scope.pre_selected_academic_id ); setTimeout(function () { $scope.$apply(function(){ $scope.academic_id = $scope.academic_years[index]; $('#academic_id').val($scope.pre_selected_academic_id); }); }, 100); $scope.getParentCourses($scope.selected_branch_id,$scope.pre_selected_academic_id); } }); } $scope.getParentCourses = function(branch_id,academic_id) { if(branch_id=='' || academic_id=='') return; $scope.resetParentCourses(); $scope.selected_academic_id = academic_id; setTimeout(function () { $scope.$apply(function(){ $('#academic_id').val(academic_id); }); }, 100); route = '{{URL_ACADEMICS_COURSES_GET_PARENT_COURSES}}'; data= { _method: 'post', '_token':httpPreConfig.getToken(), 'branch_id': branch_id, 'academic_id': academic_id }; httpPreConfig.webServiceCallPost(route, data).then(function(result){ $scope.parent_courses = result.data; if($scope.pre_selected_course_parent_id) { index = httpPreConfig.findIndexInData( $scope.parent_courses,'id', $scope.pre_selected_course_parent_id ); setTimeout(function () { $scope.$apply(function(){ $scope.course_parent_id = $scope.parent_courses[index]; $('#course_parent_id').val($scope.pre_selected_course_parent_id); }); }, 100); $scope.getChildCourses($scope.selected_branch_id, $scope.selected_academic_id, $scope.pre_selected_course_parent_id); } }); } $scope.getChildCourses = function(branch_id, academic_id, parent_course_id,selected_course_id=0){ if(branch_id=='') return; if(academic_id=='') return; if(parent_course_id=='') return ; if(selected_course_id>0) { $scope.pre_selected_course_id = selected_course_id; } $scope.resetCourses(); $scope.selected_course_parent_id = parent_course_id; setTimeout(function () { $scope.$apply(function(){ $('#course_parent_id').val(parent_course_id); }); }, 100); route = '{{URL_ACADEMICS_COURSES_GET_CHILD_COURSES}}'; data= { _method: 'post', '_token':httpPreConfig.getToken(), 'branch_id': branch_id, 'academic_id': academic_id, 'parent_course_id': parent_course_id }; httpPreConfig.webServiceCallPost(route, data).then(function(result){ angular.forEach(result.data, function(value, key){ $scope.courses.push(value.course); $scope.courses_object.push(value); if(key==0 && selected_course_id!=0){ $scope.pre_selected_course_id = value.course.id; } }); $scope.parent_selected = true; if($scope.pre_selected_course_id) { index = httpPreConfig.findIndexInData( $scope.courses,'id', $scope.pre_selected_course_id ); setTimeout(function () { $scope.$apply(function(){ $scope.course_id = $scope.courses[index]; $('#course_id').val($scope.pre_selected_course_id); }); }, 100); $scope.getCoursesections($scope.pre_selected_course_id) } }); //if($scope.isstaff==1) { $scope.selected_semister = 0; $scope.selected_year = 1; @if(!isset($doCall)) $scope.doCall(); @endif return; //} } $scope.getCoursesections = function(course_id){ $scope.resetSection(); $scope.selected_course_id = course_id; setTimeout(function () { $scope.$apply(function(){ $('#course_id').val(course_id); }); }, 100); route = '{{URL_ACADEMICS_SECTION_GET_CHILD_SECTIONS}}'; data= { _method: 'post', '_token':httpPreConfig.getToken(), 'course_id': course_id }; httpPreConfig.webServiceCallPost(route, data).then(function(result){ angular.forEach(result.data, function(value, key){ $scope.sections.push(value.section); $scope.section_object.push(value); }); }); if($scope.issection!=1){ $scope.prepareYears(course_id); } } $scope.prepareYears = function(course){ $scope.resetYears(); if(course==null || course=='') { return; } index = httpPreConfig.findIndexInData($scope.courses, 'id', course); total_years = $scope.courses[index].course_dueration; $scope.selected_course_id = $scope.courses[index].id; if(total_years==1) { $scope.selected_semister = 0; $scope.selected_year = 1; @if(!isset($doCall)) $scope.doCall(); @endif return; } $scope.years = { "current_year": "Select","values": ['Select'] }; for(i=1; i<=total_years; i++) { $scope.years.values.push(i); } $scope.current_year = 'select'; if($scope.pre_selected_year) { $scope.years.current_year = $scope.pre_selected_year; $scope.current_year = $scope.years.current_year; $scope.yearChanged($scope.years.current_year) } } $scope.prepareSection = function(section){ $scope.selected_section_id = section; $scope.selected_semister = 0; $scope.selected_year = 1; @if(!isset($doCall)) $scope.doCall(); @endif } $scope.yearChanged = function (year_number) { $scope.resetSemisters(); $scope.year_selected = true; branch_id = $scope.selected_branch_id; academic_id = $scope.selected_academic_id; parent_course_id = $scope.selected_course_parent_id; course_id = $scope.selected_course_id; $scope.selected_year = year_number; year = year_number; angular.forEach($scope.courses_object, function(course, key){ if(course.course.id == course_id){ angular.forEach(course.semister, function(semister, no){ if(semister.year== year){ if(semister.total_semisters>0) { semisters =[]; $scope.semisters = { "current_semister": "Select","values": ['Select'] }; for(i=1; i<=semister.total_semisters; i++) { $scope.semisters.values.push(i); } $scope.current_semister = 'select'; $scope.total_semisters = semister.total_semisters; $scope.have_semisters = true; } else { $scope.total_semisters = 0; $scope.semisters = []; $scope.have_semisters = false; } } }); } }); @if(!isset($doCall)) if(!$scope.have_semisters) $scope.doCall(); @endif } $scope.semisterChanged = function(current_semister){ $scope.selected_semister = current_semister; @if(!isset($doCall)) $scope.doCall(); @endif } $scope.checkReffranceno = function(reffrance_no){ reffrance_no = $('#student_reffrance_no').val(); $scope.reffrance_detail = "No Record Found of this reference number"; route = '{{URL_CHECK_REFFRANCE_NO}}'; data= { _method: 'post', '_token':httpPreConfig.getToken(), 'reffrance_no': reffrance_no }; httpPreConfig.webServiceCallPost(route, data).then(function(result){ angular.forEach(result.data, function(value, key){ $scope.reffrance_detail = "This reference number is alloted to "+value.name+" son/daughter of "+value.father_name }); }); } $scope.setPreSelectedData = function( branch_id, academic_id, parent_course_id, course_id, year, semister,isstaff,issection) { $scope.pre_selected_branch_id = branch_id; $scope.pre_selected_academic_id = academic_id; $scope.pre_selected_course_parent_id = parent_course_id; $scope.pre_selected_course_id = course_id; $scope.pre_year = year; $scope.pre_semister = semister; $scope.branch_id = branch_id; $scope.selected_branch_id = branch_id; $scope.isstaff = isstaff; $scope.issection = issection; $scope.getAcademicYears(branch_id); }