This commit is contained in:
venbatechnologies@gmail.com 2018-10-23 15:26:16 +05:30
commit 7ed85149dc
4 changed files with 140 additions and 128 deletions

View File

@ -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', 'getAnswersForPD'); // 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');
@ -315,5 +315,8 @@ defined('PDCATEGORYWEIGHTAGEID') OR define('PDCATEGORYWEIGHTAGEID','pd_category_
defined('PDDETAIL') OR define('PDDETAIL','t_pd_details');
defined('PDDETAILID') OR define('PDDETAILID','pd_detail_id');
defined('COMMONMASTER') OR define('COMMONMASTER','h_common_masters');
defined('COMMONMASTERID') OR define('COMMONMASTERID','log_id');

View File

@ -122,6 +122,7 @@ $route['saveExistEntity'] = 'Entity_Management_Controller/saveExistEntity';
$route['getEntityBillingInfo'] = 'Entity_Management_Controller/getEntityBillingInfo';
$route['getLocationHierarchy'] = 'Entity_Management_Controller/getLocationHierarchy';
$route['getEntityMasterInfo'] = 'Entity_Management_Controller/getEntityMasterInfo';
$route['saveEntityBillingInfo'] = 'Entity_Management_Controller/saveEntityBillingInfo';
//PD RELATED
$route['triggerNewPD'] = 'PD_Controller/triggerNewPD';

View File

@ -49,36 +49,16 @@ class Entity_Management_Controller extends REST_Controller {
public function saveNewEntity_post()
{
//print_r($this->post());
$records = "";
$entity_child = "";
$entity_id = "";
if($this->post('records')){ $records = $this->post('records'); }
//print_r();
if(array_key_exists('entity_child',$records))
if(!isset($records['entity_id']))
{
$entity_child = $records['entity_child'];
unset($records['entity_child']);
}
if($records != "")
{
$entity_id = $this->Entity_Management_Model->saveRecords($records,ENTITY);//insert user records and get userid
}
if($entity_child != "")
{
foreach($entity_child as $child)
{
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'createdon'=>$records['createdon'],'fk_createdby'=>$records['fk_createdby']);
$this->Entity_Management_Model->saveRecords($entity_child_array,ENTITYCHILD);
}
}
if($entity_id != '' || $entity_id != null)
$entity_id = $this->Entity_Management_Model->saveRecords($records,ENTITY);//insert user records and get userid
if($entity_id != '' || $entity_id != null)
{
// If New Entity is Lender(2) type, then create a S3 bucket for corresponding lender.
@ -105,67 +85,18 @@ class Entity_Management_Controller extends REST_Controller {
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
}
public function saveExistEntity_post()
{
$records = "";
$entity_child = "";
$entity_id = "";
if($this->post('records')){ $records = $this->post('records'); }
if(array_key_exists('entity_child',$records))
{
$entity_child = $records['entity_child'];
unset($records['entity_child']);
}
if($records != "")
{
$where_condition_array = array('entity_id' => $records['entity_id']);
$entity_id = $this->Entity_Management_Model->updateRecords($records,ENTITY,$where_condition_array);
}
if($entity_child != "")
{
foreach($entity_child as $child)
{
if($child['entity_child_id'] != "" || $child['entity_child_id'] != null)
{
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'updatedon'=>$records['updatedon'],'fk_updatedby'=>$records['fk_updatedby'],'isactive'=>$child['isactive']);
$where_condition_array = array('entity_child_id'=>$child['entity_child_id']);
$this->Entity_Management_Model->updateRecords($entity_child_array,ENTITYCHILD,$where_condition_array);
}
else
{
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$records['entity_id'],'createdon'=>$records['updatedon'],'fk_createdby'=>$records['fk_updatedby']);
$this->Entity_Management_Model->saveRecords($entity_child_array,ENTITYCHILD);
}
}
}
else
{
$where_condition_array = array('entity_id' => $records['entity_id']);
$entity_id = $this->Entity_Management_Model->updateRecords($records,ENTITY,$where_condition_array);
if($entity_id != '' || $entity_id != null)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = $entity_id;
$data['record'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
@ -174,17 +105,11 @@ class Entity_Management_Controller extends REST_Controller {
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
}
/*
* Get Location Hierarchy as Region,state,city, and branch - wrapped as one array
@ -305,6 +230,112 @@ class Entity_Management_Controller extends REST_Controller {
}
//entity_billing_id, fk_entity_id, billing_name, addressline1, addressline2, addressline3, pincode, email, mobileno, gstno, pan, gststatecode, isactive
public function saveEntityBillingInfo_post()
{
$records = "";
$child_records = "";
$count = "";
if($this->post('records')){ $records = $this->post('records'); }
if($records != "" || $records != null)
{
if(isset($records['entity_billing_id']))
{
//UPDATE
if(isset($records['billing_contacts']))
{
$child_records = $records['billing_contacts'];
unset($records['billing_contacts']);
}
$where_condition_array = array('entity_billing_id' => $records['entity_billing_id']);
$entity_id = $this->Entity_Management_Model->updateRecords($records,ENTITYBILLING,$where_condition_array);
if($entity_billing_id != "" || $entity_billing_id != null)
{
if($child_records != "" || $child_records != null)
{
foreach($child_records as $key => $child)
{
if(isset($child['entity_billing_contact_id']))
{
$where_condition_array = array('entity_billing_contact_id' => $child['entity_billing_contact_id']);
$entity_billing_contact_id = $this->Entity_Management_Model->updateRecords($child,ENTITYBILLINGCONTACTINFO,$where_condition_array);
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
}
else
{
$entity_billing_contact_id = $this->Entity_Management_Model->saveRecords($child,ENTITYBILLINGCONTACTINFO);
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
}
}
}
}
if(($entity_billing_id != "" || $entity_billing_id != null) && $count == count($child_records))
{
$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_NO_CONTENT;
$data['msg'] = "Some Thing Went Wrong! Try Later";
$this->response($data,REST_Controller::HTTP_OK);
}
}
else
{
//INSERT
if(isset($records['billing_contacts']))
{
$child_records = $records['billing_contacts'];
unset($records['billing_contacts']);
}
$entity_billing_id = $this->Entity_Management_Model->saveRecords($records,ENTITYBILLING);
if($entity_billing_id != "" || $entity_billing_id != null)
{
if($child_records != "" || $child_records != null)
{
foreach($child_records as $key => $child)
{
$child['fk_entity_billing_id'] = $entity_billing_id;
$entity_billing_contact_id = $this->Entity_Management_Model->saveRecords($child,ENTITYBILLINGCONTACTINFO);
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
}
}
}
if(($entity_billing_id != "" || $entity_billing_id != null) && $count == count($child_records))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $entity_billing_id;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = "Some Thing Went Wrong! Try Later";
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
}

View File

@ -13,7 +13,7 @@ class PD_Model extends SPARQ_Model {
public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid)// $page represents mysql offset
{
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y ") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y") as completed_on');
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on');
$this->db->FROM(PDTRIGGER.' as PDTRIGGER');
$this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT');
$this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT');
@ -190,54 +190,29 @@ class PD_Model extends SPARQ_Model {
*/
public function getPDLogs($pdid)
{
$this->db->SELECT('PDLOGS.pd_id, PDLOGS.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDLOGS.lender_applicant_id, DATE_FORMAT(PDLOGS.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDLOGS.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDLOGS.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDLOGS.fk_pd_type,PDTYPE.type_name as pd_type_name, PDLOGS.pd_status,PDSTATUS.pd_status_name, PDLOGS.pd_specific_clarification, DATE_FORMAT(PDLOGS.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDLOGS.fk_createdby, DATE_FORMAT(PDLOGS.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDLOGS.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDLOGS.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDLOGS.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDLOGS.fk_pd_template_id,TEMPLATE.template_name, PDLOGS.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDLOGS.pd_officier_final_judgement, PDLOGS.pd_agency_id,AGENCY.full_name as agency_name, PDLOGS.loan_amount,PDLOGS.addressline1,PDLOGS.addressline2,PDLOGS.addressline3,PDLOGS.fk_city,CITY.name as city_name,PDLOGS.fk_state,STATE.name as state_name,PDLOGS.pincode');
$this->db->FROM(PDLOGS.' as PDLOGS');
$this->db->JOIN(ENTITY.' as ENTITY','PDLOGS.fk_lender_id = ENTITY.entity_id ');
$this->db->JOIN(PRODUCTS.' as PRODUCTS','PDLOGS.fk_product_id = PRODUCTS.product_id');
$this->db->JOIN(SUBPRODUCTS.' as SUBPRODUCTS','PDLOGS.fk_subproduct_id = SUBPRODUCTS.subproduct_id');
$this->db->JOIN(PDTYPE.' as PDTYPE','PDLOGS.fk_pd_type = PDTYPE.pd_type_id');
$this->db->JOIN(PDSTATUS.' as PDSTATUS','PDLOGS.pd_status = PDSTATUS.pd_status_id');
$this->db->JOIN(USERPROFILE.' as USERPROFILE','PDLOGS.fk_createdby = USERPROFILE.userid');
$this->db->JOIN(USERPROFILE.' as USERPROFILE1','PDLOGS.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDLOGS.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id');
$this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDLOGS.fk_pd_allocated_to = USERPROFILE2.userid');
$this->db->JOIN(TEMPLATE.' as TEMPLATE','PDLOGS.fk_pd_template_id = TEMPLATE.template_id');
$this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDLOGS.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id');
$this->db->JOIN(ENTITY.' as AGENCY','PDLOGS.pd_agency_id = AGENCY.entity_id','LEFT');
$this->db->JOIN(STATE.' as STATE','PDLOGS.fk_state = STATE.state_id ');
$this->db->JOIN(CITY.' as CITY','PDLOGS.fk_city = CITY.city_id');
$this->db->WHERE('PDLOGS.pd_id ',$pdid);
//$this->db->ORDER_BY('PDLOGS.pd_id',$sort);
//$this->db->LIMIT($limit,$page);
$result_array['pd_master_logs'] = $this->db->GET()->result_array();
// $pdid = 61;
$this->db->SELECT('PDAPPLICANTSLOGS.pd_co_applicant_id, PDAPPLICANTSLOGS.fk_pd_id, PDAPPLICANTSLOGS.applicant_name, PDAPPLICANTSLOGS.applicant_type, PDAPPLICANTSLOGS.mobile_no, PDAPPLICANTSLOGS.email, PDAPPLICANTSLOGS.addressline1, PDAPPLICANTSLOGS.addressline2, PDAPPLICANTSLOGS.addressline3, PDAPPLICANTSLOGS.fk_city, PDAPPLICANTSLOGS.fk_state, PDAPPLICANTSLOGS.pincode,PDAPPLICANTSLOGS.relation');
$this->db->FROM(PDAPPLICANTSLOGS.' as PDAPPLICANTSLOGS');
$this->db->JOIN(STATE.' as STATE','PDAPPLICANTSLOGS.fk_state = STATE.state_id');
$this->db->JOIN(CITY.' as CITY','PDAPPLICANTSLOGS.fk_city = CITY.city_id');
$this->db->WHERE('PDAPPLICANTSLOGS.fk_pd_id ',$pdid);
$result_array['pd_applicants_logs'] = $this->db->GET()->result_array();
return $result_array;
// $arrayForText = array("fk_lender_id", fk_entity_billing_id, lender_applicant_id, pd_date_of_initiation, fk_product_id, fk_subproduct_id, fk_pd_type, pd_status, pd_specific_clarification, createdon, fk_createdby, updatedon, fk_updatedby, fk_pd_allocation_type, fk_pd_allocated_to, fk_pd_template_id, fk_customer_segment, pd_officier_final_judgement, pd_agency_id, loan_amount, addressline1, addressline2, addressline3, fk_city, fk_state, pincode, bounce_reason, executive_id, pd_contact_person, pd_contact_mobileno, scheduled_on, completed_on, OTP);
// $sql = 'SELECT * FROM '.COMMONMASTER.' WHERE table_name = "'.PDTRIGGER.'" AND primary_key = '.$pdid;
// $logs = $this->db->query($sql)->result_array();
// print_r($logs);die();
}
/*
*Get Completed PD Questions and Answers.
* GET PD Question Answers Details by pdid
*/
public function getPDQuestionAnswers($pdid)
{
return array();
}
/*
*Get PD Master Details.
*/
public function getPDMasterDetails($pdid)
{
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y") as completed_on');
$this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on');
$this->db->FROM(PDTRIGGER.' as PDTRIGGER');
$this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT');
$this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT');
@ -298,15 +273,17 @@ class PD_Model extends SPARQ_Model {
$this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question,TEMPLATEQUESTION.template_question_id, TEMPLATEQUESTION.fk_template_id, TEMPLATEQUESTION.fk_question_id, TEMPLATEQUESTION.question_weightage, TEMPLATEQUESTION.question_answerable_by,TEMPLATEQUESTION.fk_template_question_category_id, TEMPLATEQUESTION.isactive,QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,PDDETAIL.pd_detail_id');
//$this->db->FROM(TEMPLATEQUESTION.' as TEMPLATEQUESTION');
$this->db->FROM(TEMPLATEQUESTION.' as TEMPLATEQUESTION');
$this->db->JOIN(QUESTIONS.' as QUESTIONS','TEMPLATEQUESTION.fk_question_id = QUESTIONS.question_id','LEFT');
$this->db->JOIN(QUESTIONANSWERTYPE.' as QUESTIONANSWERTYPE','QUESTIONS.fk_question_answertype = QUESTIONANSWERTYPE.question_answer_type_id','LEFT');
$this->db->JOIN(QUESTIONS.' as QUESTIONS','TEMPLATEQUESTION.fk_question_id = QUESTIONS.question_id');
$this->db->JOIN(QUESTIONANSWERTYPE.' as QUESTIONANSWERTYPE','QUESTIONS.fk_question_answertype = QUESTIONANSWERTYPE.question_answer_type_id');
$this->db->JOIN(PDDETAIL.' as PDDETAIL',"QUESTIONS.question_id = PDDETAIL.fk_question_id AND PDDETAIL.fk_pd_id = $pdid",'LEFT');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE','TEMPLATEQUESTION.fk_createdby = USERPROFILE.userid','LEFT');
// $this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATEQUESTION.fk_updatedby = USERPROFILE1.userid','LEFT');
$this->db->WHERE('TEMPLATEQUESTION.fk_template_question_category_id',$category['fk_question_category_id']);
$this->db->WHERE('TEMPLATEQUESTION.fk_template_id', $template_id);
//$this->db->WHERE('TEMPLATEQUESTION.fk_template_id',$template_id);
$questions = $this->db->GET()->result_array();
//print_r($questions);
$categories[$category_key]['questions_count'] = count($questions);
if(count($questions))