2394 lines
108 KiB
PHP
Executable File
2394 lines
108 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: karthi
|
|
* Date: 12/12/17
|
|
* Time: 12:36 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Fees_status_model extends CI_Model
|
|
{
|
|
/*
|
|
* get student list for fees update
|
|
* @params mobile number,name
|
|
* created by kms
|
|
* */
|
|
public function getStudentList($search=null)
|
|
{
|
|
|
|
if($search['MobileNumber']!='' OR $search['Firstname']!='' OR $search['UniversityID']!='' OR $search['CourseID']!='' OR $search['BatchCode']!=''){
|
|
$this->db->select('ST.StudentID,ST.MobileNumber,ST.Firstname,ST.Lastname,ST.Fathername,ST.EmailID,STC.ID,US.UniversityID,US.UniversityName,CU.CourseID,CU.CourseName,ST.PermanentAddress,if(STC.EnrollmentID = "","",STC.EnrollmentID) as EnrollmentID,US.ProfilePicPath,US.MobileNumber as UnivMobileNumber,US.Address,US.EmailID,ST.MotherName,CU.Specilization1 as Specilization,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(SESSIONMASTER.' as SM', 'SM.SessionID = STC.SessionID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
|
|
$this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID');
|
|
$this->db->where('ST.IsActive','1');
|
|
$this->db->where('STC.IsActive','1');
|
|
if($search['requestedBranch']!='All'){
|
|
$this->db->where('STC.BranchID',$search['requestedBranch']);
|
|
$this->db->where('US.BranchCode',$search['requestedBranch']);
|
|
$this->db->where('CU.BranchCode',$search['requestedBranch']);
|
|
}
|
|
if($search['MobileNumber']!=''){
|
|
$this->db->where('ST.MobileNumber',$search['MobileNumber']);
|
|
}
|
|
if($search['Firstname']!=''){
|
|
// $this->db->like('ST.Firstname','%'.$search['Firstname'].'%');
|
|
$this->db->like('ST.Firstname',$search['Firstname'],'both');
|
|
}
|
|
if($search['UniversityID']!=''){
|
|
$this->db->where('STC.UniversityID',$search['UniversityID']);
|
|
}
|
|
if($search['CourseID']!=''){
|
|
$this->db->where('STC.CourseID',$search['CourseID']);
|
|
}
|
|
if($search['BatchCode']!=''){
|
|
$this->db->where('BA.BatchCode',$search['BatchCode']);
|
|
}
|
|
/* 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->distinct();
|
|
$this->db->select('CF.ID,CF.Sem_Year,CF.ProgramType,SFS.FeesID,SFS.CourseID,SFS.CourseFees,SFS.STFOrWR,SFS.Comments,SFS.Waiver,SFS.Others,SFS.RollNo,CU.PC,CU.TC,CU.DC,CU.MC,CU.OtherFees,SM.SessionName as SessionName,SM1.SessionName as ToSessionName,BA.BatchCode,BA.BatchName');
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
$this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
|
|
$this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
|
|
$this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode');
|
|
$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
|
|
$this->db->join(COURSE.' as CU', 'CU.CourseID = CF.CourseID');
|
|
$this->db->where('SFS.CourseID',$student['CourseID']);
|
|
$this->db->where('SFS.StudentID',$student['StudentID']);
|
|
$this->db->where('BA.BranchCode',$student['BranchCode']);
|
|
$this->db->order_by('SFS.FeesID','DESC');
|
|
$enrolledFeesDetails = $this->db->get();
|
|
//print_r($enrolledFeesDetails->result());die();
|
|
|
|
if($enrolledFeesDetails->result()){
|
|
$result_array['feesStatus']=true;
|
|
foreach ($enrolledFeesDetails->result() as $row) {
|
|
$fetchData['ID'] = $row->ID;
|
|
$fetchData['FeesID'] = $row->FeesID;
|
|
$fetchData['CourseID'] = $row->CourseID;
|
|
$fetchData['Sem_Year'] = $row->Sem_Year;
|
|
$fetchData['ProgramType'] = $row->ProgramType;
|
|
$fetchData['ActualFees'] = $row->CourseFees;
|
|
$fetchData['STFOrWR'] = $row->STFOrWR;
|
|
$fetchData['Comments'] = $row->Comments;
|
|
$fetchData['Waiver'] = $row->Waiver;
|
|
$fetchData['Others'] = $row->Others;
|
|
$fetchData['SessionName'] = $row->SessionName;
|
|
$fetchData['BatchName'] = $row->BatchName;
|
|
if($row->ToSessionName=='' OR $row->ToSessionName==null){
|
|
$fetchData['ToSessionName'] = "Not Applicable";
|
|
}
|
|
else{
|
|
$fetchData['ToSessionName'] = $row->ToSessionName;
|
|
}
|
|
|
|
$fetchData['RollNo'] = $row->RollNo;
|
|
$fetchData['PayableFees']=$row->CourseFees+$row->STFOrWR+$row->Others-$row->Waiver;
|
|
|
|
$this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
|
|
$this->db->where('FeesId',$row->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
|
|
if($paidBillAmount[0]->PaidBillAmount > $fetchData['PayableFees']){
|
|
$fetchData['BalanceAmount']=0;
|
|
|
|
}
|
|
else{
|
|
$fetchData['BalanceAmount']=$fetchData['PayableFees'] - $paidBillAmount[0]->PaidBillAmount;
|
|
}
|
|
$fetchData['PPC'] = $row->PC;
|
|
$fetchData['TC'] = $row->TC;
|
|
$fetchData['DC'] = $row->DC;
|
|
$fetchData['MC'] = $row->MC;
|
|
$fetchData['OtherFees'] = $row->OtherFees;
|
|
|
|
$CourseFeesArray[]=$fetchData;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$getDefaultCourseFees = $this->getDefaultCourseFees($student);
|
|
// print_r($getDefaultCourseFees);die();
|
|
if($getDefaultCourseFees!=false){
|
|
|
|
|
|
$result_array['feesDetails']=array_merge($getDefaultCourseFees,$CourseFeesArray);
|
|
}
|
|
else{
|
|
|
|
$result_array['feesDetails']=$CourseFeesArray;
|
|
}
|
|
|
|
|
|
// print_r($result_array['feesDetails']);die();
|
|
|
|
|
|
// $result_array['getFeesUpdateStatus']=$this->getFeesUpdateStatus(FEESUPDATE);
|
|
$result_array['getExistStudentFeesDetails']=$this->existStudentFeesDetails($student);
|
|
|
|
}
|
|
else{
|
|
$result_array['feesStatus']=false;
|
|
$result_array['message']="This student don't have fees details";
|
|
|
|
}
|
|
return $result_array;
|
|
|
|
}
|
|
/*
|
|
* get fees update status
|
|
* created by kms
|
|
* */
|
|
|
|
public function getFeesUpdateStatus($feesID=null)
|
|
{
|
|
$this->db->select('PLD.ListCode,PLD.ListName');
|
|
$this->db->from(DEFAULTACTIVITY.' as DA');
|
|
$this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = DA.StatusCode');
|
|
$this->db->where('StudentActivityCode',$feesID);
|
|
$this->db->where('DA.IsActive','1');
|
|
$this->db->where('PLD.IsActive','1');
|
|
$this->db->order_by('ListCode','ASC');
|
|
$status = $this->db->get();
|
|
return $status->result();
|
|
}
|
|
/*
|
|
* get default course fees for bill
|
|
* creted by kms
|
|
* */
|
|
public function getDefaultCourseFees($student=null)
|
|
{
|
|
$serachArray = ["PPC","TC","DC","MC","OTHER"];
|
|
|
|
$this->db->select('SFS.FeesID,SFS.FeesType,SFS.CourseID,SFS.CourseFees,SFS.STFOrWR,SFS.Comments,SFS.Waiver,SFS.Others,SFS.SessionName,SFS.RollNo,CU.PC,CU.TC,CU.DC,CU.MC,CU.OtherFees');
|
|
$this->db->from(STUDENTS_FEES_STATUS . ' as SFS');
|
|
//$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
|
|
$this->db->join(COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
|
|
$this->db->where('SFS.CourseID', $student['CourseID']);
|
|
$this->db->where('SFS.StudentID', $student['StudentID']);
|
|
$this->db->where_in('SFS.FeesType', $serachArray);
|
|
$this->db->order_by('SFS.FeesID','DESC');
|
|
$enrolledFeesDetails = $this->db->get();
|
|
|
|
if ($enrolledFeesDetails->result()) {
|
|
$result_array['feesStatus'] = true;
|
|
foreach ($enrolledFeesDetails->result() as $row) {
|
|
$fetchData['ID'] = $row->FeesType;
|
|
$fetchData['FeesID'] = $row->FeesID;
|
|
$fetchData['CourseID'] = $row->CourseID;
|
|
$fetchData['Sem_Year'] = $row->FeesType;
|
|
$fetchData['ProgramType'] = $row->FeesType;
|
|
$fetchData['ActualFees'] = $row->CourseFees;
|
|
$fetchData['STFOrWR'] = $row->STFOrWR;
|
|
$fetchData['Comments'] = $row->Comments;
|
|
$fetchData['Waiver'] = $row->Waiver;
|
|
$fetchData['Others'] = $row->Others;
|
|
$fetchData['SessionName'] = "Not Applicable";
|
|
$fetchData['ToSessionName'] = "Not Applicable";
|
|
$fetchData['BatchName'] = "Not Applicable";
|
|
$fetchData['RollNo'] = $row->RollNo;
|
|
$fetchData['PayableFees'] = $row->CourseFees + $row->STFOrWR + $row->Others - $row->Waiver;
|
|
|
|
$this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
|
|
$this->db->where('FeesId', $row->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
|
|
if ($paidBillAmount[0]->PaidBillAmount > $fetchData['PayableFees']) {
|
|
$fetchData['BalanceAmount'] = 0;
|
|
|
|
} else {
|
|
$fetchData['BalanceAmount'] = $fetchData['PayableFees'] - $paidBillAmount[0]->PaidBillAmount;
|
|
}
|
|
$fetchData['PPC'] = $row->PC;
|
|
$fetchData['TC'] = $row->TC;
|
|
$fetchData['DC'] = $row->DC;
|
|
$fetchData['MC'] = $row->MC;
|
|
$fetchData['OtherFees'] = $row->OtherFees;
|
|
|
|
$CourseFeesArray[] = $fetchData;
|
|
}
|
|
|
|
return $CourseFeesArray;
|
|
|
|
}
|
|
else{
|
|
return false;
|
|
|
|
}
|
|
}
|
|
/*
|
|
* get exist student fees details
|
|
* created by kms
|
|
* */
|
|
|
|
public function existStudentFeesDetails($student=null){
|
|
$serachArray=[WAIVER,REFERRAL];
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('SFS.FeesID,SFS.FeesType,SFS.RollNo,SFS.Comments,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,BA.BatchCode,BA.BatchName');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS','SFP.FeesId = SFS.FeesID');
|
|
$this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
|
|
$this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
|
|
$this->db->join(BATCH.' as BA', 'BA.BatchCode = SFS.BatchCode');
|
|
$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->join(STUDENTCOURSE.' as STC', 'STC.CourseID = SFS.CourseID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
|
|
$this->db->where('SFS.CourseID', $student['CourseID']);
|
|
$this->db->where('SFS.StudentID', $student['StudentID']);
|
|
$this->db->where('STC.StudentID', $student['StudentID']);
|
|
$this->db->where('SFP.StudentID', $student['StudentID']);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->where('US.BranchCode',$student['BranchCode']);
|
|
$this->db->where('BA.BranchCode',$student['BranchCode']);
|
|
$this->db->order_by('SFP.ID', 'DESC');
|
|
$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['ProgramType'] = $feeRow->ProgramType;
|
|
$storePaidDetails['SessionName'] = $feeRow->SessionName;
|
|
if($feeRow->ToSessionName=='' OR $feeRow->ToSessionName==null){
|
|
$storePaidDetails['ToSessionName'] = "Not Applicable";
|
|
}
|
|
else{
|
|
$storePaidDetails['ToSessionName'] = $feeRow->ToSessionName;
|
|
}
|
|
$storePaidDetails['BatchName'] = $feeRow->BatchName;
|
|
|
|
$storePaidDetails['RollNo'] = $feeRow->RollNo;
|
|
$storePaidDetails['STFOrWR'] = $feeRow->STFOrWR;
|
|
$storePaidDetails['Comments'] = $feeRow->Comments;
|
|
$storePaidDetails['Waiver'] = $feeRow->Waiver;
|
|
$storePaidDetails['Others'] = $feeRow->Others;
|
|
$storePaidDetails['PayableAmount'] = $feeRow->CourseFees+$feeRow->STFOrWR+$feeRow->Others-$feeRow->Waiver;
|
|
$storePaidDetails['Firstname'] = $feeRow->Firstname;
|
|
$storePaidDetails['MobileNumber'] = $feeRow->MobileNumber;
|
|
$storePaidDetails['Fathername'] = $feeRow->Fathername;
|
|
$storePaidDetails['EnrollmentID'] = $feeRow->EnrollmentID;
|
|
$storePaidDetails['CourseName'] = $feeRow->CourseName;
|
|
$storePaidDetails['UniversityName'] = $feeRow->UniversityName;
|
|
$storePaidDetails['UniveShortName'] = $feeRow->UniversityShortName;
|
|
$this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
|
|
$this->db->where('FeesId',$feeRow->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
|
|
|
|
$storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
|
|
|
|
if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
|
|
//$storePaidDetails['BalanceAmount']=0;
|
|
$storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
|
|
|
|
|
|
}
|
|
else{
|
|
$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('IsActive','1');
|
|
$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('IsActive','1');
|
|
$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,BR.FeesReceiptTitle,STF.Firstname as ReceivedBy,SFP.CommentsForStudent,SFP.InternalComments');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
|
|
$this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
|
|
$this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
|
|
$this->db->where('SFP.FeesId',$feeRow->FeesID);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->order_by('SFP.ID',"ASC");
|
|
$this->db->group_by('SFP.BillNO');
|
|
$storePaidDetails['paidDetails']=$this->db->get()->result();
|
|
$mergeResult[]=$storePaidDetails;
|
|
|
|
}
|
|
$existDefaultFees = $this->existStudentCourseDefaultFees($student);
|
|
if($existDefaultFees != false){
|
|
return array_merge($existDefaultFees,$mergeResult);
|
|
}
|
|
else{
|
|
return $mergeResult;
|
|
}
|
|
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* get exist student default fees details
|
|
* created by kms
|
|
* */
|
|
|
|
public function existStudentCourseDefaultFees($student=null){
|
|
$serachArray = ["PPC","TC","DC","MC","OTHER"];
|
|
$this->db->distinct();
|
|
$this->db->select('SFS.FeesID,SFS.FeesType,SFS.Comments,SFS.SessionName,SFS.ToSessionName,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,STC.EnrollmentID,US.UniversityName,US.UniversityShortName');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS','SFP.FeesId = SFS.FeesID');
|
|
$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->join(STUDENTCOURSE.' as STC', 'STC.CourseID = SFS.CourseID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID');
|
|
$this->db->where('SFS.CourseID', $student['CourseID']);
|
|
$this->db->where('SFS.StudentID', $student['StudentID']);
|
|
$this->db->where('STC.StudentID', $student['StudentID']);
|
|
$this->db->where('SFP.StudentID', $student['StudentID']);
|
|
$this->db->where('US.BranchCode',$student['BranchCode']);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->where_in('SFS.FeesType', $serachArray);
|
|
$this->db->order_by('SFP.ID', 'DESC');
|
|
$getFeeDetails = $this->db->get();
|
|
if($getFeeDetails->result()){
|
|
foreach ($getFeeDetails->result() as $feeRow){
|
|
$storePaidDetails['FeesID'] = $feeRow->FeesID;
|
|
$storePaidDetails['FeesName'] = $feeRow->FeesType;
|
|
$storePaidDetails['ProgramType'] = $feeRow->FeesType;
|
|
$storePaidDetails['CourseFees'] = $feeRow->CourseFees;
|
|
$storePaidDetails['SessionName'] = "Not Applicable";
|
|
$storePaidDetails['ToSessionName'] = "Not Applicable";
|
|
$storePaidDetails['BatchName'] = "Not Applicable";
|
|
$storePaidDetails['RollNo'] = $feeRow->RollNo;
|
|
$storePaidDetails['Comments'] = $feeRow->Comments;
|
|
$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['MobileNumber'] = $feeRow->MobileNumber;
|
|
$storePaidDetails['Fathername'] = $feeRow->Fathername;
|
|
$storePaidDetails['EnrollmentID'] = $feeRow->EnrollmentID;
|
|
$storePaidDetails['CourseName'] = $feeRow->CourseName;
|
|
$storePaidDetails['UniversityName'] = $feeRow->UniversityName;
|
|
$storePaidDetails['UniveShortName'] = $feeRow->UniversityShortName;
|
|
$this->db->select('ifnull(SUM((BillAmount)),0) as PaidBillAmount');
|
|
$this->db->where('FeesId',$feeRow->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$paidBillAmount = $this->db->get(STUDENTS_FEES_PAID)->result();
|
|
$storePaidDetails['PaidBillAmount']=$paidBillAmount[0]->PaidBillAmount;
|
|
if($paidBillAmount[0]->PaidBillAmount > $storePaidDetails['PayableAmount']){
|
|
//$storePaidDetails['BalanceAmount']=0;
|
|
$storePaidDetails['BalanceAmount']=$storePaidDetails['PayableAmount'] - $paidBillAmount[0]->PaidBillAmount;
|
|
|
|
|
|
}
|
|
else{
|
|
$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('IsActive','1');
|
|
$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('IsActive','1');
|
|
$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,BR.FeesReceiptTitle,STF.Firstname as ReceivedBy,SFP.CommentsForStudent,SFP.InternalComments');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(BRANCH.' as BR','BR.BranchCode = SFP.UpdatedBy','left');
|
|
$this->db->join(LOGIN.' as LO','LO.ID = SFP.CreatedBy');
|
|
$this->db->join(STAFF.' as STF','STF.StaffID = LO.StaffID');
|
|
$this->db->where('SFP.FeesId',$feeRow->FeesID);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->order_by('SFP.ID',"ASC");
|
|
$this->db->group_by('SFP.BillNO');
|
|
$storePaidDetails['paidDetails']=$this->db->get()->result();
|
|
$mergeResult[]=$storePaidDetails;
|
|
|
|
}
|
|
|
|
// print_r($mergeResult);
|
|
|
|
return $mergeResult;
|
|
|
|
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* update fees details
|
|
* created by kms
|
|
* */
|
|
|
|
public function updateFees($feesPaidDetails=null,$courseID=null,$feesName=null,$smsDetails=null)
|
|
{
|
|
|
|
|
|
|
|
if($feesPaidDetails['UpdatedBy']=='All'){
|
|
$this->db->select('BranchID');
|
|
$this->db->where('FeesID', $feesPaidDetails['FeesId']);
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
$this->db->join(STUDENTCOURSE.' as SC', 'SC.CourseID = SFS.CourseID');
|
|
$getStudentBranch=$this->db->get()->result();
|
|
$feesPaidDetails['UpdatedBy'] = $getStudentBranch[0]->BranchID;
|
|
|
|
}
|
|
$this->db->select('BillNO');
|
|
$this->db->where('UpdatedBy', $feesPaidDetails['UpdatedBy']);
|
|
$this->db->order_by('BillNO', 'asc');
|
|
$getLastBillNo=$this->db->get(STUDENTS_FEES_PAID)->last_row();
|
|
if($getLastBillNo){
|
|
$strExplode= explode("-", $getLastBillNo->BillNO);
|
|
|
|
$n=$strExplode[1];
|
|
$n2 = str_pad($n + 1, 5, 0, STR_PAD_LEFT);
|
|
$splitString = substr($feesPaidDetails['UpdatedBy'], 0, 3);
|
|
$feesPaidDetails['BillNO']=$splitString.'-'.$n2;
|
|
}
|
|
else{
|
|
$n='00000';
|
|
$n2 = str_pad($n + 1, 5, 0, STR_PAD_LEFT);
|
|
$splitString = substr($feesPaidDetails['UpdatedBy'], 0, 3);
|
|
$feesPaidDetails['BillNO']=$splitString.'-'.$n2;
|
|
}
|
|
$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('ReceiptNo');
|
|
$this->db->where('ReceiptNo', $feesPaidDetails['ReceiptNo']);
|
|
$this->db->where('IsActive', '1');
|
|
if($this->db->get(STUDENTS_FEES_PAID)->first_row() AND $feesPaidDetails['ReceiptNo']!=''){
|
|
$result['paidStatus'] = false;
|
|
$result['message'] = "This receipt number is already exist!";
|
|
}
|
|
else{
|
|
$this->db->insert(STUDENTS_FEES_PAID, $feesPaidDetails);
|
|
if ($this->db->affected_rows() == '1') {
|
|
|
|
$result['paidStatus'] = true;
|
|
$result['message'] = "Successfully fees details added";
|
|
$result['BillNO'] = $feesPaidDetails['BillNO'];
|
|
$feesPayedID = $this->db->insert_id();
|
|
// $entryOfCallTrack = $this->updateInCallTrack($trackDetails);
|
|
// check static date for day book entry
|
|
$validateDate=strtotime('2018-06-10');
|
|
$arrayExplode=explode('-', $feesPaidDetails['BillDate']);
|
|
$validateBillDate=strtotime($arrayExplode[2].'-'.$arrayExplode[1].'-'.$arrayExplode[0]);
|
|
// day book entry
|
|
|
|
|
|
if($feesPaidDetails['BillAmount']!='0' AND $validateDate <= $validateBillDate){
|
|
|
|
$dayBookEntry = $this->insertDayBookMaster($feesPaidDetails,$feesPayedID,$courseID,$feesName);
|
|
// set message content
|
|
$message='Thanks for the payment of Rs.'.$feesPaidDetails['BillAmount'].',BillNo-'. $feesPaidDetails['BillNO'].' for '. strtolower($smsDetails['FeesName']).' your balance fees is Rs.'.$smsDetails['CurrentBalance'].'.';
|
|
$studentDetails = $this->get_registered_mobile($feesPaidDetails['StudentID']);
|
|
$this->smssend($studentDetails->MobileNumber,$message);
|
|
}
|
|
|
|
// Entry for all status screen except fees
|
|
$this->entryForAllStatus($feesPaidDetails,$courseID,substr($feesName,0,3));
|
|
|
|
}
|
|
else{
|
|
$result['paidStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* update followup details
|
|
* created by kms
|
|
* */
|
|
public function updateInCallTrack($arrayDetails=null){
|
|
// create activity in call tracking
|
|
$this->db->select('ActivityID,ActivityName');
|
|
$this->db->like('ActivityName', 'Fees', 'after');
|
|
$this->db->where('IsActive', '1');
|
|
$activityDetails=$this->db->get(ACTIVITY)->last_row();
|
|
if($activityDetails){
|
|
$newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
|
|
$newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
|
|
$newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_DETAILS, $newLeadDetails);
|
|
// this if for insert lead details
|
|
if($this->db->affected_rows() == '1'){
|
|
// get and store insert id from db
|
|
$track_Details['LeadID']=$this->db->insert_id();
|
|
$track_Details['ActivityStatus'] = $activityDetails->ActivityID;
|
|
$track_Details['University'] = $arrayDetails['University'];
|
|
$track_Details['Course'] = $arrayDetails['Course'];
|
|
$track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['StatusCode'] = $arrayDetails['StatusCode'];
|
|
$track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING, $track_Details);
|
|
// this if for insert tracking details
|
|
if($this->db->affected_rows() == '1'){
|
|
$insertfollowup_Details['TrackingID']=$this->db->insert_id();
|
|
$insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
|
|
$insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
|
|
$insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$insertfollowup_Details['StatusName'] = $arrayDetails['StatusCode'];
|
|
$insertfollowup_Details['AssignedStaff'] = $arrayDetails['CreatedBy'];
|
|
|
|
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
|
|
// this if for insert follow up details
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
// hide tracking updated sepaerate code
|
|
|
|
/* $this->db->select('LD.LeadID,LT.TrackingID');
|
|
$this->db->from(LEAD_DETAILS.' as LD');
|
|
$this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID');
|
|
$this->db->where('LD.MobileNumber',$arrayDetails['MobileNumber']);
|
|
$this->db->where('LT.ActivityStatus',$activityDetails->ActivityID);
|
|
$this->db->like('LT.University',$arrayDetails['University'],'after');
|
|
$this->db->like('LT.Course',$arrayDetails['Course'],'after');
|
|
$leadDet=$this->db->get()->last_row();
|
|
|
|
if($leadDet){
|
|
$this->db->select('FollowupOn');
|
|
$this->db->where('TrackingID',$leadDet->TrackingID);
|
|
$this->db->order_by('InteractionId','DESC');
|
|
$existFollowupOn = $this->db->get(LEAD_TRACKING_FOLLOWUP)->last_row();
|
|
// upate tracking status
|
|
$changeStatusCode['StatusCode'] = $arrayDetails['StatusCode'];
|
|
$changeStatusCode['UpdatedBy'] = $arrayDetails['CreatedBy'];
|
|
$changeStatusCode['UpdatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->where('TrackingID',$leadDet->TrackingID);
|
|
$this->db->update(LEAD_TRACKING, $changeStatusCode);
|
|
// end update status
|
|
$updateTrackDetails['TrackingID'] = $leadDet->TrackingID;
|
|
$updateTrackDetails['FollowupOn'] = $existFollowupOn->FollowupOn;
|
|
$updateTrackDetails['FollowupComments'] = $arrayDetails['FollowupComments'];
|
|
$updateTrackDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$updateTrackDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $updateTrackDetails);
|
|
|
|
}
|
|
|
|
else{
|
|
$this->db->select('LeadID');
|
|
$this->db->where('MobileNumber',$arrayDetails['MobileNumber']);
|
|
$checkLeadDet=$this->db->get(LEAD_DETAILS)->last_row();
|
|
if($checkLeadDet){
|
|
$updateLeadDetails['LeadID'] = $checkLeadDet->LeadID;
|
|
$updateLeadDetails['ActivityStatus'] = $activityDetails->ActivityID;
|
|
$updateLeadDetails['University'] = $arrayDetails['University'];
|
|
$updateLeadDetails['Course'] = $arrayDetails['Course'];
|
|
$updateLeadDetails['AssignedTo'] = $arrayDetails['CreatedBy'];
|
|
$updateLeadDetails['StatusCode'] = $arrayDetails['StatusCode'];
|
|
$updateLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$updateLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING, $updateLeadDetails);
|
|
// this if for insert tracking details
|
|
if($this->db->affected_rows() == '1'){
|
|
$followup_Details['TrackingID']=$this->db->insert_id();
|
|
$followup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
|
|
$followup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
|
|
$followup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$followup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $followup_Details);
|
|
// this if for insert follow up details
|
|
|
|
}
|
|
|
|
}
|
|
else{
|
|
$newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
|
|
$newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
|
|
$newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_DETAILS, $newLeadDetails);
|
|
// this if for insert lead details
|
|
if($this->db->affected_rows() == '1'){
|
|
// get and store insert id from db
|
|
$track_Details['LeadID']=$this->db->insert_id();
|
|
$track_Details['ActivityStatus'] = $activityDetails->ActivityID;
|
|
$track_Details['University'] = $arrayDetails['University'];
|
|
$track_Details['Course'] = $arrayDetails['Course'];
|
|
$track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['StatusCode'] = $arrayDetails['StatusCode'];
|
|
$track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING, $track_Details);
|
|
// this if for insert tracking details
|
|
if($this->db->affected_rows() == '1'){
|
|
$insertfollowup_Details['TrackingID']=$this->db->insert_id();
|
|
$insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
|
|
$insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
|
|
$insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
|
|
// this if for insert follow up details
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* get university details
|
|
* created by kms
|
|
* */
|
|
public function getUniversityDetails($requestedBy=null,$requestedBranch=null)
|
|
{
|
|
$this ->db->select('UniversityID,UniversityName');
|
|
$this->db->where('IsActive','1');
|
|
$this->db->where('BranchCode',$requestedBranch);
|
|
$this->db->order_by('CreatedOn','DESC');
|
|
$unviversityDetails = $this->db->get(UNIVERSITY);
|
|
|
|
if($unviversityDetails->result()){
|
|
$result_university = array();
|
|
$result_university['universityStatus'] = true;
|
|
foreach ($unviversityDetails->result() as $row)
|
|
{
|
|
|
|
$university_array['universityID'] = $row->UniversityID;
|
|
$university_array['universityName'] = $row->UniversityName;
|
|
$university_array['courseDetails']= $this->getCourseDetails($row->UniversityID,$requestedBranch);
|
|
$university_array['batchDetails']= $this->getBatch($row->UniversityID,$requestedBranch);
|
|
$result_array[]=$university_array;
|
|
}
|
|
$result_university['univerSityDetails']= $result_array;
|
|
}
|
|
else {
|
|
$result_university['universityStatus'] = false;
|
|
$result_university['message'] = "No records found!";
|
|
$result_university['universityID'] = "";
|
|
$result_university['universityName'] = "";
|
|
$result_university['courseDetails']= "";
|
|
$result_university['batchDetails']="";
|
|
}
|
|
|
|
|
|
return $result_university;
|
|
|
|
}
|
|
/*
|
|
* get course details
|
|
* @params university id
|
|
* created by kms
|
|
* */
|
|
public function getCourseDetails($universityID=null,$requestedBranch=null)
|
|
{
|
|
$this->db->select('CourseID,CONCAT(CourseName, "(",CourseCode,")") AS CourseName');
|
|
$this->db->where('UniversityID',$universityID);
|
|
$this->db->where('IsActive','1');
|
|
$this->db->where('BranchCode',$requestedBranch);
|
|
$this->db->order_by('CourseID','ASC');
|
|
$courseDetails = $this->db->get(COURSE);
|
|
return $courseDetails->result();
|
|
}
|
|
/*
|
|
* get fees details assign for student
|
|
* created by kms
|
|
* */
|
|
public function getFeesStructureAssign($student=null){
|
|
|
|
$this->db->select('ID,CourseID,ProgramType,FeesAmount,Sem_Year');
|
|
$this->db->where('CourseID',$student['CourseID']);
|
|
$this->db->order_by('ProgramType');
|
|
$feesDetails = $this->db->get(COURSE_FEES);
|
|
$SNoValue=0;
|
|
if($feesDetails->result()){
|
|
|
|
$result_array['feesStatus']=true;
|
|
foreach ($feesDetails->result() as $row){
|
|
$SNoValue=$SNoValue+1;
|
|
$this->db->select('SFS.FeesID,SFS.CourseFees,SFS.Comments,SFS.STFOrWR,SFS.Waiver,SFS.Others,SFS.SessionName,SFS.ToSessionName,SFS.RollNo,SFS.BatchCode,SM.SessionName as MasterSessionName,SM1.SessionName as MasterToSessionName,bm.BatchName');
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
$this->db->join(SESSIONMASTER.' as SM', 'SM.SessionID = SFS.SessionName');
|
|
$this->db->join(SESSIONMASTER.' as SM1', 'SM1.SessionID = SFS.ToSessionName','left');
|
|
$this->db->join(BATCH.' as bm','bm.BatchCode = SFS.BatchCode','left');
|
|
// $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = SFS.FeesID','left');
|
|
$this->db->where('SFS.StudentID',$student['StudentID']);
|
|
$this->db->where('SFS.CourseID',$student['CourseID']);
|
|
$this->db->where('SFS.FeesType',$row->ID);
|
|
$existFeesDetails = $this->db->get();
|
|
|
|
// print_r($this->db->last_query());die();
|
|
if($existData=$existFeesDetails->result()){
|
|
// count the total paid fees details
|
|
$this->db->select('FeesId');
|
|
$this->db->where('FeesId',$existData[0]->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$countExistPaid = $this->db->get(STUDENTS_FEES_PAID);
|
|
if($countExistPaid->num_rows()<=0){
|
|
$fetchData['PaidStatus']=0;
|
|
}
|
|
else{
|
|
$fetchData['PaidStatus']=1;
|
|
}
|
|
// end
|
|
$fetchData['SNo']=$SNoValue;
|
|
$fetchData['ExistValue']=1;
|
|
$fetchData['FeesAssignID']=$existData[0]->FeesID;
|
|
$fetchData['ID']=$row->ID;
|
|
$fetchData['CourseID']=$row->CourseID;
|
|
$fetchData['ProgramType']=$row->ProgramType;
|
|
$fetchData['Sem_Year']=$row->Sem_Year;
|
|
$fetchData['ActualFees']=$existData[0]->CourseFees;
|
|
$fetchData['BatchCode']=$existData[0]->BatchCode;
|
|
$fetchData['STFOrWR']=$existData[0]->STFOrWR;
|
|
$fetchData['Comments']=$existData[0]->Comments;
|
|
$fetchData['Waiver']=$existData[0]->Waiver;
|
|
$fetchData['Others']=$existData[0]->Others;
|
|
$fetchData['SessionName']=$existData[0]->SessionName;
|
|
$fetchData['ToSessionName']=$existData[0]->ToSessionName;
|
|
$fetchData['MasterSessionName']=$existData[0]->MasterSessionName;
|
|
$fetchData['BatchName']=$existData[0]->BatchName;
|
|
if($existData[0]->MasterToSessionName=='' OR $existData[0]->MasterToSessionName==null){
|
|
$fetchData['MasterToSessionName']="Not Applicable";
|
|
}
|
|
else{
|
|
$fetchData['MasterToSessionName']=$existData[0]->MasterToSessionName;
|
|
}
|
|
|
|
$fetchData['RollNo']=$existData[0]->RollNo;
|
|
$fetchData['PayableFees']=$existData[0]->CourseFees+$existData[0]->STFOrWR+$existData[0]->Others-$existData[0]->Waiver;
|
|
// for installment details
|
|
$InstallemtResult = $this->getInstallmentDetails($existData[0]->FeesID);
|
|
|
|
if($InstallemtResult != false){
|
|
$fetchData['InstallmentDetails']=$InstallemtResult;
|
|
}
|
|
else{
|
|
|
|
$fetchData['InstallmentDetails']="";
|
|
|
|
|
|
}
|
|
$batchDetails = $this->getBatchDetails($existData[0]->BatchCode,$student['CourseID'],$student['StudentID'],$row->ID,$student['BranchCode']);
|
|
if($batchDetails!=false){
|
|
$fetchData['batchDetails']=$batchDetails;
|
|
}
|
|
else{
|
|
$fetchData['batchDetails']="";
|
|
}
|
|
|
|
$CourseFeesArray[]=$fetchData;
|
|
|
|
}
|
|
else{
|
|
$fetchData['PaidStatus']=0;
|
|
$fetchData['SNo']=$SNoValue;
|
|
$fetchData['ExistValue']=0;
|
|
$fetchData['FeesAssignID']="";
|
|
$fetchData['ID']=$row->ID;
|
|
$fetchData['CourseID']=$row->CourseID;
|
|
$fetchData['ProgramType']=$row->ProgramType;
|
|
$fetchData['Sem_Year']=$row->Sem_Year;
|
|
$fetchData['ActualFees']=$row->FeesAmount;
|
|
$fetchData['BatchCode']="";
|
|
$fetchData['Comments']="";
|
|
$fetchData['STFOrWR']="";
|
|
$fetchData['Waiver']="";
|
|
$fetchData['Others']="";
|
|
$fetchData['SessionName']="";
|
|
$fetchData['ToSessionName']="";
|
|
$fetchData['MasterSessionName']="Not Applicable";
|
|
$fetchData['MasterToSessionName']="Not Applicable";
|
|
$fetchData['RollNo']="";
|
|
$fetchData['PayableFees']=$row->FeesAmount;
|
|
// for installment details
|
|
$fetchData['InstallmentDetails']="";
|
|
$batchDetails = $this->getBatchDetails('',$student['CourseID'],$student['StudentID'],'',$student['BranchCode']);
|
|
if($batchDetails!=false){
|
|
$fetchData['batchDetails']=$batchDetails;
|
|
}
|
|
else{
|
|
$fetchData['batchDetails']="";
|
|
}
|
|
|
|
$CourseFeesArray[]=$fetchData;
|
|
|
|
}
|
|
|
|
}
|
|
// filter data
|
|
$KilterKey = array_search(1, array_column($CourseFeesArray, 'ExistValue'));
|
|
if($KilterKey=='' OR $KilterKey==null){
|
|
$FilterCourseArray=$CourseFeesArray;
|
|
|
|
}
|
|
else{
|
|
$FilterSNoValue=0;
|
|
|
|
foreach ($CourseFeesArray as $key => $FilterRow){
|
|
if($KilterKey<=$key){
|
|
$FilterSNoValue=$FilterSNoValue+1;
|
|
$FilterRow['SNo']=$FilterSNoValue;
|
|
$FilterCourseArray[]=$FilterRow;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
$defaultCourseDetails = $this->defaultCourseFeesDetails($student);
|
|
if($defaultCourseDetails!=false){
|
|
$result_array['feesDetails']=array_merge($FilterCourseArray,$defaultCourseDetails);
|
|
}
|
|
else{
|
|
$result_array['feesDetails']=$CourseFeesArray;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else{
|
|
$result_array['feesStatus']=false;
|
|
}
|
|
|
|
$result_array['sessionDetails'] = $this->getSession($student);
|
|
$result_array['feesetDetails'] = $this->GetFeeSetDetails($student);
|
|
|
|
return $result_array;
|
|
|
|
}
|
|
/*
|
|
* get installment details
|
|
* created by kms
|
|
* */
|
|
public function getInstallmentDetails($installment=null){
|
|
$this->db->select('ID,FeesID,Name,Amount,DueDate');
|
|
$this->db->where('FeesID',$installment);
|
|
$this->db->order_by('ID','ASC');
|
|
$installmentDetails = $this->db->get(FEES_INSTALLMENT);
|
|
if($installmentDetails->result()){
|
|
return $installmentDetails->result();
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* get batch details
|
|
* created by kms
|
|
* */
|
|
public function getBatchDetails($batchCode=null,$courseID=null,$studentID=null,$feesType=null,$branchCode=null){
|
|
if($batchCode=='' OR $batchCode==null){
|
|
$this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,BA.IsDefault,US.UniversityID,US.UniversityName,BA.IsActive');
|
|
$this->db->from(COURSE.' as CU');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
|
|
$this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID');
|
|
$this->db->order_by('BA.CreatedOn','DESC');
|
|
$this->db->where('CU.CourseID',$courseID);
|
|
$this->db->where('BA.IsActive','1');
|
|
$this->db->where('BA.BranchCode',$branchCode);
|
|
$this->db->where('US.BranchCode',$branchCode);
|
|
|
|
$batchDetails = $this->db->get();
|
|
if($batchDetails->result()){
|
|
|
|
return $batchDetails->result();
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
else{
|
|
|
|
|
|
$this->db->distinct();
|
|
$this->db->select('BA.BatchCode,BA.BatchName,BA.BatchDate,BA.IsDefault,US.UniversityID,US.UniversityName,BA.IsActive');
|
|
$this->db->from(COURSE.' as CU');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as STF', 'STF.CourseID = CU.CourseID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
|
|
$this->db->join(BATCH.' as BA', 'BA.UniversityID = US.UniversityID');
|
|
$this->db->order_by('BA.CreatedOn','DESC');
|
|
$this->db->where('CU.CourseID',$courseID);
|
|
$this->db->where('STF.StudentID',$studentID);
|
|
$this->db->where('STF.FeesType',$feesType);
|
|
$this->db->where('BA.BranchCode',$branchCode);
|
|
$this->db->where('US.BranchCode',$branchCode);
|
|
$batchDetails = array();
|
|
|
|
/* $this->db->or_where('BA.IsActive','1');
|
|
$this->db->or_where('STF.BatchCode =',$batchCode);*/
|
|
$existDetails = $this->db->get();
|
|
if($existDetails->result()){
|
|
foreach ($existDetails->result() as $row){
|
|
if($row->IsActive=='1' || $row->BatchCode==$batchCode){
|
|
array_push($batchDetails,$row);
|
|
}
|
|
|
|
}
|
|
}
|
|
if($batchDetails){
|
|
|
|
return $batchDetails;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* get default pc,tc,dc,mc,other fees
|
|
* created by kms
|
|
* */
|
|
public function defaultCourseFeesDetails($student=null){
|
|
|
|
// check student fees paid details for get default course fees
|
|
|
|
$this->db->select('ifnull(SUM((SFS.CourseFees)),0) as CourseFees,ifnull(SUM((SFS.STFOrWR)),0) as STFOrWR,ifnull(SUM((SFS.Others)),0) as Others,ifnull(SUM((SFS.Waiver)),0) as Waiver');
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
$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']);
|
|
$feesAmount = $this->db->get()->result();
|
|
|
|
$this->db->select('ifnull(SUM((SFP.BillAmount)),0) as PaidAmount');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->where('SFS.CourseID',$student['CourseID']);
|
|
$this->db->where('SFS.StudentID',$student['StudentID']);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$paidAmount = $this->db->get()->result();
|
|
|
|
if($feesAmount[0]->CourseFees+$feesAmount[0]->STFOrWR+$feesAmount[0]->Others-$feesAmount[0]->Waiver <= $paidAmount[0]->PaidAmount AND $feesAmount[0]->CourseFees !='0'){
|
|
$valid=1;
|
|
}
|
|
else{
|
|
$valid=0;
|
|
}
|
|
// get default course fees with paid
|
|
$this->db->select('CourseID,CourseName,PC,TC,DC,MC,OtherFees');
|
|
$this->db->where('CourseID',$student['CourseID']);
|
|
$endFeesDetails = $this->db->get(COURSE);
|
|
$myArray = array();
|
|
if($endFeesDetails->result()){
|
|
foreach ($endFeesDetails->result() as $value ){
|
|
$pc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'PPC', 'ActualFees'=>$value->PC);
|
|
$tc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'TC', 'ActualFees'=>$value->TC);
|
|
$dc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'DC', 'ActualFees'=>$value->DC);
|
|
$mc_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'MC', 'ActualFees'=>$value->MC);
|
|
$other_array = array('CourseID'=>$value->CourseID,'Sem_Year'=>'OTHER', 'ActualFees'=>$value->OtherFees);
|
|
|
|
array_push($myArray,$pc_array);
|
|
array_push($myArray,$tc_array);
|
|
array_push($myArray,$dc_array);
|
|
array_push($myArray,$mc_array);
|
|
array_push($myArray,$other_array);
|
|
}
|
|
|
|
// default course fees details in student status
|
|
foreach ($myArray as $row1){
|
|
$this->db->select('SFS.FeesID,SFS.CourseFees,SFS.STFOrWR,SFS.Waiver,SFS.Comments,SFS.Others,SFS.SessionName,SFS.ToSessionName,SFS.RollNo');
|
|
$this->db->where('SFS.StudentID',$student['StudentID']);
|
|
$this->db->where('SFS.CourseID',$student['CourseID']);
|
|
$this->db->where('SFS.FeesType',$row1['Sem_Year']);
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
// $this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = SFS.FeesID','left');
|
|
$existFeesDetails = $this->db->get();
|
|
if($existData=$existFeesDetails->result()){
|
|
// count the total paid fees details
|
|
$this->db->select('FeesId');
|
|
$this->db->where('FeesId',$existData[0]->FeesID);
|
|
$this->db->where('IsActive','1');
|
|
$countExistPaid = $this->db->get(STUDENTS_FEES_PAID);
|
|
if($countExistPaid->num_rows()<=0){
|
|
$fetchData['PaidStatus']=0;
|
|
}
|
|
else{
|
|
$fetchData['PaidStatus']=1;
|
|
}
|
|
$fetchData['Valid']=$valid;
|
|
$fetchData['ExistValue']=1;
|
|
$fetchData['FeesAssignID']=$existData[0]->FeesID;
|
|
$fetchData['ID']=$row1['Sem_Year'];
|
|
$fetchData['CourseID']=$row1['CourseID'];
|
|
$fetchData['ProgramType']=$row1['Sem_Year'];
|
|
$fetchData['Sem_Year']=$row1['Sem_Year'];
|
|
$fetchData['ActualFees']=$existData[0]->CourseFees;
|
|
$fetchData['STFOrWR']=$existData[0]->STFOrWR;
|
|
$fetchData['Comments']=$existData[0]->Comments;
|
|
$fetchData['Waiver']=$existData[0]->Waiver;
|
|
$fetchData['Others']=$existData[0]->Others;
|
|
$fetchData['SessionName']=$existData[0]->SessionName;
|
|
$fetchData['ToSessionName']=$existData[0]->ToSessionName;
|
|
$fetchData['MasterSessionName']="Not applicable";
|
|
$fetchData['MasterToSessionName']="Not applicable";
|
|
$fetchData['RollNo']=$existData[0]->RollNo;
|
|
$fetchData['PayableFees']=$existData[0]->CourseFees+$existData[0]->STFOrWR+$existData[0]->Others-$existData[0]->Waiver;
|
|
// for installment details
|
|
$InstallemtResult = $this->getInstallmentDetails($existData[0]->FeesID);
|
|
if($InstallemtResult != false){
|
|
$fetchData['InstallmentDetails']=$InstallemtResult;
|
|
}
|
|
else{
|
|
|
|
$fetchData['InstallmentDetails']="";
|
|
|
|
|
|
}
|
|
|
|
$CourseFeesArray1[]=$fetchData;
|
|
|
|
}
|
|
else{
|
|
$fetchData['PaidStatus']=0;
|
|
$fetchData['Valid']=$valid;
|
|
$fetchData['ExistValue']=0;
|
|
$fetchData['FeesAssignID']="";
|
|
$fetchData['ID']=$row1['Sem_Year'];
|
|
$fetchData['CourseID']=$row1['CourseID'];
|
|
$fetchData['Sem_Year']=$row1['Sem_Year'];
|
|
$fetchData['ActualFees']=$row1['ActualFees'];
|
|
$fetchData['STFOrWR']="";
|
|
$fetchData['Comments']="";
|
|
$fetchData['Waiver']="";
|
|
$fetchData['Others']="";
|
|
$fetchData['SessionName']="Not applicable";
|
|
$fetchData['ToSessionName']="Not applicable";
|
|
$fetchData['MasterSessionName']="Not applicable";
|
|
$fetchData['MasterToSessionName']="Not applicable";
|
|
$fetchData['RollNo']="";
|
|
$fetchData['PayableFees']=$row1['ActualFees'];
|
|
$fetchData['InstallmentDetails']="";
|
|
$CourseFeesArray1[]=$fetchData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $CourseFeesArray1;
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
/* }
|
|
else{
|
|
return false;
|
|
}*/
|
|
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
* set fees for student
|
|
* created by kms
|
|
* */
|
|
public function setFees($details=null,$jsonData=null){
|
|
|
|
//echo 'in';
|
|
// print_r($details);
|
|
//print_r($jsonData);
|
|
//die();
|
|
$RollNo= $details['RollNo'];
|
|
|
|
|
|
|
|
if($RollNo !='')
|
|
{
|
|
|
|
$this->db->select('*');
|
|
$this->db->from('T_Students_Fees_Status');
|
|
$this->db->where('RollNo',$RollNo);
|
|
$this->db->where('CourseID',$details['CourseID']);
|
|
$this->db->where('StudentID !=',$details['StudentID']);
|
|
$qry=$this->db->get();
|
|
$qry=$qry->result();
|
|
|
|
//print_r($this->db->last_query());die();
|
|
//echo count($qry);die();
|
|
|
|
if(count($qry)>0)
|
|
{
|
|
$result['setStatus'] = false;
|
|
$result['message'] = "RollNo Already Exists";
|
|
|
|
return $result;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$this->db->select('FeesID');
|
|
$this->db->where('CourseID', $details['CourseID']);
|
|
$this->db->where('StudentID', $details['StudentID']);
|
|
$this->db->where('FeesType', $details['FeesType']);
|
|
$checkExist=$this->db->get(STUDENTS_FEES_STATUS);
|
|
if($checkExist->result()){
|
|
$feesId = $checkExist->result();
|
|
$updateDetails['CourseFees'] = $details['CourseFees'];
|
|
$updateDetails['SessionName'] = $details['SessionName'];
|
|
$updateDetails['ToSessionName'] = $details['ToSessionName'];
|
|
$updateDetails['BatchCode'] = $details['BatchCode'];
|
|
$updateDetails['RollNo'] = $details['RollNo'];
|
|
$updateDetails['STFOrWR'] = $details['STFOrWR'];
|
|
$updateDetails['Comments'] = $details['Comments'];
|
|
$updateDetails['Waiver'] = $details['Waiver'];
|
|
$updateDetails['Others'] = $details['Others'];
|
|
$updateDetails['UpdatedOn'] = $details['CreatedOn'];
|
|
$updateDetails['UpdatedBy'] = $details['CreatedBy'];
|
|
|
|
$installmentFeesID = $feesId[0]->FeesID;
|
|
foreach ($jsonData as $jrow){
|
|
|
|
$insertInstallment['FeesID'] = $installmentFeesID;
|
|
$insertInstallment['Name'] = $jrow['Name'];
|
|
$insertInstallment['Amount'] = $jrow['Amount'];
|
|
$insertInstallment['DueDate'] = $jrow['DueDate'];
|
|
$insertInstallment['CreatedBy'] = $details['CreatedBy'];
|
|
$insertInstallment['CreatedOn'] = $details['CreatedOn'];
|
|
if($jrow['ID'] =='' OR $jrow['ID'] =='undefined'){
|
|
$this->db->insert(FEES_INSTALLMENT, $insertInstallment);
|
|
}
|
|
else{
|
|
$updateInstallment['FeesID'] = $installmentFeesID;
|
|
$updateInstallment['Name'] = $jrow['Name'];
|
|
$updateInstallment['Amount'] = $jrow['Amount'];
|
|
$updateInstallment['DueDate'] = $jrow['DueDate'];
|
|
$updateInstallment['UpdatedBy'] = $details['CreatedBy'];
|
|
$updateInstallment['UpdatedOn'] = $details['CreatedOn'];
|
|
$this->db->where('ID',$jrow['ID']);
|
|
$this->db->update(FEES_INSTALLMENT, $updateInstallment);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$this->db->where('FeesID', $feesId[0]->FeesID);
|
|
$this->db->update(STUDENTS_FEES_STATUS, $updateDetails);
|
|
$result['setStatus'] = true;
|
|
$result['message'] = "Successfully fees details is updated.";
|
|
|
|
}
|
|
else{
|
|
$this->db->insert(STUDENTS_FEES_STATUS, $details);
|
|
|
|
$this->db->select('FeesID,BatchCode,StudentID,CourseID,FeesType');
|
|
$this->db->where('CourseID', $details['CourseID']);
|
|
$this->db->where('StudentID', $details['StudentID']);
|
|
$this->db->where('FeesType', $details['FeesType']);
|
|
$existDb=$this->db->get(STUDENTS_FEES_STATUS)->last_row();
|
|
if($existDb){
|
|
$rowId = $existDb;
|
|
$installmentFeesID = $rowId->FeesID;
|
|
foreach ($jsonData as $jrow){
|
|
$insertInstallment['FeesID'] = $installmentFeesID;
|
|
$insertInstallment['Name'] = $jrow['Name'];
|
|
$insertInstallment['Amount'] = $jrow['Amount'];
|
|
$insertInstallment['DueDate'] = $jrow['DueDate'];
|
|
$insertInstallment['CreatedBy'] = $details['CreatedBy'];
|
|
$insertInstallment['CreatedOn'] = $details['CreatedOn'];
|
|
|
|
if($jrow['ID'] =='' OR $jrow['ID'] =='undefined'){
|
|
$this->db->insert(FEES_INSTALLMENT, $insertInstallment);
|
|
}
|
|
else{
|
|
$updateInstallment['FeesID'] = $installmentFeesID;
|
|
$updateInstallment['Name'] = $jrow['Name'];
|
|
$updateInstallment['Amount'] = $jrow['Amount'];
|
|
$updateInstallment['DueDate'] = $jrow['DueDate'];
|
|
$updateInstallment['UpdatedBy'] = $details['CreatedBy'];
|
|
$updateInstallment['UpdatedOn'] = $details['CreatedOn'];
|
|
|
|
$this->db->where('ID',$jrow['ID']);
|
|
$this->db->update(FEES_INSTALLMENT, $updateInstallment);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
$result['setStatus'] = true;
|
|
$result['message'] = "Successfully fees details is added.";
|
|
|
|
}
|
|
|
|
$fromd= date("d-m-Y",strtotime($details['CreatedOn']));
|
|
|
|
|
|
if(($details['FeesType']=='PPC') || ($details['FeesType']=='TC')|| ($details['FeesType']=='MC')
|
|
|| ($details['FeesType'] == 'DC'))
|
|
{
|
|
|
|
$this->db->select('ListCode');
|
|
$this->db->from('T_PickListDetails');
|
|
$this->db->where('ListName','EXPECTED');
|
|
$this->db->where('BranchCode',$details['BranchCode']);
|
|
|
|
$searchDetails = $this->db->get();
|
|
$getId=$searchDetails->result();
|
|
|
|
$listcode='';
|
|
|
|
foreach($getId as $ge)
|
|
{
|
|
$listcode=$ge->ListCode;
|
|
}
|
|
|
|
$appstatus['StudentID'] = $details['StudentID'];
|
|
$appstatus['CourseID'] = $details['CourseID'];
|
|
$appstatus['BranchCode'] = $details['BranchCode'];
|
|
$appstatus['ListCode'] = $listcode;
|
|
$appstatus['AppDate'] = $fromd;
|
|
$appstatus['Comments'] = 'Fees for the student has been set';
|
|
$appstatus['CreatedBy']= $details['CreatedBy'];
|
|
$appstatus['CreatedOn'] = $details['CreatedOn'];
|
|
$appstatus['CertificationType'] =$details['FeesType'];
|
|
$this->db->insert('T_ApplicationStatus', $appstatus);
|
|
|
|
|
|
}
|
|
// update registration details
|
|
if($jsonData){
|
|
$this->updateRegistrationDetails($details,$installmentFeesID);
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
/*
|
|
* insert registration details while set fees
|
|
* created by kms
|
|
* */
|
|
public function updateRegistrationDetails($details=null,$feesStatusID=null){
|
|
|
|
|
|
$regId='';
|
|
$this->db->select('Student_Fee_Status_Id,RegistrationMode');
|
|
$this->db->where('CourseID', $details['CourseID']);
|
|
$this->db->where('StudentID', $details['StudentID']);
|
|
$checkCourseFees=$this->db->get(REGISTRATIONDETAILS);
|
|
if($checkCourseFees->num_rows()<=0){
|
|
// insert registration details table
|
|
|
|
// $regId= $feesStatusID;
|
|
$inserRegistartion['Student_Fee_Status_Id']=$feesStatusID;
|
|
$inserRegistartion['BatchCode']=$details['BatchCode'];
|
|
$inserRegistartion['StudentID']=$details['StudentID'];
|
|
$inserRegistartion['CourseID']=$details['CourseID'];
|
|
$inserRegistartion['FeeType']=$details['FeesType'];
|
|
$inserRegistartion['RegistrationMode']=1;
|
|
$inserRegistartion['RegistrationType']=NEWREGISTRATION_CONST;
|
|
$inserRegistartion['BranchCode']=$details['BranchCode'];
|
|
$inserRegistartion['CreatedBy']=$details['CreatedBy'];
|
|
$inserRegistartion['CreatedOn']=$details['CreatedOn'];
|
|
$getlastid= $this->db->insert(REGISTRATIONDETAILS, $inserRegistartion);
|
|
|
|
|
|
}
|
|
else if($checkCourseFees->num_rows()>=1){
|
|
$this->db->select('Student_Fee_Status_Id,RegistrationMode');
|
|
$this->db->where('Student_Fee_Status_Id', $feesStatusID);
|
|
$checkRegistrationEntry=$this->db->get(REGISTRATIONDETAILS);
|
|
if($checkRegistrationEntry->num_rows()>0){
|
|
$updateRegistration['BatchCode']=$details['BatchCode'];
|
|
$updateRegistration['BranchCode']=$details['BranchCode'];
|
|
$updateRegistration['UpdatedBy']=$details['CreatedBy'];
|
|
$updateRegistration['UpdatedOn']=$details['CreatedOn'];
|
|
$this->db->where('Student_Fee_Status_Id',$feesStatusID);
|
|
$getlastid= $this->db->update(REGISTRATIONDETAILS, $updateRegistration);
|
|
|
|
|
|
// $regId= $feesStatusID;
|
|
|
|
|
|
|
|
}
|
|
else{
|
|
$reRegistartion['Student_Fee_Status_Id']=$feesStatusID;
|
|
$reRegistartion['BatchCode']=$details['BatchCode'];
|
|
$reRegistartion['StudentID']=$details['StudentID'];
|
|
$reRegistartion['CourseID']=$details['CourseID'];
|
|
$reRegistartion['FeeType']=$details['FeesType'];
|
|
$reRegistartion['RegistrationMode']=0;
|
|
$reRegistartion['RegistrationType']=RE_REGISTRATION_CONST;
|
|
$reRegistartion['BranchCode']=$details['BranchCode'];
|
|
$reRegistartion['CreatedBy']=$details['CreatedBy'];
|
|
$reRegistartion['CreatedOn']=$details['CreatedOn'];
|
|
$getlastid= $this->db->insert(REGISTRATIONDETAILS, $reRegistartion);
|
|
|
|
// $regId= $feesStatusID;
|
|
}
|
|
}
|
|
|
|
$REGID='';
|
|
if($getlastid)
|
|
{
|
|
$this->db->select('max(ID) as ID');
|
|
$this->db->from('T_Registration_Details');
|
|
$getmaxID= $this->db->get();
|
|
$maxID = $getmaxID->result();
|
|
|
|
//print_r($maxID);
|
|
|
|
foreach($maxID as $ma)
|
|
{
|
|
$REGID = $ma->ID;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// print_r($getlastid);
|
|
|
|
|
|
// echo 'in';
|
|
// die();
|
|
$this->db->select('ListCode');
|
|
$this->db->from('T_PickListDetails');
|
|
$this->db->where('ListName','EXPECTED');
|
|
$this->db->where('BranchCode',$details['BranchCode']);
|
|
|
|
$searchDetails = $this->db->get();
|
|
$getId=$searchDetails->result();
|
|
|
|
$listcode='';
|
|
|
|
foreach($getId as $ge)
|
|
{
|
|
$listcode=$ge->ListCode;
|
|
}
|
|
|
|
|
|
|
|
|
|
$fromd= date("d-m-Y",strtotime($details['CreatedOn']));
|
|
|
|
$upappform['BranchCode']=$details['BranchCode'];
|
|
$upappform['AppFormDate']=$fromd;
|
|
$upappform['Registration_Details_ID']=$REGID;
|
|
$upappform['ListCode']=$listcode;
|
|
$upappform['CreatedBy']=$details['CreatedBy'];
|
|
$upappform['CreatedOn']=$details['CreatedOn'];
|
|
$upappform['Comments']='Fees for the student has been set';
|
|
$this->db->insert('T_ApplicationFormStatus', $upappform);
|
|
|
|
|
|
|
|
|
|
|
|
// $appstatus['StudentID'] = $details['StudentID'];
|
|
// $appstatus['CourseID'] = $details['CourseID'];
|
|
// $appstatus['BranchCode'] = $details['BranchCode'];
|
|
// $appstatus['ListCode'] = $listcode;
|
|
// $appstatus['AppDate'] = $fromd;
|
|
// $appstatus['Comments'] = 'Fees for the student has been set';
|
|
// $appstatus['CreatedBy']= $details['CreatedBy'];
|
|
// $appstatus['CreatedOn'] = $details['CreatedOn'];
|
|
// $appstatus['CertificationType'] =$details['FeesType'];
|
|
// $this->db->insert('T_ApplicationStatus', $appstatus);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
/*
|
|
* insert day book master while fees update
|
|
* created by kms
|
|
* */
|
|
public function insertDayBookMaster($data=null,$paymentID,$courseID,$feesName){
|
|
$this->db->select('Firstname');
|
|
$this->db->where('StudentID', $data['StudentID']);
|
|
$getStudentName=$this->db->get(STUDENTS)->result();
|
|
if($getStudentName){
|
|
// this is for income entry
|
|
$insertArray['Date'] = $data['BillDate'];
|
|
$insertArray['CreatedBy'] = $data['CreatedBy'];
|
|
$insertArray['CreatedOn'] = $data['CreatedOn'];
|
|
$insertArray['ReceiptNo'] = $data['ReceiptNo'];
|
|
$insertArray['ReceiptNoComments'] = $data['InternalComments'];
|
|
$insertArray['PaidDescription'] = "";
|
|
$insertArray['Amount'] = $data['BillAmount'];
|
|
$insertArray['Status'] = 'Approved';
|
|
$insertArray['PaymentStatus'] = false;
|
|
$insertArray['FeesPaymentID'] = $paymentID;
|
|
$insertArray['VoucherNumber'] = $data['BillNO'];
|
|
$insertArray['PaidTo'] = $getStudentName[0]->Firstname;
|
|
$insertArray['BranchCode'] = $data['UpdatedBy'];
|
|
$insertArray['ModeOfPayment'] = $data['ModeOfPayment'];
|
|
$insertArray['StudentID'] = $data['StudentID'];
|
|
$insertArray['CourseID'] = $courseID;
|
|
$insertArray['FeePaymentDetails'] = $feesName;
|
|
|
|
$this->db->select('ID,TypeID');
|
|
$this->db->where('TypeID', 'I002');
|
|
$this->db->where('TypeName', 'FEES');
|
|
$this->db->where('BranchCode',$data['UpdatedBy']);
|
|
$getIncome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row();
|
|
|
|
if($getIncome){
|
|
$insertArray['Name'] = $getIncome->TypeID;
|
|
$insertArray['Type'] = $getIncome->ID;
|
|
$checkInsertIn=$this->add_dayBook($insertArray);
|
|
if($checkInsertIn['addDayBookStatus']==true AND $data['ModeOfPayment']!='CASH'){
|
|
//online daybook entry with only INCOME
|
|
if($data['ModeOfPayment']!='REFERRAL' AND $data['ModeOfPayment']!='WAIVER'){
|
|
$checkInsertOut=$this->add_dayBook_online($insertArray);
|
|
}
|
|
// this is for expense come entry
|
|
$now1 = new DateTime();
|
|
$now1->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
|
|
$expenseArray['Date'] = $data['BillDate'];
|
|
$expenseArray['CreatedBy'] = $data['CreatedBy'];
|
|
$expenseArray['CreatedOn'] = $now1->format('Y-m-d H:i:s');;
|
|
$expenseArray['ReceiptNo'] = $data['ReceiptNo'];
|
|
$expenseArray['ReceiptNoComments'] = $data['InternalComments'];
|
|
$expenseArray['PaidDescription'] = "";
|
|
$expenseArray['Amount'] = $data['BillAmount'];
|
|
$expenseArray['Status'] = 'Pending';
|
|
$expenseArray['PaymentStatus'] = false;
|
|
$expenseArray['FeesPaymentID'] = $paymentID;
|
|
$expenseArray['VoucherNumber'] = $data['BillNO'];
|
|
$expenseArray['PaidTo'] = $getStudentName[0]->Firstname;
|
|
$expenseArray['BranchCode'] = $data['UpdatedBy'];
|
|
$expenseArray['ModeOfPayment'] = $data['ModeOfPayment'];
|
|
$expenseArray['StudentID'] = $data['StudentID'];
|
|
$expenseArray['CourseID'] = $courseID;
|
|
$expenseArray['FeePaymentDetails'] = $feesName;
|
|
$this->db->select('ID,TypeID');
|
|
$this->db->where('TypeID', 'I001');
|
|
$this->db->where('TypeName', 'FEES');
|
|
$this->db->where('BranchCode',$data['UpdatedBy']);
|
|
$getOutcome=$this->db->get(INCOMEOUTCOMEMASTER)->last_row();
|
|
|
|
if($getOutcome){
|
|
$expenseArray['Name'] = $getOutcome->TypeID;
|
|
$expenseArray['Type'] = $getOutcome->ID;
|
|
/* $this->db->insert(DAYBOOKMASTER, $expenseArray);*/
|
|
$checkInsertOut=$this->add_dayBook($expenseArray);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* send notification for student
|
|
* created by kms
|
|
* */
|
|
public function studentNotification(){
|
|
$date = new DateTime(date("d-m-Y"));
|
|
$date->modify('+2 day');
|
|
$tomorrowDATE = $date->format('d-m-Y');
|
|
|
|
$this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
|
|
$this->db->from(FEES_INSTALLMENT.' as FIN');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
|
|
$this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
|
|
$this->db->where('FIN.DueDate',$tomorrowDATE);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentDetails = $this->db->get();
|
|
|
|
if ($getStudentDetails->result()){
|
|
foreach ($getStudentDetails->result() as $row){
|
|
$this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
|
|
$this->db->where('SFS.CourseID',$row->CourseID);
|
|
$this->db->where('SFS.StudentID',$row->StudentID);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentPaiDetails = $this->db->get()->result();
|
|
|
|
if($row->Amount > $getStudentPaiDetails[0]->BillAmount){
|
|
$studentDetails = $this->get_registered_mobile($row->StudentID);
|
|
$message ="Dear ". strtolower($studentDetails->Firstname)." your ". strtolower($row->Name)." installment due is on $row->DueDate.Please clear the dues.";
|
|
|
|
$this->smssend($studentDetails->MobileNumber,$message);
|
|
}
|
|
|
|
}
|
|
}
|
|
$date1 = new DateTime(date("d-m-Y"));
|
|
$date1->modify('+7 day');
|
|
$afterFiveDays = $date1->format('d-m-Y');
|
|
$this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
|
|
$this->db->from(FEES_INSTALLMENT.' as FIN');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
|
|
$this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
|
|
$this->db->where('FIN.DueDate',$afterFiveDays);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentDetails1 = $this->db->get();
|
|
if ($getStudentDetails1->result()){
|
|
foreach ($getStudentDetails1->result() as $row1){
|
|
$this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
|
|
$this->db->where('SFS.CourseID',$row1->CourseID);
|
|
$this->db->where('SFS.StudentID',$row1->StudentID);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentPaiDetails1 = $this->db->get()->result();
|
|
if($row1->Amount > $getStudentPaiDetails1[0]->BillAmount){
|
|
$studentDetails1 = $this->get_registered_mobile($row1->StudentID);
|
|
$message1 ="Dear ". strtolower($studentDetails1->Firstname)." your ". strtolower($row1->Name)." installment due is on $row1->DueDate.Please clear the dues.";
|
|
|
|
$this->smssend($studentDetails1->MobileNumber,$message1);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
// this is for update details in call track after due date
|
|
$yesterdayDate = new DateTime(date("d-m-Y"));
|
|
$yesterdayDate->modify('-1 day');
|
|
$preDATE = $yesterdayDate->format('d-m-Y');
|
|
$this->db->distinct();
|
|
$this->db->select('FIN.ID,FIN.Name,FIN.FeesID,FIN.Amount,FIN.DueDate,SFS.StudentID,SFS.CourseID');
|
|
$this->db->from(FEES_INSTALLMENT.' as FIN');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'FIN.FeesID = SFS.FeesID');
|
|
$this->db->join(STUDENTS_FEES_PAID.' as SFP', 'SFP.FeesId = FIN.FeesID','left');
|
|
$this->db->where('FIN.DueDate',$preDATE);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentDetails2 = $this->db->get();
|
|
if ($getStudentDetails2->result()){
|
|
foreach ($getStudentDetails2->result() as $row2){
|
|
$this->db->select('ifnull(SUM((SFP.BillAmount)),0) as BillAmount');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFP.FeesId = SFS.FeesID');
|
|
$this->db->where('SFS.CourseID',$row2->CourseID);
|
|
$this->db->where('SFS.StudentID',$row2->StudentID);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$getStudentPaiDetails2 = $this->db->get()->result();
|
|
|
|
if($row2->Amount > $getStudentPaiDetails2[0]->BillAmount){
|
|
// update in call track
|
|
$this->updateFeesStatusInCallTrack($row2->StudentID,$row2->CourseID);
|
|
// send notification to student
|
|
$getStudentPaiDetails2 = $this->get_registered_mobile($row2->StudentID);
|
|
$message2 ="Dear ". strtolower($getStudentPaiDetails2->Firstname)." your ". strtolower($row2->Name)." installment date is overdue.Please clear this immediately.Ignore if already paid.";
|
|
$this->smssend($getStudentPaiDetails2->MobileNumber,$message2);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* this is for sms send
|
|
* created by kms
|
|
* */
|
|
public function smssend($studentMobile=null,$data=null)
|
|
{
|
|
// $msg ="Dear $studentDetails->Firstname, Fees Payment for your course is falling due on $date. Please ignore if already paid.";
|
|
$mobile = "91$studentMobile";
|
|
// $message ="Your new password for logging into Apollo student portal is SAMPLE. Please change the password as soon as you login.";
|
|
// $mobile = "91$mobile";
|
|
|
|
$message = urlencode($data);
|
|
$ch=curl_init();
|
|
curl_setopt($ch,CURLOPT_URL,"https://smsapi.24x7sms.com/api_2.0/SendSMS.aspx?APIKEY=xegCdYUIMf3&MobileNo=".$mobile."&SenderID=APODEC&Message=".$message."&ServiceName=TEMPLATE_BASED");
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
|
$output =curl_exec($ch);
|
|
|
|
// print_r($output);exit();
|
|
curl_close($ch);
|
|
|
|
$arrss = explode('<br>', $output);
|
|
|
|
$time = date('Y-m-d H:i:s');
|
|
$dateTime = $time;
|
|
$msgGroup = date('YmdHis');
|
|
|
|
//print_r($arrss);
|
|
|
|
for ($i = 0, $c = count($arrss);$i < $c;$i++)
|
|
{
|
|
|
|
if ($arrss[$i] === '')
|
|
{
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
$a = explode(':', $arrss[$i]);
|
|
$msgIdState = $a[0];
|
|
$msgId = $a[1];
|
|
$msgNumb = $a[2];
|
|
$msgStatus = $a[4];
|
|
$data = array('MsgId' => $msgId, 'MobileNumber' => $msgNumb, 'MsgBody' => $data, 'Status' => $msgStatus, 'CreatedOn' => $dateTime,'MsgGroup' => $msgGroup);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
// print_r($data);die();
|
|
|
|
$this->db->insert('T_BroadcastStatus',$data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $output;
|
|
}
|
|
|
|
// self function for getting registered mobile for sms
|
|
public function get_registered_mobile($num) {
|
|
$this->db->select('MobileNumber,Firstname');
|
|
$this->db->from(STUDENTS);
|
|
$this->db->where('StudentID', $num);
|
|
$roleDetails = $this->db->get()->first_row();
|
|
return $roleDetails;
|
|
}
|
|
/*
|
|
* update followup details for fees pending in call tracking
|
|
* created by kms
|
|
* */
|
|
public function updateFeesStatusInCallTrack($studentID=null,$courseID=null){
|
|
// get student details
|
|
$studentDetails = $this->studentInfoForFeesStatus($studentID,$courseID);
|
|
|
|
$now = new DateTime();
|
|
$now->setTimezone(new DateTimezone('Asia/Kolkata'));
|
|
$currentDate = new DateTime(date("d-m-Y"));
|
|
$afterFormatedDate = $currentDate->format('d-m-Y');
|
|
// get student details
|
|
|
|
$this->db->select('PLD.ListCode');
|
|
$this->db->from(PICK_LIST_DETAILS.' as PLD');
|
|
$this->db->where('PLD.ListName','PENDING');
|
|
$this->db->where('PLD.IsActive','1');
|
|
$this->db->where('PLD.BranchCode',$studentDetails->BranchID);
|
|
$checkStatus=$this->db->get()->last_row();
|
|
if($checkStatus){
|
|
|
|
|
|
if($studentDetails){
|
|
$arrayDetails['MobileNumber']=$studentDetails->MobileNumber;
|
|
$arrayDetails['LeadName']=$studentDetails->Firstname;
|
|
$arrayDetails['University']=$studentDetails->UniversityName;
|
|
$arrayDetails['Course']=$studentDetails->CourseName;
|
|
$arrayDetails['StatusCode']=$checkStatus->ListCode;
|
|
$arrayDetails['CreatedBranch']=$studentDetails->BranchID;
|
|
$arrayDetails['CreatedOn']=$now->format('Y-m-d H:i:s');
|
|
$arrayDetails['FollowupOn']=$afterFormatedDate;
|
|
$arrayDetails['FollowupComments']="Fees payment for your course is falling.";
|
|
// get created by with branch id
|
|
|
|
$this->db->select('LO.ID');
|
|
$this->db->from(STAFF_BRANCH.' as STB');
|
|
$this->db->join(LOGIN.' as LO', 'LO.StaffID = STB.StaffID');
|
|
$this->db->where('STB.BranchCode',$studentDetails->BranchID);
|
|
$this->db->where('LO.ListCode',ADMIN);
|
|
$this->db->where('STB.IsActive','1');
|
|
$this->db->where('LO.IsActive','1');
|
|
$assignDet=$this->db->get()->last_row();
|
|
if($assignDet){
|
|
$arrayDetails['CreatedBy']=$assignDet->ID;
|
|
}
|
|
else{
|
|
$arrayDetails['CreatedBy']='';
|
|
}
|
|
|
|
// create activity in call tracking
|
|
$this->db->select('ActivityID,ActivityName');
|
|
$this->db->like('ActivityName', 'Fees', 'after');
|
|
$this->db->where('IsActive', '1');
|
|
$this->db->where('BranchCode', $studentDetails->BranchID);
|
|
$activityDetails=$this->db->get(ACTIVITY)->last_row();
|
|
if($activityDetails){
|
|
|
|
$newLeadDetails['MobileNumber'] = $arrayDetails['MobileNumber'];
|
|
$newLeadDetails['LeadName'] = $arrayDetails['LeadName'];
|
|
$newLeadDetails['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$newLeadDetails['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$this->db->insert(LEAD_DETAILS, $newLeadDetails);
|
|
// this if for insert lead details
|
|
if($this->db->affected_rows() == '1'){
|
|
// get and store insert id from db
|
|
$track_Details['LeadID']=$this->db->insert_id();
|
|
$track_Details['ActivityStatus'] = $activityDetails->ActivityID;
|
|
$track_Details['University'] = $arrayDetails['University'];
|
|
$track_Details['Course'] = $arrayDetails['Course'];
|
|
$track_Details['AssignedTo'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['StatusCode'] = $arrayDetails['StatusCode'];
|
|
$track_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$track_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$track_Details['UpdatedOn'] = $arrayDetails['CreatedOn'];
|
|
$track_Details['CreatedBranch']=$arrayDetails['CreatedBranch'];
|
|
$this->db->insert(LEAD_TRACKING, $track_Details);
|
|
// this if for insert tracking details
|
|
if($this->db->affected_rows() == '1'){
|
|
$insertfollowup_Details['TrackingID']=$this->db->insert_id();
|
|
$insertfollowup_Details['FollowupOn']=$arrayDetails['FollowupOn'];
|
|
$insertfollowup_Details['FollowupComments']=$arrayDetails['FollowupComments'];
|
|
$insertfollowup_Details['CreatedBy'] = $arrayDetails['CreatedBy'];
|
|
$insertfollowup_Details['CreatedOn'] = $arrayDetails['CreatedOn'];
|
|
$insertfollowup_Details['StatusName'] = $arrayDetails['StatusCode'];
|
|
$insertfollowup_Details['AssignedStaff'] = $arrayDetails['CreatedBy'];
|
|
|
|
|
|
$this->db->insert(LEAD_TRACKING_FOLLOWUP, $insertfollowup_Details);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* get student info for fees due updates
|
|
* created by kms
|
|
* */
|
|
public function studentInfoForFeesStatus($studentID=null,$courseID=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('ST.Firstname,ST.MobileNumber,US.UniversityName,CU.CourseName,STC.BranchID');
|
|
$this->db->from(STUDENTCOURSE.' as STC');
|
|
$this->db->join(STUDENTS.' as ST', 'ST.StudentID = STC.StudentID');
|
|
$this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID AND STC.BranchID=US.BranchCode');
|
|
$this->db->where('ST.StudentID',$studentID);
|
|
$this->db->where('STC.CourseID',$courseID);
|
|
// $this->db->where('US.BranchCode IN('. $subQuery.')', NULL, FALSE);
|
|
$leadDet=$this->db->get()->last_row();
|
|
if($leadDet){
|
|
return $leadDet;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* Get session master details
|
|
* created by kms
|
|
* */
|
|
|
|
public function getSession($details=null)
|
|
{
|
|
$this->db->select('SM.SessionID,SM.SessionDate,SM.SessionName,SM.IsActive');
|
|
$this->db->from(SESSIONMASTER.' as SM');
|
|
$this->db->join(SESSIONDETAILS.' as SD', 'SM.SessionID = SD.SessionID');
|
|
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = SD.UniversityID');
|
|
$this->db->join(COURSE.' as CU', 'CU.UniversityID = US.UniversityID');
|
|
// $this->db->where('SD.IsActive','1');
|
|
// $this->db->order_by('CU.CreatedOn','DESC');
|
|
$this->db->order_by('SM.SessionID','DESC');
|
|
$this->db->where('CU.CourseID',$details['CourseID']);
|
|
$this->db->where('US.BranchCode',$details['BranchCode']);
|
|
$this->db->where('SM.BranchCode',$details['BranchCode']);
|
|
// $this->db->group_by('SM.SessionName','DESC');
|
|
$sessionDetails = $this->db->get();
|
|
if($sessionDetails->result()){
|
|
|
|
return $sessionDetails->result();
|
|
}
|
|
else {
|
|
return false;
|
|
}
|
|
|
|
}
|
|
/*
|
|
* Entry for all status update
|
|
* created by kms
|
|
* */
|
|
public function entryForAllStatus($feesDetails=null,$courseID=null,$feesName=null){
|
|
//$singleFeesDetails=["SEM 1","SEM 2","SEM 3","SEM 4","SEM 5","SEM 6","SEM 7","SEM 8"];
|
|
|
|
$this->db->select('semnumber');
|
|
$this->db->from('T_Course_Fees_Details');
|
|
$this->db->where('CourseID',$courseID);
|
|
|
|
$Details = $this->db->get();
|
|
|
|
$results = $Details->result();
|
|
|
|
$semnum = $results[0]->semnumber;
|
|
|
|
//echo $semnum;die();
|
|
|
|
|
|
$i=$semnum;
|
|
for($j=0;$j<$i;$j++)
|
|
{
|
|
$k=$j+1;
|
|
$singleFeesDetails[$j] = 'SEM '.$k.'';
|
|
}
|
|
|
|
//print_r($singleFeesDetails);die();
|
|
|
|
// get pick list expected status
|
|
$this->db->select('ListCode,ListName');
|
|
if(strtoupper($feesName)==DMC_CONST){
|
|
$this->db->where('ListName','NOT APPLICABLE');
|
|
}
|
|
else{
|
|
$this->db->where('ListName','EXPECTED');
|
|
}
|
|
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('IsActive','1');
|
|
$existStatusDetails = $this->db->get(PICK_LIST_DETAILS)->last_row();
|
|
if($existStatusDetails){
|
|
//check if exist
|
|
$this->db->select('SFS.FeesID,SFS.FeesType');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->where('SFS.CourseID',$courseID);
|
|
$this->db->where('SFS.StudentID',$feesDetails['StudentID']);
|
|
$this->db->where('SFP.FeesId',$feesDetails['FeesId']);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$existDetails = $this->db->get();
|
|
if($existDetails->num_rows()>1){
|
|
return true;
|
|
}
|
|
else{
|
|
$fetchData = $existDetails->result();
|
|
if($fetchData[0]->FeesType!=PC AND $fetchData[0]->FeesType!=DC AND $fetchData[0]->FeesType!=TC AND $fetchData[0]->FeesType!=MC AND $fetchData[0]->FeesType!=OTHER) {
|
|
$this->db->select('SFS.FeesType,CF.Sem_Year,CF.ProgramType');
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SFS');
|
|
$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
|
|
$this->db->where('SFS.CourseID',$courseID);
|
|
$this->db->where('SFS.StudentID',$feesDetails['StudentID']);
|
|
$this->db->where('SFS.FeesID',$feesDetails['FeesId']);
|
|
$getFeesTypeDetails = $this->db->get();
|
|
|
|
if($getFeesTypeDetails->result()){
|
|
$insertDetails=array();
|
|
|
|
foreach ($getFeesTypeDetails->result() as $row){
|
|
|
|
// this array for study material and answer booklet update
|
|
$insertStudyBook['StudentID']=$feesDetails['StudentID'];
|
|
$insertStudyBook['CourseID']=$row->FeesType;
|
|
$insertStudyBook['BranchCode']=$feesDetails['UpdatedBy'];
|
|
$insertStudyBook['ListCode']=$existStatusDetails->ListCode;
|
|
// $insertStudyBook['Comments']=$feesDetails['CommentsForStudent'];
|
|
$insertStudyBook['Coursedetail']=$feesDetails['StudentID'];
|
|
$insertStudyBook['CreatedBy']=$feesDetails['CreatedBy'];
|
|
$insertStudyBook['CreatedOn']=$feesDetails['CreatedOn'];
|
|
// this array for mark card updates
|
|
$insertMark['StudentID']=$feesDetails['StudentID'];
|
|
$insertMark['CourseID']=$row->FeesType;
|
|
$insertMark['BranchCode']=$feesDetails['UpdatedBy'];
|
|
$insertMark['ListCode']=$existStatusDetails->ListCode;
|
|
// $insertMark['Comments']=$feesDetails['CommentsForStudent'];
|
|
$insertMark['Coursedetail']=$feesDetails['StudentID'];
|
|
$insertMark['CreatedBy']=$feesDetails['CreatedBy'];
|
|
$insertMark['CreatedOn']=$feesDetails['CreatedOn'];
|
|
$insertMark['CertificationType']="MARK CARD";
|
|
|
|
if($row->ProgramType==REGULARFEES OR $row->ProgramType==LATERALFEES){
|
|
foreach ($singleFeesDetails as $Fees){
|
|
$insertStudyBook['Sem']=$Fees;
|
|
// check study material status exist or not
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('Sem',$Fees);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existStudyMaterialDetails = $this->db->get(STUDY_MATERIAL_STATUS);
|
|
if($existStudyMaterialDetails->num_rows()<1){
|
|
|
|
// insert study material details
|
|
$this->db->insert(STUDY_MATERIAL_STATUS, $insertStudyBook);
|
|
}
|
|
// check answer book;et exist or not
|
|
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existAnsBookDetails = $this->db->get(ANSWER_BOOKLET);
|
|
if($existAnsBookDetails->num_rows()<1) {
|
|
// insert answer booklet details
|
|
$this->db->insert(ANSWER_BOOKLET, $insertStudyBook);
|
|
}
|
|
// check certificate exist or not
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('Sem',$row->Sem_Year);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existAnsBookDetails = $this->db->get(CERTIFICATION_STATUS);
|
|
if($existAnsBookDetails->num_rows()<1) {
|
|
// insert mark card details
|
|
$insertMark['Sem'] = $row->Sem_Year;
|
|
$this->db->insert(CERTIFICATION_STATUS, $insertMark);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else{
|
|
$insertStudyBook['Sem'] = $row->Sem_Year;
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existStudyMaterialDetails = $this->db->get(STUDY_MATERIAL_STATUS);
|
|
if($existStudyMaterialDetails->num_rows()<1) {
|
|
|
|
// insert study material details
|
|
$this->db->insert(STUDY_MATERIAL_STATUS, $insertStudyBook);
|
|
}
|
|
// check answer book;et exist or not
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existAnsBookDetails = $this->db->get(ANSWER_BOOKLET);
|
|
if($existAnsBookDetails->num_rows()<1) {
|
|
// insert answer booklet details
|
|
$this->db->insert(ANSWER_BOOKLET, $insertStudyBook);
|
|
}
|
|
// check certificate exist or not
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$row->FeesType);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$existAnsBookDetails = $this->db->get(CERTIFICATION_STATUS);
|
|
if($existAnsBookDetails->num_rows()<1) {
|
|
// insert mark card details
|
|
$insertMark['Sem'] = $row->Sem_Year;
|
|
$this->db->insert(CERTIFICATION_STATUS, $insertMark);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
else{
|
|
$this->db->select('CertificationID');
|
|
$this->db->where('CertificateName',$fetchData[0]->FeesType);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('IsActive','1');
|
|
$getEndFeesDetails = $this->db->get(CERTIFICATION_MASTER)->last_row();
|
|
if($getEndFeesDetails){
|
|
// this array for document update
|
|
$insertDocs['StudentID']=$feesDetails['StudentID'];
|
|
$insertDocs['CourseID']=$courseID;
|
|
$insertDocs['BranchCode']=$feesDetails['UpdatedBy'];
|
|
$insertDocs['ListCode']=$existStatusDetails->ListCode;
|
|
// $insertDocs['Comments']=$feesDetails['CommentsForStudent'];
|
|
$insertDocs['CreatedBy']=$feesDetails['CreatedBy'];
|
|
$insertDocs['CreatedOn']=$feesDetails['CreatedOn'];
|
|
$insertDocs['CertificationType']=$fetchData[0]->FeesType;
|
|
$this->db->select('CourseID');
|
|
$this->db->where('CourseID',$courseID);
|
|
$this->db->where('BranchCode',$feesDetails['UpdatedBy']);
|
|
$this->db->where('StudentID',$feesDetails['StudentID']);
|
|
$this->db->where('CertificationType',$getEndFeesDetails->CertificationID);
|
|
$existApplicationDetails = $this->db->get(APPLICATION_STATUS);
|
|
if($existApplicationDetails->num_rows()<1) {
|
|
// insert application details
|
|
$this->db->insert(APPLICATION_STATUS, $insertDocs);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// add dayBook
|
|
public function add_dayBook($Arr)
|
|
{
|
|
$branch = $Arr['BranchCode'];
|
|
$sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE BranchCode = '$branch'
|
|
ORDER BY ID DESC
|
|
LIMIT 1";
|
|
$prevBalance = 0;
|
|
$latestUpdate = $this->db->query($sql);
|
|
$latestUpdateDetails = $latestUpdate->result();
|
|
|
|
If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
|
|
{
|
|
$prevBalance = $latestUpdateDetails[0]->Balance;
|
|
}else{
|
|
}
|
|
|
|
if($Arr['Name'] == 'I002') {
|
|
//Income
|
|
$Arr['Balance'] = $prevBalance + $Arr['Amount'];
|
|
}else if ($Arr['Name'] == 'I001') {
|
|
//Expense
|
|
$Arr['Balance'] = $prevBalance - $Arr['Amount'];
|
|
} else {
|
|
$Arr['Balance'] = 0;
|
|
}
|
|
|
|
$this->db->insert(DAYBOOKMASTER, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addDayBookStatus'] = true;
|
|
$result['message'] = "Successfully DayBook Details Added";
|
|
} else {
|
|
$result['addDayBookStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function add_dayBook_online($Arr)
|
|
{
|
|
// print_r($Arr);
|
|
// exit;
|
|
$branch = $Arr['BranchCode'];
|
|
$sql = "SELECT * FROM ".DAYBOOKMASTERONLINE." WHERE BranchCode = '$branch'
|
|
ORDER BY ID DESC";
|
|
$prevBalance = 0;
|
|
$latestUpdate = $this->db->query($sql);
|
|
$latestUpdateDetails = $latestUpdate->result();
|
|
// print_r($latestUpdateDetails);
|
|
// exit;
|
|
If(is_array($latestUpdateDetails) && count($latestUpdateDetails)>0)
|
|
{
|
|
$prevBalance = $latestUpdateDetails[0]->Balance;
|
|
|
|
$vNo = count($latestUpdateDetails) + 1;
|
|
$Arr['VoucherNumber'] = $branch.'-O'.$vNo;
|
|
}else{
|
|
$prevBalance = 0;
|
|
$Arr['VoucherNumber'] = $branch.'-O'. 1;
|
|
}
|
|
|
|
if($Arr['Name'] == 'I002') {
|
|
//Income
|
|
$Arr['Balance'] = $prevBalance + $Arr['Amount'];
|
|
}else if ($Arr['Name'] == 'I001') {
|
|
//Expense
|
|
$Arr['Balance'] = $prevBalance - $Arr['Amount'];
|
|
} else {
|
|
$Arr['Balance'] = 0;
|
|
}
|
|
// $Arr['VoucherNumber'] => $vNo_format = $branch.'O'.'-'.$vNo;
|
|
// print_r($Arr);
|
|
// exit;
|
|
$this->db->insert(DAYBOOKMASTERONLINE, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addDayBookStatus'] = true;
|
|
$result['message'] = "Successfully DayBook Details Added";
|
|
} else {
|
|
$result['addDayBookStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
/*delete set fees details
|
|
created by kms
|
|
*/
|
|
public function deleteSetFees($details=null){
|
|
$this->db->where('FeesID', $details['FeesID']);
|
|
$this->db->delete(FEES_INSTALLMENT);
|
|
// if ($this->db->affected_rows() >= '1') {
|
|
$this->db->where('FeesID', $details['FeesID']);
|
|
$this->db->delete(STUDENTS_FEES_STATUS);
|
|
$result['deleteStatus']=true;
|
|
$result['message']="Successfully Fees Details Deleted";
|
|
|
|
// }
|
|
// else{
|
|
// $result['deleteStatus']=false;
|
|
// $result['message']="Something went wrong.please try again";
|
|
// }
|
|
//print_r($this->db->last_query());die();
|
|
return $result;
|
|
|
|
|
|
}
|
|
/*
|
|
* delete student status while cancel bill from day book
|
|
* created by kms
|
|
* */
|
|
public function deleteStudentStatusEntry($paymentID=null){
|
|
if($paymentID!='' AND $paymentID!=null){
|
|
$this->db->select('SFP.FeesId,SFS.StudentID,SFS.FeesType,CF.Sem_Year,CF.ProgramType');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->join(COURSE_FEES.' as CF', 'CF.ID = SFS.FeesType');
|
|
$this->db->where('SFP.ID',$paymentID);
|
|
$this->db->group_by('SFS.FeesType');
|
|
$getPaidRow = $this->db->get()->last_row();
|
|
if($getPaidRow AND $getPaidRow->FeesType!=PC AND $getPaidRow->FeesType!=DC AND $getPaidRow->FeesType!=TC AND $getPaidRow->FeesType!=MC AND $getPaidRow->FeesType!=OTHER){
|
|
$this->db->select('FeesId');
|
|
$this->db->where('FeesId',$getPaidRow->FeesId);
|
|
$this->db->where('IsActive','1');
|
|
$getCountOfFeesType = $this->db->get(STUDENTS_FEES_PAID);
|
|
if($getCountOfFeesType->num_rows() ==1){
|
|
if($getPaidRow->ProgramType==SEMYEARFEES){
|
|
// delete certificate status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->where('Sem', $getPaidRow->Sem_Year);
|
|
$this->db->delete(CERTIFICATION_STATUS);
|
|
// delete answer booklet status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->where('Sem', $getPaidRow->Sem_Year);
|
|
$this->db->delete(ANSWER_BOOKLET);
|
|
// delete study material status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->where('Sem', $getPaidRow->Sem_Year);
|
|
$this->db->delete(STUDY_MATERIAL_STATUS);
|
|
|
|
|
|
}
|
|
else{
|
|
// delete certificate status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->delete(CERTIFICATION_STATUS);
|
|
// delete answer booklet status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->delete(ANSWER_BOOKLET);
|
|
// delete study material status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->FeesType);
|
|
$this->db->delete(STUDY_MATERIAL_STATUS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else{
|
|
$this->db->select('SFP.FeesId,SFS.StudentID,SFS.FeesType,SFS.CourseID,SFS.BranchCode');
|
|
$this->db->from(STUDENTS_FEES_PAID.' as SFP');
|
|
$this->db->join(STUDENTS_FEES_STATUS.' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->where('SFP.ID',$paymentID);
|
|
$this->db->group_by('SFS.FeesType');
|
|
$getPaidRow = $this->db->get()->last_row();
|
|
|
|
if($getPaidRow AND $getPaidRow->FeesType==PC OR $getPaidRow->FeesType==DC OR $getPaidRow->FeesType==TC OR $getPaidRow->FeesType==MC OR $getPaidRow->FeesType==OTHER){
|
|
$this->db->select('FeesId');
|
|
$this->db->where('FeesId',$getPaidRow->FeesId);
|
|
$this->db->where('IsActive','1');
|
|
$getCountOfFeesType = $this->db->get(STUDENTS_FEES_PAID);
|
|
if($getCountOfFeesType->num_rows() ==1){
|
|
$this->db->select('CertificationID');
|
|
$this->db->where('CertificateName',$getPaidRow->FeesType);
|
|
$this->db->where('BranchCode',$getPaidRow->BranchCode);
|
|
$getCertificateDetails = $this->db->get(CERTIFICATION_MASTER)->last_row();
|
|
|
|
if($getCertificateDetails){
|
|
// delete application status
|
|
$this->db->where('StudentID', $getPaidRow->StudentID);
|
|
$this->db->where('CourseID', $getPaidRow->CourseID);
|
|
$this->db->where('CertificationType', $getCertificateDetails->CertificationID);
|
|
$this->db->delete(APPLICATION_STATUS);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function GetFeeSetDetails($student)
|
|
{
|
|
//print_r($student);
|
|
$this->db->select('FeesID,BatchCode,StudentID,SM.CourseID,SM.FeesType,Sem_Year');
|
|
$this->db->from(STUDENTS_FEES_STATUS.' as SM');
|
|
$this->db->join('T_Course_Fees_Details','T_Course_Fees_Details.ID=SM.FeesType');
|
|
$this->db->where('SM.CourseID',$student['CourseID']);
|
|
$this->db->where('SM.StudentID',$student['StudentID']);
|
|
$this->db->where('SM.BranchCode',$student['BranchCode']);
|
|
|
|
$setDetails = $this->db->get();
|
|
if($setDetails->result())
|
|
{
|
|
return $setDetails->result();
|
|
}
|
|
|
|
else
|
|
{
|
|
//return false;
|
|
return $setDetails->result();
|
|
}
|
|
}
|
|
|
|
public function getBatch($universityID=null,$br=null)
|
|
{
|
|
$this->db->select('BatchCode,BatchName,str_to_date(BatchDate, "%d-%m-%Y") BatchDate');
|
|
$this->db->where('UniversityID',$universityID);
|
|
//$this->db->where('IsActive','1');
|
|
$this->db->where('BranchCode',$br);
|
|
$this->db->order_by('BatchDate','DESC');
|
|
$batchDetails = $this->db->get(BATCH);
|
|
return $batchDetails->result();
|
|
}
|
|
|
|
} |