diff --git a/Apollo/api/application/models/Dashboard_model.php b/Apollo/api/application/models/Dashboard_model.php index ea2cef24..aead8583 100755 --- a/Apollo/api/application/models/Dashboard_model.php +++ b/Apollo/api/application/models/Dashboard_model.php @@ -295,7 +295,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' "; + and date(ltf.CreatedOn) = date(now()) and list.ListName like 'CLOSED' 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 @@ -307,7 +307,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and date(ltf.CreatedOn) = date(now()) and list.ListName like 'CLOSED' 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(); @@ -332,7 +332,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' "; + and month(ltf.CreatedOn) = month(now()) and list.ListName like 'CLOSED' 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 @@ -344,7 +344,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and month(ltf.CreatedOn) = month(now()) and list.ListName like 'CLOSED' 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) { @@ -402,7 +402,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' "; + and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and ltf.IsActive = 1 and list.ListName not like 'CLOSED' and lt.CreatedBranch = '".$branchId."' "; $followupsCount=$this->db->query($sql); $fcount = $followupsCount->result(); $ssql = "select count(ltf.TrackingID) as count @@ -414,7 +414,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and ltf.IsActive = 1 and list.ListName not like 'CLOSED' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sfollowupsCount=$this->db->query($ssql); $sfcount = $sfollowupsCount->result(); //print_r($sql);die();and ltf.StatusName ='S020' @@ -440,7 +440,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' "; + and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and ltf.IsActive = 1 and list.ListName not like 'CLOSED' and lt.CreatedBranch = '".$branchId."' "; $followupsCount=$this->db->query($sql); $fcount = $followupsCount->result(); //and ltf.StatusName ='S020' @@ -453,7 +453,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and ltf.IsActive = 1 and list.ListName not like 'CLOSED' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sfollowupsCount=$this->db->query($ssql); //print_r($sql);die(); @@ -557,7 +557,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' "; + and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and list.ListName like 'CLOSED' and lt.CreatedBranch = '".$branchId."' "; $ltd=$this->db->query($sql); $tlead = $ltd->result(); //to staff @@ -570,7 +570,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and date(ltf.CreatedOn) = date(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and list.ListName like'CLOSED' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sltd=$this->db->query($ssql); $stlead = $sltd->result(); if (count($tlead) > 0) { @@ -594,7 +594,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' "; + and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and list.ListName like 'CLOSED' and lt.CreatedBranch = '".$branchId."' "; $ltd=$this->db->query($sql); $tlead = $ltd->result(); //to staff @@ -607,7 +607,7 @@ public function leadCountMonth($branchId = null, $requestedBy = null){ 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 'CLOSED' or 'CLOSE' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and month(ltf.CreatedOn) = month(now()) and ltf.IsActive = 1 and am.ActivityName like 'Adm%' and list.ListName like 'CLOSED' and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; $sltd=$this->db->query($ssql); $stlead = $sltd->result(); if (count($tlead) > 0) { @@ -828,7 +828,7 @@ $sql="select sum(TotalBalance) as total FROM (select (sum(totalpayable) - sum(to 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'CLOSED' or 'CLOSE' and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and lt.CreatedBranch = '".$branchId."' "; + and list.ListName not like 'CLOSED' 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 @@ -841,7 +841,7 @@ $sql="select sum(TotalBalance) as total FROM (select (sum(totalpayable) - sum(to 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 'CLOSED' or 'CLOSE' and STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y') = date(now()) and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and list.ListName not like 'CLOSED' 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(); @@ -867,7 +867,7 @@ $sql="select sum(TotalBalance) as total FROM (select (sum(totalpayable) - sum(to 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 'CLOSED' or 'CLOSE' and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and lt.CreatedBranch = '".$branchId."' "; + and list.ListName not like 'CLOSED' 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 @@ -880,7 +880,7 @@ $sql="select sum(TotalBalance) as total FROM (select (sum(totalpayable) - sum(to 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 'CLOSED' or 'CLOSE' and month(STR_TO_DATE(ltf.FollowupOn,'%d-%m-%Y')) = month(now()) and lt.CreatedBranch = '".$branchId."' and ltf.AssignedStaff = '".$requestedBy."' "; + and list.ListName not like 'CLOSED' 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;