sparqapi/api/application/controllers/PD_Controller.php
2018-10-06 11:27:32 +05:30

763 lines
25 KiB
PHP

<?php
/**
* User: velz
* This Controller deals with PD Related CRUD Operations
*/
defined('BASEPATH') OR exit('No direct script access allowed');
require_once APPPATH . '/libraries/REST_Controller.php';
class PD_Controller extends REST_Controller {
function __construct()
{
// Construct the parent class
parent::__construct();
$this->load->model('PD_Model');
$this->load->library('AWS_S3');
$this->load->library('AWS_SES');
}
/***********************Get get List Of Lenders Details for PD Trigger Page************************/
public function getListOfLenders_get()
{
$fields = array('entity_id','full_name','short_name');
$where_condition_array = array('isactive' => 1,'fk_entity_type_id' => 2);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITY);
if(count($result_data))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/********************Get get List Of Products and SubProducts Name Details for PD Trigger Page*********/
public function getListOfProducts_get()
{
$fields = array('product_id','name as product_name','abbr as product_abbr');
$where_condition_array = array('isactive' => 1);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PRODUCTS);
if(count($result_data))
{
foreach($result_data as $key => $product)
{
$fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr');
$where_condition_array = array('isactive' => 1,'fk_product_id' => $product['product_id']);
$subproducts = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS);
//array_push($result_data[$key],$subproducts);
$result_data[$key]['subproducts'] = $subproducts;
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/********************Get get List Of CustomerSegments Details for PD Trigger Page*********/
public function getListOfCustomerSegments_get()
{
$fields = array('customer_segment_id','name as customer_segment','abbr');
$where_condition_array = array('isactive' => 1);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CUSTOMERSEGMENT);
if(count($result_data))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/********************Get get List Of Both PD Allocation Types and PD Types Details for PD Trigger Page*********/
public function getListOfPDAllocationTypes_get()
{
$fields = array('pd_allocation_type_id','pd_allocation_type_name','pd_allocation_logic','default');
$where_condition_array = array('isactive' => 1);
$result_data['pd_allocation_type'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDALLOCATIONTYPE);
$fields1 = array('pd_type_id','type_name');
$where_condition_array1 = array('isactive' => 1);
$result_data['pd_type'] = $this->PD_Model->selectCustomRecords($fields1,$where_condition_array1,PDTYPE);
if(count($result_data))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/********************Get get List Of States and Cities Name Details for PD Trigger Page*********/
public function getListOfStatesAndCities_get()
{
$fields = array('state_id','name as state_name','code');
$where_condition_array = array('isactive' => 1);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE);
if(count($result_data))
{
foreach($result_data as $key => $state)
{
$fields = array('city_id','name as city_name');
$where_condition_array = array('isactive' => 1,'fk_state_id' => $state['state_id']);
$cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY);
//array_push($result_data[$key],$cities);
$result_data[$key]['cities'] = $cities;
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/********For Save New PD while Trigger****/
/*
sample data
{
"pd_details":{ "fk_lender_id": "1", "lender_applicant_id":"12458","fk_product_id":"2","fk_subproduct_id":"1","fk_pd_type":"2", "fk_pd_status":"2","pd_specific_clarification":"nothing","createdon":"2017","fk_createdby":"2","fk_pd_allocation_type":"3","fk_pd_allocated_to":"1","fk_pd_template_id":"2","fk_customer_segment":"1","pd_officier_final_judgement":"54561","pd_agency_id":"1","loan_amount":"1589655","addressline1":"1", "addressline2":"2", "addressline3":"3", "fk_city":"1", "fk_state":"2", "pincode":"966852"}
}
*/
public function triggerNewPD_post()
{
$pd_details = json_decode($this->post('pd_details'),true);
$pd_applicant_details = json_decode($this->post('pd_applicant_details'),true);
$pd_document_titles = "";
if($this->post('pd_document_titles')){ $pd_document_titles = json_decode($this->post('pd_document_titles'),true); }
$pd_documents = array();
$count = 0;
/***********************CHOOSE PD TEMPALATE*********************/
$fields = array('fk_template_id');
$where_condition_array = array('fk_lender_id'=>1 ,'fk_product_id'=> 1,'fk_customer_segment'=> 1,'isactive' => 1);
$table = LENDERTEMPLATE;
$choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
if(count($choosed_template_id))
{
$pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id'];
}
/***********************PD ALLOCATION TYPE PROCESS **********/
$pd_details['fk_pd_status'] = TRIGGERED;
$pd_details['fk_pd_allocated_to'] = null;
$where_condition_array = array('fk_city_id' => $pd_details['fk_city'],'fk_lender_id' => $pd_details['fk_lender_id']);
$temp_city_id = $this->PD_Model->selectRecords(PDTEAMMAP,$where_condition_array,$limit=0,$offset=0);
if(count($temp_city_id))
{
if(isset($temp_city_id[0]['type']))
{
if($temp_city_id[0]['type'] == 0) // Allocate to Vendor
{
$pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id'];
$pd_details['fk_pd_status'] = ALLOCATED_TO_PARTNER;
}
else //Allocate to SineEdge Team with allocation logics
{
$local_pd_allocation_type = $pd_details['fk_pd_allocation_type'];
if($local_pd_allocation_type == 1)// AUTO - Load Balance Allocation
{
//select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED
$fields = array('fk_user_id,allocated');
$where_condition_array = array('fk_pd_type_id' => $pd_details['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $pd_details['fk_customer_segment'],'fk_product_id' => $pd_details['fk_product_id'],'isactive' => 1);
$list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS);
$allocated_values = array_column($list_of_pd_officers,'allocated');
$min_allocated = min($allocated_values);
$key = array_search($min_allocated,$allocated_values);
$final_pd_officer_to_allocate = $list_of_pd_officers[$key]['fk_user_id'];
//For Random Allocaiton not in use
// $key = mt_rand(0, count($list_of_pd_officers) - 1);
// $final_pd_officer_to_allocate = isset($list_of_pd_officers[$key])? $list_of_pd_officers[$key]: null;
$pd_details['fk_pd_allocated_to'] = $final_pd_officer_to_allocate;
$pd_details['fk_pd_status'] = ALLOCATED;
}
else if($local_pd_allocation_type == 2) // AUTO - NEAREST Allocation
{
}
else // Manual Allocation
{
// Do nothing, cause fk_pd_allocated_to value comes from front end.
}
}
}//End Of isset
}
/***********************END OF PD ALLOCATION TYPE AND PROCESS***********/
$pd_details['pd_date_of_initiation'] = date("Y-m-d H:i:s");
if($pd_details['fk_pd_status'] == "" || $pd_details['fk_pd_status'] == null)
{
$pd_details['fk_pd_status'] = TRIGGERED;
}
$pd_id = $this->PD_Model->saveRecords($pd_details,PDTRIGGER);
/***********************PD DOCUMENTS UPLOAD SECTION ***********/
if($pd_id != null || $pd_id != '')
{
if(!empty($_FILES['pddocuments']) && !empty($pd_document_titles))
{
foreach($pd_document_titles as $iter => $title)
{
$tempdoc = $_FILES['pddocuments']['tmp_name'][$iter];
$tempdocname = $_FILES['pddocuments']['name'][$iter];
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details['fk_lender_id'];
$key = 'pd'.$pd_id.'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record_data = array('fk_pd_id' => $pd_id,'pd_document_title'=>$title,'pd_document_name'=>$tempdocname);
$this->PD_Model->saveRecords($record_data,PDDOCUMENTS);
}
}
}
}
/***********************END OF PD DOCUMENTS UPLOAD SECTION ***********/
if($pd_id != null || $pd_id != '')
{
foreach($pd_applicant_details as $pd_applicant_detail)
{
$pd_applicant_detail['fk_pd_id'] = $pd_id;
$co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS);
if($co_applicant_id != null || $co_applicant_id != '')
{
$count = $count + 1;
}
}
}
// update into pd officer details
if($pd_details['fk_pd_allocated_to'] != null || $pd_details['fk_pd_allocated_to'] != '')
{
$this->PD_Model->updatePDofficersDetail($pd_details['fk_pd_allocated_to']);
}
if($pd_id != null || $pd_id != '' && $count != 0)
{
// CALL pdnotification Helper function to send pd alerts @ params pdid,pdstatus
PDALERTS::pdnotification($pd_id);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $pd_id;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*
*Update PD trigger Master Details(Web app only) from PD trigger Edit/view page
*/
public function updatePDMaster_post()
{
$pd_details = $this->post('pd_details');
$where_condition_array = array('pd_id' => $pd_details['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array);
if($pd_id_modified != null || $pd_id_modified != '' && $count != 0)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*
*Update PD trigger Applicats Details(Web app only) from PD trigger Edit/view page
*/
public function updatePDApplicants_post()
{
$pd_applicant_details = $this->post('pd_applicant_details');
$count = 0;
$pd_id = 0;
//print_r($this->post());die();
foreach($pd_applicant_details as $pd_applicant_detail)
{
if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "")
{
$pd_id = $pd_applicant_detail['fk_pd_id'];
$where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']);
$co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array);
if($co_applicant_id != null || $co_applicant_id != '')
{
$count = $count + 1;
}
}
else
{
$pd_applicant_detail['fk_pd_id'] = $pd_id;
$co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS);
if($co_applicant_id != null || $co_applicant_id != '')
{
$count = $count + 1;
}
}
}
if($count != 0 && count($pd_applicant_details) == $count)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
}
public function updatePDDocs_post()
{
}
/*
*
*Update PD Documents details from PD Trigger(Web application only) edit/view page
*/
public function updatePDDocs_post()
{
$pd_document_titles = json_decode($this->post('pd_document_titles'),true);
if(count($pd_document_titles))
{
//Get Lender id from PD Master
$pdid = $pd_document_titles[0]['fk_pd_id'];
$fields = array('fk_lender_id');
$where_condition_array = array('pd_id' => $pdid);
$lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
foreach($pd_document_titles as $iter => $doc)
{
if($doc['pd_document_id'] != null || $doc['pd_document_id'] != '')
{
$tempdoc = $_FILES['pddocuments']['tmp_name'][$iter];
$tempdocname = $_FILES['pddocuments']['name'][$iter];
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
//delete old doc from s3 bucket_data
$fields = array('pd_document_name');
$where_condition_array1 = array('pd_document_id' => $doc['pd_document_id']);
$old_doc_name = $this->PD_Model->selectCustomRecords($fields,$where_condition_array1,PDDOCUMENTS);
if($old_doc_name != "" || $old_doc_name != null)
{
$key = 'pd'.$doc['fk_pd_id'].'/'.$old_doc_name[0]['pd_document_name'];
$this->aws_s3->deleteSingleObjFromBucket($bucketname,$key);
}
//Update entry in PD Doc table
$record_data = array('pd_document_name'=>$tempdocname);
$where_condition_array = array('pd_document_id' => $doc['pd_document_id']);
$this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array);
}
}
else
{
$tempdoc = $_FILES['pddocuments']['tmp_name'][$iter];
$tempdocname = $_FILES['pddocuments']['name'][$iter];
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id;
$key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>$doc['pd_document_title'],'pd_document_name'=>$tempdocname);
$this->PD_Model->saveRecords($record_data,PDDOCUMENTS);
}
}
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*Allocate PD to Some PD officer
*/
public function allocatePD_post()
{
$records = $this->post('records');
if($records['fk_pd_allocated_to'] != "" || $records['fk_pd_allocated_to'] != null)
{
$records['fk_pd_status'] = ALLOCATED;
}
$where_condition_array = array('pd_id' => $records['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array);
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Not Updated! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*Schedule PD by PD officer(only on Manual Schedule)
*/
public function schdulePD_post()
{
$records = $this->post('records');
if($records['schedule_time'] != "" || $records['schedule_time'] != null)
{
$id = $this->PD_Model->saveRecords($records,PDSCHEDULE);
if($id != '' || $id != null)
{
$where_condition_array = array('pd_id' => $records['fk_pd_id']);
$temp_array = array('fk_pd_status' => SCHEDULED,'fk_updatedby'=>$records['fk_scheduled_by'],'updatedon'=>$records['createdon']);
$pd_id_modified = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['fk_pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Not Updated! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
}
/*
*GET List of PD officers for PD edit/view page for manual allocation
*@param pd
*/
public function getListPDOfficers_post()
{
$pdid = $this->post('pdid');
//1.Get LenderID and CityID by using pdid
$fields = array('fk_lender_id','fk_city','fk_pd_type','fk_product_id','fk_customer_segment');
$where_condition_array = array('pdid'=>$pdid);
$res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
//2.Get Team Map Details based on step 1
if(count($res_array))
{
$where_condition_array = array('fk_city_id' => $res_array[0]['fk_city'],'fk_lender_id' => $res_array[0]['fk_lender_id']);
$temp_city_id = $this->PD_Model->selectRecords(PDTEAMMAP,$where_condition_array,$limit=0,$offset=0);
if(count($temp_city_id))
{
if(isset($temp_city_id[0]['type']))
{
if($temp_city_id[0]['type'] == 0) // Allocate to Vendor
{
// $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id'];
// $pd_details['fk_pd_allocated_to'] = ALLOCATED_TO_PARTNER;
}
else //Allocate to SineEdge Team with allocation logics
{
//select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED
$fields = array('fk_user_id,allocated');
$where_condition_array = array('fk_pd_type_id' => $res_array['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $res_array['fk_customer_segment'],'fk_product_id' => $res_array['fk_product_id'],'isactive' => 1);
$list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS);
if(count($list_of_pd_officers))
{
foreach($list_of_pd_officers as $key => $pdofficer)
{
$this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name');
$this->db->FROM(USERPROFILE.' as USERPROFILE');
$this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']);
$data = $this->db->GET()->result_array();
$list_of_pd_officers[$key]['first_name'] = $data[0]['first_name'];
$list_of_pd_officers[$key]['last_name'] = $data[0]['last_name'];
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $list_of_pd_officers;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Officers Records Not Found!';
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Team Records Not Found!';
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'Master Records Not Found!';
$this->response($data,REST_Controller::HTTP_OK);
}
}
/* PD_Triggerd and PD_Co_Applocants Details only for Listing Page
@param page/offset
@param limit
@param sorting order(ASC/DESC)
@param cid for category_id for filter question with category wise.
*/
public function listLessPDDetails_get()
{
$page = 0;$limit = 50;$sort = 'DESC';
if($this->get('page')) { $page = $this->get('page'); }
if($this->get('limit')){ $limit = $this->get('limit'); }
if($this->get('sort')) { $sort = $this->get('sort'); }
$result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort);
if($result_data['data_status'] == true)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data['data'];
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
* Get Full PD Details like all applicant's details, all PD related documents, PD Template and
* answersd questions,PD History details.
*/
public function getFullPDDetails_post()
{
$pdid = $this->post('pdid');
// Get All PD Masters Details
$result_data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid);
// Get All Applicant's Details
$result_data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid);
// Get All PD Related Documents
$result_data['pd_documnets'] = $this->PD_Model->getSignedPDDocsURL($pdid);
//Get All PD Template and It's Question with Answers
$result_data['pd_question_answer'] = $this->PD_Model->getPDQuestionAnswers($pdid);
//Get All PD Logs
$result_data['pd_logs'] = $this->PD_Model->getPDLogs($pdid);
$applicant_msg = '';
$pd_docs_msg = '';
$pd_question_answer_msg = '';
$pd_logs_msg = '';
if(!count($result_data['applicants_details']))
{
$applicant_msg = 'Applicant Details Not Found';
}
if(!count($result_data['pd_documnets']))
{
$pd_docs_msg = 'Documents Not Found';
}
if(!count($result_data['pd_question_answer']))
{
$pd_question_answer_msg = 'PD Details Not Found';
}
if(!count($result_data['pd_logs']['pd_master_logs']) && !count($result_data['pd_logs']['pd_applicants_logs']))
{
$pd_logs_msg = 'PD Logs Not Found';
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$data['msg'] = array('applicant_msg'=>$applicant_msg,'pd_docs_msg'=>$pd_docs_msg,'pd_question_answer_msg'=>$pd_question_answer_msg,'pd_logs_msg'=>$pd_logs_msg);
$this->response($data,REST_Controller::HTTP_OK);
}
}