980 lines
51 KiB
PHP
Executable File
980 lines
51 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 = null, $requestedBy = null){
|
|
$ltsql = "select count(InteractionID) 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 date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
$sltsql = "select count(InteractionID) 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 date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltCount=$this->db->query($sltsql);
|
|
$slcount = $sltCount->result();
|
|
//print_r($lcount);
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
$results['slead_data'] = $slcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountMonth($branchId = null, $requestedBy = null){
|
|
$ltsql = "select count(InteractionID) 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(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
$sltsql = "select count(InteractionID) 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(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltCount=$this->db->query($sltsql);
|
|
$slcount = $sltCount->result();
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
$results['slead_data'] = $slcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountDayClosed($branchId = null, $requestedBy = null){
|
|
$ltsql = "select count(InteractionID) 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 date(ltf.CreatedOn) = date(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
$sltsql = "select count(InteractionID) 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 date(ltf.CreatedOn) = date(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltCount=$this->db->query($sltsql);
|
|
$slcount = $sltCount->result();
|
|
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
$results['slead_data'] = $slcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadCountMonthClosed($branchId = null, $requestedBy = null){
|
|
$ltsql = "select count(InteractionID) 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(ltf.CreatedOn) = month(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltCount=$this->db->query($ltsql);
|
|
$lcount = $ltCount->result();
|
|
$sltsql = "select count(InteractionID) 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(ltf.CreatedOn) = month(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltCount=$this->db->query($sltsql);
|
|
$slcount = $sltCount->result();
|
|
if (count($lcount) > 0) {
|
|
$results['leadList'] = true;
|
|
$results['lead_data'] = $lcount;
|
|
$results['slead_data'] = $slcount;
|
|
} else {
|
|
$results['leadList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionCountMonth($branchId = null){
|
|
$sql = "select tot_cnt as total from admission_month where BranchCode ='".$branchId."'";
|
|
// $sql = " Select tot_cnt as total from admission_month where BranchCode = '".$branchId."'";
|
|
$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($branchId = null){
|
|
//$sql = "select sum(tot_cnt) as total from admission_year ";
|
|
|
|
$sql = "select tot_cnt as total from admission_year where BranchCode ='".$branchId."'" ;
|
|
|
|
$admissionCount=$this->db->query($sql);
|
|
//print_r($sql); die();
|
|
$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;
|
|
}
|
|
//and list.ListName like 'PENDING'
|
|
public function followupsCountToday($branchId = null, $requestedBy = null){
|
|
$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 and list.ListName not like 'CLOSE' and lt.CreatedBranch = '".$branchId."' ";
|
|
$followupsCount=$this->db->query($sql);
|
|
$fcount = $followupsCount->result();
|
|
$ssql = "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 and list.ListName not like 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sfollowupsCount=$this->db->query($ssql);
|
|
$sfcount = $sfollowupsCount->result();
|
|
//print_r($sql);die();and ltf.StatusName ='S020'
|
|
if (count($fcount) > 0) {
|
|
$results['fUpList'] = true;
|
|
$results['fUp_data'] = $fcount;
|
|
$results['sfUp_data'] = $sfcount;
|
|
} else {
|
|
$results['fUpList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
//and list.ListName like 'PENDING'
|
|
public function followupsCountMonth($branchId = null, $requestedBy = null){
|
|
$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 and list.ListName not like 'CLOSE' and lt.CreatedBranch = '".$branchId."' ";
|
|
$followupsCount=$this->db->query($sql);
|
|
$fcount = $followupsCount->result();
|
|
//and ltf.StatusName ='S020'
|
|
$ssql = "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 and list.ListName not like 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sfollowupsCount=$this->db->query($ssql);
|
|
|
|
//print_r($sql);die();
|
|
|
|
$sfcount = $sfollowupsCount->result();
|
|
if (count($fcount) > 0) {
|
|
$results['fUpList'] = true;
|
|
$results['fUp_data'] = $fcount;
|
|
$results['sfUp_data'] = $sfcount;
|
|
} else {
|
|
$results['fUpList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
public function leadToday($branchId = null,$requestedBy = null, $logintype = null){
|
|
$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 am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
// print_r($sql);
|
|
//to staff/trainee
|
|
$ssql = "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 am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
// print_r($ssql);
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadMonth($branchId = null,$requestedBy = null, $logintype = null){
|
|
$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 am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
//to staff/trainee
|
|
$ssql = "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 am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadTodayClosed($branchId = null,$requestedBy = null, $logintype = null){
|
|
$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 am.ActivityName like 'Adm%' and list.ListName like 'CLOSE' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
//to staff
|
|
$ssql = "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 am.ActivityName like 'Adm%' and list.ListName like 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function leadMonthClosed($branchId = null,$requestedBy = null, $logintype = null){
|
|
$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 am.ActivityName like 'Adm%' and list.ListName like 'CLOSE' and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
// echo $sql;
|
|
//to staff
|
|
$ssql = "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 am.ActivityName like 'Adm%' and list.ListName like 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionMonth($year = null,$month = null, $branchId = null){
|
|
|
|
$sql="SELECT
|
|
wc.UniversityID AS university,
|
|
SUM(IF((wc.week_of_month = 1),
|
|
wc.tot_cnt,
|
|
0)) AS week1,
|
|
SUM(IF((wc.week_of_month = 2),
|
|
wc.tot_cnt,
|
|
0)) AS week2,
|
|
SUM(IF((wc.week_of_month = 3),
|
|
wc.tot_cnt,
|
|
0)) AS week3,
|
|
SUM(IF((wc.week_of_month = 4),
|
|
wc.tot_cnt,
|
|
0)) AS week4,
|
|
SUM(IF((wc.week_of_month = 5),
|
|
wc.tot_cnt,
|
|
0)) AS week5,
|
|
SUM(wc.tot_cnt) AS Total,
|
|
GROUP_CONCAT(DISTINCT wc.AdmittedBy, '-', wc.tot_cnt
|
|
SEPARATOR ',') AS AdmissionTakenBy
|
|
FROM
|
|
week_child wc
|
|
|
|
where BranchCode ='".$branchId."'
|
|
AND CreatedYear = '".$year."'
|
|
AND CreatedMonth = '".$month."'
|
|
GROUP BY wc.UniversityID";
|
|
|
|
|
|
|
|
|
|
|
|
$ltd=$this->db->query($sql);
|
|
// print_r($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( $fyear = null, $univ = null, $branchId = null){
|
|
|
|
|
|
$ab=$fyear;
|
|
$fa=substr($ab,0,-5);
|
|
$aa=substr($ab,5,5);
|
|
|
|
|
|
$sql="SELECT
|
|
std.University AS university,
|
|
SUM(IF((std.CreatedMonth = 6), 1, 0)) AS June,
|
|
SUM(IF((std.CreatedMonth = 7), 1, 0)) AS July,
|
|
SUM(IF((std.CreatedMonth = 8), 1, 0)) AS August,
|
|
SUM(IF((std.CreatedMonth = 9), 1, 0)) AS September,
|
|
SUM(IF((std.CreatedMonth = 10), 1, 0)) AS October,
|
|
SUM(IF((std.CreatedMonth = 11), 1, 0)) AS November,
|
|
SUM(IF((std.CreatedMonth = 12), 1, 0)) AS December,
|
|
SUM(IF((std.CreatedMonth = 1), 1, 0)) AS January,
|
|
SUM(IF((std.CreatedMonth = 2), 1, 0)) AS February,
|
|
SUM(IF((std.CreatedMonth = 3), 1, 0)) AS March,
|
|
SUM(IF((std.CreatedMonth = 4), 1, 0)) AS April,
|
|
SUM(IF((std.CreatedMonth = 5), 1, 0)) AS May,
|
|
COUNT(std.StudentID) AS Total,gad as AdmittedBy
|
|
|
|
FROM
|
|
admissions std
|
|
LEFT JOIN (SELECT sc.cyear,sc.University,sc.BranchCode, group_concat(sc.AdmittedBy,'-',sc.cnt SEPARATOR ',') AS gad FROM staff_count_year sc GROUP BY sc.cyear,sc.University,sc.BranchCode) ssc ON ssc.University = std.University and ssc.cyear = std.CreatedYear and ssc.BranchCode = std.BranchCode
|
|
where
|
|
std.AdmittedBy IS NOT NULL
|
|
AND
|
|
std.CreatedOn between '".$fa."-06-01'
|
|
and '".$aa."-05-31' and std.BranchCode ='".$branchId."'
|
|
|
|
GROUP BY std.University";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// print_r($sql); die();
|
|
$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 feeOutstandingtotal($branchId = null)
|
|
{
|
|
|
|
$sql="select sum(TotalBalance) as total FROM (select (sum(totalpayable) - sum(totalpaid)) as TotalBalance
|
|
from
|
|
(SELECT
|
|
a.BatchCode AS bcode,str_to_date(bm.BatchDate,'%d-%m-%Y') as BDate,
|
|
bm.UniversityID AS uid,
|
|
bm.BatchName as Batches,
|
|
IFNULL(std.AdmittedBy, '-') AS admittedby,
|
|
IFNULL(CONCAT(sd.Firstname, sd.Lastname),
|
|
'-') AS staff,
|
|
SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) AS totalpayable,
|
|
IFNULL(SUM(bb.BillAmount), 0) AS totalpaid,
|
|
(SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) - IFNULL(SUM(bb.BillAmount), 0)) AS balpayable,
|
|
ROUND((((SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) - IFNULL(SUM(bb.BillAmount), 0)) / SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others))) * 100),
|
|
0) AS bal_percentage
|
|
FROM
|
|
T_Students_Fees_Status a
|
|
LEFT JOIN BalFeesChild bb ON a.FeesID = bb.FeesId
|
|
LEFT JOIN T_Course_Fees_Details c ON c.ID = a.FeesType
|
|
LEFT JOIN T_StudentDetails std ON std.StudentID = a.StudentID
|
|
LEFT JOIN T_StaffDetails sd ON sd.StaffID = std.AdmittedBy
|
|
LEFT JOIN T_BatchMaster bm ON bm.BatchCode = a.BatchCode
|
|
where a.BranchCode = '".$branchId."' and a.BatchCode != 'Not applicable'
|
|
GROUP BY std.AdmittedBy , bcode) b group by bcode ORDER BY BDate DESC) final";
|
|
|
|
$ltd=$this->db->query($sql);
|
|
|
|
//print_r($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($branchId = null, $univ = null){
|
|
$sql = "select bcode,BDate,Batches,uid,staff,admittedby,sum(totalpayable) as TotalPayableFee,sum(totalpaid) as TotalPaidFee,(sum(totalpayable) - sum(totalpaid)) as TotalBalance,
|
|
concat(round((((sum(totalpayable) - sum(totalpaid)) / sum(totalpayable)) * 100),0),'%') as BalancePercentage,
|
|
GROUP_CONCAT(staff,'-',CONCAT_WS('',bal_percentage, '%') separator ',') as BalancePercentageByStaff
|
|
from
|
|
(SELECT
|
|
a.BatchCode AS bcode,str_to_date(bm.BatchDate,'%d-%m-%Y') as BDate,
|
|
bm.UniversityID AS uid,
|
|
bm.BatchName as Batches,
|
|
IFNULL(std.AdmittedBy, '-') AS admittedby,
|
|
IFNULL(CONCAT(sd.Firstname, sd.Lastname),
|
|
'-') AS staff,
|
|
SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) AS totalpayable,
|
|
IFNULL(SUM(bb.BillAmount), 0) AS totalpaid,
|
|
(SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) - IFNULL(SUM(bb.BillAmount), 0)) AS balpayable,
|
|
ROUND((((SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others)) - IFNULL(SUM(bb.BillAmount), 0)) / SUM((((a.CourseFees + a.STFOrWR) + a.Waiver) + a.Others))) * 100),
|
|
0) AS bal_percentage
|
|
FROM
|
|
T_Students_Fees_Status a
|
|
LEFT JOIN BalFeesChild bb ON a.FeesID = bb.FeesId
|
|
LEFT JOIN T_Course_Fees_Details c ON c.ID = a.FeesType
|
|
LEFT JOIN T_StudentDetails std ON std.StudentID = a.StudentID
|
|
LEFT JOIN T_StaffDetails sd ON sd.StaffID = std.AdmittedBy
|
|
LEFT JOIN T_BatchMaster bm ON bm.BatchCode = a.BatchCode
|
|
where a.BranchCode = '".$branchId."' and bm.UniversityID = '".$univ."' and a.BatchCode != 'Not applicable'
|
|
GROUP BY std.AdmittedBy , bcode) b ";
|
|
|
|
// if($univ != ''){
|
|
// $sql.= " where uid = '".$univ."' ";
|
|
// }
|
|
|
|
$sql.= " group by bcode ";
|
|
|
|
$sql.=" ORDER BY BDate DESC";
|
|
|
|
|
|
//print_r($sql); die();
|
|
|
|
$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;
|
|
}
|
|
//and list.ListName like 'PENDING'
|
|
public function followupsToday($branchId = null, $requestedBy = null, $logintype = null){
|
|
$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 STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
//to staff
|
|
$ssql = "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 STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
|
|
|
|
if (count($tlead) > 0) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function followupsPending($branchId = null, $requestedBy = null, $logintype = null){
|
|
$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 month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and lt.CreatedBranch = '".$branchId."' ";
|
|
$ltd=$this->db->query($sql);
|
|
$tlead = $ltd->result();
|
|
//To staff
|
|
$ssql = "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 month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' ";
|
|
$sltd=$this->db->query($ssql);
|
|
$stlead = $sltd->result();
|
|
//echo $requestedBy;
|
|
if ((count($tlead) > 0) or (count($stlead) > 0)) {
|
|
$results['lList'] = true;
|
|
$results['l_data'] = $tlead;
|
|
$results['sl_data'] = $stlead;
|
|
} else {
|
|
$results['lList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
public function admissionBatch($univ = null, $branchId = null){
|
|
|
|
|
|
// $sql="SELECT BatchName, BatchDate,University,AdmittedBy,count(*)as count FROM admissions
|
|
// WHERE CASE WHEN MONTH(curdate()) >= 6 THEN CreatedYear = YEAR(curdate())
|
|
// ELSE (CreatedYear = YEAR(curdate()) - 1 AND CreatedMonth >= 6) OR CreatedYear = YEAR(curdate()) END
|
|
// and BranchCode ='".$branchId."' and UniversityID ='".$univ."'";
|
|
|
|
$sql="SELECT BatchName, BatchDate,University,AdmittedBy,1 as count FROM admissions where CASE WHEN MONTH(curdate())>=6 THEN CreatedYear =
|
|
concat(YEAR(curdate()), '-',right(YEAR(curdate())+1,2))
|
|
ELSE CreatedYear = concat(YEAR(curdate())-1,'-' ,right(YEAR(curdate()),2)) END
|
|
and BranchCode ='".$branchId."' and UniversityID ='".$univ."'";
|
|
|
|
// if($univ != ''){
|
|
// $sql.= " and UniversityID ='".$univ."'";
|
|
// }
|
|
|
|
//$sql.= " GROUP BY BatchName";
|
|
|
|
|
|
//$sql.= " ORDER BY BatchDate DESC";
|
|
|
|
|
|
|
|
|
|
$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';
|
|
}
|
|
//print_r($sql); die();
|
|
return $results;
|
|
}
|
|
//To Filters
|
|
public function getYear($branch = null,$univ = null){
|
|
$sql = "select year(CreatedOn) as year from T_StudentDetails where year(CreatedOn) != 0 group by year ";
|
|
$ltd=$this->db->query($sql);
|
|
$year = $ltd->result();
|
|
|
|
//get university
|
|
$usql = "select UniversityID,UniversityName from T_UniversityMaster where BranchCode ='".$branch."' ";
|
|
$uf=$this->db->query($usql);
|
|
$univf = $uf->result();
|
|
|
|
|
|
|
|
//get batch
|
|
$brsql = "select BatchCode,BatchName from T_BatchMaster
|
|
|
|
where BranchCode ='".$branch."' and UniversityID ='".$univ."'";
|
|
$brf=$this->db->query($brsql);
|
|
$branchf = $brf->result();
|
|
|
|
//get fiscal
|
|
$ysql = "SELECT CASE WHEN MONTH(CreatedOn)>=6 THEN
|
|
concat(YEAR(CreatedOn), '-',YEAR(CreatedOn)+1)
|
|
ELSE concat(YEAR(CreatedOn)-1,'-', YEAR(CreatedOn)) END AS fy
|
|
FROM T_StudentDetails
|
|
GROUP BY fy ";
|
|
$yf=$this->db->query($ysql);
|
|
$univyf = $yf->result();
|
|
|
|
if (count($year) > 0) {
|
|
$results['yearList'] = true;
|
|
$results['year'] = $year;
|
|
$results['branch'] = $branchf;
|
|
$results['univ'] = $univf;
|
|
$results['fyr'] = $univyf;
|
|
} else {
|
|
$results['yearList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
//End of filters
|
|
|
|
|
|
} |