diff --git a/Apollo/api/application/controllers/Dashboard_Controller.php b/Apollo/api/application/controllers/Dashboard_Controller.php index 1eeb9c46..18f773bc 100755 --- a/Apollo/api/application/controllers/Dashboard_Controller.php +++ b/Apollo/api/application/controllers/Dashboard_Controller.php @@ -116,7 +116,8 @@ class Dashboard_Controller extends REST_Controller { * */ public function getleadCountToday_post(){ $branchId = $this->post('branchId'); - $getleadCountToday = $this->dashboard_model->leadCountDay($branchId); + $requestedBy = $this->post('requestedBy'); + $getleadCountToday = $this->dashboard_model->leadCountDay($branchId,$requestedBy); if ($getleadCountToday) { $getleadCountToday['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -133,7 +134,8 @@ class Dashboard_Controller extends REST_Controller { } public function getleadCountMonth_post(){ $branchId = $this->post('branchId'); - $getleadCountMonth = $this->dashboard_model->leadCountMonth( $branchId); + $requestedBy = $this->post('requestedBy'); + $getleadCountMonth = $this->dashboard_model->leadCountMonth( $branchId,$requestedBy); if ($getleadCountMonth) { $getleadCountMonth['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -150,7 +152,8 @@ class Dashboard_Controller extends REST_Controller { } public function getleadCountDayClosed_post(){ $branchId = $this->post('branchId'); - $getleadCountDayClosed = $this->dashboard_model->leadCountDayClosed($branchId); + $requestedBy = $this->post('requestedBy'); + $getleadCountDayClosed = $this->dashboard_model->leadCountDayClosed($branchId, $requestedBy); if ($getleadCountDayClosed) { $getleadCountDayClosed['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -167,7 +170,8 @@ class Dashboard_Controller extends REST_Controller { } public function getleadCountMonthClosed_post(){ $branchId = $this->post('branchId'); - $getleadCountMonthClosed = $this->dashboard_model->leadCountMonthClosed( $branchId); + $requestedBy = $this->post('requestedBy'); + $getleadCountMonthClosed = $this->dashboard_model->leadCountMonthClosed( $branchId, $requestedBy); if ($getleadCountMonthClosed) { $getleadCountMonthClosed['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -201,7 +205,7 @@ class Dashboard_Controller extends REST_Controller { } public function getadmimssionYear_post(){ $branchId = $this->post('branchId'); - $data = $this->post('data'); + $requestedBy = $this->post('requestedBy'); $getadmimssionYear = $this->dashboard_model->admissionCountYear($branchId); if ($getadmimssionYear) { $getadmimssionYear['status'] = REST_Controller::HTTP_OK; @@ -219,7 +223,8 @@ class Dashboard_Controller extends REST_Controller { } public function getfupToday_post(){ $branchId = $this->post('branchId'); - $getfupToday = $this->dashboard_model->followupsCountToday($branchId); + $requestedBy = $this->post('requestedBy'); + $getfupToday = $this->dashboard_model->followupsCountToday($branchId,$requestedBy); if ($getfupToday) { $getfupToday['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -236,7 +241,8 @@ class Dashboard_Controller extends REST_Controller { } public function getfupMonth_post(){ $branchId = $this->post('branchId'); - $getfupMonth = $this->dashboard_model->followupsCountMonth($branchId); + $requestedBy = $this->post('requestedBy'); + $getfupMonth = $this->dashboard_model->followupsCountMonth($branchId,$requestedBy); if ($getfupMonth) { $getfupMonth['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -252,9 +258,10 @@ class Dashboard_Controller extends REST_Controller { } } public function leadToday_post(){ + $logintype = $this->post('requestedDept'); $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $leadToday = $this->dashboard_model->leadToday($branchId,$requestedBy); + $leadToday = $this->dashboard_model->leadToday($branchId,$requestedBy,$logintype); if ($leadToday) { $leadToday['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -272,7 +279,8 @@ class Dashboard_Controller extends REST_Controller { public function leadMonth_post(){ $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $leadMonth = $this->dashboard_model->leadMonth($branchId,$requestedBy); + $logintype = $this->post('requestedDept'); + $leadMonth = $this->dashboard_model->leadMonth($branchId,$requestedBy,$logintype); if ($leadMonth) { $leadMonth['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -290,7 +298,8 @@ class Dashboard_Controller extends REST_Controller { public function leadTodayClosed_post(){ $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $leadTodayClosed = $this->dashboard_model->leadTodayClosed($branchId,$requestedBy); + $logintype = $this->post('requestedDept'); + $leadTodayClosed = $this->dashboard_model->leadTodayClosed($branchId,$requestedBy,$logintype); if ($leadTodayClosed) { $leadTodayClosed['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -308,7 +317,8 @@ class Dashboard_Controller extends REST_Controller { public function leadMonthClosed_post(){ $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $leadMonthClosed = $this->dashboard_model->leadMonthClosed($branchId,$requestedBy); + $logintype = $this->post('requestedDept'); + $leadMonthClosed = $this->dashboard_model->leadMonthClosed($branchId,$requestedBy,$logintype); if ($leadMonthClosed) { $leadMonthClosed['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -326,7 +336,8 @@ class Dashboard_Controller extends REST_Controller { public function admissionMonth_post(){ $year = $this->post('year'); $month = $this->post('month'); - $admissionMonth = $this->dashboard_model->admissionMonth($year,$month); + $branchId = $this->post('branchId'); + $admissionMonth = $this->dashboard_model->admissionMonth($year,$month,$branchId); if ($admissionMonth) { $admissionMonth['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -381,7 +392,8 @@ class Dashboard_Controller extends REST_Controller { public function followupsToday_post(){ $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $followupsToday = $this->dashboard_model->followupsToday( $branchId, $requestedBy); + $logintype = $this->post('requestedDept'); + $followupsToday = $this->dashboard_model->followupsToday( $branchId, $requestedBy,$logintype); if ($followupsToday) { $followupsToday['status'] = REST_Controller::HTTP_OK; // Set the response and exit @@ -399,7 +411,8 @@ class Dashboard_Controller extends REST_Controller { public function followupsPending_post(){ $branchId = $this->post('branchId'); $requestedBy = $this->post('requestedBy'); - $followupsPending = $this->dashboard_model->followupsPending( $branchId, $requestedBy); + $logintype = $this->post('requestedDept'); + $followupsPending = $this->dashboard_model->followupsPending( $branchId, $requestedBy,$logintype); if ($followupsPending) { $followupsPending['status'] = REST_Controller::HTTP_OK; // Set the response and exit diff --git a/Apollo/api/application/models/Dashboard_model.php b/Apollo/api/application/models/Dashboard_model.php index 02fa5524..85fee0e1 100755 --- a/Apollo/api/application/models/Dashboard_model.php +++ b/Apollo/api/application/models/Dashboard_model.php @@ -212,7 +212,7 @@ class Dashboard_model extends CI_Model } - public function leadCountDay($branchId){ + 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 @@ -225,11 +225,23 @@ from T_Lead_Tracking_Followup as ltf and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 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 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'; @@ -237,7 +249,7 @@ if (count($lcount) > 0) { return $results; } -public function leadCountMonth($branchId){ +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 @@ -250,10 +262,22 @@ public function leadCountMonth($branchId){ and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 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 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'; @@ -261,7 +285,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadCountDayClosed($branchId){ + 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 @@ -274,11 +298,23 @@ public function leadCountMonth($branchId){ and date(ltf.CreatedOn) = date(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 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 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'; @@ -286,7 +322,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadCountMonthClosed($branchId){ + 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 @@ -299,10 +335,22 @@ public function leadCountMonth($branchId){ and month(ltf.CreatedOn) = month(now()) and list.ListName like 'CLOSE' and ltf.IsActive = 1 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 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'; @@ -338,7 +386,7 @@ public function leadCountMonth($branchId){ return $results; } - public function followupsCountToday($branchId = null){ + 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 @@ -351,9 +399,22 @@ public function leadCountMonth($branchId){ and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and ltf.IsActive = 1 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 lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + $sfollowupsCount=$this->db->query($ssql); + $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'; @@ -361,7 +422,7 @@ public function leadCountMonth($branchId){ return $results; } - public function followupsCountMonth($branchId = null){ + 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 @@ -374,9 +435,23 @@ public function leadCountMonth($branchId){ and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and ltf.IsActive = 1 and lt.CreatedBranch = '".$branchId."' "; $followupsCount=$this->db->query($sql); $fcount = $followupsCount->result(); + //to staff + $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 lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + $sfollowupsCount=$this->db->query($ssql); + $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'; @@ -385,7 +460,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadToday($branchId = null,$requestedBy = null){ + 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 @@ -409,7 +484,7 @@ public function leadCountMonth($branchId){ 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 lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sltd=$this->db->query($ssql); $stlead = $sltd->result(); // print_r($ssql); @@ -424,7 +499,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadMonth($branchId = null,$requestedBy = null){ + 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 @@ -447,7 +522,7 @@ public function leadCountMonth($branchId){ 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 lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sltd=$this->db->query($ssql); $stlead = $sltd->result(); if (count($tlead) > 0) { @@ -461,7 +536,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadTodayClosed($branchId = null,$requestedBy = null){ + 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 @@ -484,7 +559,7 @@ public function leadCountMonth($branchId){ 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' and lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 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) { @@ -498,7 +573,7 @@ public function leadCountMonth($branchId){ return $results; } - public function leadMonthClosed($branchId = null,$requestedBy = null){ + 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 @@ -511,6 +586,7 @@ public function leadCountMonth($branchId){ and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 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 @@ -521,7 +597,7 @@ public function leadCountMonth($branchId){ 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' and lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and list.ListName like 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sltd=$this->db->query($ssql); $stlead = $sltd->result(); @@ -536,7 +612,7 @@ public function leadCountMonth($branchId){ return $results; } - public function admissionMonth($year = null,$month = null){ + public function admissionMonth($year = null,$month = null, $branchId = null){ $sql = "select UniversityID as uid,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, @@ -544,18 +620,20 @@ public function leadCountMonth($branchId){ 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(tot_cnt) as total, - group_concat(AdmittedBy,'-',tot_cnt separator ',') as AdmissionTakenBy + group_concat(name,'-',tot_cnt separator ',') as AdmissionTakenBy from (SELECT scd.UniversityID AS UniversityID, um.UniversityName as university, std.CreatedOn AS cdate, std.AdmittedBy AS AdmittedBy, + concat(sd.Firstname,'',sd.Lastname) as name, (FLOOR(((DAYOFMONTH(std.CreatedOn) - 1) / 7)) + 1) AS week_of_month, COUNT(scd.StudentID) AS tot_cnt FROM T_StudentDetails std JOIN getUniv scd ON scd.StudentID = std.StudentID left join T_UniversityMaster um on um.UniversityID = scd.UniversityID + left join T_StaffDetails sd on sd.StaffID = std.AdmittedBy WHERE std.AdmittedBy IS NOT NULL AND YEAR(std.CreatedOn) = YEAR(NOW()) @@ -571,18 +649,20 @@ public function leadCountMonth($branchId){ 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(tot_cnt) as total, - group_concat(AdmittedBy,'-',tot_cnt separator ',') as AdmissionTakenBy + group_concat(name,'-',tot_cnt separator ',') as AdmissionTakenBy from (SELECT scd.UniversityID AS UniversityID, um.UniversityName as university, std.CreatedOn AS cdate, std.AdmittedBy AS AdmittedBy, + concat(sd.Firstname,'',sd.Lastname) as name, (FLOOR(((DAYOFMONTH(std.CreatedOn) - 1) / 7)) + 1) AS week_of_month, COUNT(scd.StudentID) AS tot_cnt FROM T_StudentDetails std JOIN getUniv scd ON scd.StudentID = std.StudentID left join T_UniversityMaster um on um.UniversityID = scd.UniversityID + left join T_StaffDetails sd on sd.StaffID = std.AdmittedBy WHERE std.AdmittedBy IS NOT NULL AND YEAR(std.CreatedOn) = '".$year."' @@ -631,7 +711,7 @@ public function leadCountMonth($branchId){ GROUP_CONCAT(DISTINCT sc.sname, '-', sc.cnt SEPARATOR ';') AS AdmissionTakenBy FROM T_StudentDetails std - JOIN getUniYear scd ON scd.StudentID = std.StudentID + JOIN T_Student_CourseDetails scd ON scd.StudentID = std.StudentID JOIN (select UniversityID,AdmittedBy,cnt,sname,group_concat(sname,'-',cnt) as staf from (SELECT scd.UniversityID AS UniversityID, std.BranchCode, std.CreatedOn, @@ -676,7 +756,7 @@ public function leadCountMonth($branchId){ GROUP_CONCAT(DISTINCT sc.sname, '-', sc.cnt SEPARATOR ';') AS AdmissionTakenBy FROM T_StudentDetails std - JOIN getUniYear scd ON scd.StudentID = std.StudentID + JOIN T_Student_CourseDetails scd ON scd.StudentID = std.StudentID JOIN (select UniversityID,AdmittedBy,cnt,sname,group_concat(sname,'-',cnt) as staf from (SELECT scd.UniversityID AS UniversityID, std.BranchCode, std.CreatedOn, @@ -719,8 +799,8 @@ public function leadCountMonth($branchId){ public function feeOutstanding($branchId = null, $univ = null){ $sql = "select bcode,Batches,uid,staff,admittedby,sum(totalpayable) as TotalPayableFee,sum(totalpaid) as TotalPaidFee,(sum(totalpayable) - sum(totalpaid)) as TotalBalance, - round((((sum(totalpayable) - sum(totalpaid)) / sum(totalpayable)) * 100),0) as BalancePercentage, - group_concat(staff,'-',bal_percentage separator ',') as BalancePercentageByStaff + 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, @@ -765,7 +845,7 @@ public function leadCountMonth($branchId){ return $results; } - public function followupsToday($branchId = null, $requestedBy = null){ + 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 @@ -788,7 +868,7 @@ public function leadCountMonth($branchId){ 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 lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + 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(); @@ -803,7 +883,7 @@ public function leadCountMonth($branchId){ return $results; } - public function followupsPending($branchId = null, $requestedBy = null){ + 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 @@ -813,7 +893,7 @@ public function leadCountMonth($branchId){ 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' and lt.CreatedBranch = '".$branchId."' "; + and list.ListName not like 'CLOSE' and list.ListName like 'PENDING' 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 @@ -826,10 +906,10 @@ public function leadCountMonth($branchId){ 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' and lt.CreatedBranch = '".$branchId."' and sd.StaffID = '".$requestedBy."' "; + and list.ListName not like 'CLOSE' and list.ListName like 'PENDING' 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; diff --git a/Apollo/assets/js/controllers/dashboardCtrl.js b/Apollo/assets/js/controllers/dashboardCtrl.js index d8e8e479..df1e4152 100755 --- a/Apollo/assets/js/controllers/dashboardCtrl.js +++ b/Apollo/assets/js/controllers/dashboardCtrl.js @@ -200,7 +200,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $scope.sl_dataToday[i].Sl_No = i + 1; $scope.ltl = false; - if ($scope.l_dataToday == '') { + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005') { $scope.Dt_leadtoday = $scope.sl_dataToday; // console.log($scope.Dt_leadtoday); // console.log('if'); @@ -271,7 +271,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " for (var i = 0; i < $scope.sl_dataMonth.length; i++) $scope.sl_dataMonth[i].Sl_No = i + 1; $scope.lml = false; - if ($scope.l_dataMonth == '') { + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005') { $scope.Dt_leadmonth = $scope.sl_dataMonth; // console.log($scope.Dt_leadmonth); // console.log('if'); @@ -340,7 +340,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " for (var i = 0; i < $scope.sl_dataDayClosed.length; i++) $scope.sl_dataDayClosed[i].Sl_No = i + 1; $scope.cdl = false; - if ($scope.l_dataDayClosed == '') { + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005') { $scope.Dt_dataDayClosed = $scope.sl_dataDayClosed; // console.log($scope.Dt_dataDayClosed); // console.log('if'); @@ -410,7 +410,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " for (var i = 0; i < $scope.sl_dataMonthClosed.length; i++) $scope.sl_dataMonthClosed[i].Sl_No = i + 1; $scope.cml = false; - if ($scope.l_dataMonthClosed == '') { + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { $scope.Dt_dataMonthClosed = $scope.sl_dataMonthClosed; // console.log($scope.Dt_dataMonthClosed); // console.log('if'); @@ -451,7 +451,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " showColumnLines: "showColumnLines", showRowLines: "showRowLines", rowAlternationEnabled: "rowAlternationEnabled", - dataSource: 'l_dataMonthClosed' + dataSource: 'Dt_dataMonthClosed' }, columns: ['TrackingId', 'name', 'mobileNo', 'course', 'university', 'activity', 'AssignTo', 'followUpDate', 'status'] }; @@ -701,7 +701,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " columns: [{ dataField: "Sl_No", dataType: "number", - //width:50 + width:50 }, { dataField: "Batches", dataType: "number", @@ -720,7 +720,8 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " // width:80 }, { dataField: "BalancePercentage", - dataType: "number", + cssClass: "cls", + // dataType: "number", // width:80 }, { dataField: "BalancePercentageByStaff", @@ -754,7 +755,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $scope.sftoday[i].Sl_No = i + 1; $scope.futl = false; // console.log($scope.ftoday); - if ($scope.ftoday == '') { + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { $scope.Dt_ftoday = $scope.sftoday; // console.log($scope.Dt_dataMonthClosed); // console.log('if'); @@ -812,6 +813,8 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " } }; + console.log(JSON.parse(localStorage.getItem('localObj')).localType); + $http(fpending).then(function (response) { if (response.data.lList == true) { $scope.fpending = response.data.l_data; @@ -823,15 +826,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $scope.sfpending = response.data.sl_data; for (var i = 0; i < $scope.sfpending.length; i++) $scope.sfpending[i].Sl_No = i + 1; - //console.log($scope.fpending); - if ($scope.fpending == '') { + // console.log($scope.fpending); + // console.log($scope.sfpending); + + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { $scope.Dt_fpending = $scope.sfpending; // console.log($scope.Dt_dataMonthClosed); // console.log('if'); } else { $scope.Dt_fpending = $scope.fpending; - // console.log($scope.Dt_dataMonthClosed); + console.log($scope.Dt_fpending); // console.log('else'); } } else { @@ -908,6 +913,7 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " "export": { enabled: true, fileName: "AdmissionsBatch" + }, dataSource: { fields: [{ @@ -1338,14 +1344,28 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " } /*end dashboard tab*/ /*For dashboard tiles*/ - $scope.lead_dataToday = 0; - $scope.lead_dataMonth = 0; - $scope.leadCountDayClosed = 0; - $scope.leadCountMonthClosed = 0; - $scope.ad_data = 0; - $scope.ad_dataYear = 0; - $scope.fup_today = 0; - $scope.fup_month = 0; + $scope.lead_dataToday = ''; + $scope.lead_dataMonth = ''; + $scope.leadCountDayClosed = ''; + $scope.leadCountMonthClosed = ''; + $scope.ad_data = ''; + $scope.ad_dataYear = ''; + $scope.fup_today = ''; + $scope.fup_month = ''; + //to staff + $scope.slead_dataToday = ''; + $scope.slead_dataMonth = ''; + $scope.sleadCountDayClosed = ''; + $scope.sleadCountMonthClosed = ''; + $scope.sfup_today = ''; + $scope.sfup_month = ''; + //common variable + $scope.cslead_dataToday = ''; + $scope.cslead_dataMonth = ''; + $scope.csleadCountDayClosed = ''; + $scope.csleadCountMonthClosed = ''; + $scope.csfup_today = ''; + $scope.csfup_month = ''; //1st tile for lead created today var todayCount = { method: 'POST', @@ -1363,6 +1383,18 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(todayCount).then(function (response) { if (response.data.leadList == true) { $scope.lead_dataToday = response.data.lead_data[0].count; + $scope.slead_dataToday = response.data.slead_data[0].count; + + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.cslead_dataToday = $scope.slead_dataToday; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.cslead_dataToday = $scope.lead_dataToday; + //console.log($scope.Dt_fpending); + // console.log('else'); + } // console.log($scope.lead_dataToday); } else { @@ -1386,7 +1418,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(monthCount).then(function (response) { if (response.data.leadList == true) { $scope.lead_dataMonth = response.data.lead_data[0].count; - + $scope.slead_dataMonth = response.data.slead_data[0].count; + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.cslead_dataMonth = $scope.slead_dataMonth; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.cslead_dataMonth = $scope.lead_dataMonth; + //console.log($scope.Dt_fpending); + // console.log('else'); + } //console.log($scope.lead_dataMonth); } else { $scope.message = response.data.message; @@ -1409,6 +1451,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(dayCountClosed).then(function (response) { if (response.data.leadList == true) { $scope.leadCountDayClosed = response.data.lead_data[0].count; + $scope.sleadCountDayClosed = response.data.slead_data[0].count; + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.csleadCountDayClosed = $scope.sleadCountDayClosed; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.csleadCountDayClosed = $scope.leadCountDayClosed; + //console.log($scope.Dt_fpending); + // console.log('else'); + } // console.log($scope.leadCountDayClosed); } else { @@ -1432,6 +1485,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(monthCountClosed).then(function (response) { if (response.data.leadList == true) { $scope.leadCountMonthClosed = response.data.lead_data[0].count; + $scope.sleadCountMonthClosed = response.data.slead_data[0].count; + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.csleadCountMonthClosed = $scope.sleadCountMonthClosed; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.csleadCountMonthClosed = $scope.leadCountMonthClosed; + //console.log($scope.Dt_fpending); + // console.log('else'); + } //console.log($scope.leadCountMonthClosed); } else { @@ -1499,6 +1563,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(fupToday).then(function (response) { if (response.data.fUpList == true) { $scope.fup_today = response.data.fUp_data[0].count; + $scope.sfup_today = response.data.sfUp_data[0].count; + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.csfup_today = $scope.sfup_today; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.csfup_today = $scope.fup_today; + //console.log($scope.Dt_fpending); + // console.log('else'); + } // console.log($scope.fup_today); } else { @@ -1522,6 +1597,17 @@ app.controller('dashboardCtrl', ["$scope", "$rootScope", "toaster", "$filter", " $http(fupMonth).then(function (response) { if (response.data.fUpList == true) { $scope.fup_month = response.data.fUp_data[0].count; + $scope.sfup_month = response.data.sfUp_data[0].count; + if ($scope.getLoginType == 'R002' || $scope.getLoginType == 'R005' ) { + $scope.csfup_month = $scope.sfup_month; + // console.log($scope.Dt_dataMonthClosed); + // console.log('if'); + } + else { + $scope.csfup_month = $scope.fup_month; + //console.log($scope.Dt_fpending); + // console.log('else'); + } // console.log($scope.fup_month); } else { diff --git a/Apollo/assets/views/dashboard.html b/Apollo/assets/views/dashboard.html index b8e2ed71..7a03c6be 100755 --- a/Apollo/assets/views/dashboard.html +++ b/Apollo/assets/views/dashboard.html @@ -20,7 +20,7 @@
+ Today +
{{cslead_dataToday || 0}} ++ This month +
{{cslead_dataMonth || 0}} ++ + view more + +
++ Today +
{{csleadCountDayClosed || 0}} ++ This month +
{{csleadCountMonthClosed || 0}} ++ + view more + +
++ Today +
{{csfup_today || 0}} ++ This month +
{{csfup_month || 0}} ++ + view more + +
+