diff --git a/Apollo/api/application/models/Calltracking_model.php b/Apollo/api/application/models/Calltracking_model.php index 93cb0630..a70a0596 100755 --- a/Apollo/api/application/models/Calltracking_model.php +++ b/Apollo/api/application/models/Calltracking_model.php @@ -19,6 +19,7 @@ class Calltracking_model extends CI_Model { $this->db->from(LEAD_DETAILS.' as LD'); $this->db->join(LEAD_TRACKING.' as LT', 'LT.LeadID = LD.LeadID'); $this->db->where('LD.MobileNumber',$mobileNumber); + $this->db->where('LT.CreatedBranch',$branchID); $leadDet=$this->db->get()->last_row(); $result_array = []; if($leadDet){ @@ -31,6 +32,8 @@ class Calltracking_model extends CI_Model { $this->db->join(UNIVERSITY.' as US', 'US.UniversityID = STC.UniversityID'); $this->db->join(COURSE.' as CU', 'CU.CourseID = STC.CourseID'); $this->db->where('ST.MobileNumber',$mobileNumber); + $this->db->where('STC.BranchID',$branchID); + $this->db->where('US.BranchCode',$branchID); $enrolledStudDet=$this->db->get()->last_row(); if($enrolledStudDet) { $leadDet['LeadName'] = $enrolledStudDet->Firstname; @@ -60,8 +63,8 @@ class Calltracking_model extends CI_Model { } } // store lead,university and course details in comman array - //$result_array['universityDetails']=$this->getUniversityDetails(); - $result_array['activityDetails']=$this->getActivityDetails($mobileNumber); + //$result_array['universityDetails']=$this->getUniversityDetails($branchID); + $result_array['activityDetails']=$this->getActivityDetails($mobileNumber,$branchID); // $result_array['statusDetails']=$this->getStatus(); $result_array['staffDetails']=$this->getStaff("1",$branchID,$userType,$requestedBy); return $result_array; @@ -72,10 +75,11 @@ class Calltracking_model extends CI_Model { * get university details * created by kms * */ - public function getUniversityDetails() + public function getUniversityDetails($branchID) { $this->db->select('UniversityID,UniversityName'); $this->db->where('IsActive','1'); + $this->db->where('BranchCode',$branchID); $this->db->order_by('UniversityID','ASC'); $unviversityDetails = $this->db->get(UNIVERSITY); @@ -86,7 +90,7 @@ class Calltracking_model extends CI_Model { $university_array['universityStatus'] = true; $university_array['universityID'] = $row->UniversityID; $university_array['universityName'] = $row->UniversityName; - $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID); + $university_array['courseDetails']= $this->getCourseDetails($row->UniversityID,$branchID); $result_university[]=$university_array; } } @@ -108,11 +112,12 @@ class Calltracking_model extends CI_Model { * @params university id * created by kms * */ - public function getCourseDetails($universityID=null) + public function getCourseDetails($universityID=null,$branchID=null) { $this->db->select('CourseID,CourseName'); $this->db->where('UniversityID',$universityID); $this->db->where('IsActive','1'); + $this->db->where('BranchCode',$branchID); $this->db->order_by('CourseID','ASC'); $courseDetails = $this->db->get(COURSE); return $courseDetails->result(); @@ -123,7 +128,7 @@ class Calltracking_model extends CI_Model { * created by kms * */ - public function getActivityDetails($mobileNo=null) + public function getActivityDetails($mobileNo=null,$branchID=null) { $this->db->distinct(); $this->db->select('LT.ActivityStatus,LT.ActivityStatus'); @@ -132,6 +137,9 @@ class Calltracking_model extends CI_Model { $this->db->join(PICK_LIST_DETAILS.' as PLD', 'LT.StatusCode = PLD.ListCode'); $this->db->where('PLD.ListName !=','CLOSE'); $this->db->where('LD.MobileNumber',$mobileNo); + $this->db->where('LT.CreatedBranch',$branchID); + $this->db->where('PLD.BranchCode',$branchID); + $getExistActivity=$this->db->get(); $existArrayActivity=array(); if($getExistActivity->result()){ @@ -148,6 +156,7 @@ class Calltracking_model extends CI_Model { $this->db->select('ActivityID,ActivityName'); $this->db->where('IsActive','1'); + $this->db->where('BranchCode',$branchID); if($existArrayActivity){ $this->db->where_not_in('ActivityID',$existArrayActivity); } @@ -202,7 +211,7 @@ class Calltracking_model extends CI_Model { public function getStaff($status=null,$branchID=null,$userType=null,$requestedBy) { - if($userType != SUPER_ADMIN){ + // if($userType != SUPER_ADMIN OR $userType== SUPER_ADMIN){ $this->db->select('LO.ID,ST.StaffID,ST.Firstname'); $this->db->from(LOGIN.' as LO'); @@ -219,6 +228,9 @@ class Calltracking_model extends CI_Model { $this->db->where('STB.BranchCode',$branchID); $this->db->where('LO.ID',$requestedBy); } + if($userType== SUPER_ADMIN){ + $this->db->where('STB.BranchCode',$branchID); + } $staffDetails=$this->db->get(); if($staffDetails){ $result_staff = array(); @@ -233,7 +245,7 @@ class Calltracking_model extends CI_Model { else{ $result_staff[]=""; } - } + /* } else{ $this->db->select('BR.BranchCode,BR.BranchName'); $this->db->from(BRANCH.' as BR'); @@ -254,7 +266,7 @@ class Calltracking_model extends CI_Model { } - } + }*/ return $result_staff; }