From 819efcf35697c919128696c90e41a3d662251915 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Tue, 24 Apr 2018 18:21:13 +0530 Subject: [PATCH] student view changes --- .../application/models/Studentview_model.php | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/Apollo/api/application/models/Studentview_model.php b/Apollo/api/application/models/Studentview_model.php index 9b9def61..08bfef9a 100755 --- a/Apollo/api/application/models/Studentview_model.php +++ b/Apollo/api/application/models/Studentview_model.php @@ -16,7 +16,7 @@ class Studentview_model extends CI_Model * */ // get student list based on login user - public function getStudentInfo($requestedBy=null,$requestFrom=null) + public function getStudentInfo($requestedBy=null,$requestFrom=null,$requestedBranch=null) { if($requestFrom =='2'){ $this->db->select('ST.*'); @@ -28,7 +28,7 @@ class Studentview_model extends CI_Model $result['studentStatus'] = true; $result['studentDetails'] = $studentDetails; // get student course details - $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom); + $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom,$requestedBranch); } else{ $result['studentStatus'] = false; @@ -45,7 +45,7 @@ class Studentview_model extends CI_Model $result['studentStatus'] = true; $result['studentDetails'] = $studentDetails; // get student course details - $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom); + $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom,$requestedBranch); } else{ $result['studentStatus'] = false; @@ -62,7 +62,7 @@ class Studentview_model extends CI_Model $result['studentStatus'] = true; $result['studentDetails'] = $studentDetails; // get student course details - $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom); + $result['courseDetails'] = $this->getStudentCourse($studentDetails->StudentID,$requestFrom,$requestedBranch); } else{ $result['studentStatus'] = false; @@ -77,14 +77,22 @@ class Studentview_model extends CI_Model * get student course details * created by kms * */ - public function getStudentCourse($studentId=null,$requestFrom=null){ - + public function getStudentCourse($studentId=null,$requestFrom=null,$requestedBranch=null){ + // this sub query for avoid university duplicate id + /* $this->db->select('BranchID')->from(STUDENTCOURSE); + $this->db->where('StudentID',$studentId); + $subQuery = $this->db->get_compiled_select();*/ + // subquery end $this->db->select('SCU.EnrollmentID,CU.CourseID,CU.CourseName,US.UniversityID,US.UniversityName,US.UniversityShortName'); $this->db->from( STUDENTCOURSE . ' as SCU'); $this->db->join( COURSE . ' as CU', 'CU.CourseID = SCU.CourseID'); - $this->db->join( UNIVERSITY . ' as US', 'US.UniversityID = SCU.UniversityID'); + $this->db->join( UNIVERSITY . ' as US', 'US.UniversityID = SCU.UniversityID AND SCU.BranchID=US.BranchCode'); // $this->db->join( SESSIONMASTER . ' as SM', 'SM.SessionID = SCU.SessionID'); - $this->db->where('SCU.StudentID', $studentId); + $this->db->where('SCU.StudentID',$studentId); + if($requestFrom!='2'){ + $this->db->where('CU.BranchCode',$requestedBranch); + } + // $this->db->where('US.BranchCode IN('. $subQuery.')', NULL, FALSE); $courseDetails = $this->db->get(); if($courseDetails->result()){ $studentCourseStatus['status'] = true; @@ -139,10 +147,10 @@ class Studentview_model extends CI_Model $this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left'); $this->db->join(STUDENTS_FEES_PAID.' as SFP','SFP.FeesId = SFS.FeesID','left'); $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType'); - $this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode'); + $this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode AND SFS.BranchCode=BA.BranchCode'); $this->db->where('SFS.CourseID', $courseID); $this->db->where('SFS.StudentID', $studentID); - $this->db->where('SFP.IsActive', '1'); + // $this->db->where('SFP.IsActive', '1'); $this->db->order_by('SFS.FeesID', 'ASC'); $getFeeDetails = $this->db->get(); if($getFeeDetails->result()){ @@ -255,7 +263,7 @@ class Studentview_model extends CI_Model //$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType'); $this->db->where('SFS.CourseID', $courseID); $this->db->where('SFS.StudentID', $studentID); - $this->db->where('SFP.IsActive', '1'); + // $this->db->where('SFP.IsActive', '1'); $this->db->where_in('SFS.FeesType', $serachArray); $this->db->order_by('SFS.FeesID', 'ASC'); $getFeeDetails = $this->db->get();