diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php
index 0fa3186b..e88bde74 100644
--- a/api/application/controllers/PD_Controller.php
+++ b/api/application/controllers/PD_Controller.php
@@ -37,12 +37,12 @@ class PD_Controller extends REST_Controller {
//$this->load->library('excel');
$this->load->library('phpmailer_library');
}
-
+
public function base_get()
{
$base64_img = "data:image/gif;base64,R0lGODlhPQBEAPeoAJosM//AwO/AwHVYZ/z595kzAP/s7P+goOXMv8+fhw/v739/f+8PD98fH/8mJl+fn/9ZWb8/PzWlwv///6wWGbImAPgTEMImIN9gUFCEm/gDALULDN8PAD6atYdCTX9gUNKlj8wZAKUsAOzZz+UMAOsJAP/Z2ccMDA8PD/95eX5NWvsJCOVNQPtfX/8zM8+QePLl38MGBr8JCP+zs9myn/8GBqwpAP/GxgwJCPny78lzYLgjAJ8vAP9fX/+MjMUcAN8zM/9wcM8ZGcATEL+QePdZWf/29uc/P9cmJu9MTDImIN+/r7+/vz8/P8VNQGNugV8AAF9fX8swMNgTAFlDOICAgPNSUnNWSMQ5MBAQEJE3QPIGAM9AQMqGcG9vb6MhJsEdGM8vLx8fH98AANIWAMuQeL8fABkTEPPQ0OM5OSYdGFl5jo+Pj/+pqcsTE78wMFNGQLYmID4dGPvd3UBAQJmTkP+8vH9QUK+vr8ZWSHpzcJMmILdwcLOGcHRQUHxwcK9PT9DQ0O/v70w5MLypoG8wKOuwsP/g4P/Q0IcwKEswKMl8aJ9fX2xjdOtGRs/Pz+Dg4GImIP8gIH0sKEAwKKmTiKZ8aB/f39Wsl+LFt8dgUE9PT5x5aHBwcP+AgP+WltdgYMyZfyywz78AAAAAAAD///8AAP9mZv///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAKgALAAAAAA9AEQAAAj/AFEJHEiwoMGDCBMqXMiwocAbBww4nEhxoYkUpzJGrMixogkfGUNqlNixJEIDB0SqHGmyJSojM1bKZOmyop0gM3Oe2liTISKMOoPy7GnwY9CjIYcSRYm0aVKSLmE6nfq05QycVLPuhDrxBlCtYJUqNAq2bNWEBj6ZXRuyxZyDRtqwnXvkhACDV+euTeJm1Ki7A73qNWtFiF+/gA95Gly2CJLDhwEHMOUAAuOpLYDEgBxZ4GRTlC1fDnpkM+fOqD6DDj1aZpITp0dtGCDhr+fVuCu3zlg49ijaokTZTo27uG7Gjn2P+hI8+PDPERoUB318bWbfAJ5sUNFcuGRTYUqV/3ogfXp1rWlMc6awJjiAAd2fm4ogXjz56aypOoIde4OE5u/F9x199dlXnnGiHZWEYbGpsAEA3QXYnHwEFliKAgswgJ8LPeiUXGwedCAKABACCN+EA1pYIIYaFlcDhytd51sGAJbo3onOpajiihlO92KHGaUXGwWjUBChjSPiWJuOO/LYIm4v1tXfE6J4gCSJEZ7YgRYUNrkji9P55sF/ogxw5ZkSqIDaZBV6aSGYq/lGZplndkckZ98xoICbTcIJGQAZcNmdmUc210hs35nCyJ58fgmIKX5RQGOZowxaZwYA+JaoKQwswGijBV4C6SiTUmpphMspJx9unX4KaimjDv9aaXOEBteBqmuuxgEHoLX6Kqx+yXqqBANsgCtit4FWQAEkrNbpq7HSOmtwag5w57GrmlJBASEU18ADjUYb3ADTinIttsgSB1oJFfA63bduimuqKB1keqwUhoCSK374wbujvOSu4QG6UvxBRydcpKsav++Ca6G8A6Pr1x2kVMyHwsVxUALDq/krnrhPSOzXG1lUTIoffqGR7Goi2MAxbv6O2kEG56I7CSlRsEFKFVyovDJoIRTg7sugNRDGqCJzJgcKE0ywc0ELm6KBCCJo8DIPFeCWNGcyqNFE06ToAfV0HBRgxsvLThHn1oddQMrXj5DyAQgjEHSAJMWZwS3HPxT/QMbabI/iBCliMLEJKX2EEkomBAUCxRi42VDADxyTYDVogV+wSChqmKxEKCDAYFDFj4OmwbY7bDGdBhtrnTQYOigeChUmc1K3QTnAUfEgGFgAWt88hKA6aCRIXhxnQ1yg3BCayK44EWdkUQcBByEQChFXfCB776aQsG0BIlQgQgE8qO26X1h8cEUep8ngRBnOy74E9QgRgEAC8SvOfQkh7FDBDmS43PmGoIiKUUEGkMEC/PJHgxw0xH74yx/3XnaYRJgMB8obxQW6kL9QYEJ0FIFgByfIL7/IQAlvQwEpnAC7DtLNJCKUoO/w45c44GwCXiAFB/OXAATQryUxdN4LfFiwgjCNYg+kYMIEFkCKDs6PKAIJouyGWMS1FSKJOMRB/BoIxYJIUXFUxNwoIkEKPAgCBZSQHQ1A2EWDfDEUVLyADj5AChSIQW6gu10bE/JG2VnCZGfo4R4d0sdQoBAHhPjhIB94v/wRoRKQWGRHgrhGSQJxCS+0pCZbEhAAOw==";
-
+
$output_file = APPPATH."/docs/temp_base64_image.png";
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
@@ -51,8 +51,8 @@ class PD_Controller extends REST_Controller {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:i:s');
-
-
+
+
$ifp = fopen( $output_file, 'wb' );
// split the string on commas
@@ -67,13 +67,13 @@ class PD_Controller extends REST_Controller {
fclose( $ifp );
print_r($output_file);
-
+
$tempdoc = $output_file;
$tempdocname = $temp_file_name.'.png';
$bucketname = LENDER_BUCKET_NAME_PREFIX.'1';
$key = 'pd'.'1'.'/'.$tempdocname ;
$sourcefile = $tempdoc;
-
+
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
print_r($s3result);
@@ -92,17 +92,17 @@ class PD_Controller extends REST_Controller {
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITY);
if(count($result_data))
{
-
+
foreach($result_data as $key => $value)
{
$fields = array('*');
$where_condition_array = array('isactive' => 1,'fk_entity_id' => $value['entity_id']);
$result_data[$key]['billing_address'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITYBILLING);
-
+
$fields = array('entity_lender_branch_id', 'branch_name');
$where_condition_array = array('fk_entity_id' => $value['entity_id'],'isactive'=>1);
$result_data[$key]['branches'] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENTITYLENDERBRANCH);
-
+
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@@ -135,7 +135,7 @@ class PD_Controller extends REST_Controller {
//array_push($result_data[$key],$subproducts);
$result_data[$key]['subproducts'] = $subproducts;
}
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
@@ -160,8 +160,8 @@ class PD_Controller extends REST_Controller {
$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;
@@ -189,8 +189,8 @@ class PD_Controller extends REST_Controller {
$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;
@@ -216,13 +216,13 @@ class PD_Controller extends REST_Controller {
// $where_condition_array = array('isactive' => 1);
// $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE);
-
+
$fields = array('city_id','name as city_name');
$where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid);
$cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY);
//array_push($result_data[$key],$cities);
$result_data['cities'] = $cities;
-
+
// $fields = array('pincode_id','pincode');
// $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid);
// $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE);
@@ -230,17 +230,17 @@ class PD_Controller extends REST_Controller {
$pincode = $this->db->DISTINCT()->SELECT('pincode,pincode_id')->FROM(PINCODE)->WHERE('fk_state_id',$stateid)->OR_WHERE('fk_state_id is null')->ORDER_BY('is_others')->GROUP_BY('pincode')->ORDER_BY('pincode')->GET()->result_array();
//print_r($this->db->last_query());
$result_data['pincode'] = $pincode;
-
-
-
-
+
+
+
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
-
-
+
+
}
@@ -249,22 +249,22 @@ class PD_Controller extends REST_Controller {
public function getStateCityNamesAndPincode_post()
{
$records = $this->post('records');
-
+
//get state name
$fields = array('name as state_name');
$where_condition_array = array('isactive' => 1,'state_id' => $records['state_id']);
$state = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE);
-
+
//get city name
$fields = array('name as city_name');
$where_condition_array = array('isactive' => 1,'city_id' => $records['city_id']);
$city = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY);
-
+
//get pincode
$fields = array('pincode');
$where_condition_array = array('isactive' => 1,'pincode_id' => $records['pincode_id']);
$pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE);
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = array('state_name' => $state[0]['state_name'],'city_name' => $city[0]['city_name'],'pincode' => $pincode[0]['pincode']);
@@ -291,25 +291,25 @@ class PD_Controller extends REST_Controller {
$cities = $this->db->DISTINCT()->SELECT('city_id,name as city_name')->FROM(CITY)->WHERE('fk_state_id',$res['state_id'])->OR_WHERE('fk_state_id is null')->ORDER_BY('fk_state_id,city_name')->GET()->result_array();
$result_data[$key]['cities'] = $cities;
//print_r($this->db->last_query());
-
+
// $fields = array('pincode_id','pincode');
// $where_condition_array = array('isactive' => 1,'fk_state_id' => $stateid);
// $pincode = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PINCODE);
// //array_push($result_data[$key],$cities);
// $result_data['pincode'] = $pincode;
-
-
+
+
}
-
-
+
+
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $result_data;
$this->response($data,REST_Controller::HTTP_OK);
-
-
-
+
+
+
}
@@ -369,16 +369,16 @@ class PD_Controller extends REST_Controller {
{
$fields = array('fk_template_id');
-
+
$where_condition_array = array('fk_lender_id'=>$pd_details['fk_lender_id'] ,'fk_product_id'=> $pd_details['fk_product_id'],'fk_customer_segment'=> $pd_details['fk_customer_segment'],'isactive' => 1);
-
+
$table = LENDERTEMPLATE;
-
+
$choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
if(count($choosed_template_id))// CHOOSE FILTERED TEMPLATE//
{
-
+
$pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id'];
}
else // CHOOSE GENERIC TEMPLATE//
@@ -407,9 +407,9 @@ class PD_Controller extends REST_Controller {
}
}
-
+
/***********************PD ALLOCATION TYPE PROCESS **********/
-
+
// $pd_details['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']);
@@ -431,48 +431,48 @@ class PD_Controller extends REST_Controller {
// $local_pd_allocation_type = $pd_details['fk_pd_allocation_type'];
// if($local_pd_allocation_type == 1)// AUTO - Load Balance Allocation
// {
-
+
// //echo "AUTO LOAD";
// //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);
// //echo "PD OFF";
// //print_r($list_of_pd_officers);
// $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['pd_status'] = ALLOCATED;
// //echo "final".$final_pd_officer_to_allocate;
-
+
// }
// 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");
-
+
//Generate Random string
/************ASSIGN Random URL******************/
@@ -500,53 +500,53 @@ class PD_Controller extends REST_Controller {
/************ASSIGN Random URL******************/
//End of Generate Random string
-
+
$pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : NULL;
$pd_id = $this->PD_Model->saveRecords($pd_details,PDTRIGGER);
-
-
+
+
/***********************PD DOCUMENTS UPLOAD SECTION FROM WEB***********/
if($pd_id != null || $pd_id != '')
{
//If PD created sucessfully then create a externa folder named with pd_id
-
+
if(!file_exists($this->external_path.'/pd_reports/'.$pd_id))
{
mkdir($this->external_path.'/pd_reports/'.$pd_id,0777);
}
-
+
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 FROM WEB***********/
if($pd_id != null || $pd_id != '')
{
-
-
+
+
if($pd_applicant_details != "" || $pd_applicant_details != null)
@@ -563,11 +563,11 @@ class PD_Controller extends REST_Controller {
}
}
}
-
+
/***********************PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/
if($pd_id != null || $pd_id != '')
{
-
+
if(!empty($pd_document_from_mobile))
{
$this->saveBase64Images($pd_id,null,null,null,$pd_document_from_mobile);
@@ -576,7 +576,7 @@ class PD_Controller extends REST_Controller {
// $temp_base64_string = $doc['image'];
// $title = $doc['Name'];
// $output_file = APPPATH."/docs/temp_base64_image.png";
-
+
// //Generate Random File Name
// $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
// $charactersLength = strlen($characters);
@@ -585,8 +585,8 @@ class PD_Controller extends REST_Controller {
// $randomString .= $characters[rand(0, $charactersLength - 1)];
// }
// $temp_file_name = $randomString.date('Y-m-d-h:i:s').'.png';
-
-
+
+
// $ifp = fopen( $output_file, 'wb' );
// $temp_data = explode( ',', $temp_base64_string );
// fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
@@ -596,22 +596,22 @@ class PD_Controller extends REST_Controller {
// $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(base64 type) UPLOAD SECTION FROM MOBILE***********/
-
-
+
+
/****************ADDTIONAL REQUIREMENTS SECTION*******************************************/
if($pd_id != null || $pd_id != '')
{
@@ -638,12 +638,12 @@ class PD_Controller extends REST_Controller {
}
}
}
-
-
+
+
$temp_address_id = null;
if(count($addresses))
{
-
+
foreach($addresses as $address_key => $address)
{
$address['fk_pd_id'] = $pd_id;
@@ -655,11 +655,11 @@ class PD_Controller extends REST_Controller {
$temp_address_id = $address_id;
}
}
-
+
}
-
-
-
+
+
+
//update parent pd id for same pd itself after PK generated
$temp = array('parent_pd_id' => $pd_id);
if(count($addresses) == 1)
@@ -669,7 +669,7 @@ class PD_Controller extends REST_Controller {
}
$where_condition_array = array('pd_id' => $pd_id);
$this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array);
-
+
if(count($company))
{
foreach($company as $company_key => $new_company)
@@ -679,17 +679,17 @@ class PD_Controller extends REST_Controller {
}
}
}
-
+
/****************END OF ADDTIONAL REQUIREMENTS SECTION*******************************************/
-
-
+
+
if($pd_id != null || $pd_id != '' && $count != 0)
{
// CALL pdnotification Helper function to send pd alerts @ params pdid,pdstatus
$logger = MYLOG::logFunction(null,$pd_id);
$logger->info("NEW PD Trigged : ".$pd_id,array('ENV'=>ENVIRONMENT,'DATA' => $pd_details));
PDALERTS::pdnotification($pd_id);
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $pd_id;
@@ -701,15 +701,15 @@ class PD_Controller extends REST_Controller {
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
-
+
public function savePDAdditionalRequiremets_post()
{
$records = $this->post('records');
$pd_addtional_requirements = $records['addtional_requirements'];
$count = 0;
-
+
if(count($pd_addtional_requirements))
{
foreach($pd_addtional_requirements as $requirement_key => $pd_addtional_requirement)
@@ -745,7 +745,7 @@ class PD_Controller extends REST_Controller {
$data['msg'] = "Some thing went wrong";
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
public function savePDDocsToBeCollected_post()
@@ -753,7 +753,7 @@ class PD_Controller extends REST_Controller {
$records = $this->post('records');
$docs_to_be_collected = $records['docs_to_be_collected'];
$count = 0;
-
+
if(count($docs_to_be_collected))
{
foreach($docs_to_be_collected as $pd_doc_key => $pd_doc_requirement)
@@ -789,9 +789,9 @@ class PD_Controller extends REST_Controller {
$data['msg'] = "Some thing went wrong";
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
-
+
/*
*
*Update PD trigger Master Details(Web app only) from PD trigger Edit/view page
@@ -815,17 +815,17 @@ class PD_Controller extends REST_Controller {
if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == INITIATED)
{
-
+
unset($pd_details['mobile_no']);
unset($pd_details['firstName']);
unset($pd_details['officerName']);
$pd_details['initiate_location'] = isset($pd_details['link']) ? $pd_details['link'] : null;;
unset($pd_details['link']);
-
+
}
if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == STARTED)
{
-
+
$pd_details['start_location'] = $pd_details['link'];
$pd_details['pd_visit_date'] = date('Y-m-d H:i:s');
unset($pd_details['link']);
@@ -836,23 +836,26 @@ class PD_Controller extends REST_Controller {
unset($pd_details['mobile_no']);
$pd_details['OTP'] = $OTP;
//$pd_details['OTP'] = '123456';
-
-
+
+
// $client = new \GuzzleHttp\Client();
// $response = $client->post($url);
- SMS_GUPSHUP::sendSMS($msg,$no,array('pd_id' => $pd_details['pd_id'],'status' => 'STARTED','msg' => 'Started OTP msg from PD controlller'));
+ if($exist_pd_details[0]['is_otp_enabled'] == 1)
+ {
+ SMS_GUPSHUP::sendSMS($msg,$no,array('pd_id' => $pd_details['pd_id'],'status' => 'STARTED','msg' => 'Started OTP msg from PD controlller'));
+ }
}
-
+
if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == COMPLETED)
{
-
+
if(array_key_exists('link',$pd_details))
{
$pd_details['complete_location'] = isset($pd_details['link']) ? $pd_details['link'] : null;;
unset($pd_details['link']);
}
-
+
//get satellite image blob and store it in DB
$pd_details['satellite_image_base64_blob'] = $this->getSatelliteImage($pd_details['pd_id']);
//die();
@@ -879,17 +882,17 @@ class PD_Controller extends REST_Controller {
{
$this->PD_Model->updateRecords($single_pd,PDTRIGGER,array('pd_id' => $single_pd['pd_id']));
}
-
-
-
+
+
+
}
//print_r($pd_details);
}
//die();
-
+
if(isset($pd_details['pd_status']) && ($pd_details['pd_status'] == TRIGGERED || $pd_details['pd_status'] == INITIATED))
{
-
+
/***********************CHOOSE PD TEMPALATE*********************/
$pd_details['fk_pd_template_id'] = $this->assignPDTempalate($pd_details['pd_id']);
//echo $pd_details['fk_pd_template_id'];
@@ -923,16 +926,16 @@ class PD_Controller extends REST_Controller {
$where_condition_array = array('pd_address_id' => $primary_address_id);
$temp_data = array('is_primary' => 1,'assigned_pd' => $pd_details['pd_id']);
-
+
$id = $this->PD_Model->updateRecords($temp_data,PDADDRESS,$where_condition_array);
}
if($pd_id_modified != null || $pd_id_modified != '' && $count != 0)
{
-
+
$logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $pd_details,'Pre-Status' => $exist_pd_details[0]['pd_status'],'Current_status' => $pd_details['pd_status']));
-
+
PDALERTS::pdnotification($pd_details['pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@@ -945,7 +948,7 @@ class PD_Controller extends REST_Controller {
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}//end of normal PD
else//#################### Handle Addtional PD
{
@@ -1002,17 +1005,17 @@ class PD_Controller extends REST_Controller {
$where_condition_array = array('pd_address_id' => $newpd['fk_address_id']);
$temp_data = array('assigned_pd' => $pd_id);
$id = $this->PD_Model->updateRecords($temp_data,PDADDRESS,$where_condition_array);
-
+
$logger = MYLOG::logFunction(null,$pd_id);
$logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED AND TEMPLATED ID - ".$newpd['fk_pd_template_id']." CHOOSED",array('ENV'=>ENVIRONMENT,'Parent-PDID' => $newpd['parent_pd_id'],'Addresss ID'=>$newpd['fk_address_id'] ,'PDID' => $pd_id,'PD Type' => "Addtional PD",'Current_status' => $newpd['pd_status']));
+
-
-
-
-
+
+
+
//PDALERTS::pdnotification($newpd['pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@@ -1047,31 +1050,31 @@ class PD_Controller extends REST_Controller {
}
}
-
+
}
//While PD Completion stage, send lenth of PD address
public function getPDCompleteDetails_post()
{
-
-
+
+
$records = $this->post('records');
$pdid = $records['pd_id'];
$pd_master_detials = $this->PD_Model->getPDMasterDetails($pdid);
-
+
$address_count = $this->db->SELECT('count(*) as count')->FROM(PDADDRESS.' as PDADDRESS')->WHERE('PDADDRESS.fk_pd_id',$pd_master_detials[0]['parent_pd_id'])->WHERE('assigned_pd is null')->WHERE('PDADDRESS.isactive',1)->GET()->result_array();
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = array('address_count' => (int)$address_count[0]['count']);
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
public function assignPDTempalate($data)
{
-
+
//print_r($data);
if(!is_array($data))
{
@@ -1081,11 +1084,11 @@ public function assignPDTempalate($data)
$where_condition_array = array('pd_id' => $data);
$res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
}
-
+
$templateid = null;
$fields = array('fk_template_id');
$where_condition_array = array();
-
+
if(!is_array($data))
{
$where_condition_array = array('fk_lender_id'=>$res_array[0]['fk_lender_id'] ,'fk_product_id'=> $res_array[0]['fk_product_id'],'fk_customer_segment'=> $res_array[0]['fk_customer_segment'],'isactive' => 1);
@@ -1097,23 +1100,23 @@ public function assignPDTempalate($data)
$logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED",array('ENV'=>ENVIRONMENT,'DATA' => $data));
$where_condition_array = array('fk_lender_id'=>$data['lender'] ,'fk_product_id'=> $data['product'],'fk_customer_segment'=> $data['customer_segment'],'isactive' => 1);
}
-
-
+
+
$table = LENDERTEMPLATE;
-
+
$choosed_template_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
-
+
if(count($choosed_template_id))// CHOOSE FILTERED TEMPLATE//
{
$templateid = $choosed_template_id[0]['fk_template_id'];
-
+
}
else // CHOOSE GENERIC TEMPLATE//
{
//echo "CHOOSE GENERIC ";
$customer_segment = isset($res_array[0]['fk_customer_segment']) ? $res_array[0]['fk_customer_segment'] : $data['customer_segment'];
-
-
+
+
if($customer_segment == 1 || $customer_segment == 2)
{
//SAL - (CASH/CHQ)
@@ -1128,7 +1131,7 @@ public function assignPDTempalate($data)
{
//* SENP/SEP - (AI)
$templateid = 3;
-
+
}
else if($customer_segment == 8)
{
@@ -1137,13 +1140,13 @@ public function assignPDTempalate($data)
}
}
return $templateid;
-
-
-
-
+
+
+
+
}
-
-
+
+
public function updatePDAddress_post()
{
$records = $this->post('records');
@@ -1154,7 +1157,7 @@ public function assignPDTempalate($data)
{
$value['is_primary'] = 1;
}
-
+
if($value['pd_address_id'] != "" || $value['pd_address_id'] != null)
{
$where_condition_array = array('pd_address_id' => $value['pd_address_id']);
@@ -1167,7 +1170,7 @@ public function assignPDTempalate($data)
if($id != "" || $id != null){ $count++; }
}
}
-
+
if($count == count($records))
{
$data['dataStatus'] = true;
@@ -1183,7 +1186,7 @@ public function assignPDTempalate($data)
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
/**
* Pd Discussion OTP Checking function
* sriram
@@ -1207,7 +1210,7 @@ public function assignPDTempalate($data)
{
$where_condition_array = array('pd_id' => $pdotp['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($updatePd,PDTRIGGER,$where_condition_array);
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
@@ -1223,7 +1226,7 @@ public function assignPDTempalate($data)
else
{
//echo "WITHOUT OTP CALLED";
-
+
$updatePd['pd_id'] = $pdotp['pd_id'];
$updatePd['pd_status'] = INPROGRESS;
$updatePd['is_otp_done'] = 0;
@@ -1231,20 +1234,20 @@ public function assignPDTempalate($data)
$updatePd['otp_reject_other_reason'] = $pdotp['other_reason'];
//$updatePd['updatedon'] = date('Y-m-d h:m:00');
$updatePd['fk_updatedby'] = $pdotp['fk_updatedby'];
-
+
$where_condition_array = array('pd_id' => $pdotp['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($updatePd,PDTRIGGER,$where_condition_array);
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
-
-
-
+
+
+
/*
*
@@ -1278,7 +1281,7 @@ public function assignPDTempalate($data)
}
}
}
-
+
if($count != 0 && count($pd_applicant_details) == $count)
{
$data['dataStatus'] = true;
@@ -1314,7 +1317,7 @@ public function assignPDTempalate($data)
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$pd_document_details[0]['fk_pd_id'].'/'.$pd_document_details[0]['pd_document_name'];
$this->aws_s3->deleteSingleObjFromBucket($bucketname,$key);
-
+
//delete old entry
$modified = $this->db->where('pd_document_id',$pdid)->$this->db->delete(PDDOCUMENTS);
if($modified)
@@ -1330,8 +1333,8 @@ public function assignPDTempalate($data)
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
-
-
+
+
}
}
@@ -1356,37 +1359,37 @@ public function assignPDTempalate($data)
{
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
{
@@ -1399,7 +1402,7 @@ public function assignPDTempalate($data)
$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);
@@ -1407,13 +1410,13 @@ public function assignPDTempalate($data)
}
}
}
-
-
+
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
@@ -1471,26 +1474,26 @@ public function assignPDTempalate($data)
$where_condition_array = array('pd_id' => $records['fk_pd_id']);
$temp_array = array('pd_status' => SCHEDULED,'fk_updatedby'=>$records['fk_scheduled_by'],'scheduled_on'=>$records['schedule_time']);
$pd_id_modified = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
-
+
// /******* Code Snippt for Save Template Category Weightage info to PD category Info*/
// $fields = array('fk_pd_template_id');
// $where_condition_array = array('pd_id'=>$records['fk_pd_id']);
// $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
-
+
// if(count($res_array))
// {
// $fields = array('fk_pd_template_id');
// $where_condition_array = array('pd_id'=>$records['fk_pd_id']);
// $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
-
+
// if(count($res_array))
// {
// $template_id = $res_array[0]['fk_pd_template_id'];
-
+
// $fields = array('fk_question_category_id','weightage');
// $where_condition_array = array('fk_template_id'=>$template_id);
// $template_categories = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TEMPLATECATEGORYWEIGHTAGE);
-
+
// foreach($template_categories as $key => $category)
// {
// $temp_data = array('fk_pd_id'=>$records['fk_pd_id'],'fk_category_id'=>$category['fk_question_category_id'],'pd_category_weightage'=>$category['weightage']);
@@ -1499,8 +1502,8 @@ public function assignPDTempalate($data)
// }
// }
/******* End of Code Snippt Save Template Category Weightage info to PD category Info*/
-
-
+
+
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['fk_pd_id']);
@@ -1559,11 +1562,11 @@ public function assignPDTempalate($data)
//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','fk_pd_type_id');
-
+
$where_condition_array = array('fk_team_id' => $temp_city_id[0]['pdteam_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)
@@ -1573,13 +1576,13 @@ public function assignPDTempalate($data)
$this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']);
$names = $this->db->GET()->result_array();
if(count($names)){
-
-
+
+
$list_of_pd_officers[$key]['first_name'] = $names[0]['first_name'];
$list_of_pd_officers[$key]['last_name'] = $names[0]['last_name'];
$list_of_pd_officers[$key]['mobile_no'] = $names[0]['mobile_no'];
$list_of_pd_officers[$key]['count'] = 0;
-
+
$this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,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.lender_applicant_id,ENTITY.short_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');
@@ -1587,7 +1590,7 @@ public function assignPDTempalate($data)
$this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT');
$this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT');
$this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT');
-
+
$this->db->OR_GROUP_START();
$this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED);
$this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS);
@@ -1606,9 +1609,9 @@ public function assignPDTempalate($data)
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
-
+
$bucket_name = PROFILE_PICTURE_BUCKET_NAME;
$profilepics3path = 'sineedge/'.$names[0]['profilepic'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes');
@@ -1630,7 +1633,7 @@ public function assignPDTempalate($data)
{
foreach($central_pd_officers as $k => $central_pd_officer)
{
-
+
//Get PD Details assigned to Central Officers
$this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,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.lender_applicant_id,ENTITY.short_name');
$this->db->FROM(PDTRIGGER.' as PDTRIGGER');
@@ -1639,7 +1642,7 @@ public function assignPDTempalate($data)
$this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT');
$this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT');
$this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT');
-
+
$this->db->OR_GROUP_START();
$this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED);
$this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS);
@@ -1653,8 +1656,8 @@ public function assignPDTempalate($data)
$central_pd_officers[$k]['pd_details'] = $pd_count;
$central_pd_officers[$k]['count'] = count($pd_count); }
//End Get PD Details assigned to Central Officers
-
-
+
+
$bucket_name = PROFILE_PICTURE_BUCKET_NAME;
$profilepics3path = 'sineedge/'.$central_pd_officer['profilepic'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes');
@@ -1662,7 +1665,7 @@ public function assignPDTempalate($data)
}
}
}
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers);
@@ -1675,35 +1678,35 @@ public function assignPDTempalate($data)
$data['msg'] = 'Officers Records Not Found!';
$this->response($data,REST_Controller::HTTP_OK);
}
+
-
-
+
}
}
-
-
-
-
+
+
+
+
}
else // Find Officers in General Team
{
-
-
-
+
+
+
//Find General Team ID
$fields = array('pdteam_id');
$where_condition_array = array('team_name' => "General");
$general_team_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTEAM);
-
+
if(count($general_team_id))
{
-
-
+
+
$fields = array('fk_user_id','fk_pd_type_id');
$where_condition_array = array('fk_team_id' => $general_team_id[0]['pdteam_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)
@@ -1712,14 +1715,14 @@ public function assignPDTempalate($data)
$this->db->FROM(USERPROFILE.' as USERPROFILE');
$this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']);
$names = $this->db->GET()->result_array();
-
-
+
+
if(count($names)){
$list_of_pd_officers[$key]['first_name'] = $names[0]['first_name'];
$list_of_pd_officers[$key]['last_name'] = $names[0]['last_name'];
$list_of_pd_officers[$key]['mobile_no'] = $names[0]['mobile_no'];
$list_of_pd_officers[$key]['count'] = 0;
-
+
$this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,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.lender_applicant_id,ENTITY.short_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');
@@ -1746,18 +1749,18 @@ public function assignPDTempalate($data)
$list_of_pd_officers[$key]['pd_details'] = $pd_count;
$list_of_pd_officers[$key]['count'] =count($pd_count);
}
-
+
// Get Profile Pic from S3
-
+
$bucket_name = PROFILE_PICTURE_BUCKET_NAME;
$profilepics3path = 'sineedge/'.$names[0]['profilepic'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes');
$list_of_pd_officers[$key]['profile_url'] = $singed_uri;
-
-
+
+
}
}
-
+
// Get Central PD Officers List
$central_pd_officers = array();
if($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3)
@@ -1768,13 +1771,13 @@ public function assignPDTempalate($data)
$this->db->JOIN(ROLES.' as ROLES','USERPROFILEROLES.user_role = ROLES.role_id');
$this->db->WHERE('ROLES.role_id',2);
$central_pd_officers = $this->db->GET()->result_array();
-
+
if(count($central_pd_officers))
{
foreach($central_pd_officers as $k => $central_pd_officer)
{
-
-
+
+
//Get PD Details assigned to Central Officers
$this->db->SELECT('pd_id,pd_status,fk_pd_type,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i:%s %p") as scheduled_on,PDAPPLICANTSDETAILS.applicant_name,PDTYPE.type_name as pd_type_name,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode');
$this->db->FROM(PDTRIGGER.' as PDTRIGGER');
@@ -1782,7 +1785,7 @@ public function assignPDTempalate($data)
$this->db->JOIN(PDTYPE.' as PDTYPE','PDTRIGGER.fk_pd_type = PDTYPE.pd_type_id AND PDTYPE.isactive = 1');
$this->db->JOIN(STATE.' as STATE','PDTRIGGER.fk_state = STATE.state_id ','LEFT');
$this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id','LEFT');
-
+
$this->db->OR_GROUP_START();
$this->db->OR_WHERE('PDTRIGGER.pd_status',SCHEDULED);
$this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS);
@@ -1796,8 +1799,8 @@ public function assignPDTempalate($data)
$central_pd_officers[$k]['pd_details'] = $pd_count;
$central_pd_officers[$k]['count'] = count($pd_count); }
//End Get PD Details assigned to Central Officers
-
-
+
+
$bucket_name = PROFILE_PICTURE_BUCKET_NAME;
$profilepics3path = 'sineedge/'.$central_pd_officer['profilepic'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes');
@@ -1835,7 +1838,7 @@ public function assignPDTempalate($data)
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
/* PD_Triggerd and PD_Co_Applocants Details only for Listing Page
@param page/offset
@param limit
@@ -1845,18 +1848,24 @@ public function assignPDTempalate($data)
public function listLessPDDetails_get()
{
$page = 0;$limit = 1000;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate ="";
- $lenderid = "";$status="";
+ $lenderid = "";$status="";$lender_details = array();
if($this->get('page')) { $page = $this->get('page'); }
if($this->get('limit')){ $limit = $this->get('limit'); }
if($this->get('sort')) { $sort = $this->get('sort'); }
if($this->get('pdofficerid')) { $pdofficerid = $this->get('pdofficerid'); }
- if($this->get('lenderid')) { $lenderid = $this->get('lenderid'); }
+ if($this->get('lenderid'))
+ {
+ $lenderid = $this->get('lenderid');
+ $lender_details = $this->getLenderHierarchyForPDListing($lenderid);
+
+
+ }
if($this->get('datetype')) { $datetype = $this->get('datetype'); }
if($this->get('fdate')) { $fdate = $this->get('fdate'); }
if($this->get('tdate')) { $tdate = $this->get('tdate'); }
if($this->get('status')) { $status = $this->get('status'); }
- $result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status);
+ $result_data = $this->PD_Model->listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status,$lender_details);
if($result_data['data_status'] == true)
{
@@ -1873,8 +1882,47 @@ public function assignPDTempalate($data)
}
}
-
-
+
+ // PD listing based on lender role hierarchy
+ function getLenderHierarchyForPDListing($lender_user_id)
+ {
+ //get role of lender_user_id`
+ $user_role_details = $this->PD_Model->getLenderHierarchyForPDListing($lender_user_id);
+ //print_r($user_role_details);
+ if(count($user_role_details))
+ {
+ $role_id = $user_role_details[0]['user_role'];
+ switch($role_id)
+ {
+ case 11:// National Sales Head
+ case 12:// National Credit Head
+ //Get all PD's which were triggered in this entity id
+ return array('entity' => $user_role_details[0]['fk_entity_id']);
+ case 13:// Zonal Sales Head
+ case 14:// Zonal Credit Head
+ //Get all cities id's from m_entity_region_mapping table using region_id / zone id
+ $citiesInCurrentZone = $this->PD_Model->selectCustomRecords(array('fk_city_id'),ENTITYREGION,array('fk_region_id' => $user_role_details[0]['fk_region_id']));
+ //Get all PD's which were triggered in this entity id and city id's in current zone
+ return array('entity' => $user_role_details[0]['fk_entity_id'],'zone' => $citiesInCurrentZone);
+ case 15://Area Sales Head
+ case 16://Area Credit Head
+ //Get all PD's which were triggered in this entity id and city id's in current zone
+ return array('entity' => $user_role_details[0]['fk_entity_id'],'state' => $user_role_details[0]['fk_state']);
+ case 17://City Sales Head
+ case 18://City Credit Head
+ //Get all PD's which were triggered in this entity id and current city
+ return array('entity' => $user_role_details[0]['fk_entity_id'],'city' => $user_role_details[0]['fk_city']);
+ case 17://Branch Sales
+ case 18://Branch Credit
+ //Get all PD's which were triggered in this entity id and current branch
+ return array('entity' => $user_role_details[0]['fk_entity_id'],'branch' => $user_role_details[0]['entity_lender_branch_id']);
+ default:
+ return array();
+ }
+ }
+ }
+
+
public function filterPDList_post()
{
//echo "Hi";
@@ -1907,9 +1955,9 @@ public function assignPDTempalate($data)
$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.
@@ -1926,7 +1974,7 @@ public function assignPDTempalate($data)
// 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);
@@ -1970,14 +2018,14 @@ public function assignPDTempalate($data)
$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);
-
+
}
/******** for Load Whole PD Template for PD Screen @param template_id***************/
@@ -2037,19 +2085,19 @@ public function assignPDTempalate($data)
if($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null)
{
-
+
if($record['answers'] != "" || $record['answers'] != null)
{
$answers_array = $record['answers'];
unset($record['answers']);
}
-
+
if($record['images'] != "" || $record['images'] != null)
{
$images_array = $record['images'];
unset($record['images']);
}
-
+
$where_condition_array = array('pd_detail_id' => $record['pd_detail_id']);
$pd_detail_id = $this->PD_Model->updateRecords($record,PDDETAIL,$where_condition_array);
@@ -2068,17 +2116,17 @@ public function assignPDTempalate($data)
$temp_array = array('isactive' => 0);
$pd_detail_answer_id = $this->PD_Model->updateRecords($temp_array,PDANSWER,$where_condition_array);
}
-
+
foreach($answers_array as $answer_key => $answer)
{
if($answer['pd_detail_answer_id'] == "" || $answer['pd_detail_answer_id'] == null)
{
-
+
//INsert New Answers
$answer['fk_pd_detail_id'] = $record['pd_detail_id'];
$pd_detail_answer_id = $this->PD_Model->saveRecords($answer,PDANSWER);
if($pd_detail_answer_id != "" || $pd_detail_answer_id != null){ $answer_count++; }
-
+
}
else
{
@@ -2088,7 +2136,7 @@ public function assignPDTempalate($data)
$pd_detail_answer_id = $this->PD_Model->updateRecords($answer,PDANSWER,$where_condition_array);
if($pd_detail_answer_id != "" || $pd_detail_answer_id != null){ $answer_count++; }
}
-
+
}
}
@@ -2097,16 +2145,16 @@ public function assignPDTempalate($data)
{
foreach($images_array as $image_key => $image)
{
-
-
+
+
//Get Lender ID
$sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"];
$lender_id = $this->db->query($sql)->result_array();
-
+
$temp_base64_string = $image['pd_document_name'];
$title = $image['pd_document_title'];
$output_file = APPPATH."/docs/temp_base64_image.jpeg";
-
+
//Generate Random File Name
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
@@ -2115,8 +2163,8 @@ public function assignPDTempalate($data)
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:i:s').'.jpeg';
-
-
+
+
$ifp = fopen( $output_file, 'wb' );
$temp_data = explode( ',', $temp_base64_string );
fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
@@ -2126,10 +2174,10 @@ public function assignPDTempalate($data)
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$record['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)
{
$image['pd_document_name'] = $tempdocname;
@@ -2137,15 +2185,15 @@ public function assignPDTempalate($data)
$image['fk_pd_id'] = $record['fk_pd_id'];
$pd_document_id = $this->PD_Model->saveRecords($image,PDDOCUMENTS);
if($pd_document_id != "" || $pd_document_id != null){ $image_count++; }
-
+
}
-
+
}
}
if(($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count)
{
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
@@ -2163,15 +2211,15 @@ public function assignPDTempalate($data)
}
else
{
+
-
-
+
if($record['answers'] != "" || $record['answers'] != null)
{
$answers_array = $record['answers'];
unset($record['answers']);
}
-
+
if($record['images'] != "" || $record['images'] != null)
{
$images_array = $record['images'];
@@ -2196,16 +2244,16 @@ public function assignPDTempalate($data)
{
foreach($images_array as $image_key => $image)
{
-
-
+
+
//Get Lender ID
$sql = 'SELECT fk_lender_id FROM '. PDTRIGGER .' WHERE pd_id ='.$record["fk_pd_id"];
$lender_id = $this->db->query($sql)->result_array();
-
+
$temp_base64_string = $image['pd_document_name'];
$title = $image['pd_document_title'];
$output_file = APPPATH."/docs/temp_base64_image.jpeg";
-
+
//Generate Random File Name
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
@@ -2214,8 +2262,8 @@ public function assignPDTempalate($data)
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:i:s').'.jpeg';
-
-
+
+
$ifp = fopen( $output_file, 'wb' );
$temp_data = explode( ',', $temp_base64_string );
fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
@@ -2225,27 +2273,27 @@ public function assignPDTempalate($data)
$bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$record['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)
{
$image['pd_document_name'] = $tempdocname;
-
+
$image['fk_pd_detail_id'] = $record['pd_detail_id'];
$image['fk_pd_id'] = $record['fk_pd_id'];
$pd_document_id = $this->PD_Model->saveRecords($image,PDDOCUMENTS);
if($pd_document_id != "" || $pd_document_id != null){ $image_count++; }
-
+
}
-
+
}
}
if(($pd_detail_id != "" || $pd_detail_id != null) && count($images_array) == $image_count && count($answers_array) == $answer_count)
{
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $pd_detail_id;
@@ -2259,11 +2307,11 @@ public function assignPDTempalate($data)
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
-
-
+
+
+
}
-
+
@@ -2277,12 +2325,12 @@ public function assignPDTempalate($data)
$pd_id = $this->post('pd_id');
$template_id = $this->post('template_id');
$category_id = $this->post('category_id');
-
+
$answers = $this->PD_Model->getAnswersForPD($question_id,$pd_id,$template_id,$category_id);
if(count($answers))
{
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $answers;
@@ -2295,7 +2343,7 @@ public function assignPDTempalate($data)
$data['msg'] = "Something Went Wrong..!Try Later";
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
@@ -2353,12 +2401,12 @@ public function assignPDTempalate($data)
}
-
+
if($formid == 10)
{
$this->updateSubProductFromLoanDetailsForm($records);
}
-
+
//From Business form save Employee Salary as Business Expenses
if($formid == 13)
{
@@ -2370,7 +2418,7 @@ public function assignPDTempalate($data)
$this->PD_Model->updateRecords(array('is_business_photo_saved' => 1),T_PD_INLINE_PHOTO_FORM_STATUS,array('fk_pd_id' => $pdid));
}
}
-
+
if($formid == 22)
{
$this->saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records);
@@ -2383,15 +2431,15 @@ public function assignPDTempalate($data)
{
$where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid,'company_id' => $company_id);
}
-
+
if($rental_count_id != null)
{
$where_condition_array['rental_count_id'] = $rental_count_id;
}
-
+
$id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array);
-
+
/*****Call Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA******/
if(PROCESSJSON == true)
{
@@ -2400,7 +2448,7 @@ public function assignPDTempalate($data)
case 1:
$processed_json = GETPROCESSEDJSON::convertSupplierForm($records,$formid);
break;
-
+
case 2:
$processed_json = GETPROCESSEDJSON::convertClientForm($records,$formid);
break;
@@ -2411,7 +2459,7 @@ public function assignPDTempalate($data)
case 5:
$processed_json = GETPROCESSEDJSON::convertAddressForm($records,$formid);
break;
-
+
case 6:
$processed_json = GETPROCESSEDJSON::convertOtherFamilyDetailsForm($records,$formid);
break;
@@ -2427,7 +2475,7 @@ public function assignPDTempalate($data)
case 10:
$processed_json = GETPROCESSEDJSON::convertLoanDetailsForm($records,$formid);
break;
-
+
case 11: //In Stock UOM Only - also coming Text - right now No need to convert.
$processed_json = GETPROCESSEDJSON::convertStockDetailsForm($records,$formid);
//print_r($processed_json);die();
@@ -2435,11 +2483,11 @@ public function assignPDTempalate($data)
case 12:
$processed_json = $records;
break;
-
+
case 14: // There is no master Data in Financial Form
$processed_json = $records;
break;
-
+
case 13:
$processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records,$formid);
break;
@@ -2452,18 +2500,18 @@ public function assignPDTempalate($data)
case 18:
$processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records,$formid);
break;
-
+
case 19:
$processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records,$formid);
break;
case 20:
$processed_json = GETPROCESSEDJSON::convertFinalRemarksForm($records,$formid);
break;
-
+
case 21:
$processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid);
break;
-
+
case 22:
$processed_json = GETPROCESSEDJSON::convertBusinessAssetsForm($records,$formid);
break;
@@ -2476,16 +2524,16 @@ public function assignPDTempalate($data)
$records['docs_to_be_sighted'] = $processed_json['docs_to_be_sighted'];
unset($processed_json['docs_to_be_sighted']);
-
+
//default:
//echo "Something Wrong! Form ID did not match, Contact System Administrator";
}
}
-
-
-
+
+
+
/*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/
-
+
unset($records['pdid']);
unset($records['formid']);
unset($records['fk_createdby']);
@@ -2497,22 +2545,22 @@ public function assignPDTempalate($data)
{
$processed_json = json_encode($processed_json);
}
-
-
+
+
$temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id);
-
+
$id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON);
if($id != "" || $id != null)
{
// Update form dummy entry against Additional PD common form ID to avoid every time fetch data from additional PD forms - scenarios like exist loan obligations, other family details
-
+
// if($formid == 4)//other asset - here this should happen for only if it is additional PD.
// {
// $temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$additional_pd_id,'fk_createdby'=>$createdby,'json'=>$records,'processed_json' => $processed_json,'rental_count_id' => $rental_count_id);
// $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON);
// }
// End Of update Additional Entry
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $id;
@@ -2525,7 +2573,7 @@ public function assignPDTempalate($data)
$data['msg'] = 'Something Went Wrong! Try Later..!';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
@@ -2545,13 +2593,13 @@ public function getPDFormDetailsJSON_post()
$parent_form_index = array_search($pd_form_id,$parent_forms);
$additional_pd_id = $pd_id;
$pd_id = $parent_form_index != null ? $parent_pd_id : $pd_id;
-
+
}
//echo $pd_id;echo $pd_form_id;
-
+
if($pd_form_id == 18)
{
-
+
$fields = array('*');
$where_condition_array = array('fk_pd_id' => $pd_id,'fk_form_id' =>$pd_form_id , 'isactive' => 1);
$form_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
@@ -2562,7 +2610,7 @@ public function getPDFormDetailsJSON_post()
$fields = array('json','processed_json');
$where_condition_array = array('isactive' => 1,'fk_form_id'=>$pd_form_id,'fk_pd_id'=>$parent_pd_id);
$rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
+
if(count($rec))
{
$temp_json = $this->renewGeneralFormForAddtionalPD($rec[0]['json']);
@@ -2571,7 +2619,7 @@ public function getPDFormDetailsJSON_post()
$data['records'] = $temp_json;
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
}
@@ -2579,14 +2627,14 @@ public function getPDFormDetailsJSON_post()
if($is_addtional_pd == 1 && $pd_form_id == 5)//address form && ($parent_pd_id != $pd_id)
{
-
+
$fields = array('*');
$where_condition_array = array('fk_pd_id' => $pd_id,'fk_form_id' =>$pd_form_id , 'isactive' => 1);
$form_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
+
if(count($form_count))
{
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = json_decode($form_count[0]['json']);
@@ -2605,29 +2653,29 @@ public function getPDFormDetailsJSON_post()
//construct address form jsn format here
$address = array();
$address[] = array('address' => $temp_address['addressline1'],'address_type' => "",'address_type_others' => '','state'=>$temp_address['fk_state'],'city'=>$temp_address['fk_city'],'citySearch' =>'','stateSearch'=>'','citySearch'=>'','pinSearch' => '','pincode'=>$temp_address['pincode'],'pincode_others' => '','locality' => '','locality_others'=>'','pd_location' => '','comment_locality' => '','estimated_area' => '','uom' => '','uom_others'=>'');
-
+
$records['addresses'] = $address;
$records['address_form_remark'] = '';
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $records;
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
}
-
+
$fields = array('json','processed_json');
$where_condition_array = array('isactive' => 1,'fk_form_id'=>$pd_form_id,'fk_pd_id'=>$pd_id);
-
+
if($company_id != null)
{
$where_condition_array = array('fk_form_id'=>$pd_form_id,'fk_pd_id'=>$pd_id,'company_id' => $company_id,'isactive' => 1);
}
$rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
//print_r($this->db->last_query());
-
+
// if(count($rec))
// {
// if($pd_form_id == 8 && $is_addtional_pd == 1)
@@ -2636,10 +2684,10 @@ public function getPDFormDetailsJSON_post()
// $additional_count = $this->PD_Model->selectCustomRecords(array('*'),array('fk_form_id'=>8,'fk_pd_id'=>$additional_pd_id,'company_id' => $company_id,'isactive' => 1),PDFORMDETAILSJSON);
// if(!count($additional_count))
// {
-
+
// //get addtional PD business and other assets details and attach it with existing loan Obligation From(Parent PD existing Loan JSON Details).
// $json = $this->getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($rec[0]['json'],$pd_id,$additional_pd_id,$company_id);
-
+
// $data['dataStatus'] = true;
// $data['status'] = REST_Controller::HTTP_OK;
// $data['records'] = $json;
@@ -2647,17 +2695,17 @@ public function getPDFormDetailsJSON_post()
// }
// }
// }
-
-
+
+
if(count($rec))
{
$json = null;
if($pd_form_id == 17)
{
-
+
foreach($rec as $r)
{
-
+
$json[] = json_decode($r['json'],true);
}
}
@@ -2682,8 +2730,8 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'No Data Available';
$this->response($data,REST_Controller::HTTP_OK);
}
-
-
+
+
}
//get documents to be sight form images S3 url's and fetch it to frond end form
@@ -2695,9 +2743,9 @@ public function getPDFormDetailsJSON_post()
{
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
//echo $bucketname;
-
+
foreach ($pd_documnets as $doc_key => $doc_value) {
-
+
foreach ($credit_manager_form_data['docs_to_be_sighted'] as $docs_to_be_sighted_key => $docs_to_be_sighted_value)
{
if(isset($docs_to_be_sighted_value['img']) && $docs_to_be_sighted_value['img'] == $doc_value['pd_document_id'])
@@ -2714,8 +2762,8 @@ public function getPDFormDetailsJSON_post()
}
return $credit_manager_form_data;
}
-
-
+
+
public function getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets($parentpd_existing_loan_details,$pd_id,$additional_pd_id,$company_id = null)
{
$parentpd_existing_loan_details = json_decode($parentpd_existing_loan_details,true);
@@ -2729,20 +2777,20 @@ public function getPDFormDetailsJSON_post()
//Get Business Assets
$fields = array('json','processed_json');
$where_condition_array = array('isactive' => 1,'fk_form_id'=>22,'fk_pd_id'=>$additional_pd_id);
-
+
if($company_id != null)
{
$where_condition_array['company_id'] = $company_id;
}
$business_assests = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
+
if(count($other_assests))
{
$other_assests = json_decode($other_assests[0]['json'],true);
//print_r($other_assests);
foreach($other_assests['assets_details'] as $other_assest)
{
-
+
if($other_assest['emi'] == 'ýes')
{
$converted_data = $this->convertOtherAssetAsExistingLoanParams($other_assest);
@@ -2751,15 +2799,15 @@ public function getPDFormDetailsJSON_post()
}
}
-
+
}
-
+
if(count($business_assests))
{
$business_assests = json_decode($business_assests[0]['json'],true);
//print_r($other_assests);
-
+
if(isset($business_assests['business_assets_for_address']))
{
if($business_assests['business_assets_for_address'][0]['business_emi'] == 'yes')
@@ -2785,20 +2833,20 @@ public function getPDFormDetailsJSON_post()
if($business_assest['business_emi'] == 'yes')
{
$converted_data = $this->convertBusinessAssetAsExistingLoanParams($business_assest);
-
+
$parentpd_existing_loan_details['loan_details'][] = $converted_data;
}
}
-
-
+
+
}
-
-
+
+
return $parentpd_existing_loan_details;
}
-
+
function convertBusinessAssetAsExistingLoanParams($business_assest)
{
$data['loan_amount'] = "";
@@ -2814,15 +2862,15 @@ public function getPDFormDetailsJSON_post()
$data['current_balance_tenure'] = "";
$data['elapsed_tenure'] = "";
$label = null;
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$investment_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,INVESTMENTTYPE);
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES);
-
+
// print_r($investment_types);
//print_r($other_assest);
switch($business_assest['business_assets_mode'])
@@ -2830,15 +2878,15 @@ public function getPDFormDetailsJSON_post()
case 7 :
$label = $business_assest['business_name_of_the_owner'][0]['name'].' - Investments ('. $investment_types[ ($business_assest['details'][0]['investments_type'] - 1) ]['name'] .')';
break;
-
+
case 4 :
$label = $business_assest['business_name_of_the_owner'][0]['name'].' - Equipment & Machinary ('. ($business_assest['details'][0]['equipment_manufacturing_description']) .')';
break;
-
+
case 6 :
$label = $business_assest['business_name_of_the_owner'][0]['name'].' - Life Insurance Policy';
break;
-
+
case 2 :
$label = $business_assest['business_name_of_the_owner'][0]['name'].' - Property ('. ($property_types[ $business_assest['details'][0]['property_type'] - 1]['name']) .')';
break;
@@ -2846,8 +2894,8 @@ public function getPDFormDetailsJSON_post()
$data['label'] = $label;
return $data;
}
-
-
+
+
function convertOtherAssetAsExistingLoanParams($other_assest)
{
//echo 'convertOtherAssetAsExistingLoanParams';
@@ -2864,15 +2912,15 @@ public function getPDFormDetailsJSON_post()
$data['current_balance_tenure'] = "";
$data['elapsed_tenure'] = "";
$label = null;
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$investment_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,INVESTMENTTYPE);
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES);
-
+
// print_r($investment_types);
//print_r($other_assest);
switch($other_assest['assets_mode'])
@@ -2880,25 +2928,25 @@ public function getPDFormDetailsJSON_post()
case 7 :
$label = $other_assest['name_of_the_owner'][0]['name'].' - Investments ('. $investment_types[ ($other_assest['details'][0]['investments_type'] - 1) ]['name'] .')';
break;
-
+
case 4 :
$label = $other_assest['name_of_the_owner'][0]['name'].' - Equipment & Machinary ('. ($other_assest['details'][0]['equipment_manufacturing_description']) .')';
break;
-
+
case 6 :
$label = $other_assest['name_of_the_owner'][0]['name'].' - Life Insurance Policy';
break;
-
+
case 2 :
$label = $other_assest['name_of_the_owner'][0]['name'].' - Property ('. ($property_types[ $other_assest['details'][0]['property_type'] - 1]['name']) .')';
break;
-
+
//case
}
$data['label'] = $label;
return $data;
}
-
+
public function renewGeneralFormForAddtionalPD($json)
{
//echo 'renewGeneralFormForAddtionalPD';
@@ -2910,7 +2958,7 @@ public function getPDFormDetailsJSON_post()
$json['individuals'][$individual_key]['is_person_met'] = false;
}
}
-
+
if(array_key_exists('companies',$json))
{
foreach($json['companies'] as $company_key => $compnay)
@@ -2926,11 +2974,11 @@ public function getPDFormDetailsJSON_post()
}
$json['company_with_relationships'][] = array('applicant_name' => "",'company_relationship' => '','relation_to_company' => "");
$json['general_remark'] = "";
-
+
return (($json));
-
+
}
-
+
public function downloadExcel_get()
{
$this->excel->setActiveSheetIndex(0)->mergeCells('F3:M3');
@@ -2949,7 +2997,7 @@ public function getPDFormDetailsJSON_post()
//Save Co applicants details from General Form
public function saveCoApplicantsFromGeneralInfoForm($records)
{
-
+
//print_r($records);die();
if(count($records['individuals']))
{
@@ -2961,34 +3009,34 @@ public function getPDFormDetailsJSON_post()
foreach($records['individuals'] as $applicant_key => $new_applicant)
{
$count = 0;
-
-
+
+
if($new_applicant['is_new'] == true && ($new_applicant['is_applicant'] == true || $new_applicant['is_person_met'] == true))
{
-
+
$current_temp_id = $new_applicant['pd_co_applicant_id'];
$temp_array = array();
if($new_applicant['is_person_met'] == true)
{
$temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>3,'applicant_title_name'=>$new_applicant['applicant_title_name']);
}
-
+
if($new_applicant['is_applicant'] == true)
{
$temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>0,'applicant_title_name'=>$new_applicant['applicant_title_name']);
}
$new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array,PDAPPLICANTSDETAILS);
-
-
-
-
-
+
+
+
+
+
if($new_co_appliacant_id != null || $new_co_appliacant_id != "")
{
$records['individuals'][$applicant_key]['pd_co_applicant_id'] = $new_co_appliacant_id;
$records['individuals'][$applicant_key]['is_new'] = false;
-
-
+
+
if(array_key_exists('persons_with_relationships',$records))
{
foreach($records['persons_with_relationships'] as $persons_with_relationship_key => $persons_with_relationship)
@@ -2997,14 +3045,14 @@ public function getPDFormDetailsJSON_post()
{
$records['persons_with_relationships'][$persons_with_relationship_key]['pd_co_applicant_id'] = $new_co_appliacant_id;
}
-
+
if($persons_with_relationship['relation_to'] == $current_temp_id)
{
$records['persons_with_relationships'][$persons_with_relationship_key]['relation_to'] = $new_co_appliacant_id;
}
}
}
-
+
if(array_key_exists('company_with_relationships',$records))
{
foreach($records['company_with_relationships'] as $company_with_relationship_key => $company_with_relationship)
@@ -3013,46 +3061,46 @@ public function getPDFormDetailsJSON_post()
{
$records['company_with_relationships'][$company_with_relationship_key]['applicant_name'] = $new_co_appliacant_id;
}
-
-
+
+
}
}
-
-
+
+
/*################### LOGGING #########################*/
-
+
$logger = MYLOG::logFunction(null,$records['pdid']);
$temp_array['pd_co_applicant_id'] = $new_co_appliacant_id;
$logger->info("APPLICANT ADDED FROM GENERAL FORM - ENV (".ENVIRONMENT.")",$temp_array);
-
-
-
-
-
-
+
+
+
+
+
+
/*################### LOGGING #########################*/
-
+
}
-
-
-
+
+
+
}
-
+
// if($new_applicant['is_new'] == false)
// {
-
+
// $temp_array = array();
// $where_condition_array = array('pd_co_applicant_id'=>$new_applicant['pd_co_applicant_id']);
// if($new_applicant['is_person_met'] == true)
// {
// $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>3,'applicant_title_name'=>$new_applicant['applicant_title_name']);
// }
-
+
// if($new_applicant['is_applicant'] == true)
// {
// $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>0,'applicant_title_name'=>$new_applicant['applicant_title_name']);
// }
-
+
// if($new_applicant['is_main_applicant'] == true)
// {
// $temp_array = array('applicant_name'=>$new_applicant['applicant_name'],'applicant_type'=>1,'applicant_title_name'=>$new_applicant['applicant_title_name']);
@@ -3060,123 +3108,123 @@ public function getPDFormDetailsJSON_post()
// $new_co_appliacant_id = $this->PD_Model->updateRecords($temp_array,PDAPPLICANTSDETAILS,$where_condition_array);
// if($new_co_appliacant_id != "" || $new_co_appliacant_id != null)
// {
-
+
// /*################### LOGGING #########################*/
-
+
// $logger = MYLOG::logFunction();
// $temp_array['pd_co_applicant_id'] = $new_applicant['pd_co_applicant_id'];
// $logger->info("APPLICANT EDITED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$temp_array);
-
-
-
-
-
+
+
+
+
+
// /*################### LOGGING #########################*/
-
+
// }
// }
-
+
if(array_key_exists('is_active',$new_applicant))
{
if($new_applicant['is_active'] == false)
{
$rows_afftecd = $this->db->where('pd_co_applicant_id',$new_applicant['pd_co_applicant_id'])->delete(PDAPPLICANTSDETAILS);
-
+
if($rows_afftecd != "" && $rows_afftecd != null)
{
/*################### LOGGING #########################*/
-
+
$logger = MYLOG::logFunction(null,$records['pdid']);
-
+
$logger->info("APPLICANT DELETED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$new_applicant);
-
-
-
-
-
-
+
+
+
+
+
+
/*################### LOGGING #########################*/
}
}
}
-
-
-
-
+
+
+
+
}
-
+
foreach($records['companies'] as $company_key => $company)
{
-
+
if($company['is_company_applicant'] == true && $company['is_new'] == true)
{
-
+
$temp_array = array('fk_pd_id'=>$records['pdid'],'applicant_name'=>$company['company_name'],'applicant_type'=>2,'applicant_title_name'=>$company['company_messrs_name']);
$new_co_appliacant_id = $this->PD_Model->saveRecords($temp_array,PDAPPLICANTSDETAILS);
-
+
$records['companies'][$company_key]['is_new'] = false;
$records['companies'][$company_key]['pd_co_applicant_id'] = $new_co_appliacant_id;
-
-
+
+
/*################### LOGGING #########################*/
-
+
$logger = MYLOG::logFunction(null,$records['pdid']);
$temp_array['pd_co_applicant_id'] = $new_co_appliacant_id;
$logger->info("COMPANY ADDED AS APPLICANT FROM GENERAL FORM ENV (".ENVIRONMENT.")",$temp_array);
-
-
-
-
-
-
+
+
+
+
+
+
/*################### LOGGING #########################*/
-
+
}
-
+
if(array_key_exists('is_active',$company))
{
if($company['is_active'] == false && $company['is_company_applicant'] == true)
{
-
-
+
+
$rows_afftecd = $this->db->where('applicant_name',$company['company_name'])->where('fk_pd_id',$records['pdid'])->delete(PDAPPLICANTSDETAILS);
-
-
+
+
if($rows_afftecd != "" || $rows_afftecd != null)
{
/*################### LOGGING #########################*/
-
+
$logger = MYLOG::logFunction(null,$records['pdid']);
//$temp_array['pd_co_applicant_id'] = $new_co_appliacant_id;
$logger->info("COMPANY(APPLICANT) DELETED FROM GENERAL FORM ENV (".ENVIRONMENT.")",$company);
-
-
-
-
-
+
+
+
+
+
/*################### LOGGING #########################*/
}
-
+
}
}
}
}
-
+
return $records;
-
-
+
+
}
-
+
public function getAssessedIncome_post()
{
$pd_id = $this->post('pd_id');
$pd_form_id = $this->post('pd_form_id');
$company_id = $this->post('company_id') ? $this->post('company_id') : null;
-
+
$result_array = $this->PD_Model->getAssessedIncome($pd_id,$company_id);
-
+
$result_array['final_data'] = array();
$fine = $this->calculateAssessedIncome($pd_id,$company_id);
//print_r($fine);die();
@@ -3190,10 +3238,10 @@ public function getPDFormDetailsJSON_post()
//$fine['purchase_billwise'] = $result_array['purchase_billwise'];
$fine['business_expense_details'] = $result_array['business_expenses'];
$fine['house_hold_expense_details'] = $result_array['house_hold_expenses'];
-
+
$result_array['final_data'][] = $fine;
}
-
+
if(count($result_array['sales_declared_by_customer']) == 0 && count($result_array['sales_calculated_by_itemwise']) == 0 && count($result_array['purchase_details']) == 0 && count($result_array['purchase_declared_by_customer']) == 0 && count($result_array['business_expenses']) == 0 && count($result_array['house_hold_expenses']) == 0 && count($result_array['gross_profit_calculation_type']) == 0)
{
$data['dataStatus'] = false;
@@ -3209,14 +3257,14 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
public function saveAssessedIncomeSalesDeclaredByCustomer_post()
{
$records = $this->post('records');
$pk = "";
if($records['sdc_id'] != null || $records['sdc_id'] != "")
{
-
+
$where_condition_array = array('sdc_id'=>$records['sdc_id']);
$pk = $this->PD_Model->updateRecords($records,SALESDECLAREDBYCUSTOMER,$where_condition_array);
}
@@ -3224,7 +3272,7 @@ public function getPDFormDetailsJSON_post()
{
$pk = $this->PD_Model->saveRecords($records,SALESDECLAREDBYCUSTOMER);
}
-
+
if($pk != "" || $pk != null)
{
$data['dataStatus'] = true;
@@ -3239,7 +3287,7 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'Something went wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
public function saveAssessedIncomePurchaseDeclaredByCustomer_post()
@@ -3248,7 +3296,7 @@ public function getPDFormDetailsJSON_post()
$pk = "";
if($records['pdc_id'] != null || $records['pdc_id'] != "")
{
-
+
$where_condition_array = array('pdc_id'=>$records['pdc_id']);
$pk = $this->PD_Model->updateRecords($records,PURCHASEDECLAREDBYCUSTOMER,$where_condition_array);
}
@@ -3256,7 +3304,7 @@ public function getPDFormDetailsJSON_post()
{
$pk = $this->PD_Model->saveRecords($records,PURCHASEDECLAREDBYCUSTOMER);
}
-
+
if($pk != "" || $pk != null)
{
$data['dataStatus'] = true;
@@ -3271,9 +3319,9 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'Something went wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
-
+
public function saveOtherBusinessIncome_post()
{
$records = $this->post('records');
@@ -3306,7 +3354,7 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'Something went wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
public function saveAssessedIncomeSalesCalculatedByItemwise_post()
@@ -3323,7 +3371,7 @@ public function getPDFormDetailsJSON_post()
unset($record['child']);
}
-
+
if($record['sci_id'] != null || $record['sci_id'] != "")
{
$where_condition_array = array('sci_id'=>$record['sci_id']);
@@ -3374,8 +3422,8 @@ public function getPDFormDetailsJSON_post()
}
}
}
-
-
+
+
}
if($count == count($records))
{
@@ -3392,7 +3440,7 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
public function saveAssessedIncomePurchaseDetails_post()
{
$records = $this->post('records');
@@ -3415,7 +3463,7 @@ public function getPDFormDetailsJSON_post()
{
if($id != "" || $id != null)
{
-
+
foreach($child_data as $ckey => $child)
{
if($child['pbwc_id'] != "" || $child['pbwc_id'] != null)
@@ -3441,7 +3489,7 @@ public function getPDFormDetailsJSON_post()
{
if($id != "" || $id != null)
{
-
+
foreach($child_data as $ckey => $child)
{
if($child['pbwc_id'] != "" || $child['pbwc_id'] != null)
@@ -3474,7 +3522,7 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
public function saveAssessedIncomeBusinessExpenses_post()
{
$records = $this->post('records');
@@ -3493,7 +3541,7 @@ public function getPDFormDetailsJSON_post()
if($id != "" || $id != null){$count++;}
}
}
-
+
if($count == count($records))
{
$data['dataStatus'] = true;
@@ -3509,7 +3557,7 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
public function saveAssessedIncomeHouseholdExpenses_post()
{
$records = $this->post('records');
@@ -3528,7 +3576,7 @@ public function getPDFormDetailsJSON_post()
if($id != "" || $id != null){$count++;}
}
}
-
+
if($count == count($records))
{
$data['dataStatus'] = true;
@@ -3544,8 +3592,8 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
-
+
+
/*************NOT IN USE***********NOT IN USE*************************NOT IN USE************
*************NOT IN USE*********NOT IN USE*****************NOT IN USE***********************/
public function saveAssessedIncomeMonthwiseItems($item)//SALESITEMMONTHWISECHILD - NOT IN USE
@@ -3602,11 +3650,11 @@ public function getPDFormDetailsJSON_post()
}
}
}
-
+
}
else
{
-
+
$id = $this->PD_Model->saveRecords($record,SALESITEMMONTHWISE);
if($id != "" || $id != null)
{
@@ -3622,7 +3670,7 @@ public function getPDFormDetailsJSON_post()
}
}
}
-
+
}
//}
@@ -3639,7 +3687,7 @@ public function getPDFormDetailsJSON_post()
$count = 0;
foreach($records as $key => $record)
{
-
+
$child_data = array();
if(array_key_exists('child',$record))
{
@@ -3668,7 +3716,7 @@ public function getPDFormDetailsJSON_post()
}
}
}
-
+
}
else
{
@@ -3840,7 +3888,7 @@ public function getPDFormDetailsJSON_post()
return $current_question_array ;
-
+
}
@@ -3981,16 +4029,16 @@ public function getPDFormDetailsJSON_post()
// {
foreach($purchases as $purchase_key => $purchase)
{
-
+
$overall_purchase_total += $purchase['annual_purchase_value'];
}
// }
// else if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 2)////purchase bill wise
// {
-
+
// foreach($purchase_billwise as $purchase_billwise_key => $bill)
// {
-
+
// $overall_purchase_total = $overall_purchase_total + ($bill['annual_purchase_value'] * (12/ count($bill['items'])) );
// }
//}
@@ -4023,7 +4071,7 @@ public function getPDFormDetailsJSON_post()
// // {
// //print_r($sales_by_item_month['items']);
// //echo isset($sales_by_item_month['items']);die();
-
+
// $temp_netprofit = $temp_netprofit + $item['margin_final_value'];
// if(isset($item['items']))
// {
@@ -4031,7 +4079,7 @@ public function getPDFormDetailsJSON_post()
// foreach($item['items'] as $month_key => $month)
// {
// $temp = 0;
-
+
// $i++;
// foreach($month as $key => $m)
// {
@@ -4040,20 +4088,20 @@ public function getPDFormDetailsJSON_post()
// $month_total = $month_total + $temp;
// }
// }
-
+
// //die();
// $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $item['sales_type']);
// //}
-
-
+
+
// //print_r($sales_monthwise);die();
// $total_sales_monthwise = 0;
// foreach($sales_monthwise as $sale)
// {
-
-
+
+
// $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1);
-
+
// if($sale['sales_type'] == 1)
// {
// $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier);
@@ -4118,7 +4166,7 @@ public function getPDFormDetailsJSON_post()
// foreach($sales_by_item_month['items'] as $month_key => $month)
// {
// $temp = 0;
-
+
// $i++;
// foreach($month as $key => $m)
// {
@@ -4127,19 +4175,19 @@ public function getPDFormDetailsJSON_post()
// $month_total = $month_total + $temp;
// }
// }
-
+
// //die();
// $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $sales_by_item_month['sales_type']);
// }
-
-
+
+
// //print_r($sales_monthwise);die();
// foreach($sales_monthwise as $sale)
// {
-
-
+
+
// $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1);
-
+
// if($sale['sales_type'] == 1)
// {
// $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier);
@@ -4149,7 +4197,7 @@ public function getPDFormDetailsJSON_post()
// $total_sales_monthwise = $total_sales_monthwise + $sale['total'];
// }
// }
-
+
// //calculation part
// //calculatin part
// if($gross_profit_calculation_type[0]['mode'] == 1)
@@ -4167,7 +4215,7 @@ public function getPDFormDetailsJSON_post()
// //echo $temp_netprofit.'-'.$total_sales_monthwise;die();
// $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100;
// }
-
+
// $overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'] = round($total_sales_monthwise);
// ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_monthwise']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_calculated_by_monthwise']['cost_of_goods_sold'] = round($temp_purchases);
// $overall_summary_report['sales_calculated_by_monthwise']['grossprofit'] = round($temp_grossprofit);
@@ -4176,10 +4224,10 @@ public function getPDFormDetailsJSON_post()
// $overall_summary_report['sales_calculated_by_monthwise']['house_hold_expenses'] = round($overall_household_total);
// $overall_summary_report['sales_calculated_by_monthwise']['disposable_income'] = round($temp_netprofit - $overall_household_total);
// $overall_summary_report['sales_calculated_by_monthwise']['netmargin'] = round($temp_netmargin,2);
-
-
-
-
+
+
+
+
// }
if($sales_declared_by_customer_flag == 1)
@@ -4209,7 +4257,7 @@ public function getPDFormDetailsJSON_post()
$temp_purchases = $total_sales_declared_by_customer - $temp_grossprofit;
$temp_netmargin = $total_sales_declared_by_customer > 0 ?($temp_netprofit/$total_sales_declared_by_customer) * 100 : 0;
}
-
+
$overall_summary_report['sales_declared_by_customer']['sales_revenue'] = round($total_sales_declared_by_customer);
($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_declared_by_customer']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_declared_by_customer']['cost_of_goods_sold'] = round($temp_purchases);
@@ -4346,37 +4394,37 @@ public function getPDFormDetailsJSON_post()
$temp = file_get_contents($latest_pd_report_html_file_path);
//Replace Span tags from HTML File
-
+
$total_replaces = substr_count($temp,'');for($i = 0 ;$i < $total_replaces;$i++)
{
$start_pos = strpos($temp,'');
-
+
$end_pos = strpos($temp, '', strpos($temp,''));
$end_pos = $end_pos + 14;
//echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-';
$temp = substr_replace($temp,'',$start_pos,($end_pos - $start_pos));
-
-
+
+
$temp = substr_replace($temp,'',strpos($temp,''),(strlen('')));
-
+
}
-
-
+
+
//End Of Replace Span tags from HTML File
-
-
-
-
+
+
+
+
//PDF Gen using DOM PDF
$pdf_doc = $this->pdfgenerator->generate($temp, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
//End of PDF Gen using DOM PDF
$output_file2 = $this->external_path."/pd_reports/". $pdid ."/sample.pdf";
$bytes = file_put_contents($output_file2, $pdf_doc);
-
+
if(file_put_contents($output_file2, $pdf_doc))
{
-
+
$sourcefile = $output_file2;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
@@ -4387,13 +4435,13 @@ public function getPDFormDetailsJSON_post()
$where_condition_array = array("pd_id" => $pdid);
$temp_array['is_qc_edited'] = 0;
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
-
+
//call all reports functionality and send it.
-
-
-
+
+
+
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
-
+
if($id != null || $id != "" )
{
$data['dataStatus'] = true;
@@ -4409,7 +4457,7 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'Something Went Wrong..!Try later';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
}else
{
@@ -4423,7 +4471,7 @@ public function getPDFormDetailsJSON_post()
{
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
-
+
if($singed_uri != null || $singed_uri != "" )
{
$data['dataStatus'] = true;
@@ -4440,10 +4488,10 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
+
}//funcion end
-
-
+
+
//Generate Report as HTML File
public function generatePDReport_post()
{
@@ -4513,12 +4561,12 @@ public function getPDFormDetailsJSON_post()
$fields = array('processed_json');
$where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i);
$data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC');
-
+
$fields2 = array('*');
$data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i);
}
-
-
+
+
$temp = $this->load->view('report_templates/JSONTOREPORT',$data,true);
$pd_report_time = date('Y-m-d-H-i-s');
@@ -4529,17 +4577,17 @@ public function getPDFormDetailsJSON_post()
{
//$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time),PDTRIGGER,array('pd_id' => $pdid));
-
+
$where_condition_array = array("pd_id" => $pdid);
$temp_array = array('is_original_report_created'=>1,'pd_report_html_filename' => $pd_report_time,'pd_report_generated_date' => date('Y-m-d H:i:s'),'is_qc_edited' => 2);
-
+
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
-
+
$response_data['dataStatus'] = true;
$response_data['status'] = REST_Controller::HTTP_OK;
$response_data['msg'] = 'Report Generated Sucessfully..!';
$this->response($response_data,REST_Controller::HTTP_OK);
-
+
}
else
{
@@ -4549,7 +4597,7 @@ public function getPDFormDetailsJSON_post()
$this->response($response_data,REST_Controller::HTTP_OK);
}
-
+
}
public function archivePDImages_post()
@@ -4585,9 +4633,9 @@ public function getPDFormDetailsJSON_post()
else
{
-
+
$all_pd_images = $this->PD_Model->getSignedPDDocsURL($pdid);
-
+
$all_form_names = $this->PD_Model->selectCustomRecords(array('pd_form_id','pd_form_name'),array(),PDFORMS);
$form_name = array();
foreach($all_form_names as $form)
@@ -4596,24 +4644,24 @@ public function getPDFormDetailsJSON_post()
}
//print_r($form_name);die();
//Generate zip file
-
+
$this->load->library('zip');
-
+
$this->zip->add_dir('pdimages');
-
+
foreach($all_pd_images as $image)
{
$temp_dir_name = isset($form_name[ $image['fk_form_id'] ]) ? $form_name[ $image['fk_form_id'] ] : 'Common';
-
+
$this->zip->add_data('pdimages/'.$temp_dir_name.'/'.$image['pd_document_name'],file_get_contents($image['doc_url']));
}
-
+
$temp_path = $main_applicant_name.'_'.$pdid.'_'.'pd_images.zip';
$this->zip->archive($this->external_path.'/pd_reports/'.$pdid.'/'.$temp_path);
-
+
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>($this->external_path.'/pd_reports/'.$pdid.'/'.$temp_path));
-
+
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
//print_r($s3result);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
@@ -4624,9 +4672,9 @@ public function getPDFormDetailsJSON_post()
$id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
- unlink($this->external_path.'/pd_reports/'.$pdid.'/'.$temp_path);
}
-
-
-
+
+
+
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes');
$response_data['dataStatus'] = true;
@@ -4634,10 +4682,10 @@ public function getPDFormDetailsJSON_post()
$response_data['records'] = $singed_uri;
$this->response($response_data,REST_Controller::HTTP_OK);
}
-
-
+
+
}
-
+
@@ -4689,13 +4737,13 @@ public function getPDFormDetailsJSON_post()
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id'];
$key = 'pd'.$pdid.'/pd_reports/'.$main_applicant_name.'_version'.$latest_version.'.pdf';
$sourcefile = $output_file2;
-
+
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
//print_r($s3result);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
-
+
$urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid);
if($id != null || $id != "" )
{
@@ -4712,15 +4760,15 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
}
-
-
+
+
//End of convert BLOB as html then pdf then store it s3.
-
-
+
+
}
-
-
-
+
+
+
}
/*********************************************************************************************
@@ -4744,7 +4792,7 @@ public function getPDFormDetailsJSON_post()
if(count($urls))
{
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = array('pdstatus' => $pd_master_details[0]['pd_status'],'reports_urls' => $urls);
@@ -4757,8 +4805,8 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'PD Report Not Generated';
$this->response($data,REST_Controller::HTTP_OK);
}
-
-
+
+
}
@@ -4776,7 +4824,7 @@ public function getPDFormDetailsJSON_post()
$joins = array( array('table' => USERPROFILE. ' as USERPROFILE',
'condition' =>'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid',
'jointype' => 'INNER')
-
+
);
//Get Max No of blob version
@@ -4795,32 +4843,32 @@ public function getPDFormDetailsJSON_post()
//print_r($uri);
if(count($uri))
{
-
+
foreach($uri as $uri_key => $url)
{
$uri[$uri_key]['doc_uri'] = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$url['doc_name'],$time = '3600 seconds');
//echo $key;
$uri[$uri_key]['doc_name'] = str_replace($key.'/',"",$uri[$uri_key]['doc_name']);
-
+
//find version no from file
$version_no = 0;
-
+
if(is_numeric(substr($uri[$uri_key]['doc_name'],-7,3)))
{
$version_no = substr($uri[$uri_key]['doc_name'],-7,3);
-
+
}
else if(is_numeric(substr($uri[$uri_key]['doc_name'],-6,2)))
{
$version_no = substr($uri[$uri_key]['doc_name'],-6,2);
-
+
}else if(is_numeric(substr($uri[$uri_key]['doc_name'],-5,1)))
{
$version_no = substr($uri[$uri_key]['doc_name'],-5,1);
}
-
+
$uri[$uri_key]['version'] = (int)$version_no;
-
+
if(count($blob_versions))
{
foreach($blob_versions as $blob_key => $blob)
@@ -4846,7 +4894,7 @@ public function getPDFormDetailsJSON_post()
// }
}
}
-
+
return $uri;
}
@@ -4875,7 +4923,7 @@ public function getPDFormDetailsJSON_post()
$this->db->OR_WHERE('column_name','profession_name');
$this->db->GROUP_END();
$result_array = $this->db->GET()->result_array();
-
+
//print_r($result_array);die();
if(count($result_array))
@@ -4894,7 +4942,7 @@ public function getPDFormDetailsJSON_post()
}
}
//print_r($final_data);
-
+
if(array_key_exists('type_of_activity',$final_data))
{
foreach($final_data['type_of_activity'] as $f_key => $f_value)
@@ -4903,10 +4951,10 @@ public function getPDFormDetailsJSON_post()
$where_condition_array = array('type_of_activity_id'=>$f_value,'isactive'=>1);
$result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,TYPEOFACTIVITY);
$final_data['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value,'name' =>$result[0]['name']);
-
+
}
}
-
+
if(count($final_data))
{
//Get Products from Business Form
@@ -4924,7 +4972,7 @@ public function getPDFormDetailsJSON_post()
$temp = array();
foreach($prodcuts as $product_key => $product)
{
-
+
if($product['iter_column_name'] == 'manufacturing_activity_details')
{
$temp[] = array('id' => $product_key,'name' => $product['column_value']);
@@ -4987,8 +5035,8 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = "Fill Business Details First/ No Data Available!";
$this->response($data,REST_Controller::HTTP_OK);
}
-
-
+
+
}else{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
@@ -4996,7 +5044,7 @@ public function getPDFormDetailsJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
public function getTypeOfActivetyFromBusinessJSON_post()
@@ -5021,7 +5069,7 @@ public function getPDFormDetailsJSON_post()
// $final_array['profession_name_other'] = $temp_data['profession_name_other'];
// }
$final_array['type_of_activity'] = $temp_data['select_business_activity_type'];
-
+
foreach($final_array['type_of_activity'] as $f_key => $f_value)
{
$fields = array('name');
@@ -5058,7 +5106,7 @@ public function getPDFormDetailsJSON_post()
$temp = array();
foreach($temp_data['wholesale_trading_activity_details'] as $product_key => $product)
{
-
+
$temp[] = array('id' => $product_key,'name' => $product['main_products']);
}
$final_array['type_of_activity'][$f_key]['prodcuts'] =$temp;
@@ -5075,12 +5123,12 @@ public function getPDFormDetailsJSON_post()
$final_array['type_of_activity'][$f_key]['prodcuts'] =$temp;
}
}
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $final_array;
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
else
{
@@ -5088,14 +5136,14 @@ public function getPDFormDetailsJSON_post()
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = "Fill Business Form First! / No Company Found at this ID $company_id!";
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
-
-
-
-
+
+
+
+
}
-
+
/*********************************************************************************************
*********************************************************************************************/
@@ -5132,28 +5180,28 @@ public function getPDFormDetailsJSON_post()
//Get Latest Version from PD Master Table
//$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
-
+
//Get Blob from blob table
$fields = array('content');
$where_condition_array = array('fk_pd_id'=>$pdid,'version_no'=>$version_no);
$result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDREPORTSVERSIONBLOB);
-
+
if(count($result))
{
$temp_array = array('content' => $result[0]['content'],'fk_pd_id'=> $pdid,'fk_createdby'=>$fk_createdby,'version_no' => ($pd_master_details[0]['pd_report_latest_version'] + 1));
$id = $this->PD_Model->saveRecords($temp_array,PDREPORTSVERSIONBLOB);
-
+
if($id != null || $id != "")
{
$temp_array = array('pd_report_latest_version_blob' => $result[0]['content'],'pd_report_latest_version' => ($pd_master_details[0]['pd_report_latest_version'] + 1));
-
+
$where_condition_array = array('pd_id'=>$pdid);
$master_result = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
-
+
if($master_result != null || $master_result != "")
{
//do doc renegerate things here.....
-
+
$output_file = APPPATH."/docs/temp.html";
$ifp = fopen( $output_file, 'wb' );
//fwrite( $ifp, $original_template );
@@ -5163,7 +5211,7 @@ public function getPDFormDetailsJSON_post()
$file= file_get_contents($output_file);
$pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
//print_r($pdf_doc);
-
+
$output_file2 = APPPATH."/docs/sample.pdf";
if(file_put_contents($output_file2, $pdf_doc))
@@ -5174,7 +5222,7 @@ public function getPDFormDetailsJSON_post()
$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)
{
@@ -5195,13 +5243,13 @@ public function getPDFormDetailsJSON_post()
}
}
}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
}
else
{
@@ -5257,7 +5305,7 @@ public function getPDFormDetailsJSON_post()
// $temp_array = array('content' => $fin,'fk_pd_id'=> 555);
// $id = $this->PD_Model->saveRecords($temp_array,PDREPORTSVERSIONBLOB);
-
+
// $data['dataStatus'] = true;
// $data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
// $data['msg'] = $fin;
@@ -5345,10 +5393,10 @@ public function getPDFormDetailsJSON_post()
function getDetailedScoreCardChart($score)
{
-
+
$business_score['business'] = ($score['business']);
$general_score['general'] = ($score['general']);
-
+
foreach($business_score['business'] as $bsk => $score)
{
if((!($bsk == 'cerificates')) && (!strcasecmp($score['answer'],'not applicable')))
@@ -5356,7 +5404,7 @@ public function getPDFormDetailsJSON_post()
unset($business_score['business'][$bsk]);
}
}
-
+
foreach($general_score['general'] as $gsk => $g_score)
{
if(($gsk == 'neibourhood_check_as_per_pd_officer') && (!strcasecmp($g_score['answer'],'Could not verify')))
@@ -5364,15 +5412,15 @@ public function getPDFormDetailsJSON_post()
unset($general_score['general'][$gsk]);
}
}
-
-
+
+
$business_score['business'] = array_reverse($business_score['business']);
$general_score['general'] = array_reverse($general_score['general']);
// print_r($general_score['general']);
// print_r($business_score['business']);
-
+
// die();
-
+
$data = array();
$img_name = '';
@@ -5381,19 +5429,19 @@ public function getPDFormDetailsJSON_post()
// Incase running from local windows
//$dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantom_dsc_local'),SCRIPTS);
-
+
$dsc_script_from_db = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => DETAILED_SCORE_CARD_IMAGE_LOCATION),SCRIPTS);
-
+
if(count($dsc_script_from_db))
{
-
+
$dsc_script_from_db = $dsc_script_from_db[0]['script_content'];
//print_r($dsc_script_from_db);
-
+
$html_content = "";
if($i == 1){ $html_content = $this->load->view('business_scorecard',$business_score,true); }
-
+
else if($i == 2) { $html_content = $this->load->view('general_scorecard',$general_score,true);}
//print_r($html_content);
$apppath = str_replace('\\','/',APPPATH);
@@ -5406,13 +5454,13 @@ public function getPDFormDetailsJSON_post()
//echo $dsc_script_from_db;
//echo "*************";
file_put_contents(APPPATH.'/views/js/phantomdsc.js',$dsc_script_from_db);
-
+
//call& execute phantom script
$str = 'phantomjs '.APPPATH.'/views/js/phantomdsc.js';
exec($str,$ou);
exec('phantom.exit();');
-
-
+
+
// //convert as base 64 image.
$dsc_image_png_path = $i == 1 ? APPPATH.'/views/report_templates/dsc_business.png' : APPPATH.'/views/report_templates/dsc_general.png';
$type = pathinfo($dsc_image_png_path, PATHINFO_EXTENSION);
@@ -5420,7 +5468,7 @@ public function getPDFormDetailsJSON_post()
$base64_dsc_url = 'data:image/' . $type . ';base64,' . base64_encode($dsc_img_content);
if($i == 1){ $data['base64_dsc_business'] = $base64_dsc_url; }
else if($i == 2){ $data['base64_dsc_general'] = $base64_dsc_url; }
-
+
}
else
{
@@ -5434,7 +5482,7 @@ public function getPDFormDetailsJSON_post()
}
-
+
function getAssessedIncomeForPDReport($pdid)
{
@@ -5458,25 +5506,25 @@ public function getPDFormDetailsJSON_post()
}
function demo($var) {
-
+
echo " Before try block";
try {
$try = 'THis is declared in side try block';
echo "\n Inside try block";
-
+
// If var is zero then only if will be executed
if($var == 0)
{
-
+
// If var is zero then only exception is thrown
throw new Exception('Number is zero.');
-
+
// This line will never be executed
echo "\n After throw (It will never be executed)";
}
}
-
+
// Catch block will be executed only
// When Exception has been thrown by try block
catch(Exception $e) {
@@ -5485,12 +5533,12 @@ public function getPDFormDetailsJSON_post()
echo "\n Exception Caught", $e->getFile();
echo $try;
}
-
+
// This line will be executed whether
// Exception has been thrown or not
echo "\n After catch (will be always executed)";
}
-
+
public function codeigniterViewTest_post()
{
@@ -5513,7 +5561,7 @@ public function getPDFormDetailsJSON_post()
//$this->demo(5);
//$this->demo(0);
-
+
$is_regenerate = 0;
if(isset($records['regenerate']))
{
@@ -5543,32 +5591,32 @@ public function getPDFormDetailsJSON_post()
//GET phantom script from DB
$phantom_script = $this->PD_Model->selectCustomRecords(array('*'),array('script_name' => 'phantomjs_local'),SCRIPTS);
-
+
$exact_script = $phantom_script[0]['script_content'];
//print_r($exact_script);
-
+
$apppath = str_replace('\\','/',APPPATH);
$exact_script = str_replace('{{APPPATH}}',$apppath,$exact_script);
$exact_script = str_replace('{{place_score_here}}',$score_for_chart,$exact_script);
$exact_script = str_replace('{{APPPATH}}',APPPATH,$exact_script);
//print_r($exact_script);die();
//GENERATE CHART PART
-
+
file_put_contents(APPPATH.'/views/js/phantomchart.js',$exact_script,LOCK_EX);
-
+
$str = 'phantomjs '.APPPATH.'/views/js/phantomchart.js';
exec($str,$ou);
exec('phantom.exit();');
-
+
//print_r($ou);
-
+
$chart_img_path = $this->external_path.'/pd_reports/'. $pdid .'/chart.png';
$type = pathinfo($chart_img_path, PATHINFO_EXTENSION);
$chart_img_content = file_get_contents($chart_img_path);
$base64_pdscore_chart_url = 'data:image/' . $type . ';base64,' . base64_encode($chart_img_content);
$data['base64_pdscore_chart_url'] = $base64_pdscore_chart_url;
//echo $data['base64_pdscore_chart_url'];
-
+
//GENERATE CHART PART
}
//die();
@@ -5577,13 +5625,13 @@ public function getPDFormDetailsJSON_post()
{
$fields = array('processed_json');
$where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i);
-
+
$data['pd_processed_forms'][$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC');
-
+
$fields2 = array('*');
$data['pd_images'][$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i);
-
-
+
+
// $this->getPDImages_post``($fields2,array('fk_pd_id'=>$pdid,'fk_form_id' => $i),PDDOCUMENTS,array(),'','company_id','ASC');
// print_r($this->db->last_query());
}
@@ -5594,8 +5642,8 @@ public function getPDFormDetailsJSON_post()
//echo "*******************************************";
$t = $this->load->view('report_templates/JSONTOREPORT',$data,true);
//$t = $this->load->view('temp_html.html',null,true);
- echo $t;
- die();
+ // echo $t;
+ // die();
$total_replaces = substr_count($t,'');
//echo $total_replaces;
@@ -5609,19 +5657,19 @@ public function getPDFormDetailsJSON_post()
for($i = 0 ;$i < $total_replaces;$i++)
{
$start_pos = strpos($t,'');
-
+
$end_pos = strpos($t, '', strpos($t,''));
$end_pos = $end_pos + 14;
//echo $start_pos.'-';echo $end_pos.'-';echo ($end_pos - $start_pos).'-';
$t = substr_replace($t,'',$start_pos,($end_pos - $start_pos));
-
+
$t = substr_replace($t,'',strpos($t,''),(strlen('')));
-
+
}
//echo $t;
-
+
//PDF Gen using DOM PDF
//$this->pdfgenerator->setEncryption('test1234');
$pdf_doc = $this->pdfgenerator->generate($t, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
@@ -5640,24 +5688,24 @@ public function getPDFormDetailsJSON_post()
public function calculatePDScore($data)
{
-
+
$pd_form_raw_data = $data;
-
+
$actual_score = 0;
$exact_score = 0;
foreach($pd_form_raw_data as $raw_key => $raw_data)
{
-
+
if($raw_data['category_weightage'] != '' && $raw_data['question_weightage'] != '' && $raw_data['score'] != '' && $raw_data['max_score'] != '')
{
-
-
+
+
$pd_form_raw_data[$raw_key]['actual_score'] = (($raw_data['category_weightage']/100) * ($raw_data['question_weightage']/100) * $raw_data['max_score']);
$pd_form_raw_data[$raw_key]['exact_score'] = (($raw_data['category_weightage']/100) * ($raw_data['question_weightage']/100) * $raw_data['score']);
-
+
// $actual_score = $actual_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['max_score']);
// $exact_score = $exact_score + ($raw_data['category_weightage'] * $raw_data['question_weightage'] * $raw_data['score']);
-
+
}
else
{
@@ -5665,11 +5713,11 @@ public function getPDFormDetailsJSON_post()
$pd_form_raw_data[$raw_key]['exact_score'] = null;
}
}
-
+
return $pd_form_raw_data;
-
-
-
+
+
+
}
public function getQCLenderRemarks_post()
@@ -5712,7 +5760,7 @@ public function getPDFormDetailsJSON_post()
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'No Remarks Available for this PD!';
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
else
@@ -5722,7 +5770,7 @@ public function getPDFormDetailsJSON_post()
$data['msg'] = 'InAppropriate Params!';
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
$where_condition_array = array('pd_id'=>$pdid);
$result = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
if(count($result))
@@ -5737,7 +5785,7 @@ public function getPDFormDetailsJSON_post()
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'No Remarks Available for this PD!';
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
@@ -5755,7 +5803,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//echo $str;
if(!strcmp($str,'AI')) { $ai_flag = 1; }
//echo $ai_flag;
-
+
$company_list = array();
$fields = array('json');
$where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id);
@@ -5766,7 +5814,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// print_r($temp_data);die();
foreach($temp_data['companies'] as $company)
{
-
+
if($company['associate_pd_id'] == $pd_id)
{
$temp_array = array('company_order_id' => $company['company_order_id'],'company_name' => $company['company_name'],'is_active' => $company['is_active'],'is_company_applicant'=>$company['is_company_applicant'],'business_entity_type'=>$company['business_entity_type'],'business_years'=>$company['business_years'],'business_month'=>$company['business_month'],'business_month'=>$company['business_month'],'business_date_object'=>$company['business_date_object']);
@@ -5782,7 +5830,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$form_array = array();
if($ai_flag == 0) // DI case
{
-
+
$form_array = array(
array('form_id' => 13,'form_name' => 'About Business'),
array('form_id' => 22,'form_name' => 'Business Assets'),
@@ -5791,12 +5839,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
array('form_id' => 1,'form_name' => 'Supplier Details'),
array('form_id' => 2,'form_name' => 'Client Details'),
array('form_id' => 11,'form_name' => 'Stock Details'),
-
+
);
}
else // AI Case
{
-
+
$form_array = array(
array('form_id' => 13,'form_name' => 'About Business'),
array('form_id' => 22,'form_name' => 'Business Assets'),
@@ -5806,11 +5854,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
array('form_id' => 2,'form_name' => 'Client Details'),
array('form_id' => 11,'form_name' => 'Stock Details'),
array('form_id' => 16,'form_name' => 'Assessed Income')
-
+
);
-
-
-
+
+
+
}
if(!strcasecmp($lender_short_name, 'CLIX')){$form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments');}
@@ -5818,14 +5866,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($form_array);//die();
foreach($company_list as $list_key => $company)
{
-
+
$temp = array();
$business_form_status = 0;
$supplier_form_status = 0;
$client_form_status = 0;
foreach($form_array as $form)
{
-
+
$template_forms_count = 0;
if($form['form_id'] != 16)
{
@@ -5839,7 +5887,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
else
{
-
+
$fields = array('count(*) as count');
$where_condition_array = array('fk_pd_id'=>$pd_id,'company_id' => $company['company_order_id'],'is_completed' => 1);
$template_forms_count = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE);
@@ -5847,11 +5895,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// print_r($this->db->last_query());
// print_r($template_forms_count);echo $form['form_id'];
if($template_forms_count[0]['count'] != 0) {
-
+
if($form['form_id'] == 13 || $form['form_id'] == 22)
{
-
+
$temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true);
if($form['form_id'] == 22)
{
@@ -5862,9 +5910,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
else
{
if($business_form_status == 1){
-
-
-
+
+
+
if($form['form_id'] == 1)//if supplier form answered set supplier_form_status = 1
{
$supplier_form_status = 1;
@@ -5874,7 +5922,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$client_form_status = 1;
}
-
+
if($form['form_id'] == 11 || $form['form_id'] == 23)
{
//echo "COUNT YES STOCK"
@@ -5887,7 +5935,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true);
}
-
+
}
else //busienss false
{
@@ -5901,9 +5949,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//echo "else-- " .$form['form_id'];
if($form['form_id'] == 13 || $form['form_id'] == 22)
{
-
+
$temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true);
-
+
}
else{
if($business_form_status == 1){
@@ -5928,9 +5976,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
else
{
-
+
$temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false);
-
+
}
}
}
@@ -5938,11 +5986,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
$company_list[$list_key]['form_status'] = $temp;
-
-
+
+
}
}
-
+
// print_r($company_list);die();
if(count($company_list))
{
@@ -5956,7 +6004,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['msg'] = 'No Comapany Details Found!';
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
@@ -6002,10 +6050,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
else
{
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
-
+
if($pd_master_details[0]['fk_subproduct_id'] != "" || $pd_master_details[0]['fk_subproduct_id'] != null)
{
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1,'fk_subproduct_id' => $pd_master_details[0]['fk_subproduct_id']);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN);
@@ -6026,17 +6074,17 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
else
{
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1,'fk_subproduct_id' => null);
$result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN);
-
+
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
$data['records'] = $result_data;
$data['msg'] = 'Sub Product Not Applicable for this PD!';
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
}
@@ -6049,7 +6097,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$current_location = $this->post('link');
$record_data = array('fk_pd_id' => $pdid,'current_location'=>$current_location);
$id = $this->PD_Model->saveRecords($record_data,PDOFFICERCURRENTLOCATION);
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = $id;
@@ -6070,7 +6118,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$offcier_name = $pd_master_details[0]['pd_allocated_to'];
$result_data['officer_details']['officer_name'] = $offcier_name;
$result_data['location'] = $this->db->SELECT('*')->FROM(PDOFFICERCURRENTLOCATION)->WHERE('fk_pd_id',$pdid[0]['pd_id'])->ORDER_BY(PDOFFICERCURRENTLOCATIONID,'DESC')->LIMIT(1)->GET()->result_array();
-
+
if(count($result_data))
{
$data['dataStatus'] = true;
@@ -6115,22 +6163,22 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$relation['age'] = $ind['age'];
$relation['applicant_title_name'] = $ind['applicant_title_name'];
}
-
+
}
$temp_array = array_merge($temp_array,array($relation));
}
}
}
$final_data['from_general_form'] = $temp_array;
-
-
+
+
//Get Details from All Business Froms
$fields = array('json','company_id');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid);
$business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
+
//print_r($business_data);
-
+
if(count($business_data))
{
$temp_array = array();
@@ -6140,11 +6188,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($json);
if(array_key_exists('persons_with_relationships',$json))
{
-
-
+
+
foreach($json['persons_with_relationships'] as $person => $value)
{
-
+
if(count($general_data))
{
$genjson = json_decode($general_data[0]['json'],true);
@@ -6165,33 +6213,33 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
-
+
+
$final_data['from_business_form'] = $temp_array;
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = $final_data;
$this->response($data,REST_Controller::HTTP_OK);
-
-
-
+
+
+
}
public function getAssetsWithLoanFromBusiness_post()
{
$pdid = $this->post('pd_id');
-
+
// GET Assest Types and Properties type from Master
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$assest_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ASSETTYPE);
-
+
$fields = array('*');
$where_condition_array = array('isactive' => 1);
$property_types = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PROPERTIES);
-
-
+
+
$fields = array('json','company_id');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>22,'fk_pd_id' => $pdid);
$assest_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
@@ -6201,11 +6249,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($assest_data);die();
if(count($assest_data))
{
-
-
-
+
+
+
//print_r($property_types);die();
-
+
foreach($assest_data as $key => $assest)
{
$json = json_decode($assest['json'],true);
@@ -6214,12 +6262,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
foreach($json['business_assets_details'] as $asset_key => $business_asset)
{
-
+
//print_r($business_asset);
if(!strcmp($business_asset['business_emi'],'yes'))
{
$business_assets_mode_name = "";
-
+
foreach($assest_types as $asset_type)
{
if($asset_type['id'] == $business_asset['business_assets_mode'])
@@ -6227,7 +6275,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$business_assets_mode_name = $asset_type['name'];
}
}
-
+
if( $business_asset['business_assets_mode'] == 2)
{
//echo $business_asset['business_details'][0]['property_type'];
@@ -6239,14 +6287,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
$business_assest_data[] = array('business_assets_mode'=>$business_asset['business_assets_mode'],'business_assets_mode_name'=>$business_assets_mode_name,'business_details'=>$business_asset['business_details'],'business_name_of_the_owner'=>$business_asset['business_name_of_the_owner'],'business_name_of_the_other_owner' => $business_asset['business_name_of_the_other_owner']);
}
-
+
}
}
-
-
+
+
if(array_key_exists('business_assets_for_address',$json))
{
foreach($json['business_assets_for_address'] as $address_key => $address_asset)
@@ -6258,11 +6306,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
-
+
+
}
}
-
+
//Get Other Assets with Loan
$fields = array('json');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>4,'fk_pd_id' => $pdid);
@@ -6282,7 +6330,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
if(!strcmp($asset['emi'],'yes'))
{
$assets_mode_name = "";
-
+
foreach($assest_types as $asset_type)
{
if($asset_type['id'] == $asset['assets_mode'])
@@ -6290,7 +6338,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$assets_mode_name = $asset_type['name'];
}
}
-
+
if($asset['assets_mode'] == 2)
{
//echo $business_asset['business_details'][0]['property_type'];
@@ -6302,15 +6350,15 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
$other_assest_data[] = array('assets_mode'=>$asset['assets_mode'],'assets_mode_name'=>$assets_mode_name,'details'=>$asset['details'],'name_of_the_owner'=>$asset['name_of_the_owner'],'other_owner' => $asset['other_owner']);
}
-
+
}
}
}
}
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = array('business_assets' =>$business_assest_data, 'other_assests'=> $other_assest_data,'business_address_asset' => $business_address_assest_data);
@@ -6340,11 +6388,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$temp_data['products'][] = $manufacturing_activity_details['main_products'];
}
-
+
$final_data_from_business[] = $temp_data;
$temp_data = array();
}
-
+
if(array_key_exists('retail_trading_activity_details',$json))
{
$temp_data['type_of_activity_id'] = 3;
@@ -6353,11 +6401,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$temp_data['products'][] = $retail_trading_activity_details['main_products'];
}
-
+
$final_data_from_business[] = $temp_data;
$temp_data = array();
}
-
+
if(array_key_exists('wholesale_trading_activity_details',$json))
{
$temp_data['type_of_activity_id'] = 4;
@@ -6366,11 +6414,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$temp_data['products'][] = $wholesale_trading_activity_details['main_products'];
}
-
+
$final_data_from_business[] = $temp_data;
$temp_data = array();
}
-
+
if(array_key_exists('service_provider_activity_details',$json))
{
$temp_data['type_of_activity_id'] = 5;
@@ -6379,14 +6427,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$temp_data['products'][] = $service_provider_activity_details['main_products'];
}
-
+
$final_data_from_business[] = $temp_data;
$temp_data = array();
}
-
-
+
+
}
-
+
//GET RAW MATERIALS FROM SUPPLIER Form
$fields = array('json');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>1,'fk_pd_id' => $pdid,'company_id' => $company_id);
@@ -6395,12 +6443,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($supplier_data);
if(count($supplier_data))
{
-
+
$supplier_data = json_decode($supplier_data[0]['json'],true);
//print_r($supplier_data);
if(array_key_exists('manufacturing_details',$supplier_data))
{
-
+
foreach($supplier_data['manufacturing_details'] as $manufacturing_activity_detail_key => $manufacturing_activity_detail)
{
$temp_data = $manufacturing_activity_detail['main_raw_materials'];
@@ -6417,12 +6465,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
}
-
+
if(array_key_exists('trade_details',$supplier_data))
{
-
+
foreach($supplier_data['trade_details'] as $trade_detail_key => $trade_detail)
{
$temp_data = $trade_detail['trading_products'];
@@ -6439,17 +6487,17 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
}
}
-
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = array('from_business' => $final_data_from_business,'from_supplier' => $final_data_from_supplier);
$this->response($data,REST_Controller::HTTP_OK);
-
-
-
+
+
+
}
@@ -6479,7 +6527,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$final_names[] = array('applicant_name' => $persons['applicant_name'],'applicant_type' => 1,'applicant_id'=>$persons['pd_co_applicant_id']);
}
}
-
+
if(array_key_exists('companies',$json))
{
foreach($json['companies'] as $key => $persons)
@@ -6492,15 +6540,15 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
//print_r($final_names);die();
//Get Details from All Business Froms
$fields = array('json','company_id');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid);
$business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
+
//print_r($business_data);die();
-
+
if(count($business_data))
{
foreach($business_data as $business_data_key => $business)
@@ -6513,18 +6561,18 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$final_names[] = array('applicant_name' => $persons['family_member_name'],'applicant_type' => 3,'applicant_id'=>$persons['family_member_name']);
}
-
+
}
}
}
-
+
//Get Memebers from Other Family Members form
$fields = array('json','company_id');
$where_condition_array = array('isactive' => 1,'fk_form_id' =>6,'fk_pd_id' => $pdid);
$family_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON);
-
-
-
+
+
+
if(count($family_data))
{
$family_data = json_decode($family_data[0]['json'],true);
@@ -6532,7 +6580,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// print_r($family_data);die();
foreach($family_data as $family_data_key => $family)
{
-
+
if(is_array($family))
{
if(array_key_exists('family_members_details',$family))
@@ -6541,13 +6589,13 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$final_names[] = array('applicant_name' => $persons['applicant_name'],'applicant_type' => 3,'applicant_id'=>$persons['applicant_name']);
}
-
+
}
}
}
}
-
-
+
+
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['record'] = $final_names;
@@ -6580,7 +6628,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//$location = isset($records['link']) ? $records['link'] : null;
//echo $rental_count_id;die();
$res = $this->saveBase64Images($records['pd_id'],$records['formid'],$company_id,$rental_count_id,$records['images']);
-
+
if(count($res))
{
$data['dataStatus'] = true;
@@ -6622,8 +6670,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
public function saveBase64Images($pd_id,$form_id = null,$company_id = null,$rental_count_id = null,$data)
{
-
-
+
+
$count = 0;
$result = array();
$pks = array();
@@ -6637,7 +6685,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$is_show_report = isset($doc['is_show_report']) ? $doc['is_show_report'] : null;
//$external_path = $this->config->item('external_data_path');
$output_file = $this->external_path."/pd_reports/". $pd_id ."/temp_base64_image.jpeg";
-
+
//Generate Random File Name
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
@@ -6646,15 +6694,15 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
$temp_file_name = $randomString.date('Y-m-d-H:i:s').'.jpeg';
-
-
+
+
$ifp = fopen( $output_file, 'wb' );
$temp_data = explode( ',', $temp_base64_string );
fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) );
fclose( $ifp );
-
+
// ################### start img water marking with text
-
+
$imagetobewatermark = imagecreatefromstring(file_get_contents($output_file));
$location_watermarktext="Location: ".$doc['link'];
@@ -6678,10 +6726,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$sy = imagesy($curret_file);
// imagecopyresized ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) : bool
imagecopyresized ( $curret_file , $pd_logo ,5, ($sy - 54) , 0 , 0 , 50 , 50 , 50 , 54 );
-
+
imagejpeg($curret_file,$output_file);// save png image in specified location
//###########end of image water marking with logo
-
+
$tempdoc = $output_file;
$tempdocname = $temp_file_name;
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id'];
@@ -6691,10 +6739,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// $key = 'pd'.$pd_id.'/'.'form'.$form_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,'fk_form_id'=>$form_id,'is_show_report' =>$is_show_report,'rental_count_id' => $rental_count_id,'location' => $doc['link']);
@@ -6702,9 +6750,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS);
if($id != null || $id != "") { $count++; $pks[] = $id;}
}
-
+
}
-
+
if($count == count($data))
{
//$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id));
@@ -6723,17 +6771,17 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
return $result;
}
-
+
public function calculateScore($pdid)
{
-
+
//echo $pdid;die();
//GET JSON FORM DATA
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
//print_r($pd_master_details);
$form_data = $this->PD_Model->getScorablePDFormDetailsJSON($pdid);
//print_r($form_data);
-
+
//Get Latest Loan Amount form loan form.
$loan_amt_from_loam_form = json_decode($form_data[10][0]['processed_json'],true);
$loan_amt_from_loam_form = $loan_amt_from_loam_form['loan_amount'];
@@ -6754,7 +6802,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
else
{
-
+
$this->db->SELECT('*');
$this->db->FROM(PERSONALASSETGRID);
$this->db->WHERE('isactive',1);
@@ -6769,20 +6817,20 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$this->db->FROM(PERSONALASSETGRIDVARIANCE);
$this->db->WHERE('isactive',1);
$personal_asset_grid['variance_grid'] = $this->db->GET()->result_array();
-
+
// echo "calculateScore";
// print_r($personal_asset_grid);die();
-
+
// Call PD score functions
$combination = $pd_master_details[0]['fk_lender_id'].$pd_master_details[0]['fk_product_id'].$pd_master_details[0]['fk_customer_segment'];
-
-
+
+
switch($combination)
{
case 111111:
PDSCORE::calculatePDScore111($score_questions,$loan_amt_from_loam_form,$personal_asset_grid);
break;
-
+
default:
switch($pd_master_details[0]['fk_customer_segment'])
{
@@ -6794,29 +6842,29 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
break;
}
}
-
+
return $score_questions;
-
-
+
+
}
-
-
+
+
//Get All Score able Question from various PD Forms - 3 Questions Pending
public function seperateScoreQuestions($form_data,$OTP)
{
$score_questions = array();
-
+
#####General Form Questions########
$general_form = (json_decode($form_data[18][0]['processed_json'],true));
// echo "seperateScoreQuestions";
//print_r($general_form);die();
-
+
// - QNO (1.7) OTP AUTHENDICATION DONE
-
+
$score_questions['general']['otp_done'] = $OTP ? 'Yes': 'No';
// 1 - QNO(1.1) - Is Person Met, One Of the Applicant's
$qualification_temp_array = array();
-
+
$score_questions['general']['person_met_is_applicant'] = 'no';
foreach($general_form['individuals'] as $person)
{
@@ -6834,25 +6882,25 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
},$qualification_temp_array);
//print_r($qualification_temp_array);
$min = count($qualification_temp_array) ? min($qualification_temp_array) : 6;
-
+
//die();
-
-
+
+
// 2 - QNO(1.8) - Qualification
$score_questions['general']['qualification'] = $min;
-
+
// 3 - QNO(2.1) - No of Years Business Run
if(array_key_exists('companies',$general_form))
{
$score_questions['business']['no_of_years_business_run'] = isset($general_form['companies'][0]['business_years']) ? $general_form['companies'][0]['business_years'] : 0;
}
#####End of General Form Questions########
-
-
+
+
#####Address Form Questions########
$address_form = (json_decode($form_data[5][0]['processed_json'],true));
//print_r($address_form);die();
-
+
if(isset($address_form['is_pd_done_on_initiated_address']) && $address_form['is_pd_done_on_initiated_address'] != 1)
{
@@ -6860,7 +6908,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$score_questions['general']['comment_locality'] = $address_form['alternative_addresses'][0]['comment_locality_master'];
// 5 - QNO(1.3) - pd location approach
$score_questions['general']['pd_location_approach'] = $address_form['alternative_addresses'][0]['pd_location_master'];
-
+
}
else //get it from alternative address
{
@@ -6934,7 +6982,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$property_count = 0;
$vechile_count = 0;
-
+
if(array_key_exists('business_assets_for_address',$business_assest_form) && isset($business_assest_form['business_assets_for_address'][0]))
{
$property_count = (!strcasecmp($business_assest_form['business_assets_for_address'][0]['business_ownership_type'],'owned')) ? (++$property_count) : $property_count;
@@ -6976,8 +7024,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials']))
{
-
-
+
+
foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value)
{
@@ -6988,15 +7036,15 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
}
-
+
if(array_key_exists('trade_details',$supplier_form))
{
-
+
if(isset($supplier_form['trade_details'][0]['trading_products']))
{
-
+
foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value)
{
if($trading_value['trade_product_name'] != "" && $trading_value['trade_supplier_name'] != "" )
@@ -7004,16 +7052,16 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$supplier_count ++;
}
}
-
+
}
}
if(array_key_exists('servicing_details',$supplier_form))
{
-
+
if(isset($supplier_form['servicing_details'][0]['service_providers']))
{
-
+
foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value)
{
if($service_value['service_provider_name'] != "" && $service_value['service_provider_supplier_name'] != "" )
@@ -7021,9 +7069,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$supplier_count ++;
}
}
-
+
}
-
+
}
$score_questions['business']['minimum_supplier_info'] = $supplier_count ? 'Provided':'Not Provided';
@@ -7050,12 +7098,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
if( isset($client_form['client_info_available']) && $client_form['client_info_available'] == 1)
{
-
+
if(array_key_exists('manufacturing_details',$client_form))
{
if(isset($client_form['manufacturing_details'][0]['main_raw_materials']))
{
-
+
foreach ($client_form['manufacturing_details'][0]['main_raw_materials'] as $key => $value)
{
if($value['manufacturing_product_name'] != "" && $value['manufacturing_client_name'] != "" )
@@ -7063,13 +7111,13 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
if(array_key_exists('trade_details',$client_form))
{
-
+
if(isset($client_form['trade_details'][0]['trading_products']))
{
-
+
foreach ($client_form['trade_details'][0]['trading_products'] as $key => $value)
{
//print_r($value);die();
@@ -7077,12 +7125,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$client_count++;
}
-
+
}
-
+
}
}
-
+
if(array_key_exists('service_provider_details',$client_form))
{
if(isset($client_form['service_provider_details'][0]['service_products']))
@@ -7092,27 +7140,27 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
if($value['service_provider_product_name'] != "" && $value['service_provider_client_name'] != "" )
{ $client_count++; }
-
+
}
-
+
}
}
$score_questions['business']['minimum_client_info'] = $client_count ? 'Provided':'Not Provided';
-
-
+
+
}
else
{
$score_questions['business']['minimum_client_info'] = 'Not Provided';
}
-
+
}
else
{
$score_questions['business']['minimum_client_info'] = 'Not Applicable';
}
-
+
#####End of client Form Questions########
#####Stock Form Questions########
@@ -7123,7 +7171,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($stock_form);die();
if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != ""))
{
-
+
$score_questions['business']['stock_raw_material_enough'] = isset($stock_form['manufacturing_details'][0]['is_sufficiant_raw']) ? $stock_form['manufacturing_details'][0]['is_sufficiant_raw']: 'Not Applicable';
}
$score_questions['business']['stock_finished_goods_enough'] = isset($stock_form['is_sufficiant_finished_and_traded_goods']) && ($stock_form['is_sufficiant_finished_and_traded_goods'] != "" || $stock_form['is_sufficiant_finished_and_traded_goods'] != null)? $stock_form['is_sufficiant_finished_and_traded_goods'] : 'Not Applicable';
@@ -7135,12 +7183,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//$score_questions['general']['value_of_other_assets'] = 'Not Applicable';
}
#####End of Stock Form Questions########
-
-
+
+
#####Other Assest Form Questions########
$other_asset_form = (json_decode($form_data[4][0]['processed_json'],true));
//print_r($other_asset_form);
-
+
$over_all_asset_value = 0;
if(array_key_exists('assets_details',$other_asset_form))
{
@@ -7165,14 +7213,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//echo 'over_all_asset_value from FUN - '.$over_all_asset_value;die();
// 18 Q.NO(1.9)
$score_questions['general']['value_of_other_assets'] = $over_all_asset_value;
-
-
+
+
#####End of Other Assest Form Questions########
-
+
######Business Banking ##############
$business_bank_form = (json_decode($form_data[21][0]['processed_json'],true));
//print_r($business_bank_form);
-
+
$vintage = array();
if(array_key_exists('banking_details',$business_bank_form))
{
@@ -7184,23 +7232,23 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$vintage = array_merge($vintage,array($temp));
}
}
-
+
$score_questions['business']['vintage_of_business_account'] = count($vintage)? max($vintage) : 0;
//echo $vintage_of_business_account_for_display;
//$score_questions['business']['vintage_of_business_account_for_display'] = $vintage_of_business_account_for_display;
######End of Business Banking ##############
return $score_questions;
-
-
+
+
}
-
+
public function updateSubProductFromLoanDetailsForm($records)
{
$pd_master_details = $this->PD_Model->getPDMasterDetails($records['pdid']);
-
+
$new_sub_product = $records['sub_product'];
$old_sub_product = $pd_master_details[0]['fk_subproduct_id'];
-
+
if($new_sub_product != $old_sub_product)
{
$where_condition_array = array('pd_id' => $records['pdid']);
@@ -7208,32 +7256,32 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$pk_id = $this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array);
}
-
+
}
-
+
public function saveEmpSalaryAsBusinessExpensesFromBusinessForm($records)
{
//echo "FROM saveEmpSalaryAsBusinessExpensesFromBusinessForm";
if(isset($records['employees_appx_salary']) && ($records['employees_appx_salary'] != null|| $records['employees_appx_salary'] != ''))
{
//pd_expense_id, fk_pd_id, expense_item_id, expense_value, fk_frequency_id, annual_expenses_value, isactive, fk_createdby, createdon, company_id, comments
-
+
$annual_emp_salary = ($records['employees_appx_salary'] * 12);
//echo $annual_emp_salary;
-
+
$temp_array = array( 'fk_pd_id' => $records['pdid'],'expense_item_id' => 3,'expense_value' => $records['employees_appx_salary'],'fk_frequency_id' => 7, 'annual_expenses_value' => $annual_emp_salary,'fk_createdby' => $records['fk_createdby'],'company_id' => $records['company_id'],'comments' => 'Derived from Business Form');
-
-
+
+
$fields = array('pd_expense_id','expense_item_id','fk_frequency_id','expense_value','annual_expenses_value','comments');
-
+
$table = PDBUSINESSEXPENSES.' as PDBUSINESSEXPENSES';
-
+
$where_condition_array = array('fk_pd_id'=>$records['pdid'],'isactive'=>1,'expense_item_id' => 3,'fk_frequency_id' => 7,'company_id' => $records['company_id'],'comments' => 'Derived from Business Form');
-
+
$business_expenses = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
-
+
//print_r($business_expenses);
-
+
if(count($business_expenses))
{
//echo "Update";
@@ -7245,20 +7293,20 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//echo "insert";
$this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES);
}
-
-
-
-
-
-
+
+
+
+
+
+
}
}
-
-
+
+
public function saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records)
{
//echo "saveAssetRentAsBusinessExpensesFromBusinessAssestForm";
-
+
$over_all_rent_amt = 0;
if(isset($records['business_assets_for_address']) && ($records['business_assets_for_address'] != "" || $records['business_assets_for_address'] != null))
{
@@ -7270,7 +7318,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
if(isset($records['business_assets_details']) && ($records['business_assets_details'] != "" || $records['business_assets_details'] != null))
{
foreach($records['business_assets_details'] as $business_asset)
@@ -7281,23 +7329,23 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
}
-
+
//echo $over_all_rent_amt;
-
-
+
+
$temp_array = array( 'fk_pd_id' => $records['pdid'],'expense_item_id' => 9,'expense_value' => $over_all_rent_amt,'fk_frequency_id' => 7, 'annual_expenses_value' => ($over_all_rent_amt * 12),'fk_createdby' => $records['fk_createdby'],'company_id' => $records['company_id'],'comments' => 'Derived from Business Form');
-
-
+
+
$fields = array('pd_expense_id','expense_item_id','fk_frequency_id','expense_value','annual_expenses_value','comments');
-
+
$table = PDBUSINESSEXPENSES.' as PDBUSINESSEXPENSES';
-
+
$where_condition_array = array('fk_pd_id'=>$records['pdid'],'isactive'=>1,'expense_item_id' => 9,'fk_frequency_id' => 7,'company_id' => $records['company_id'],'comments' => 'Derived from Business Form');
-
+
$business_expenses = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,$table);
-
+
//print_r($business_expenses);
-
+
if(count($business_expenses))
{
//echo "Update";
@@ -7309,14 +7357,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//echo "insert";
$this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES);
}
-
-
-
+
+
+
}
-
+
public function saveHTMLReport_post()
{
-
+
$records = $this->post('records');
$pdid = $records['pdid'];
$content = $records['content'];
@@ -7325,18 +7373,18 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$pd_report_time = date('Y-m-d-h-i-s');
$pd_report_store = $this->external_path.'/pd_reports/'.$pdid.'/'.$pd_report_time.'.html';
file_put_contents($pd_report_store,$content);
-
+
//Update Latest File name and qc edited status into trigger table
$update = $this->PD_Model->updateRecords(array('pd_report_html_filename' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_qc_edited' => 1),PDTRIGGER,array('pd_id' => $pdid,'random_string' => $random_string));
-
+
//Update previous latest as 0
$update_reports_version_blob = $this->PD_Model->updateRecords(array('is_latest' => 0),PDREPORTSVERSIONBLOB,array('fk_pd_id' => $pdid,'is_latest' => 1));
-
+
//insert current PD report html file name as latest
$pd_reports_version_blob_new = $this->PD_Model->saveRecords( array('html_file_name' => $pd_report_time,'fk_createdby' => $fk_createdby,'is_latest' => 1,'fk_pd_id' => $pdid),PDREPORTSVERSIONBLOB );
-
-
-
+
+
+
if($update && $update_reports_version_blob && $pd_reports_version_blob_new)
{
$logger = MYLOG::logFunction(null,$pdid);
@@ -7354,7 +7402,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$pdid = $this->uri->segment(3);
$random_string = $this->uri->segment(2);
$this->getLatestPDReportHTMLFile($pdid,$random_string);
-
+
}
function getLatestPDReportHTMLFile($pdid,$random_string,$return_type = false)
@@ -7434,7 +7482,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$client = $this->post('client') ? $this->post('client') : 'WEB';
//print_r($pd_master_details);die();
$business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>","owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>","stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>");
-
+
$general_captions = array("otp_done" => "OTP authentication done >>","person_met_is_applicant" => "Is person Met, a loan applicant >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Business Board Sighted >>","value_of_other_assets" => "Asset Value by Loan Amount % >>");
//Get all form Images
@@ -7444,7 +7492,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
for($i = 1;$i<=30;$i++)
{
$pd_images[$i] = $this->PD_Model->getSignedPDDocsURL($pdid,$i);
-
+
$fields = array('processed_json');
$where_condition_array = array('isactive' => 1,'fk_pd_id'=>$pdid,'fk_form_id' => $i);
$form_data[$i] = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON,array(),'','company_id','ASC');
@@ -7452,7 +7500,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$incomplete_details = array();
// print_r($pd_images);die();
-
+
#####General Form Questions########
@@ -7460,7 +7508,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// echo "seperateScoreQuestions";
//print_r($general_form);die();
-
+
$person_met_is_applicant_count = 0;
$person_met_selfie_count = 0;
$person_met_id_proof_count = 0;
@@ -7550,12 +7598,12 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$incomplete_details[] = 'Business Section - Company Employees Details Not Filled';
}
-
+
if($client != 'WEB')// if API came from web then ignore this check
{
$certificate_count = 0;
$name_board_image_count = 0;
-
+
if(count($pd_images[13]))
{
foreach ($pd_images[13] as $key => $value) {
@@ -7566,8 +7614,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
}
if(!$name_board_image_count){ $incomplete_details[] = 'Busienss Section - Business Name Board Image not captured'; }
-
-
+
+
if(isset($business_form['shop_eat_act_cert']))
{
if(strtoupper($business_form['shop_eat_act_cert'])=='YES' && $business_form['shop_eat_act_cert_pic'] == "")
@@ -7614,7 +7662,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
} //else { $certificate_count++; }
}
-
+
//If Business Type of activity is manufacturing,wholesale,retail then check
if(in_array('2',$selected_type_of_activity) || in_array('4',$selected_type_of_activity) || in_array('3',$selected_type_of_activity))
{
@@ -7645,7 +7693,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
if($certificate_count){ $incomplete_details[] = 'Business Section - Images for Document Sighted Not Sufficient'; }
}
-
+
#####End of Business Form Questions########
@@ -7713,7 +7761,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
if($client != 'WEB')
{
-
+
#####supplier Form Questions########
$supplier_form = isset($form_data[1][0]['processed_json'])?(json_decode($form_data[1][0]['processed_json'],true)):array();
@@ -7722,7 +7770,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$insufficient_supplier_info = 0;
$supplier_images = isset($pd_images[1]) ? $pd_images[1] : array();
//print_r($pd_images[1]);die();
-
+
if(count($supplier_form))
{
if($supplier_form['supplier_info_available'] == 1)
@@ -7731,8 +7779,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials']))
{
-
-
+
+
foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value)
{
@@ -7744,7 +7792,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//Images name check
//$supplier_name = $manu_value['manufacturing_supplier_name'].' - Raw Material '.($manu_key+1);
-
+
// if(count($supplier_images))
// {
// foreach ($supplier_images as $key => $value)
@@ -7772,21 +7820,21 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// $incomplete_details[] = 'Supplier Section - Supplier (Raw Material '.($key+1).') Details not sufficient';
// }
}
-
-
+
+
}
//echo 'IN manu-'.$supplier_count;
}
-
-
-
+
+
+
if(array_key_exists('trade_details',$supplier_form))
{
-
+
if(isset($supplier_form['trade_details'][0]['trading_products']))
{
-
+
foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value)
{
if($trading_value['trade_product_name'] != "" && $trading_value['trade_supplier_name'] != "" && $trading_value['trade_product_contact_person_name'] != "" && ($trading_value['trade_product_contact_person_mobile_number'] != "" || $trading_value['person_landline'] != ""))
@@ -7812,7 +7860,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// {
// $incomplete_details[] = 'Supplier Section - '.$supplier_name.' - Images Not Found';
// }
-
+
else if($trading_value['trade_product_name'] == "" || $trading_value['trade_supplier_name'] == "" )
{
$insufficient_supplier_info++;
@@ -7822,8 +7870,8 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// $incomplete_details[] = 'Supplier Section - Supplier (Trading Product '.($key+1).') Details not sufficient';
// }
}
-
-
+
+
}
//echo 'IN trade-'.$supplier_count;
}
@@ -7832,10 +7880,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
if(array_key_exists('servicing_details',$supplier_form))
{
-
+
if(isset($supplier_form['servicing_details'][0]['service_providers']))
{
-
+
foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value)
{
if($service_value['service_provider_name'] != "" && $service_value['service_provider_supplier_name'] != "" && $service_value['service_provider_contact_person_name'] != "" && ($service_value['service_provider_contact_person_mobile_number'] != "" || $service_value['person_landline'] != ""))
@@ -7861,7 +7909,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// {
// $incomplete_details[] = 'Supplier Section - '.$supplier_name.' - Images Not Found';
// }
-
+
else if($service_value['service_provider_name'] == "" || $service_value['service_provider_supplier_name'] == "" )
{
$insufficient_supplier_info++;
@@ -7871,14 +7919,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// $incomplete_details[] = 'Supplier Section - Supplier (Trading Product '.($key+1).') Details not sufficient';
// }
}
-
-
+
+
}
//echo 'IN trade-'.$supplier_count;
}
-
-
-
+
+
+
}
}
@@ -8046,11 +8094,11 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
if(isset($client_form['bill_info']) && $client_form['bill_info'] == 'yes' && $client_count && (count($client_images) < 3) ){ $incomplete_details[] = 'Client Section - Images not sufficient';}
if($insufficient_client_info){ $incomplete_details[] = 'Client Section - Information Not Sufficient';}
}
-
+
}
#####End of client Form Questions########
-
+
#####Stock Form Questions########
$stock_form = isset($form_data[11][0]['processed_json'])?(json_decode($form_data[11][0]['processed_json'],true)):array();
@@ -8060,7 +8108,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
//print_r($stock_form);die();
if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != ""))
{
-
+
// if( strcasecmp($stock_form['manufacturing_details'][0]['is_sufficiant_raw'],'not applicable') && strcasecmp($stock_form['is_sufficiant_finished_and_traded_goods'],'not applicable'))
// {
// echo 'Yes';
@@ -8071,7 +8119,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// }
// else
// {
-
+
$total_stock_observed = 0;
if( isset($stock_form['manufacturing_details'][0]['manufacturing_raw_materials']) && count($stock_form['manufacturing_details'][0]['manufacturing_raw_materials']))
@@ -8079,7 +8127,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
foreach ($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'] as $key => $value)
{
//echo strcasecmp($value['stock_observed'],'no');die();
-
+
if((strcasecmp($value['stock_observed'],'no'))) { $total_stock_observed++; }
}
@@ -8091,7 +8139,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
foreach ($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'] as $key => $value)
{
if((strcasecmp($value['goods_observed'],'no'))) { $total_stock_observed++; }
-
+
}
}
@@ -8101,7 +8149,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
foreach ($stock_form['retail_details'][0]['retail_traded_goods'] as $key => $value)
{
if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; }
-
+
}
}
@@ -8110,17 +8158,17 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
foreach ($stock_form['trade_details'][0]['trading_traded_goods'] as $key => $value)
{
if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; }
-
+
}
}
-
+
if( $total_stock_observed != 0 && !(count($pd_images[11])))//&& !count($pd_images[11][0])) )
{
$incomplete_details[] = 'Stock Section - Images not sufficient';//. Available Images';// - '.(count($pd_images[11]) ? count($pd_images[11]) : 0);
}
//}
}
-
+
}
}// end of CS - SE
else if($pd_master_details[0]['customer_segment_abbr'] == 'SAL-CASH' || $pd_master_details[0]['customer_segment_abbr'] == 'SAL-CHQ')
@@ -8139,7 +8187,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$data['records'] = $incomplete_details;
$data['msg'] = count($incomplete_details) ? 'PD Details are incomplete' : 'All forms were answered';
$this->response($data,REST_Controller::HTTP_OK);
-
+
}
@@ -8163,7 +8211,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$this->response($data,REST_Controller::HTTP_OK);
}
-
+
}
@@ -8185,10 +8233,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id'];
$key = 'pd'.$records['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_updatedby' => $records['fk_updatedby']);
@@ -8219,10 +8267,10 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$data['msg'] = 'Something Went Wrong! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
-
-
-
-
+
+
+
+
}
@@ -8301,12 +8349,17 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
$pdid = $this->post('pd_id');
- $score = $this->calculateScore($pdid);
- //print_r($score);die();
- $score_questions_display = $this->PD_Model->getScoreableQuestionToDispaly($pdid);
- $t = $this->load->view('report_templates/scorecard',array('pd_score' => $score,'score_questions_display' => $score_questions_display),true);
- //echo $t;die();
-
+ //CHeck whether this PD is scoreable or not
+ $is_score_card_enabled = $this->PD_Model->getScoreCardEnabledStatusByPDID($pdid);
+ $t = '';
+ if(count($is_score_card_enabled) && $is_score_card_enabled[0]['is_score_card_enabled'] == 1)
+ {
+ $score = $this->calculateScore($pdid);
+ //print_r($score);die();
+ $score_questions_display = $this->PD_Model->getScoreableQuestionToDispaly($pdid);
+ $t = $this->load->view('report_templates/scorecard',array('pd_score' => $score,'score_questions_display' => $score_questions_display),true);
+ //echo $t;die();
+ }
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $t;
diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php
index d9270a5e..b5779f99 100644
--- a/api/application/models/PD_Model.php
+++ b/api/application/models/PD_Model.php
@@ -11,7 +11,7 @@ class PD_Model extends SPARQ_Model {
}
- public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status)// $page represents mysql offset
+ public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status,$lender_details)// $page represents mysql offset
{
//echo $status;die();
$this->db->SELECT('PDTRIGGER.pd_id,PDTRIGGER.pd_sno,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,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.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,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,PINCODE.pincode,PDTRIGGER.pincode as pincode_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDTRIGGER.other_pincode,PDAPPLICANTSDETAILS.applicant_name,PDTRIGGER.is_otp_done,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.encrypted_url,PDTRIGGER.random_string,PDTRIGGER.pd_qc_note');
@@ -46,7 +46,34 @@ class PD_Model extends SPARQ_Model {
if($lenderid != "" || $lenderid != null)
{
- $this->db->WHERE('PDTRIGGER.fk_createdby',$lenderid);
+ //$this->db->WHERE('PDTRIGGER.fk_createdby',$lenderid);
+ //print_r($lender_details);die();
+ if(isset($lender_details['entity']))
+ {
+ $this->db->WHERE('PDTRIGGER.fk_lender_id',$lender_details['entity']);
+ }
+
+ if(isset($lender_details['zone']))
+ {
+ $this->db->WHERE_IN('PDTRIGGER.fk_city',$lender_details['zone']);
+ }
+
+ if(isset($lender_details['state']))
+ {
+ $this->db->WHERE('PDTRIGGER.fk_state',$lender_details['state']);
+ }
+
+ if(isset($lender_details['city']))
+ {
+ $this->db->WHERE('PDTRIGGER.fk_city',$lender_details['city']);
+ }
+
+ if(isset($lender_details['branch']))
+ {
+ $this->db->WHERE('PDTRIGGER.fk_city',$lender_details['pd_branch_id']);
+ }
+
+
}
if($status != "" || $status != null)
@@ -83,7 +110,7 @@ class PD_Model extends SPARQ_Model {
$this->db->ORDER_BY('PDTRIGGER.pd_id',$sort);
$this->db->LIMIT($limit,$page);
$result_array = $this->db->GET()->result_array();
- // print_r($this->db->last_query());die();
+ // print_r($this->db->last_query());die();
if(count($result_array) != 0)
{
foreach($result_array as $key => $result)
@@ -828,7 +855,7 @@ class PD_Model extends SPARQ_Model {
if($result_array[0]['fk_state'] == "" || $result_array[0]['fk_state'] == null){ $mandatory_fields[] = 'fk_state'; }
if($result_array[0]['pincode'] == "" || $result_array[0]['pincode'] == null){ $mandatory_fields[] = 'pincode'; }
- if($result_array[0]['short_name'] != 'IMGC')
+ if($result_array[0]['lender_short_name'] != 'IMGC')
{
if($result_array[0]['pd_contact_person'] == "" || $result_array[0]['pd_contact_person'] == null){ $mandatory_fields[] = 'pd_contact_person'; }
@@ -1815,6 +1842,16 @@ class PD_Model extends SPARQ_Model {
return $return_data;
}
+
+ function getScoreCardEnabledStatusByPDID($pdid)
+ {
+ $this->db->SELECT('ENTITY.is_score_card_enabled');
+ $this->db->FROM(ENTITY.' as ENTITY');
+ $this->db->JOIN(PDTRIGGER.' as PDTRIGGER','ENTITY.entity_id = PDTRIGGER.fk_lender_id');
+ $this->db->WHERE('PDTRIGGER.pd_id',$pdid);
+ $res = $this->db->GET()->result_array();
+ return $res;
+ }
public function getScoreableQuestionToDispaly()
{
@@ -1878,5 +1915,21 @@ class PD_Model extends SPARQ_Model {
//print_r($this->db->last_query());
return $result;
}
+
+ function getLenderHierarchyForPDListing($lender_user_id)
+ {
+ $this->db->select('USERPROFILE.userid, concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name,USERPROFILE.fk_entity_id,USERPROFILE.fk_city,USERPROFILE.fk_state,USERPROFILEROLES.user_role,USERPROFILE.fk_entity_type_id,ROLES.role_name,if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type,ENTITYREGION.fk_region_id,ENTITYLENDERBRANCH.entity_lender_branch_id');
+ $this->db->from(USERPROFILE.' as USERPROFILE');
+ $this->db->join(USERPROFILEROLES. ' as USERPROFILEROLES','USERPROFILEROLES.fk_userid = USERPROFILE.userid and USERPROFILEROLES.isactive = 1');
+ $this->db->join(ROLES.' as ROLES','ROLES.role_id = USERPROFILEROLES.user_role');
+ $this->db->join(ENTITYREGION.' as ENTITYREGION','USERPROFILE.fk_city = ENTITYREGION.fk_city_id');
+ $this->db->join(ENTITYLENDERBRANCH.' as ENTITYLENDERBRANCH',"USERPROFILE.fk_entity_id = ENTITYLENDERBRANCH.fk_entity_id and ENTITYLENDERBRANCH.isactive = 1 and ENTITYLENDERBRANCH.fk_city_id = USERPROFILE.fk_city");
+ $this->db->where('USERPROFILE.isactive',1);
+ $this->db->where('USERPROFILE.userid',$lender_user_id);
+ $result = $this->db->get()->result_array();
+ //print_r($this->db->last_query());
+ return $result;
+
+ }
}
\ No newline at end of file
diff --git a/api/application/views/js/phantomchart.js b/api/application/views/js/phantomchart.js
index f875551a..59b8bd36 100644
--- a/api/application/views/js/phantomchart.js
+++ b/api/application/views/js/phantomchart.js
@@ -1 +1 @@
-var page = require('webpage').create();page.viewportSize = { width: 600, height: 350 };page.clipRect = { top: 0, left: 0, width: 600, height: 350 };var score = 81.7;var url = 'http://localhost/AWSEC2/sparqapi/api?'+score;var image_url = 'C:/xampp/htdocs/AWSEC2/sparqapi/api/application//chart.png' ;page.open(url,function() {setTimeout(function() {page.render(image_url);phantom.exit();}, 500);});
\ No newline at end of file
+var page = require('webpage').create();page.viewportSize = { width: 600, height: 350 };page.clipRect = { top: 0, left: 0, width: 600, height: 350 };var score = 56.7;var url = 'http://localhost/AWSEC2/sparqapi/api?'+score;var image_url = 'C:/xampp/htdocs/AWSEC2/sparqapi/api/application//chart.png' ;page.open(url,function() {setTimeout(function() {page.render(image_url);phantom.exit();}, 500);});
\ No newline at end of file
diff --git a/api/application/views/report_templates/JSONTOREPORT.php b/api/application/views/report_templates/JSONTOREPORT.php
index c68f890b..7e706c17 100644
--- a/api/application/views/report_templates/JSONTOREPORT.php
+++ b/api/application/views/report_templates/JSONTOREPORT.php
@@ -727,7 +727,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo ''.$general_form['general_remark'].'
';
}
?>
-
+
@@ -737,156 +737,156 @@ defined('BASEPATH') OR exit('No direct script access allowed');
if( isset($pd_score) && count($pd_score))
{
-
- echo 'PD Score Summary
';
-
- ?>
-
- | | Actual Score | Max Score | Score % |
- | General Section Score | | | |
-
- | Business Section Score | | | |
-
- | Final Remarks Score | | | |
-
- | Final PD Score | | | |
-
-
-
";
-
- echo '
';
-
- }
- // else
- // { echo "Score Chart Not Generated"; }
-
-
-
- //######################### CHART ###########################
-
-
- // if(isset($dsc_cards['base64_dsc_business']))
- // {
- // echo "
";
-
- // echo '
';
-
- // }
- // else
- // {
- // //echo "Score Chart Not Generated";
- // }
-
- // if(isset($dsc_cards['base64_dsc_general']))
- // {
- // echo "
";
-
- // echo '
';
-
- // }
- // else
- // {
- // //echo "Score Chart Not Generated";
- // }
-
-
- echo "";
- //######################### CHART ###########################
- }
- $business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>","owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>","stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>");
-
- $general_captions = array("otp_done" => "OTP authentication done >>","person_met_is_applicant" => "Is person Met, a loan applicant >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Business Board Sighted >>","value_of_other_assets" => "Asset Value by Loan Amount % >>");
-
-
- $address_type_remarks_caption = array('well_suited' => 'well suited','fairly_suited' => 'fairly suited','not_suited' => 'not suited');
-
-
- echo '';
- echo ' | Business Related Parameters Impacting Score | Response |
';
-
- echo '';
- foreach($pd_score['business'] as $bsk => $business_score)
- {
-
- $class = null;
- $answer = null;
- $per = $business_score['attributed_score'] > 0 && $business_score['max_score'] > 0 ? ( ($business_score['attributed_score'] / $business_score['max_score']) * 100) : 0;
-
- $class = ( $per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red')));
-
- // if($bsk == 'business_seasonality')
- // {
- // echo "BUSINESS";
- // echo $per;
- // echo $class;
- // echo $per >= 80 ? 'rcorners_green' : 'SOME';
- // die();
- // }
- if($bsk == 'location_suited_for_busienss')
- {
- $answer = $address_type_remarks_caption[ $business_score['answer'] ];
- }
- else if($bsk == 'cerificates')
- {
- $answer = $per > 0 ? 'Yes' : 'No';
- }
- else if($bsk == 'no_of_years_business_run')
- {
- $answer = isset($business_score['answer']) ? $business_score['answer'].' Yrs' : '';
- }
- else if($bsk == 'business_seasonality')
- {
- $answer = isset($business_score['answer']) ? ((!strcasecmp($business_score['answer'], 'yes')) ? 'Seasonal': 'Not Seasonal') : '';
- }
- else
- {
- $answer = isset($business_score['answer']) ? $business_score['answer'] : '';
- }
-
- if(strcasecmp($answer,'Not Applicable'))
- {
- echo ' | '. $business_captions[$bsk] .' | '. ' | '. ucfirst($answer).' |
';
- }
- }
- echo '';
- echo '
';
- echo '
';
-
- echo '';
- echo ' | Other Parameters Impacting Score | Response |
';
-
- echo '';
- foreach($pd_score['general'] as $gsk => $general_score)
- {
- $class = null;
- $per = $general_score['attributed_score'] > 0 && $general_score['max_score'] > 0 ? ( ($general_score['attributed_score'] / $general_score['max_score']) * 100) : 0;
-
- $class = ( $per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red')));
-
- $answer = ucfirst($general_score['answer']);
+ echo '
';
+ echo 'PD Score Summary
';
+
+ ?>
+
+ | | Actual Score | Max Score | Score % |
+ | General Section Score | | | |
+
+ | Business Section Score | | | |
+
+ | Final Remarks Score | | | |
+
+ | Final PD Score | | | |
+
+
+
";
+
+ echo '
';
+
+ }
+ // else
+ // { echo "Score Chart Not Generated"; }
+
+
+
+ //######################### CHART ###########################
+
+
+ // if(isset($dsc_cards['base64_dsc_business']))
+ // {
+ // echo "
";
+
+ // echo '
';
+
+ // }
+ // else
+ // {
+ // //echo "Score Chart Not Generated";
+ // }
+
+ // if(isset($dsc_cards['base64_dsc_general']))
+ // {
+ // echo "
";
+
+ // echo '
';
+
+ // }
+ // else
+ // {
+ // //echo "Score Chart Not Generated";
+ // }
+
+
+ echo "";
+ //######################### CHART ###########################
+
+ $business_captions = array("no_of_years_business_run" => "Business Vintage >>", "location_suited_for_busienss" => "Business Location suitability >>", "business_seasonality" => "Seasonality >>", "employees_total" => "Employee Strength >>", "cerificates" => "Business Certifications Sighted >>","owned_property" => "Business Premise Ownership >>", "owned_vechile" => "Vehicle Ownership >>", "business_activity_has_seen" => "Business Activity Observed >>", "minimum_supplier_info" => "Supplier Information Provided >>", "minimum_client_info" => "Client Information Provided >>","stock_raw_material_enough" => "Raw Materials Stock Sufficiency >>", "stock_finished_goods_enough" => "Finished/Traded Stock Sufficiency >>", "vintage_of_business_account" => "Main Business Banking Account Vintage >>");
+
+ $general_captions = array("otp_done" => "OTP authentication done >>","person_met_is_applicant" => "Is person Met, a loan applicant >>","qualification" => "Qualification of Loan Applicants >>","comment_locality" => "Comment on Locality >>","pd_location_approach" => "Approach to PD location >>","customer_behaviour" => "Customer Behaviour >>","neibourhood_check_as_per_pd_officer" => "Neighbourhood check >>","was_the_company_name_board_sighted" => "Business Board Sighted >>","value_of_other_assets" => "Asset Value by Loan Amount % >>");
+
+
+ $address_type_remarks_caption = array('well_suited' => 'well suited','fairly_suited' => 'fairly suited','not_suited' => 'not suited');
+
+
+ echo '';
+ echo ' | Business Related Parameters Impacting Score | Response |
';
+
+ echo '';
+ foreach($pd_score['business'] as $bsk => $business_score)
+ {
+
+ $class = null;
+ $answer = null;
+ $per = $business_score['attributed_score'] > 0 && $business_score['max_score'] > 0 ? ( ($business_score['attributed_score'] / $business_score['max_score']) * 100) : 0;
+
+ $class = ( $per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red')));
+
+ // if($bsk == 'business_seasonality')
+ // {
+ // echo "BUSINESS";
+ // echo $per;
+ // echo $class;
+ // echo $per >= 80 ? 'rcorners_green' : 'SOME';
+ // die();
+ // }
+ if($bsk == 'location_suited_for_busienss')
+ {
+ $answer = $address_type_remarks_caption[ $business_score['answer'] ];
+ }
+ else if($bsk == 'cerificates')
+ {
+ $answer = $per > 0 ? 'Yes' : 'No';
+ }
+ else if($bsk == 'no_of_years_business_run')
+ {
+ $answer = isset($business_score['answer']) ? $business_score['answer'].' Yrs' : '';
+ }
+ else if($bsk == 'business_seasonality')
+ {
+ $answer = isset($business_score['answer']) ? ((!strcasecmp($business_score['answer'], 'yes')) ? 'Seasonal': 'Not Seasonal') : '';
+ }
+ else
+ {
+ $answer = isset($business_score['answer']) ? $business_score['answer'] : '';
+ }
+
+ if(strcasecmp($answer,'Not Applicable'))
+ {
+ echo ' | '. $business_captions[$bsk] .' | '. ' | '. ucfirst($answer).' |
';
+ }
+ }
+ echo '';
+ echo '
';
+ echo '
';
+
+ echo '';
+ echo ' | Other Parameters Impacting Score | Response |
';
+
+ echo '';
+ foreach($pd_score['general'] as $gsk => $general_score)
+ {
+ $class = null;
+ $per = $general_score['attributed_score'] > 0 && $general_score['max_score'] > 0 ? ( ($general_score['attributed_score'] / $general_score['max_score']) * 100) : 0;
+
+ $class = ( $per >= 80 ? 'rcorners_green' : ($per >= 65 && $per < 80 ? 'rcorners_light_green' : ($per >= 50 && $per < 65 ? 'rcorners_amber' : 'rcorners_red')));
+
+ $answer = ucfirst($general_score['answer']);
- if($gsk == 'value_of_other_assets')
- {
- //print_r($general_score);die();
- $answer = round((($answer/$loan_form['loan_amount']) * 100),2) .' %';
+ if($gsk == 'value_of_other_assets')
+ {
+ //print_r($general_score);die();
+ $answer = round((($answer/$loan_form['loan_amount']) * 100),2) .' %';
- }
-
- if(strcasecmp($answer,'Not Applicable'))
- {
- echo ' | '. $general_captions[$gsk] .' | '. ' | '. $answer.' |
';
- }
- }
- echo '';
- echo '
';
-
-
+ }
+
+ if(strcasecmp($answer,'Not Applicable'))
+ {
+ echo ' | '. $general_captions[$gsk] .' | '. ' | '. $answer.' |
';
+ }
+ }
+ echo '';
+ echo '
';
+
+
//
-
+ } //end of is score card enabled for this pd
?>
@@ -3747,7 +3747,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
0){
//print_r($familyResult);
?>
-
+
$fmValue) { ?>
@@ -3855,7 +3855,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
//
}
else {?>
- As per loan applicant he does not have any existing loan obligations.
+ As per loan applicant he does not have any existing loan obligations.
'.$existing_loan_form_common_remarks.'
';}
@@ -3941,13 +3941,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
// echo 'CREDIT ********************';
// print_r($data['pd_processed_forms'][24]);
//print_r($credit_officier_specific_queries);
- if(count($credit_officier_specific_queries))
- {
-
- if(count($credit_officier_specific_queries['additional_requirements_processed']))
+ // if(count($credit_officier_specific_queries))
+ // {
+ echo '
';
+ echo 'Credit Manager`s Specific Queries:
';
+ //echo '
';
+ if(isset($credit_officier_specific_queries['additional_requirements_processed']) && count($credit_officier_specific_queries['additional_requirements_processed']))
{
- echo 'A . Credit Manager`s Specific Queries:
';
- echo '
';
+
foreach ($credit_officier_specific_queries['additional_requirements_processed'] as $key => $value)
{
@@ -3956,11 +3957,17 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo '
';
}
}
-
- if(count($credit_officier_specific_queries['docs_to_be_sighted_processed']))
+ else
{
- echo 'B . Documents to be collected:
';
- echo '
';
+ echo 'There are no specific queries raised by Credit Manager.';
+ }
+
+ echo '
';
+ echo 'Documents to be collected:
';
+ //
+ if(isset($credit_officier_specific_queries['docs_to_be_sighted_processed']) && count($credit_officier_specific_queries['docs_to_be_sighted_processed']))
+ {
+
foreach ($credit_officier_specific_queries['docs_to_be_sighted_processed'] as $doc_key => $doc_value)
{
@@ -3972,9 +3979,13 @@ defined('BASEPATH') OR exit('No direct script access allowed');
}
echo '
';
}
+ }
+ else
+ {
+ echo 'There are no specific documents to be collect.';
}
- }
+ //}
?>
@@ -3982,7 +3993,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
- PD OFFICER`S REMARKS ON CUSTOMER BEHAVIOUR, BUSINESS LOCATION & OVERALL PD STATUS
+
PD OFFICER`S REMARKS ON CUSTOMER BEHAVIOUR, BUSINESS LOCATION & OVERALL PD STATUS