db->select('ST.StudentID,ST.MobileNumber,ST.Firstname,ST.Fathername,ST.EmailID,STC.ID,US.UniversityID,US.UniversityName,CU.CourseID,CU.CourseName,BA.BatchCode,BA.BatchName'); $this->db->from(STUDENTS.' as ST'); $this->db->join(STUDENTCOURSE.' as STC', 'STC.StudentID = ST.StudentID'); $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID'); $this->db->join(BATCH.' as BA', 'BA.BatchCode = STC.BatchCode'); $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID'); $this->db->where('ST.IsActive','1'); $this->db->where('STC.IsActive','1'); if($search['MobileNumber']!='' AND $search['Firstname']==''){ $this->db->where('ST.MobileNumber',$search['MobileNumber']); } else if($search['MobileNumber']=='' AND $search['Firstname']!=''){ $this->db->where('ST.Firstname',$search['Firstname']); } else if($search['MobileNumber']!='' AND $search['Firstname']!=''){ $this->db->where('ST.MobileNumber',$search['MobileNumber']); $this->db->where('ST.Firstname',$search['Firstname']); } $searchDetails = $this->db->get(); if($searchDetails->result()) { $result_array['studentStatus'] = true; $result_array['details'] = $searchDetails->result(); } else{ $result_array['studentStatus'] = false; $result_array['details'] = "No records found!"; } } else{ $result_array['studentStatus'] = false; $result_array['details'] = "No records found!"; } return $result_array; } /* * get student fees structure for fees update * @params student ID * created by kms * */ public function getStudentFeesStructure($student=null){ $this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year'); $this->db->where('CourseID',$student['CourseID']); $feesDetails = $this->db->get(COURSE_FEES); if($feesDetails->result()){ $result_array['feesStatus']=true; foreach ($feesDetails->result() as $row){ $this->db->select('ifnull(SUM(CourseFees),0) as CourseFees,ifnull(SUM(STFOrWR),0) as STFOrWR,ifnull(SUM(Waiver),0) as Waiver,ifnull(SUM(Others),0) as Others,ifnull(SUM(CourseFees+STFOrWR+Others-Waiver),0) as PayableFees'); $this->db->where('StudentID',$student['StudentID']); $this->db->where('CourseID',$student['CourseID']); $this->db->where('FeesType',$row->ID); $existFeesDetails = $this->db->get(STUDENTS_FEES_STATUS); if($existData=$existFeesDetails->result()){ $fetchData['ID']=$row->ID; $fetchData['CourseID']=$row->CourseID; $fetchData['Sem_Year']=$row->Sem_Year; $fetchData['ActualFees']=$row->FeesAmount; $fetchData['PayableFees']=$existData[0]->PayableFees; $fetchData['PendingFees']=$row->FeesAmount; $fetchData['STFOrWR']=$existData[0]->STFOrWR; $fetchData['Waiver']=$existData[0]->Waiver; $fetchData['Others']=$existData[0]->Others; $CourseFeesArray[]=$fetchData; } else{ $fetchData['ID']=$row->ID; $fetchData['CourseID']=$row->CourseID; $fetchData['Sem_Year']=$row->Sem_Year; $fetchData['ActualFees']=$row->FeesAmount; $fetchData['PayableFees']=0; $fetchData['PendingFees']=$row->FeesAmount; $fetchData['STFOrWR']=0; $fetchData['Waiver']=0; $fetchData['Others']=0; $CourseFeesArray[]=$fetchData; } } $result_array['feesDetails']=$CourseFeesArray; $result_array['getExistStudentFeesDetails']=$this->existStudentFeesDetails($student); } else{ $result_array['feesStatus']=false; } return $result_array; } /* * get exist student fees details * created by kms * */ public function existStudentFeesDetails($student=null){ $this->db->select('SFS.FeesID,SFS.FeesType,ifnull(SFS.CourseFees,0) as CourseFees,ifnull(SFS.STFOrWR,0) as STFOrWR,ifnull(SFS.Waiver,0) as Waiver,ifnull(SFS.Others,0) as Others,ST.Firstname,CU.CourseName,CU.CourseID,CF.Sem_Year'); $this->db->from(STUDENTS_FEES_STATUS.' as SFS'); $this->db->join(STUDENTS.' as ST', 'ST.StudentID = SFS.StudentID'); $this->db->join(COURSE.' as CU', 'CU.CourseID = SFS.CourseID'); $this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType'); $this->db->where('SFS.CourseID', $student['CourseID']); $this->db->where('SFS.StudentID', $student['StudentID']); $getFeeDetails = $this->db->get(); if($getFeeDetails->result()){ foreach ($getFeeDetails->result() as $feeRow){ $storePaidDetails['FeesID'] = $feeRow->FeesID; $storePaidDetails['FeesName'] = $feeRow->Sem_Year; $storePaidDetails['CourseFees'] = $feeRow->CourseFees; $storePaidDetails['STFOrWR'] = $feeRow->STFOrWR; $storePaidDetails['Waiver'] = $feeRow->Waiver; $storePaidDetails['Others'] = $feeRow->Others; $storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver; $storePaidDetails['Firstname'] = $feeRow->Firstname; $storePaidDetails['CourseName'] = $feeRow->CourseName; $this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount'); $this->db->where('FeesId',$feeRow->FeesID); $paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result(); $storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount; // for get paid bill details $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO'); $this->db->where('FeesId',$feeRow->FeesID); $this->db->group_by('BillNO'); $storePaidDetails['paidDetails']=$this->db->get(STUDENTS_FEES_PAID)->result(); $mergeResult[]=$storePaidDetails; } return $mergeResult; } else { return false; } } /* * update fees details * created by kms * */ public function updateFees($feesDetails=null,$feesPaidDetails=null) { $this->db->select('BillNO'); $this->db->where('BillNO', $feesPaidDetails['BillNO']); if($this->db->get(STUDENTS_FEES_PAID)->first_row()){ $result['paidStatus'] = false; $result['message'] = "This bill number is already exist!"; } else { $this->db->select('FeesID'); $this->db->where('CourseID', $feesDetails['CourseID']); $this->db->where('StudentID', $feesDetails['StudentID']); $this->db->where('FeesType', $feesDetails['FeesType']); if($this->db->get(STUDENTS_FEES_STATUS)->first_row()){ $feesDetails['UpdatedOn'] = $feesDetails['CreatedOn']; $feesDetails['UpdatedBy'] = $feesDetails['CreatedBy']; $this->db->where('CourseID', $feesDetails['CourseID']); $this->db->where('StudentID', $feesDetails['StudentID']); $this->db->where('FeesType', $feesDetails['FeesType']); $this->db->update(STUDENTS_FEES_STATUS, $feesDetails); } else{ $this->db->insert(STUDENTS_FEES_STATUS, $feesDetails); } if ($this->db->affected_rows() == '1') { $last = $this->db->where('StudentID',$feesPaidDetails['StudentID'])->order_by('FeesID',"desc")->limit(1)->get(STUDENTS_FEES_STATUS)->last_row(); $feesPaidDetails['FeesId']=$last->FeesID; $this->db->insert(STUDENTS_FEES_PAID, $feesPaidDetails); if ($this->db->affected_rows() == '1') { $result['paidStatus'] = true; $result['message'] = "Successfully course details added"; } else{ $this -> db -> where('FeesId', $feesPaidDetails['FeesId']); $this -> db -> delete('STUDENTS_FEES_STATUS'); $result['paidStatus'] = false; $result['message'] = "Something went wrong.please try again"; } } else { $result['paidStatus'] = false; $result['message'] = "Something went wrong.please try again"; } } return $result; } /* * get university details * created by kms * */ public function getUniversityDetails() { $this->db->select('UniversityID,UniversityName'); $this->db->where('IsActive','1'); $this->db->order_by('UniversityID','ASC'); $unviversityDetails = $this->db->get(UNIVERSITY); if($unviversityDetails->result()){ $result_university = array(); foreach ($unviversityDetails->result() as $row) { $university_array['universityStatus'] = true; $university_array['universityID'] = $row->UniversityID; $university_array['universityName'] = $row->UniversityName; $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID); $result_university[]=$university_array; } } else { $university_array['universityStatus'] = false; $university_array['message'] = "No records found!"; $university_array['universityID'] = ""; $university_array['universityName'] = ""; $university_array['courseDetails']= ""; $result_university[]=$university_array; } return $result_university; } /* * get course details * @params university id * created by kms * */ public function getCourseDetails($universityID=null) { $this->db->select('CourseID,CourseName'); $this->db->where('UniversityID',$universityID); $this->db->where('IsActive','1'); $this->db->order_by('CourseID','ASC'); $courseDetails = $this->db->get(COURSE); return $courseDetails->result(); } }