From 9427d68378257c84c689a62c0fe871e4bc566615 Mon Sep 17 00:00:00 2001 From: velz Date: Tue, 27 Nov 2018 10:51:08 +0530 Subject: [PATCH] PD HISTORY LIST OF PD OFFICERS SMART PD QUESTIONS --- api/application/config/constants.php | 2 +- api/application/controllers/PD_Controller.php | 19 +++++++--- api/application/models/PD_Model.php | 35 ++++++++++++++++--- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 3cbbb932..8c3ea7fe 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto // define login route name for token verification //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getFinalPDReportQuestions'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getFullPDDetails'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 82798e72..11948b7f 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -900,8 +900,9 @@ class PD_Controller extends REST_Controller { $list_of_pd_officers[$key]['mobile_no'] = $names[0]['mobile_no']; $list_of_pd_officers[$key]['count'] = 0; - $this->db->SELECT('COUNT(*) as count'); + $this->db->SELECT('pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %H:%i:%s") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); $this->db->OR_GROUP_START(); $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); @@ -910,7 +911,9 @@ class PD_Controller extends REST_Controller { $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); $pd_count = $this->db->GET()->result_array(); //print_r($this->db->last_query()); - if(count($pd_count)){ $list_of_pd_officers[$key]['count'] = $pd_count[0]['count']; } + if(count($pd_count)){ + $list_of_pd_officers[$key]['pd_details'] = $pd_count; + $list_of_pd_officers[$key]['count'] =count($pd_count); } // Get Profile Pic from S3 @@ -995,8 +998,9 @@ class PD_Controller extends REST_Controller { $list_of_pd_officers[$key]['mobile_no'] = $names[0]['mobile_no']; $list_of_pd_officers[$key]['count'] = 0; - $this->db->SELECT('COUNT(*) as count'); + $this->db->SELECT('pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %H:%i:%s") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); + $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); $this->db->OR_GROUP_START(); $this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED); $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); @@ -1005,7 +1009,10 @@ class PD_Controller extends REST_Controller { $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); $pd_count = $this->db->GET()->result_array(); //print_r($this->db->last_query()); - if(count($pd_count)){ $list_of_pd_officers[$key]['count'] = $pd_count[0]['count']; } + if(count($pd_count)){ + $list_of_pd_officers[$key]['pd_details'] = $pd_count; + $list_of_pd_officers[$key]['count'] =count($pd_count); + } // Get Profile Pic from S3 @@ -1176,11 +1183,13 @@ class PD_Controller extends REST_Controller { public function loadFullTemplate_get() { $pd_id = ""; + $client = ""; if($this->get('pd_id')) { $pd_id = $this->get('pd_id'); } + if($this->get('client')) { $client = $this->get('client'); } if($pd_id != "" || $pd_id != null) { - $template_details = $this->PD_Model->getTemplateForPD($pd_id); + $template_details = $this->PD_Model->getTemplateForPD($pd_id,$client); if(count($template_details)) { $data['dataStatus'] = true; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index ce2ed306..b0e761e4 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -243,8 +243,18 @@ class PD_Model extends SPARQ_Model { { foreach($logs as $log_key => $log) { - //print_r($log); - //echo $arrayForText[$log['field_name']].' Changed From "'. $log['old_value'] .'" To "'. $log['new_value'].'"'; + + if($log_key == 0) + { + $log_string = 'PD Ctreated with '.$log['old_value'].'" status "'.'"'; + $user = $log['createdby']; + $time = $log['createdon']; + $actual_logs[$log_key]['log'] = $log_string; + $actual_logs[$log_key]['user'] = $user; + $actual_logs[$log_key]['time'] = $time; + } + else + { $field_name = $log['field_name']; //print_r($field_name); switch($field_name){ @@ -375,6 +385,7 @@ class PD_Model extends SPARQ_Model { $actual_logs[$log_key]['time'] = $time; } + } } } @@ -436,9 +447,10 @@ class PD_Model extends SPARQ_Model { - public function getTemplateForPD($pdid) + public function getTemplateForPD($pdid,$client) { + $template_id = ""; $categories = ""; $overall_answered_count = 0; @@ -446,7 +458,7 @@ class PD_Model extends SPARQ_Model { //Get PD Master Details including Template id @param $pd_id $pd_master_detials = $this->getPDMasterDetails($pdid); $pd_applicants_detials = $this->getApplicantsDetails($pdid); - //sprint_r($pd_master_detials); + //print_r($pd_master_detials);die(); if(count($pd_master_detials)){ $template_id = $pd_master_detials[0]['fk_pd_template_id']; } @@ -573,7 +585,20 @@ class PD_Model extends SPARQ_Model { } + if($pd_master_detials[0]['fk_pd_type'] == 2 && $client == 1) + { + //$temp_array = array(3,5,10,13); + foreach($template_forms as $key => $form) + { + if($form['form_id'] != 3 && $form['form_id'] != 5 && $form['form_id'] != 10 && $form['form_id'] != 13) + { + unset($template_forms[$key]) ; + } + } + + + } @@ -589,7 +614,7 @@ class PD_Model extends SPARQ_Model { return $result_data; } - + public function getAnswersForPD($question_id,$pd_id,$template_id,$category_id) { $overalldata =array();