637 lines
30 KiB
PHP
Executable File
637 lines
30 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class Dashboard_model extends CI_Model
|
|
{
|
|
/*
|
|
* dashboard model
|
|
*
|
|
*/
|
|
/*
|
|
* get Dashboard Details
|
|
*/
|
|
|
|
// get total number of users
|
|
public function get_total_users( $data ) {
|
|
$sql1 = "SELECT * from ".STUDENTS."";
|
|
$count1 = $this->db->query($sql1);
|
|
$sql2 = "SELECT * from ".STAFF."";
|
|
$count2 = $this->db->query($sql2);
|
|
|
|
if( $count2->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count1->num_rows();
|
|
$result['total_staff'] = $count2->num_rows();
|
|
$result['message'] = "Total Number of Users";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count1->num_rows();
|
|
$result['total_staff'] = $count2->num_rows();
|
|
$result['message'] = "No student Users";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get total number of students
|
|
public function get_total_students($data) {
|
|
// print_r($data);exit();
|
|
$sql = "SELECT * from ".STUDENTS."";
|
|
$count = $this->db->query($sql);
|
|
if( $count->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count->num_rows();
|
|
$result['message'] = "Total Number of Students";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_student'] = $count->num_rows();
|
|
$result['message'] = "No student exist";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// get total number of employees
|
|
public function get_total_employee($data) {
|
|
// print_r($data);exit();
|
|
$sql = "SELECT * from ".STAFF."";
|
|
$count = $this->db->query($sql);
|
|
if( $count->num_rows() > 0) {
|
|
$result['status'] = true;
|
|
$result['total_employee'] = $count->num_rows();
|
|
$result['message'] = "Total Number of Employee";
|
|
} else {
|
|
$result['status'] = true;
|
|
$result['total_employee'] = $count->num_rows();
|
|
$result['message'] = "No Employee exist";
|
|
}
|
|
return $result;
|
|
}
|
|
/*
|
|
* get university registerd student details
|
|
* created by kms
|
|
* */
|
|
public function get_univ_registered_student($details){
|
|
$this->db->distinct();
|
|
$this->db->select('UniversityID,UniversityName');
|
|
$this->db->from(UNIVERSITY);
|
|
$this->db->order_by('ID','DESC');
|
|
$this->db->where('BranchCode',$details['localBranchID']);
|
|
$getUnivDetails = $this->db->get();
|
|
if($getUnivDetails->result()){
|
|
foreach ($getUnivDetails->result() as $rows){
|
|
$fetchDetails['UniversityID']=$rows->UniversityID;
|
|
$fetchDetails['UniversityName']=$rows->UniversityName;
|
|
$this->db->select('StudentID');
|
|
$this->db->from(STUDENTCOURSE);
|
|
$this->db->where('BranchID',$details['localBranchID']);
|
|
$this->db->where('UniversityID',$rows->UniversityID);
|
|
$getRegisterDetails = $this->db->get();
|
|
if($getRegisterDetails->num_rows()>0){
|
|
$fetchDetails['StudentCounts']=$getRegisterDetails->num_rows();
|
|
}
|
|
else{
|
|
$fetchDetails['StudentCounts']=0;
|
|
}
|
|
$getArray[]=$fetchDetails;
|
|
$getFeesArray[]= $this->getUniversityFeesPending($rows->UniversityName,$rows->UniversityID,$details['localBranchID']);
|
|
}
|
|
$resultDetails['details']=$getArray;
|
|
$resultDetails['universityFeesDetails']=$getFeesArray;
|
|
}
|
|
else{
|
|
$resultDetails['details']=false;
|
|
$resultDetails['Message']="No records found!";
|
|
$resultDetails['universityFeesDetails']=false;
|
|
}
|
|
$resultDetails['batchFeesDetails']=$this->getBatchPendingFees($details['localBranchID']);
|
|
|
|
return $resultDetails;
|
|
}
|
|
/*
|
|
* get university pending fees details
|
|
* created by kms
|
|
* */
|
|
public function getUniversityFeesPending($universityName=null,$universityID=null,$branchCode=null){
|
|
$feesDetails=array();
|
|
$feesDetails['UniversityID']=$universityID;
|
|
$feesDetails['UniversityName']=$universityName;
|
|
$this->db->select("SUM(SFS.CourseFees+SFS.STFOrWR+Others) as PayableFees");
|
|
$this->db->from( STUDENTS_FEES_STATUS . ' as SFS');
|
|
$this->db->join( COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
|
|
$this->db->where('CU.UniversityID',$universityID);
|
|
$this->db->where('CU.BranchCode',$branchCode);
|
|
$this->db->order_by('CU.CourseID','DESC');
|
|
$getUnivFeesDetails = $this->db->get();
|
|
if($getUnivFeesDetails->result()){
|
|
foreach ($getUnivFeesDetails->result() as $payableRow){
|
|
$feesDetails['PayableFees']=$payableRow->PayableFees;
|
|
}
|
|
}
|
|
else{
|
|
$feesDetails['PayableFees']=0;
|
|
}
|
|
$this->db->select("SUM(SFP.BillAmount) as PaidFees");
|
|
$this->db->from( STUDENTS_FEES_PAID . ' as SFP');
|
|
$this->db->join( STUDENTS_FEES_STATUS . ' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->join( COURSE . ' as CU', 'CU.CourseID = SFS.CourseID');
|
|
$this->db->where('CU.UniversityID',$universityID);
|
|
$this->db->where('CU.BranchCode',$branchCode);
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->order_by('CU.CourseID','DESC');
|
|
$getUnivPaidFeesDetails = $this->db->get();
|
|
if($getUnivPaidFeesDetails->result()){
|
|
foreach ($getUnivPaidFeesDetails->result() as $paidRow){
|
|
$feesDetails['PaidFees']=$paidRow->PaidFees;
|
|
}
|
|
}
|
|
else{
|
|
$feesDetails['PaidFees']=0;
|
|
}
|
|
|
|
return $feesDetails;
|
|
|
|
|
|
}
|
|
/*
|
|
* get batch pending fees details
|
|
* created by kms
|
|
* */
|
|
public function getBatchPendingFees($branchCode=null){
|
|
$this->db->distinct();
|
|
$this->db->select('BatchCode,BatchName');
|
|
$this->db->from(BATCH);
|
|
$this->db->order_by('BatchID','DESC');
|
|
$this->db->where('BranchCode',$branchCode);
|
|
$getBatchDetails = $this->db->get();
|
|
if($getBatchDetails->result()){
|
|
foreach ($getBatchDetails->result() as $bRows){
|
|
$batchFeesDetails['BatchCode']=$bRows->BatchCode;
|
|
$batchFeesDetails['BatchName']=$bRows->BatchName;
|
|
$this->db->select("SUM(SFS.CourseFees+SFS.STFOrWR+Others) as PayableFees");
|
|
$this->db->from( STUDENTS_FEES_STATUS . ' as SFS');
|
|
$this->db->where('SFS.BatchCode',$bRows->BatchCode);
|
|
$this->db->where('SFS.BranchCode',$branchCode);
|
|
$getBatchFeesDetails = $this->db->get();
|
|
if($getBatchFeesDetails->result()){
|
|
foreach ($getBatchFeesDetails->result() as $bpayableRow){
|
|
$batchFeesDetails['PayableFees']=$bpayableRow->PayableFees;
|
|
}
|
|
}
|
|
else{
|
|
$batchFeesDetails['PayableFees']=0;
|
|
}
|
|
// get paid details
|
|
$this->db->select("SUM(SFP.BillAmount) as PaidFees");
|
|
$this->db->from( STUDENTS_FEES_PAID . ' as SFP');
|
|
$this->db->join( STUDENTS_FEES_STATUS . ' as SFS', 'SFS.FeesID = SFP.FeesId');
|
|
$this->db->where('SFP.IsActive','1');
|
|
$this->db->where('SFS.BatchCode',$bRows->BatchCode);
|
|
$this->db->where('SFS.BranchCode',$branchCode);
|
|
$getBatchPaidFeesDetails = $this->db->get();
|
|
if($getBatchPaidFeesDetails->result()){
|
|
foreach ($getBatchPaidFeesDetails->result() as $bpaidRow){
|
|
$batchFeesDetails['PaidFees']=$bpaidRow->PaidFees;
|
|
}
|
|
}
|
|
else{
|
|
$batchFeesDetails['PaidFees']=0;
|
|
}
|
|
$fetchBatchFees[]=$batchFeesDetails;
|
|
|
|
}
|
|
|
|
return $fetchBatchFees;
|
|
}
|
|
else{
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
public function leadCountDay($branchId){
|
|
$ltsql = "select count(distinct TrackingID) as count from T_Lead_Tracking_Followup ltf
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID) ";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
|
|
//print_r($lcount);
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountMonth(){
|
|
$ltsql = "select count(distinct TrackingID) as count from T_Lead_Tracking_Followup ltf
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountDayClosed(){
|
|
$ltsql = "select count(distinct TrackingID) as count from T_Lead_Tracking_Followup ltf
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and list.ListName like 'CLOSE' and InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
|
|
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountMonthClosed(){
|
|
$ltsql = "select count(distinct TrackingID) as count from T_Lead_Tracking_Followup ltf
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and list.ListName like 'CLOSE' and InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionCountMonth(){
|
|
$sql = "select sum(total) as total from admission_month";
|
|
$admissionCount=$this->db->query($sql);
|
|
$acount = $admissionCount->result();
|
|
if (count($acount) > 0) {
|
|
$results['ad_List'] = true;
|
|
$results['ad_data'] = $acount;
|
|
} else {
|
|
$results['ad_List'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionCountYear(){
|
|
$sql = "select sum(tot_cnt) as total from admission_year";
|
|
$admissionCount=$this->db->query($sql);
|
|
$acount = $admissionCount->result();
|
|
if (count($acount) > 0) {
|
|
$results['ad_List'] = true;
|
|
$results['ad_data'] = $acount;
|
|
} else {
|
|
$results['ad_List'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function followupsCountToday(){
|
|
$sql = "select count(ltf.TrackingID) as count
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and ltf.IsActive = 1 ";
|
|
$followupsCount=$this->db->query($sql);
|
|
$fcount = $followupsCount->result();
|
|
if (count($fcount) > 0) {
|
|
$results['fUpList'] = true;
|
|
$results['fUp_data'] = $fcount;
|
|
} else {
|
|
$results['fUpList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function followupsCountMonth(){
|
|
$sql = "select count(ltf.TrackingID) as count
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and ltf.IsActive = 1 ";
|
|
$followupsCount=$this->db->query($sql);
|
|
$fcount = $followupsCount->result();
|
|
if (count($fcount) > 0) {
|
|
$results['fUpList'] = true;
|
|
$results['fUp_data'] = $fcount;
|
|
} else {
|
|
$results['fUpList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
public function leadToday(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as followUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadMonth(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as followUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadTodayClosed(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as followUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and list.ListName like 'CLOSE'";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadMonthClosed(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as followUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and list.ListName like 'CLOSE'";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionMonth(){
|
|
$sql = "SELECT * FROM admission_month ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionYear(){
|
|
if (date('m') >= 4) {
|
|
$yearl = date('Y').'-'.(date('Y')+1);
|
|
} else {
|
|
$yearl = (date('Y')-1).'-'.date('Y');
|
|
}
|
|
$ab=$yearl;
|
|
$fa=substr($ab,0,-5);
|
|
$aa=substr($ab,5,5);
|
|
|
|
$sql = "SELECT month(std.CreatedOn),
|
|
std.AdmittedBy AS AdmittedBy,
|
|
um.UniversityName AS university,
|
|
SUM(IF((MONTH(std.CreatedOn) = 6), 1, 0)) AS June,
|
|
SUM(IF((MONTH(std.CreatedOn) = 7), 1, 0)) AS July,
|
|
SUM(IF((MONTH(std.CreatedOn) = 8), 1, 0)) AS August,
|
|
SUM(IF((MONTH(std.CreatedOn) = 9), 1, 0)) AS September,
|
|
SUM(IF((MONTH(std.CreatedOn) = 10), 1, 0)) AS October,
|
|
SUM(IF((MONTH(std.CreatedOn) = 11), 1, 0)) AS November,
|
|
SUM(IF((MONTH(std.CreatedOn) = 12), 1, 0)) AS December,
|
|
SUM(IF((MONTH(std.CreatedOn) = 1), 1, 0)) AS January,
|
|
SUM(IF((MONTH(std.CreatedOn) = 2), 1, 0)) AS February,
|
|
SUM(IF((MONTH(std.CreatedOn) = 3), 1, 0)) AS March,
|
|
SUM(IF((MONTH(std.CreatedOn) = 4), 1, 0)) AS April,
|
|
SUM(IF((MONTH(std.CreatedOn) = 5), 1, 0)) AS May,
|
|
COUNT(DISTINCT std.StudentID) AS total,
|
|
GROUP_CONCAT(DISTINCT sc.sname, '-', sc.cnt SEPARATOR ';') AS AdmissionTakenBy
|
|
FROM
|
|
T_StudentDetails std
|
|
JOIN getUniYear scd ON scd.StudentID = std.StudentID
|
|
JOIN staff_count sc ON sc.UniversityID = scd.UniversityID
|
|
AND sc.AdmittedBy = std.AdmittedBy
|
|
LEFT JOIN T_UniversityMaster um ON um.UniversityID = scd.UniversityID
|
|
WHERE
|
|
std.AdmittedBy IS NOT NULL and (date(std.CreatedOn) >= '".$fa."-06-01' and date(std.CreatedOn) <= '".$aa."-05-31')";
|
|
|
|
$sql.=" GROUP BY scd.UniversityID";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function feeOutstanding(){
|
|
$sql = "select b.bcode,b.Batches,sum(b.totalpayable) as TotalPayableFee,sum(b.totalpaid) as TotalPaidFee,sum(b.balpayable) as TotalBalance,round(ifnull(((sum(b.balpayable)/sum(b.totalpayable))*100),0),2) as BalancePercentage,
|
|
scb.staff as BalancePercentageByStaff
|
|
from BalFees b
|
|
left join (select bcode,sum(totalpayable) as tot,sum(totalpaid) as paid,sum(balpayable) as balance,((sum(balpayable)/sum(totalpayable)) * 100) as balPercentage,group_concat(staff,'-',bal_percentage) as staff from staff_count_batch
|
|
group by bcode) scb on scb.bcode = b.bcode
|
|
group by b.bcode; ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function followupsToday(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as FollowUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function followupsPending(){
|
|
$sql = "select InteractionID,ifnull(date_format(ltf.CreatedOn,'%d-%m-%Y'),'-') as date,ltf.TrackingID as TrackingId,ifnull(ltf.FollowupOn,'-') as FollowUpDate,ld.LeadName as name,ifnull(ld.MobileNumber,'-') as mobileNo,lt.University as university,lt.Course as course,list.ListName as status,ltf.FollowupComments as cmnts,ifnull(am.ActivityName,'-') as activity,sd.FirstName as AssignTo
|
|
from T_Lead_Tracking_Followup as ltf
|
|
left join T_Lead_Tracking lt on lt.TrackingID=ltf.TrackingID
|
|
join T_Login l on l.ID=lt.AssignedTo
|
|
join T_StaffDetails sd on sd.StaffID=l.StaffID
|
|
left join T_Lead_Details ld on ld.LeadID=lt.LeadID
|
|
left join T_ActivityMaster am on am.ActivityID=lt.ActivityStatus
|
|
join T_PickListDetails list on list.ListCode=ltf.StatusName
|
|
where InteractionID in (select max(InteractionID) from T_Lead_Tracking_Followup group by TrackingID)
|
|
and list.ListName not like 'CLOSE' and list.ListName like 'PENDING' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionBatch($univ = null){
|
|
$sql = "SELECT sfs.BatchCode as bcode,scd.UniversityID as uid,ifnull(bm.BatchName,'-') as Batches,month(std.CreatedOn),ifnull(concat(sd.Firstname,' ',sd.Lastname),'-') as Staff,ifnull(std.AdmittedBy,'-') as admittedby,count(distinct std.StudentID) as TotalNoOfAdmissions
|
|
FROM T_StudentDetails std
|
|
join T_Student_CourseDetails scd on scd.StudentID = std.StudentID
|
|
left join T_Students_Fees_Status sfs on sfs.StudentID =scd.StudentID and sfs.CourseID = scd.CourseID
|
|
left join T_BatchMaster bm on bm.BatchCode = sfs.BatchCode
|
|
left join T_StaffDetails sd on sd.StaffID = std.AdmittedBy
|
|
where year(std.CreatedOn) = year(now())
|
|
";
|
|
|
|
if($univ != ''){
|
|
$sql.= " and scd.UniversityID = '".$univ."'";
|
|
}
|
|
|
|
$sql.= " group by bcode,admittedby";
|
|
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
//To Filters
|
|
public function getYear($branch = null){
|
|
$sql = "select year(CreatedOn) as year from T_StudentDetails group by year ";
|
|
$ltd=$this->db->query($sql);
|
|
$year = $ltd->result();
|
|
//get batch
|
|
$brsql = "select BatchCode,BatchName from T_BatchMaster ";
|
|
$brf=$this->db->query($brsql);
|
|
$branchf = $brf->result();
|
|
//get university
|
|
$usql = "select UniversityID,UniversityName from T_UniversityMaster ";
|
|
$uf=$this->db->query($usql);
|
|
$univf = $uf->result();
|
|
|
|
if (count($year) > 0) {
|
|
$results['yearList'] = true;
|
|
$results['year'] = $year;
|
|
$results['branch'] = $branchf;
|
|
$results['univ'] = $univf;
|
|
} else {
|
|
$results['yearList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
//End of filters
|
|
|
|
|
|
} |