From 3dea8a1e0e70923dd69b482657351faa8f7339b0 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 31 Aug 2018 12:05:27 +0000 Subject: [PATCH 1/2] Reports_model.php edited online with Bitbucket --- Apollo/api/application/models/Reports_model.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Apollo/api/application/models/Reports_model.php b/Apollo/api/application/models/Reports_model.php index 1f2facc4..c005a636 100755 --- a/Apollo/api/application/models/Reports_model.php +++ b/Apollo/api/application/models/Reports_model.php @@ -178,6 +178,13 @@ from left join T_PickListDetails p on p.ListCode = app.ListCode left join BalFees bal on bal.student=app.StudentID and bal.course=app.CourseID where CertificateName not like 'APPLICATION%' and app.ID IN (SELECT max(ID) FROM T_ApplicationStatus group by StudentID,CourseID,ListCode,BranchCode,CertificationType) + group by app.ID +union +SELECT app.ID,app.StudentID as sid,app.CourseID as cid,app.BranchCode as branch,app.ListCode as lcode,p.ListName as status,AppDate as adate,app.Comments as acmts,CertificationType as ctype,app.CertificationType as certname,sum(bal.balpayable) as balance + FROM T_ApplicationStatus as app + left join T_PickListDetails p on p.ListCode = app.ListCode + left join BalFees bal on bal.student=app.StudentID and bal.course=app.CourseID + where app.CertificationType not like 'CERT%' and app.ID IN (SELECT max(ID) FROM T_ApplicationStatus group by StudentID,CourseID,ListCode,BranchCode,CertificationType) group by app.ID) as sms left join (SELECT FeesID as fid,BatchCode as batch,StudentID as sid,CourseID as cid,FeesType as ftype,sum(CourseFees) as cf,Sum(STFOrWR) as stf,sum(Others) as others @@ -258,7 +265,7 @@ left join BalFees bal on bal.student=c.StudentID and bal.course=sfs.CourseID and where CDate is not null and (list.ListName like 'ISSUED TO STUDENT' or list.ListName like 'RECEIVED%' ) group by sid,cid,sem,ctype union -select a.ID,a.StudentID as sid,a.CourseID as cid,sfs.BranchCode as branch,sfs.FeesID as fid,'-' as sem,cm.CertificateName as certname,a.CertificationType as ctype,AppDate as mdate,bal.balpayable as balance, +select a.ID,a.StudentID as sid,a.CourseID as cid,sfs.BranchCode as branch,sfs.FeesID as fid,'-' as sem,ifnull(cm.CertificateName,a.CertificationType) as certname,a.CertificationType as ctype,AppDate as mdate,bal.balpayable as balance, max(if(ListName = 'ISSUED TO STUDENT', AppDate,'-')) as issuedate,max(if(ListName = 'ISSUED TO STUDENT', ListName,'-')) as istatus, max(if(ListName = 'RECEIVED', AppDate,'-')) as rcvedate,max(if(ListName = 'RECEIVED', ListName,'-')) as rstatus,a.Comments as acmts from T_ApplicationStatus a From 3b5c7272d5adad718bc07b991f045a256920ca92 Mon Sep 17 00:00:00 2001 From: gandhimathi Date: Fri, 31 Aug 2018 17:49:59 +0530 Subject: [PATCH 2/2] fees changes --- .../Receive_Enrolment_Fees_Univ_model.php | 192 +++++++++++++++--- 1 file changed, 159 insertions(+), 33 deletions(-) diff --git a/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php b/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php index e8d8d6ac..8cdd9baf 100644 --- a/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php +++ b/Apollo/api/application/models/Receive_Enrolment_Fees_Univ_model.php @@ -27,6 +27,7 @@ class Receive_Enrolment_Fees_Univ_model extends CI_Model { $get_data=array(); // loop for fetch details foreach ($enrolment as $k => $checkRow){ + // check enrolment no and form id in upload list if(array_key_exists("Enrollment_No",$checkRow) AND array_key_exists("Form Id",$checkRow)){ // start @@ -277,31 +278,61 @@ class Receive_Enrolment_Fees_Univ_model extends CI_Model { } } - // check form id exit in table for insert / update - $formIDData = $this->db->select('FormID')->order_by('SubmitID','ASC')->get(ENROLMENTRECEIVEDFROMUNIV)->result_array(); + if(sizeof($get_data)>0) { + // check form id exit in table for insert / update + $formIDData = $this->db->select('FormID')->order_by('SubmitID', 'ASC')->get(ENROLMENTRECEIVEDFROMUNIV)->result_array(); - $form_ids=array(); - $insertForms=array(); - $updateForms=array(); - foreach($formIDData as $fkey => $fvalue): - $matchedKey=array_search($fvalue['FormID'], array_column($get_data, 'FormID')); - if(count($matchedKey)>0){ - $updateForms[count($updateForms)]=$get_data[$matchedKey]; - // $form_ids[]=$fvalue['FormID']; - array_splice($get_data,$matchedKey,1); + $form_ids = array(); + $insertForms = array(); + $updateForms = array(); + foreach ($formIDData as $fkey => $fvalue): + if(sizeof($get_data)>0){ + + $matchedKey = array_search($fvalue['FormID'], array_column($get_data, 'FormID')); + if ($matchedKey!='') { + // $updateForms[count($updateForms)] = $get_data[$matchedKey]; + // $form_ids[]=$fvalue['FormID']; + array_splice($get_data, 0, 1); + + } + } + + endforeach; + if (sizeof($get_data) > 0) { + $this->db->insert_batch(ENROLMENTRECEIVEDFROMUNIV, $get_data); + if ($this->db->affected_rows() > 0) { + $finalArray['status'] = true; + $finalArray['message'] = "Inserted successfully"; + $finalArray['insertedRows'] = $this->db->affected_rows(); + $finalArray['details'] = $errorArray; + return $finalArray; + } else { + $finalArray['status'] = false; + $finalArray['message'] = "Insert failed please check data."; + $finalArray['insertedRows'] = $this->db->affected_rows(); + $finalArray['details'] = $errorArray; + return $finalArray; + } + + } else { + $finalArray['status'] = false; + $finalArray['message'] = "Updated Successfully.";; + $finalArray['details'] = $errorArray; } - endforeach; - - if(count($get_data)>0){ - $this->db->insert_batch(ENROLMENTRECEIVEDFROMUNIV, $get_data); + /* if(count($updateForms)>0){ + //$this->db->where_in('FormID',$form_ids); + $this->db->update_batch(ENROLMENTRECEIVEDFROMUNIV, $updateForms,'FormID'); + }*/ } - /* if(count($updateForms)>0){ - //$this->db->where_in('FormID',$form_ids); - $this->db->update_batch(ENROLMENTRECEIVEDFROMUNIV, $updateForms,'FormID'); - }*/ - $finalArray['status']=true; - $finalArray['details']=$errorArray; + else{ + $finalArray['status'] = false; + $finalArray['message'] = "Insert failed please check data."; + $finalArray['insertedRows'] = $this->db->affected_rows(); + $finalArray['details'] = $errorArray; + return $finalArray; + } + return $finalArray; } @@ -423,21 +454,57 @@ class Receive_Enrolment_Fees_Univ_model extends CI_Model { } public function getStudentUnivFeeCompareDetails($univCode=null,$courseCode=null){ - // echo $univID, $courseID;exit(); - - $this->db->select('t1.FormID, t1.FormType, t2.SemesterYear, t2.EnrolmentNo,t2.CourseName,t2.RollNo, t4.*,t5.UniversityID, t5.UniversityName'); - $this->db->from('T_FormId_FeeDetails_Received_From_University as t1'); - $this->db->join('T_Enrolment_Received_From_University as t2', 't2.FormID = t1.FormID'); - $this->db->join('T_Student_CourseDetails as t3', 't3.EnrollmentID = t2.EnrolmentNo'); - $this->db->join('T_StudentDetails as t4', 't4.StudentID = t3.StudentID'); - $this->db->join('T_UniversityMaster as t5', 't5.UniversityID = t3.UniversityID'); - $this->db->where('t2.CourseCode', $courseCode); - $this->db->where('t2.UniversityCode', $univCode); + $this->db->select('t1.FormID, t1.FormType, t1.SemesterYear, t1.EnrolmentNo,t1.CourseName,t1.RollNo, t4.*,t5.UniversityID, t5.UniversityName,t3.CourseID,t2.Amount as UniversityPaidAmount'); + $this->db->from(ENROLMENTRECEIVEDFROMUNIV.' as t1'); + $this->db->join(STUDENTCOURSE.' as t3', 't3.EnrollmentID = t1.EnrolmentNo'); + $this->db->join(STUDENTS.' as t4', 't4.StudentID = t3.StudentID'); + $this->db->join(UNIVERSITY.' as t5', 't5.UniversityID = t3.UniversityID'); + $this->db->join(FORMFEESRECEIVEDFROMUNIV.' as t2', 't2.FormID = t1.FormID','left'); + $this->db->where('t1.CourseCode', $courseCode); + $this->db->where('t1.UniversityCode', $univCode); $details = $this->db->get(); $detailsList = $details->result(); - if($detailsList){ - $resultArr['studentFeeCompareDetails'] = $detailsList; + foreach ($detailsList as $fetchStudentRow){ + $formResult['FormID']=$fetchStudentRow->FormID; + $formResult['FormType']=$fetchStudentRow->FormType; + $formResult['SemesterYear']=$fetchStudentRow->SemesterYear; + $formResult['EnrolmentNo']=$fetchStudentRow->EnrolmentNo; + $formResult['CourseName']=$fetchStudentRow->CourseName; + $formResult['RollNo']=$fetchStudentRow->RollNo; + $formResult['StudentID']=$fetchStudentRow->StudentID; + $formResult['MobileNumber']=$fetchStudentRow->MobileNumber; + $formResult['Firstname']=$fetchStudentRow->Firstname; + $formResult['Lastname']=$fetchStudentRow->Lastname; + $formResult['Fathername']=$fetchStudentRow->Fathername; + $formResult['MotherName']=$fetchStudentRow->MotherName; + $formResult['EmailID']=$fetchStudentRow->EmailID; + $formResult['AlternateNumber']=$fetchStudentRow->AlternateNumber; + $formResult['Gender']=$fetchStudentRow->Gender; + $formResult['DOB']=$fetchStudentRow->DOB; + $formResult['PresentAddress']=$fetchStudentRow->PresentAddress; + $formResult['PermanentAddress']=$fetchStudentRow->PermanentAddress; + $formResult['AadharNumber']=$fetchStudentRow->AadharNumber; + $formResult['OtherID']=$fetchStudentRow->OtherID; + $formResult['OtherIDDetails']=$fetchStudentRow->OtherIDDetails; + $formResult['Qualification']=$fetchStudentRow->Qualification; + $formResult['UniversityID']=$fetchStudentRow->UniversityID; + $formResult['UniversityName']=$fetchStudentRow->UniversityName; + $formResult['UniversityPaidAmount']=$fetchStudentRow->UniversityPaidAmount; + + // form id bases get student paid details + $getStudentPaidDetails=$this->getFormIDStudentPaidDetails($fetchStudentRow->StudentID,$fetchStudentRow->CourseID,$fetchStudentRow->SemesterYear); + if(sizeof($getStudentPaidDetails)!=0){ + $formResult['StudentPaidAmount']=$getStudentPaidDetails['StudentPaidAmount']; + } + else{ + $formResult['StudentPaidAmount']=''; + } + + $mergeFormDetails[]=$formResult; + + } + $resultArr['studentFeeCompareDetails'] = $mergeFormDetails; $resultArr['formTypeStatus'] = true; $resultArr['message'] = "Successfully data generated"; } else { @@ -447,6 +514,64 @@ class Receive_Enrolment_Fees_Univ_model extends CI_Model { } return $resultArr; } + /*form id bases get student paid details for getStudentUnivFeeCompareDetails methods*/ + public function getFormIDStudentPaidDetails($studentID=null,$courseID=null,$sem=null){ + // create array for find sem value + $keyArray = array(0 => 'SEM1', 1 => 'SEM2', 2 => 'SEM3', 3 => 'SEM4',4 => 'SEM5',5 => 'SEM6',6 => 'SEM7',7 => 'SEM8',8 => 'YEAR1',9 => 'YEAR2',10 => 'YEAR3',11 => 'YEAR4',12 => "DMC CHANGE SEM1",13 => "DMC CHANGE SEM2",14 => "DMC CHANGE SEM3",15 => "DMC CHANGE SEM4",16 => "DMC CHANGE SEM5",17 => "DMC CHANGE SEM6",18 => "DMC CHANGE SEM7",19 => "DMC CHANGE SEM8",20 => "DMC CHANGE YEAR1",21 => "DMC CHANGE YEAR2",22 => "DMC CHANGE YEAR3",23 => "DMC CHANGE YEAR4"); + $valueArray = array("1","2","3","4","5","6","7","8","1","2","3","4","1","2","3","4","5","6","7","8","1","2","3","4"); + $feesArray=array(); + $this->db->select("CF.ID,CF.ProgramType,CF.Sem_Year"); + $this->db->from(COURSE_FEES . ' as CF'); + $this->db->where('CF.CourseID', $courseID); + $courseFeesDetails = $this->db->get(); + //this is for sem year type check fees + if ($courseFeesDetails->num_rows() > 1) { + foreach ($courseFeesDetails->result() as $fetchRow) { + $serachKey = array_search(strtoupper($fetchRow->Sem_Year), $keyArray); + if ($valueArray[$serachKey] == $sem) { + $this->db->select("SUM(BillAMount) as StudentPaidAmount"); + $this->db->from(STUDENTS_FEES_STATUS . ' as SFS'); + $this->db->join(STUDENTS_FEES_PAID . ' as SFP', 'SFP.FeesId = SFS.FeesID'); + $this->db->where('SFS.FeesType', $fetchRow->ID); + $this->db->where('SFS.StudentID', $studentID); + $this->db->where('SFP.IsActive', '1'); + $feesDetails = $this->db->get()->last_row(); + if ($feesDetails) { + $feesArray['StudentPaidAmount'] = $feesDetails->StudentPaidAmount; + break; + } else { + $feesArray['StudentPaidAmount'] = 0; + break; + } + } + + } + + } + else if($courseFeesDetails->num_rows()==1){ + foreach ($courseFeesDetails->result() as $fetchRow){ + $this->db->select("SUM(BillAMount) as StudentPaidAmount"); + $this->db->from(STUDENTS_FEES_STATUS.' as SFS'); + $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = SFS.FeesID'); + $this->db->where('SFS.FeesType',$fetchRow->ID); + $this->db->where('SFS.StudentID',$studentID); + $this->db->where('SFP.IsActive','1'); + $feesDetails = $this->db->get()->last_row(); + if ($feesDetails) { + $feesArray['StudentPaidAmount'] = $feesDetails->StudentPaidAmount; + break; + } else { + $feesArray['StudentPaidAmount'] = 0; + break; + } + + } + } + else{ + $feesArray['StudentPaidAmount'] = 0; + } + return $feesArray; + } /* * form id bases get fees compare details * created by kms @@ -497,6 +622,7 @@ class Receive_Enrolment_Fees_Univ_model extends CI_Model { } + } else if($studentCourseDetails->num_rows()==1){ foreach ($studentCourseDetails->result() as $fetchRow){