diff --git a/Apollo/api/application/models/Fees_status_model.php b/Apollo/api/application/models/Fees_status_model.php index 15d5baea..69ef3bc2 100755 --- a/Apollo/api/application/models/Fees_status_model.php +++ b/Apollo/api/application/models/Fees_status_model.php @@ -78,7 +78,6 @@ class Fees_status_model extends CI_Model * created by kms * */ public function getStudentFeesStructure($student=null){ - $this->db->select('CF.ID,CF.Sem_Year,CF.ProgramType,SFS.FeesID,SFS.CourseID,SFS.CourseFees,SFS.STFOrWR,SFS.Waiver,SFS.Others,SFS.RollNo,CU.PC,CU.TC,CU.DC,CU.MC,CU.OtherFees,SM.SessionName as SessionName,SM1.SessionName as ToSessionName'); $this->db->from(STUDENTS_FEES_STATUS.' as SFS'); $this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName'); @@ -234,6 +233,7 @@ class Fees_status_model extends CI_Model * */ public function existStudentFeesDetails($student=null){ + $serachArray=[WAIVER,REFERRAL]; $this->db->distinct(); $this->db->select('SFS.FeesID,SFS.FeesType,SFS.RollNo,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,ST.MobileNumber,ST.Fathername,CU.CourseName,CU.CourseID,CF.Sem_Year,STC.EnrollmentID,US.UniversityName,US.UniversityShortName,SM.SessionName,SM1.SessionName as ToSessionName,CF.ProgramType'); @@ -281,7 +281,9 @@ class Fees_status_model extends CI_Model $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; + if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){ $storePaidDetails['BalanceAmount']=0; @@ -290,6 +292,22 @@ class Fees_status_model extends CI_Model $storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount; } + // sepearte for student waiver and referral bill list + $this->db->select('ifnull(SUM((BillAmount)),0) as StudentWaiverRefAmount'); + $this->db->where('FeesId',$feeRow->FeesID); + $this->db->where_in('ModeOfPayment',$serachArray); + $studentWaiverRefAmount = $this->db->get(STUDENTS_FEES_PAID)->result(); + + $storePaidDetails['StudentWaiverRefAmount']=$studentWaiverRefAmount[0]->StudentWaiverRefAmount; + + $this->db->select('ifnull(SUM((BillAmount)),0) as StudentPaidAmount'); + $this->db->where('FeesId',$feeRow->FeesID); + $this->db->where('ModeOfPayment !=',WAIVER); + $this->db->where('ModeOfPayment !=',REFERRAL); + $studentPaidAmount = $this->db->get(STUDENTS_FEES_PAID)->result(); + + $storePaidDetails['StudentPaidAmount']=$studentPaidAmount[0]->StudentPaidAmount; + // for get paid bill details $this->db->select('ifnull(SUM((BillAmount)),0) as BillAmount,BillNO,BillDate,ModeOfPayment,ReceiptNo,BR.BranchName,BR.Address,BR.LogoPath,STF.Firstname as ReceivedBy'); $this->db->from(STUDENTS_FEES_PAID.' as SFP');