From 5b36c708c77383ec103f0075dc3dfd9e0585ef6e Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Fri, 23 Aug 2019 12:27:59 +0530 Subject: [PATCH] ENTITY API NOTIFICATION FOR SALES ANS CREDIT PD REPORT --- api/application/config/constants.php | 3 + api/application/config/routes.php | 2 + .../Entity_Management_Controller.php | 52 + api/application/controllers/PD_Controller.php | 9039 +++++++++-------- api/application/helpers/pdalerts_helper.php | 61 +- api/application/models/PD_Model.php | 2 +- api/application/views/js/phantomchart.js | 2 +- .../views/report_templates/JSONTOREPORT.php | 13 +- 8 files changed, 4634 insertions(+), 4540 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index cdae39a4..bd83763b 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -579,5 +579,8 @@ defined('PURCHASEDECLAREDBYCUSTOMERID') OR define('PURCHASEDECLAREDBYCUSTOMERID' defined('PDDOCSTOBECOLLECTED') OR define('PDDOCSTOBECOLLECTED','t_pd_docs_to_be_collected'); defined('PDDOCSTOBECOLLECTEDID') OR define('PDDOCSTOBECOLLECTEDID','pd_doc_to_be_collect_id'); +defined('ENTITYDISCLAIMER') OR define('ENTITYDISCLAIMER','m_entity_disclaimer'); +defined('ENTITYDISCLAIMERID') OR define('ENTITYDISCLAIMERID','entity_disclaimer_id'); + diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 58590d5b..b50f09e4 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -145,6 +145,8 @@ $route['saveTATInfo'] = 'Entity_Management_Controller/saveTATInfo'; $route['deleteTATCombimaion'] = 'Entity_Management_Controller/deleteTATCombimaion'; $route['saveEntityPricingInfo'] = 'Entity_Management_Controller/saveEntityPricingInfo'; $route['listEntityPricingInfo'] = 'Entity_Management_Controller/listEntityPricingInfo'; +$route['saveEntityDisclaimer'] = 'Entity_Management_Controller/saveEntityDisclaimer'; +$route['getEntityDisclaimer'] = 'Entity_Management_Controller/getEntityDisclaimer'; //PD RELATED $route['triggerNewPD'] = 'PD_Controller/triggerNewPD'; diff --git a/api/application/controllers/Entity_Management_Controller.php b/api/application/controllers/Entity_Management_Controller.php index 05f0960f..85777085 100644 --- a/api/application/controllers/Entity_Management_Controller.php +++ b/api/application/controllers/Entity_Management_Controller.php @@ -826,6 +826,58 @@ class Entity_Management_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } } + + public function saveEntityDisclaimer_post() + { + $records = $this->post('records'); + $id = null; + if($records['entity_disclaimer_id']) + { + $id = $this->Entity_Management_Model->updateRecords($records,ENTITYDISCLAIMER,array('entity_disclaimer_id' => $records['entity_disclaimer_id'])); + } + else + { + + $id = $this->Entity_Management_Model->saveRecords($records,ENTITYDISCLAIMER); + } + + if($id != null) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + public function getEntityDisclaimer_get() + { + $entity_id = $this->get('eid'); + + $res = $this->Entity_Management_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $entity_id)); + if(count($res)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res[0]; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Records Found'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } } \ No newline at end of file diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index e9e35a28..0fa3186b 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -21,11 +21,11 @@ class PD_Controller extends REST_Controller { //class level variable declaration protected $external_path; - function __construct() - { + function __construct() + { // Construct the parent class - parent::__construct(); - $this->external_path = $this->config->item('external_data_path'); + parent::__construct(); + $this->external_path = $this->config->item('external_data_path'); $this->load->model('PD_Model'); $this->load->library('AWS_S3'); @@ -36,52 +36,52 @@ class PD_Controller extends REST_Controller { $this->load->library('pdfgenerator'); //$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); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - $temp_file_name = $randomString.date('Y-m-d-H:i:s'); - - - $ifp = fopen( $output_file, 'wb' ); + $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); + $randomString = ''; + for ($i = 0; $i < 5; $i++) { + $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 // $data[ 0 ] == "data:image/png;base64" // $data[ 1 ] == - $data = explode( ',', $base64_img ); - print_r($data); + $data = explode( ',', $base64_img ); + print_r($data); // we could add validation here with ensuring count( $data ) > 1 - fwrite( $ifp, base64_decode( $data[ 1 ] ) ); + fwrite( $ifp, base64_decode( $data[ 1 ] ) ); // clean up the file resource - fclose( $ifp ); + 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); - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) - { + 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); + 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); - } + } } /***********************Get get List Of Lenders Details for PD Trigger Page************************/ @@ -92,28 +92,28 @@ 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; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); + + 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; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -127,25 +127,25 @@ class PD_Controller extends REST_Controller { $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PRODUCTS); if(count($result_data)) { - foreach($result_data as $key => $product) - { - $fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr','is_others'); - $where_condition_array = array('isactive' => 1,'fk_product_id' => $product['product_id']); - $subproducts = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS); + foreach($result_data as $key => $product) + { + $fields = array('subproduct_id','name as subproduct_name','abbr as subproduct_abbr','is_others'); + $where_condition_array = array('isactive' => 1,'fk_product_id' => $product['product_id']); + $subproducts = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,SUBPRODUCTS); //array_push($result_data[$key],$subproducts); - $result_data[$key]['subproducts'] = $subproducts; - } - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); + $result_data[$key]['subproducts'] = $subproducts; + } + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -160,18 +160,18 @@ 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; - $this->response($data,REST_Controller::HTTP_OK); + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -189,18 +189,18 @@ 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; - $this->response($data,REST_Controller::HTTP_OK); + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -216,31 +216,31 @@ 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); + + $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; - + $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); //echo "sds"; - $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(); + $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); + $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,26 +249,26 @@ 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); - + $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); - + $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']); - $this->response($data,REST_Controller::HTTP_OK); + $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']); + $this->response($data,REST_Controller::HTTP_OK); } /********************Get get List Of States and Cities Name only for Business form *********/ @@ -280,36 +280,36 @@ class PD_Controller extends REST_Controller { $where_condition_array = array('isactive' => 1); $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,STATE); - if(count($result_data)) - { - foreach($result_data as $key => $res) - { + if(count($result_data)) + { + foreach($result_data as $key => $res) + { // $fields = array('city_id','name as city_name'); // $where_condition_array = array('isactive' => 1,'fk_state_id' => $res['state_id']); // $cities = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,CITY); //array_push($result_data[$key],$cities); - $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; + $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); - - + + + } + + } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + + + } @@ -368,48 +368,48 @@ class PD_Controller extends REST_Controller { if($pd_details['pd_status'] == TRIGGERED) { - $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); + $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']; + + $pd_details['fk_pd_template_id'] = $choosed_template_id[0]['fk_template_id']; } else // CHOOSE GENERIC TEMPLATE// { - if($pd_details['fk_customer_segment'] == 1 || $pd_details['fk_customer_segment'] == 2) - { + if($pd_details['fk_customer_segment'] == 1 || $pd_details['fk_customer_segment'] == 2) + { //SAL - (CASH/CHQ) - $pd_details['fk_pd_template_id'] = 1; - } - else if($pd_details['fk_customer_segment'] == 3 || $pd_details['fk_customer_segment'] == 5) - { + $pd_details['fk_pd_template_id'] = 1; + } + else if($pd_details['fk_customer_segment'] == 3 || $pd_details['fk_customer_segment'] == 5) + { //* SENP/SEP - (DI) - $pd_details['fk_pd_template_id'] = 2; - } - else if($pd_details['fk_customer_segment'] == 4 || $pd_details['fk_customer_segment'] == 6) - { + $pd_details['fk_pd_template_id'] = 2; + } + else if($pd_details['fk_customer_segment'] == 4 || $pd_details['fk_customer_segment'] == 6) + { //* SENP/SEP - (DI) - $pd_details['fk_pd_template_id'] = 3; - } - else if($pd_details['fk_customer_segment'] == 8) - { + $pd_details['fk_pd_template_id'] = 3; + } + else if($pd_details['fk_customer_segment'] == 8) + { //* SENP/SEP - (RI) - $pd_details['fk_pd_template_id'] = 4; - } + $pd_details['fk_pd_template_id'] = 4; + } } - } + } - - /***********************PD ALLOCATION TYPE PROCESS **********/ - + + /***********************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,60 +431,60 @@ 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"); - + + /***********************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******************/ - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 16; $i++) - { - $randomString .= $characters[rand(0, $charactersLength - 1)]; - } - $pd_details['random_string'] = $randomString; - $url = 'https://pdgenie.com/otnew/#/'.$randomString; + /************ASSIGN Random URL******************/ + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 16; $i++) + { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + $pd_details['random_string'] = $randomString; + $url = 'https://pdgenie.com/otnew/#/'.$randomString; /* $ch = curl_init(); $timeout = 5; $url = 'https://ssa.sineedge.com/ot/#/officertracking/'.$randomString; @@ -497,86 +497,86 @@ class PD_Controller extends REST_Controller { curl_close($ch); */ $pd_details['encrypted_url'] = $url; //echo $tinyurl; - /************ASSIGN Random URL******************/ + /************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 != '') - { + + $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(!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) - { - foreach($pd_applicant_details as $pd_applicant_detail) - { - $pd_applicant_detail['fk_pd_id'] = $pd_id; - $pd_applicant_detail['applicant_name'] = MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['applicant_name']); - $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); - if($co_applicant_id != null || $co_applicant_id != '') - { - $count = $count + 1; - } - } - } - } - - /***********************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); + if($pd_applicant_details != "" || $pd_applicant_details != null) + { + foreach($pd_applicant_details as $pd_applicant_detail) + { + $pd_applicant_detail['fk_pd_id'] = $pd_id; + $pd_applicant_detail['applicant_name'] = MYUTIL::applicantNameCamelCaseConvertion($pd_applicant_detail['applicant_name']); + $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); + if($co_applicant_id != null || $co_applicant_id != '') + { + $count = $count + 1; + } + } + } + } + + /***********************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); // foreach($pd_document_from_mobile as $iter => $doc) // { // $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,202 +596,202 @@ 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 != '') - { - if(count($pd_addtional_requirements)) - { - foreach($pd_addtional_requirements as $pd_addtional_requirement_key => $pd_addtional_requirement) - { - if($pd_addtional_requirement['add_requirement'] != null) - { - $pd_addtional_requirement['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); - } - } - } - - if(count($docs_to_be_collected)) - { - foreach($docs_to_be_collected as $docs_to_be_collected_key => $docs_to_be_collect) - { - if($docs_to_be_collect['doc_name'] != null) - { - $docs_to_be_collect['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($docs_to_be_collect,PDDOCSTOBECOLLECTED); - } - } - } - - - $temp_address_id = null; - if(count($addresses)) - { - - foreach($addresses as $address_key => $address) - { - $address['fk_pd_id'] = $pd_id; - $address['is_primary'] = count($addresses) == 1 ? 1:0; - $address['assigned_pd'] = count($addresses) == 1 ? $pd_id:null; - $address_id = $this->PD_Model->saveRecords($address,PDADDRESS); - if($address_key == 0) - { - $temp_address_id = $address_id; - } - } + } + } + /***********************END OF PD DOCUMENTS(base64 type) UPLOAD SECTION FROM MOBILE***********/ - } - - - - //update parent pd id for same pd itself after PK generated - $temp = array('parent_pd_id' => $pd_id); - if(count($addresses) == 1) + + /****************ADDTIONAL REQUIREMENTS SECTION*******************************************/ + if($pd_id != null || $pd_id != '') { - $temp['fk_primary_address_id'] = $temp_address_id; - $temp['fk_address_id'] = $temp_address_id; - } - $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) - { - $new_company['fk_pd_id'] = $pd_id; - $this->PD_Model->saveRecords($new_company,PDCOMPANY); - } - } - } - - /****************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; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $this->response($data,REST_Controller::HTTP_OK); - } - - } - - 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) - { - if($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "" && ($pd_addtional_requirement['add_requirement'] != null) ) - { - $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); - $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS,$where_condition_array); - if($pk_id != "" || $pk_id != null){ $count++; } - } - else - { - if( $pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") - { - $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; - $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); - if($pk_id != "" || $pk_id != null){ $count++; } - } - } - } - } - if($count != 0 && $count == count($pd_addtional_requirements)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Some thing went wrong"; - $this->response($data,REST_Controller::HTTP_OK); - } - - } + if(count($pd_addtional_requirements)) + { + foreach($pd_addtional_requirements as $pd_addtional_requirement_key => $pd_addtional_requirement) + { + if($pd_addtional_requirement['add_requirement'] != null) + { + $pd_addtional_requirement['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); + } + } + } - public function savePDDocsToBeCollected_post() - { - $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) - { - if($pd_doc_requirement['pd_doc_to_be_collect_id'] != null || $pd_doc_requirement['pd_doc_to_be_collect_id'] != "" && ($docs_to_be_collect['doc_name'] != null) ) - { - $where_condition_array = array('pd_doc_to_be_collect_id' => $pd_doc_requirement['pd_doc_to_be_collect_id']); - $pk_id = $this->PD_Model->updateRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED,$where_condition_array); - if($pk_id != "" || $pk_id != null){ $count++; } - } - else - { - if($pd_doc_requirement['doc_name'] != null) - { - $pd_doc_requirement['fk_pd_id'] = $records['pdid']; - $pk_id = $this->PD_Model->saveRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED); - if($pk_id != "" || $pk_id != null){ $count++; } + if(count($docs_to_be_collected)) + { + foreach($docs_to_be_collected as $docs_to_be_collected_key => $docs_to_be_collect) + { + if($docs_to_be_collect['doc_name'] != null) + { + $docs_to_be_collect['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($docs_to_be_collect,PDDOCSTOBECOLLECTED); + } + } + } + + + $temp_address_id = null; + if(count($addresses)) + { + + foreach($addresses as $address_key => $address) + { + $address['fk_pd_id'] = $pd_id; + $address['is_primary'] = count($addresses) == 1 ? 1:0; + $address['assigned_pd'] = count($addresses) == 1 ? $pd_id:null; + $address_id = $this->PD_Model->saveRecords($address,PDADDRESS); + if($address_key == 0) + { + $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) + { + $temp['fk_primary_address_id'] = $temp_address_id; + $temp['fk_address_id'] = $temp_address_id; + } + $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) + { + $new_company['fk_pd_id'] = $pd_id; + $this->PD_Model->saveRecords($new_company,PDCOMPANY); + } + } + } + + /****************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; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $this->response($data,REST_Controller::HTTP_OK); + } + } - } - } - } - if($count != 0 && $count == count($docs_to_be_collected)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Some thing went wrong"; - $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) + { + if($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "" && ($pd_addtional_requirement['add_requirement'] != null) ) + { + $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); + $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS,$where_condition_array); + if($pk_id != "" || $pk_id != null){ $count++; } + } + else + { + if( $pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") + { + $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; + $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); + if($pk_id != "" || $pk_id != null){ $count++; } + } + } + } + } + if($count != 0 && $count == count($pd_addtional_requirements)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong"; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + + public function savePDDocsToBeCollected_post() + { + $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) + { + if($pd_doc_requirement['pd_doc_to_be_collect_id'] != null || $pd_doc_requirement['pd_doc_to_be_collect_id'] != "" && ($docs_to_be_collect['doc_name'] != null) ) + { + $where_condition_array = array('pd_doc_to_be_collect_id' => $pd_doc_requirement['pd_doc_to_be_collect_id']); + $pk_id = $this->PD_Model->updateRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED,$where_condition_array); + if($pk_id != "" || $pk_id != null){ $count++; } + } + else + { + if($pd_doc_requirement['doc_name'] != null) + { + $pd_doc_requirement['fk_pd_id'] = $records['pdid']; + $pk_id = $this->PD_Model->saveRecords($pd_doc_requirement,PDDOCSTOBECOLLECTED); + if($pk_id != "" || $pk_id != null){ $count++; } + } + } + } + } + if($count != 0 && $count == count($docs_to_be_collected)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Some thing went wrong"; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + /* * *Update PD trigger Master Details(Web app only) from PD trigger Edit/view page @@ -800,100 +800,100 @@ class PD_Controller extends REST_Controller { { $pd_details = $this->post('records'); - if((isset($pd_details['pd_id']) && $pd_details['pd_id'] != "" ) && (isset($pd_details['random_string']) && $pd_details['random_string'] != " ")) - { - $logger = MYLOG::logFunction(null,$pd_details['pd_id']); - EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_details['pd_id']); - $exist_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['pd_id']); + if((isset($pd_details['pd_id']) && $pd_details['pd_id'] != "" ) && (isset($pd_details['random_string']) && $pd_details['random_string'] != " ")) + { + $logger = MYLOG::logFunction(null,$pd_details['pd_id']); + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_details['pd_id']); + $exist_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['pd_id']); //print_r($exist_pd_details); - if(!file_exists($this->external_path.'/pd_reports/'.$pd_details['pd_id'])) + if(!file_exists($this->external_path.'/pd_reports/'.$pd_details['pd_id'])) { mkdir($this->external_path.'/pd_reports/'.$pd_details['pd_id'],0777); } - 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']); - $string2 = str_shuffle('1234567890'); - $OTP = substr($string2,0,6); - $msg = "OTP for starting your personal discussions with the verification officer is ".$OTP.".Pls share this only when the officer has reached your place in person."; - $no = (string)$pd_details['mobile_no']; - unset($pd_details['mobile_no']); - $pd_details['OTP'] = $OTP; + 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']); + $string2 = str_shuffle('1234567890'); + $OTP = substr($string2,0,6); + $msg = "OTP for starting your personal discussions with the verification officer is ".$OTP.".Pls share this only when the officer has reached your place in person."; + $no = (string)$pd_details['mobile_no']; + 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')); + 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']); } + 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']); + $pd_details['satellite_image_base64_blob'] = $this->getSatelliteImage($pd_details['pd_id']); //die(); //If it is Addtional PD ,then update 'COMPLETE' status for primary and all other addtional PD's - if($exist_pd_details[0]['is_child'] == 1) - { + if($exist_pd_details[0]['is_child'] == 1) + { //echo "child"; - $all_pd_id = array(); + $all_pd_id = array(); //get all associated PD ID's from address table - $all_associated_addresses = $this->PD_Model->getPDAddress($exist_pd_details[0]['parent_pd_id']); + $all_associated_addresses = $this->PD_Model->getPDAddress($exist_pd_details[0]['parent_pd_id']); //print_r($all_associated_addresses); - if(count($all_associated_addresses)) - { - foreach($all_associated_addresses as $address) + if(count($all_associated_addresses)) { - if($address['assigned_pd'] != $pd_details['pd_id']) + foreach($all_associated_addresses as $address) { - $all_pd_id[] = array('pd_id' => $address['assigned_pd'],'pd_status' => COMPLETED, 'fk_updatedby' => $pd_details['fk_updatedby']); - } - } - } + if($address['assigned_pd'] != $pd_details['pd_id']) + { + $all_pd_id[] = array('pd_id' => $address['assigned_pd'],'pd_status' => COMPLETED, 'fk_updatedby' => $pd_details['fk_updatedby']); + } + } + } //print_r($all_pd_id); - foreach($all_pd_id as $single_pd) - { - $this->PD_Model->updateRecords($single_pd,PDTRIGGER,array('pd_id' => $single_pd['pd_id'])); + foreach($all_pd_id as $single_pd) + { + $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']); + 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']; - } + } //die(); $primary_address_id = null; @@ -923,38 +923,38 @@ 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) - { + 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; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_OK); + } - $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; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); - } - }//end of normal PD else//#################### Handle Addtional PD { //echo 'else'; if(($pd_details['parent_pd_id'] != "" || $pd_details['parent_pd_id'] != null) && - (($pd_details['fk_customer_segment'] != "" || $pd_details['fk_customer_segment'] != null)) && - (($pd_details['fk_address_id'] != "" || $pd_details['fk_address_id'] != null)) && - (($pd_details['pd_status'] != "" || $pd_details['pd_status'] != null)) && - (($pd_details['fk_updatedby'] != "" || $pd_details['fk_updatedby'] != null)) ) + (($pd_details['fk_customer_segment'] != "" || $pd_details['fk_customer_segment'] != null)) && + (($pd_details['fk_address_id'] != "" || $pd_details['fk_address_id'] != null)) && + (($pd_details['pd_status'] != "" || $pd_details['pd_status'] != null)) && + (($pd_details['fk_updatedby'] != "" || $pd_details['fk_updatedby'] != null)) ) { //GET PArent PD Details $parent_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['parent_pd_id']); @@ -990,212 +990,212 @@ class PD_Controller extends REST_Controller { if(!file_exists($this->external_path.'/pd_reports/'.$pd_id)) - { - mkdir($this->external_path.'/pd_reports/'.$pd_id,0777); - } + { + mkdir($this->external_path.'/pd_reports/'.$pd_id,0777); + } //update Applicant details $fields = array('pd_co_applicant_id'=>$pd_details['pd_co_applicant_id'],'mobile_no' => $pd_details['mobile_no']); $where_condition_array = array('additional_pd_id' => $pd_id); $this->PD_Model->updateRecords($fields,PDAPPLICANTSDETAILS,$where_condition_array); //update Assiged PD to Address Table - $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); - + $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; - $data['records'] = $pd_id; - $data['msg'] = "Addtional PD Created!"; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pd_id; + $data['msg'] = "Addtional PD Created!"; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong. Try later!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong. Try later!'; + $this->response($data,REST_Controller::HTTP_OK); } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Parent PD Details Not available!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Parent PD Details Not available!'; + $this->response($data,REST_Controller::HTTP_OK); } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Addtional PD :- ParentPD ID,Customer Segment, Address,, PD Status, Created by Required!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Addtional PD :- ParentPD ID,Customer Segment, Address,, PD Status, Created by Required!'; + $this->response($data,REST_Controller::HTTP_OK); } } - - } - +} + + //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 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)) + { + $logger = MYLOG::logFunction(null,$data); + $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED",array('ENV'=>ENVIRONMENT,'DATA' => $data)); + $fields = array('fk_lender_id','fk_product_id','fk_customer_segment','pd_status'); + $where_condition_array = array('pd_id' => $data); + $res_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); } - public function assignPDTempalate($data) - { - - //print_r($data); - if(!is_array($data)) - { - $logger = MYLOG::logFunction(null,$data); - $logger->info("TEMPLATE ASSIGN FUNCTIONALTIY CALLED",array('ENV'=>ENVIRONMENT,'DATA' => $data)); - $fields = array('fk_lender_id','fk_product_id','fk_customer_segment','pd_status'); - $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); - } - else - { + $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); + } + else + { //print_r('else'); - $logger = MYLOG::logFunction(null,$data['pd_id']); - $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); - + $logger = MYLOG::logFunction(null,$data['pd_id']); + $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']; - + $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) - { + $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) - $templateid = 1; - } - else if($customer_segment == 3 || $customer_segment == 5) - { + $templateid = 1; + } + else if($customer_segment == 3 || $customer_segment == 5) + { //* SENP/SEP - (DI) - $templateid = 2; - } - else if($customer_segment == 4 || $customer_segment == 6) - { + $templateid = 2; + } + else if($customer_segment == 4 || $customer_segment == 6) + { //* SENP/SEP - (AI) - $templateid = 3; - - } - else if($customer_segment == 8) - { + $templateid = 3; + + } + else if($customer_segment == 8) + { //* SENP/SEP - (RI) - $templateid = 4; - } + $templateid = 4; + } } - return $templateid; - - - - - } - - - public function updatePDAddress_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $key => $value) - { - if(count($records) == 1) - { - $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']); - $id = $this->PD_Model->updateRecords($value,PDADDRESS,$where_condition_array); - if($id != "" || $id != null){ $count++; } - } - else - { - $id = $this->PD_Model->saveRecords($value,PDADDRESS); - if($id != "" || $id != null){ $count++; } - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - + return $templateid; + + + + + } + + + public function updatePDAddress_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $key => $value) + { + if(count($records) == 1) + { + $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']); + $id = $this->PD_Model->updateRecords($value,PDADDRESS,$where_condition_array); + if($id != "" || $id != null){ $count++; } + } + else + { + $id = $this->PD_Model->saveRecords($value,PDADDRESS); + if($id != "" || $id != null){ $count++; } + } + } + + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + /** * Pd Discussion OTP Checking function * sriram */ - public function checkOTP_post() - { - $pdotp = $this->post('records'); + public function checkOTP_post() + { + $pdotp = $this->post('records'); - $pdotpStatus = 0; - if(!array_key_exists('reason',$pdotp)) - { + $pdotpStatus = 0; + if(!array_key_exists('reason',$pdotp)) + { $pdotpStatus = $this->PD_Model->checkotp($pdotp); $updatePd['pd_id'] = $pdotp['pd_id']; $updatePd['pd_status'] = INPROGRESS; @@ -1205,46 +1205,46 @@ class PD_Controller extends REST_Controller { if($pdotpStatus != 0 || $pdotpStatus != '' && count($pdotpStatus) != 0) { - $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); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - //echo "WITHOUT OTP CALLED"; - - $updatePd['pd_id'] = $pdotp['pd_id']; - $updatePd['pd_status'] = INPROGRESS; - $updatePd['is_otp_done'] = 0; - $updatePd['otp_reject_reason'] = $pdotp['reason']; - $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); - } - - } - + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_OK); + } + } + else + { + //echo "WITHOUT OTP CALLED"; - + $updatePd['pd_id'] = $pdotp['pd_id']; + $updatePd['pd_status'] = INPROGRESS; + $updatePd['is_otp_done'] = 0; + $updatePd['otp_reject_reason'] = $pdotp['reason']; + $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); + } + + } + + + /* * @@ -1257,41 +1257,41 @@ class PD_Controller extends REST_Controller { $pd_id = 0; //print_r($this->post());die(); foreach($pd_applicant_details as $pd_applicant_detail) + { + if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "") { - if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "") - { //$pd_id = $pd_applicant_detail['fk_pd_id']; - $where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']); - $co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array); - if($co_applicant_id != null || $co_applicant_id != '') - { - $count = $count + 1; - } - } - else + $where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']); + $co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array); + if($co_applicant_id != null || $co_applicant_id != '') { - //$pd_applicant_detail['fk_pd_id'] = $pd_id; - $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); - if($co_applicant_id != null || $co_applicant_id != '') - { - $count = $count + 1; - } + $count = $count + 1; } } - - if($count != 0 && count($pd_applicant_details) == $count) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); + //$pd_applicant_detail['fk_pd_id'] = $pd_id; + $co_applicant_id = $this->PD_Model->saveRecords($pd_applicant_detail,PDAPPLICANTSDETAILS); + if($co_applicant_id != null || $co_applicant_id != '') + { + $count = $count + 1; + } } + } + + if($count != 0 && count($pd_applicant_details) == $count) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -1311,27 +1311,27 @@ class PD_Controller extends REST_Controller { $where_condition_array = array('pd_id' => $pdid); $lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - $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); - + $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) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $this->response($data,REST_Controller::HTTP_OK); - } - - + $modified = $this->db->where('pd_document_id',$pdid)->$this->db->delete(PDDOCUMENTS); + if($modified) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $this->response($data,REST_Controller::HTTP_OK); + } + + } } @@ -1352,68 +1352,68 @@ class PD_Controller extends REST_Controller { $fields = array('fk_lender_id'); $where_condition_array = array('pd_id' => $pdid); $lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER); - foreach($pd_document_titles as $iter => $doc) + foreach($pd_document_titles as $iter => $doc) + { + if($doc['pd_document_id'] != null || $doc['pd_document_id'] != '') { - 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) { - - $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); - } - + $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); - } - else - { - - $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; - $tempdocname = $_FILES['pddocuments']['name'][$iter]; - $bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id; - $key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ; - $sourcefile = $tempdoc; - - $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); - $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); - - if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + if($old_doc_name != "" || $old_doc_name != null) { - $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>$doc['pd_document_title'],'pd_document_name'=>$tempdocname); - $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); + $key = 'pd'.$doc['fk_pd_id'].'/'.$old_doc_name[0]['pd_document_name']; + $this->aws_s3->deleteSingleObjFromBucket($bucketname,$key); } + + //Update entry in PD Doc table + $record_data = array('pd_document_name'=>$tempdocname); + $where_condition_array = array('pd_document_id' => $doc['pd_document_id']); + $this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array); + } + + + } + else + { + + $tempdoc = $_FILES['pddocuments']['tmp_name'][$iter]; + $tempdocname = $_FILES['pddocuments']['name'][$iter]; + $bucketname = LENDER_BUCKET_NAME_PREFIX.$lender_id; + $key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ; + $sourcefile = $tempdoc; + + $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + $record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>$doc['pd_document_title'],'pd_document_name'=>$tempdocname); + $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); } } - - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - + } + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -1428,7 +1428,7 @@ class PD_Controller extends REST_Controller { //print_r($records); //if($records['fk_pd_allocated_to'] != "" || $records['fk_pd_allocated_to'] != null) //{ - $records['pd_status'] = ALLOCATED; + $records['pd_status'] = ALLOCATED; //} $where_condition_array = array('pd_id' => $records['pd_id']); $pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array); @@ -1438,22 +1438,22 @@ class PD_Controller extends REST_Controller { // $pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array); if($pd_id_modified != "" || $pd_id_modified != null) - { - $logger = MYLOG::logFunction(null,$records['pd_id']); - $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'TRIGGERED','Current_status' => $records['pd_status'])); - PDALERTS::pdnotification($records['pd_id']); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Not Updated! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } + { + $logger = MYLOG::logFunction(null,$records['pd_id']); + $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'TRIGGERED','Current_status' => $records['pd_status'])); + PDALERTS::pdnotification($records['pd_id']); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Not Updated! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -1468,29 +1468,29 @@ class PD_Controller extends REST_Controller { { //$id = $this->PD_Model->saveRecords($records,PDSCHEDULE); - $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); - + $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']); @@ -1498,26 +1498,26 @@ class PD_Controller extends REST_Controller { // } // } // } - /******* 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']); - $logger = MYLOG::logFunction(); - $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'NA','Current_status' => SCHEDULED)); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Not Updated! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } + /******* 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']); + $logger = MYLOG::logFunction(); + $logger->info("PD UPDATED",array('ENV'=>ENVIRONMENT,'DATA' => $records,'Pre-Status' => 'NA','Current_status' => SCHEDULED)); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Not Updated! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -1541,13 +1541,13 @@ class PD_Controller extends REST_Controller { //2.Get Team ID based on Lender ID if(count($res_array)) { - $where_condition_array = array('lender_id' => $res_array[0]['fk_lender_id'],'city_id' =>$res_array[0]['fk_city'] ,'cs_id' =>$res_array[0]['fk_customer_segment'] ,'product_id' =>$res_array[0]['fk_product_id']); - $temp_city_id = $this->PD_Model->selectRecords(PDTEAM_CTY_PRODUCT_CS_COMBINATIONS,$where_condition_array,$limit=0,$offset=0); + $where_condition_array = array('lender_id' => $res_array[0]['fk_lender_id'],'city_id' =>$res_array[0]['fk_city'] ,'cs_id' =>$res_array[0]['fk_customer_segment'] ,'product_id' =>$res_array[0]['fk_product_id']); + $temp_city_id = $this->PD_Model->selectRecords(PDTEAM_CTY_PRODUCT_CS_COMBINATIONS,$where_condition_array,$limit=0,$offset=0); //print_r($temp_city_id);die(); - if(count($temp_city_id)) + if(count($temp_city_id)) + { + if(isset($temp_city_id[0]['team_type'])) { - if(isset($temp_city_id[0]['team_type'])) - { if($temp_city_id[0]['team_type'] == 0) // Allocate to Vendor { // $pd_details['pd_agency_id'] = $temp_city_id[0]['fk_team_id']; @@ -1558,28 +1558,80 @@ class PD_Controller extends REST_Controller { { //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'); + $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) + { + $this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no'); + $this->db->FROM(USERPROFILE.' as USERPROFILE'); + $this->db->WHERE('USERPROFILE.userid',$pdofficer['fk_user_id']); + $names = $this->db->GET()->result_array(); + if(count($names)){ - $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)) + $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'); + $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->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); + $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); + $this->db->GROUP_END(); + if($pdofficer['fk_pd_type_id'] == 1) { - foreach($list_of_pd_officers as $key => $pdofficer) + $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); + } + else + { + $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); + } + $pd_count = $this->db->GET()->result_array(); + //print_r($this->db->last_query()); + if(count($pd_count)){ + $list_of_pd_officers[$key]['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) + { + $this->db->SELECT('USERPROFILE.userid as fk_user_id,USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); + $this->db->FROM(USERPROFILE.' as USERPROFILE'); + $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); + $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(); + //print_r($central_pd_officers); + if(count($central_pd_officers)) + { + foreach($central_pd_officers as $k => $central_pd_officer) { - $this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no'); - $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; + //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'); $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); @@ -1593,257 +1645,205 @@ class PD_Controller extends REST_Controller { $this->db->OR_WHERE('PDTRIGGER.pd_status',INPROGRESS); $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); $this->db->GROUP_END(); - if($pdofficer['fk_pd_type_id'] == 1) - { - $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); - } - else - { - $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); - } + $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); $pd_count = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - if(count($pd_count)){ - $list_of_pd_officers[$key]['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) - { - $this->db->SELECT('USERPROFILE.userid as fk_user_id,USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); - $this->db->FROM(USERPROFILE.' as USERPROFILE'); - $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); - $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(); - //print_r($central_pd_officers); - 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,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'); - $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->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); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->GROUP_END(); - $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); - $pd_count = $this->db->GET()->result_array(); //print_r($this->db->last_query()); - $central_pd_officers[$k]['count'] = 0; - if(count($pd_count)){ - $central_pd_officers[$k]['pd_details'] = $pd_count; - $central_pd_officers[$k]['count'] = count($pd_count); } + $central_pd_officers[$k]['count'] = 0; + if(count($pd_count)){ + $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'); - $central_pd_officers[$k]['profile_url'] = $singed_uri; - } + + + $bucket_name = PROFILE_PICTURE_BUCKET_NAME; + $profilepics3path = 'sineedge/'.$central_pd_officer['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); + $central_pd_officers[$k]['profile_url'] = $singed_uri; } } - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Officers Records Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Officers Records Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } - + + + } + } + + + + } - } - - - - - } else // 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)) { - - //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) - { - $this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no'); - $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'); - $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); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); - $this->db->GROUP_END(); - if($pdofficer['fk_pd_type_id'] == 1) - { - $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); - } - else - { - $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); - } - $pd_count = $this->db->GET()->result_array(); + $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) + { + $this->db->SELECT('USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no'); + $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'); + $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); + $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); + $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); + $this->db->GROUP_END(); + if($pdofficer['fk_pd_type_id'] == 1) + { + $this->db->WHERE('PDTRIGGER.fk_pd_allocated_to',$pdofficer['fk_user_id']); + } + else + { + $this->db->WHERE('PDTRIGGER.executive_id',$pdofficer['fk_user_id']); + } + $pd_count = $this->db->GET()->result_array(); //print_r($this->db->last_query()); - if(count($pd_count)){ - $list_of_pd_officers[$key]['pd_details'] = $pd_count; - $list_of_pd_officers[$key]['count'] =count($pd_count); - } - + if(count($pd_count)){ + $list_of_pd_officers[$key]['pd_details'] = $pd_count; + $list_of_pd_officers[$key]['count'] =count($pd_count); + } + // Get Profile Pic from S3 - - $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; - - - } - } - + + $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) - { - $this->db->SELECT('USERPROFILE.userid as fk_user_id,USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); - $this->db->FROM(USERPROFILE.' as USERPROFILE'); - $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); - $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) - { - - + $central_pd_officers = array(); + if($res_array[0]['fk_pd_type'] == 2 || $res_array[0]['fk_pd_type'] == 3) + { + $this->db->SELECT('USERPROFILE.userid as fk_user_id,USERPROFILE.first_name,USERPROFILE.last_name,USERPROFILE.profilepic,USERPROFILE.mobile_no,USERPROFILEROLES.user_role,ROLES.role_name'); + $this->db->FROM(USERPROFILE.' as USERPROFILE'); + $this->db->JOIN(USERPROFILEROLES.' as USERPROFILEROLES','USERPROFILE.userid = USERPROFILEROLES.fk_userid'); + $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'); - $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); - $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); - $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); - $this->db->GROUP_END(); - $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); - $pd_count = $this->db->GET()->result_array(); + $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'); + $this->db->JOIN(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS','PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1'); + $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); + $this->db->OR_WHERE('PDTRIGGER.pd_status',ALLOCATED); + $this->db->GROUP_END(); + $this->db->WHERE('PDTRIGGER.central_pd_officer_id',$central_pd_officer['fk_user_id']); + $pd_count = $this->db->GET()->result_array(); //print_r($this->db->last_query()); - $central_pd_officers[$k]['count'] = 0; - if(count($pd_count)){ - $central_pd_officers[$k]['pd_details'] = $pd_count; - $central_pd_officers[$k]['count'] = count($pd_count); } + $central_pd_officers[$k]['count'] = 0; + if(count($pd_count)){ + $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'); - $central_pd_officers[$k]['profile_url'] = $singed_uri; - } - } - } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Officers Records Not Found in General Team!'; - $this->response($data,REST_Controller::HTTP_OK); + + + $bucket_name = PROFILE_PICTURE_BUCKET_NAME; + $profilepics3path = 'sineedge/'.$central_pd_officer['profilepic']; + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+10 minutes'); + $central_pd_officers[$k]['profile_url'] = $singed_uri; } + } + } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = array('pdofficers' => $list_of_pd_officers,'centralpdofficers' => $central_pd_officers); + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Officers Records Not Found in General Team!'; + $this->response($data,REST_Controller::HTTP_OK); + } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'General Team Not Found'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'General Team Not Found'; + $this->response($data,REST_Controller::HTTP_OK); } } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'PD Master Records Not Found!'; - $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'PD Master Records Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } } - } - + /* PD_Triggerd and PD_Co_Applocants Details only for Listing Page @param page/offset @param limit @param sorting order(ASC/DESC) @param cid for category_id for filter question with category wise. */ - public function listLessPDDetails_get() - { + public function listLessPDDetails_get() + { $page = 0;$limit = 1000;$sort = 'DESC';$pdofficerid = "";$datetype = "";$fdate ="";$tdate =""; $lenderid = "";$status=""; if($this->get('page')) { $page = $this->get('page'); } @@ -1872,26 +1872,26 @@ class PD_Controller extends REST_Controller { $this->response($data,REST_Controller::HTTP_OK); } - } - - - public function filterPDList_post() - { + } + + + public function filterPDList_post() + { //echo "Hi"; - $records = $this->post('records'); + $records = $this->post('records'); //print_r($this->post('records'));die(); - $pd_type = $records['pd_type']; + $pd_type = $records['pd_type']; //print_r($records);die(); - $pd_status = $records['pd_status']; - $pd_from_date = $records['pd_from_date']; - $pd_to_date = $records['pd_to_date']; - $pd_city = $records['pd_city']; - $pd_products = $records['pd_products']; - $pd_lender = $records['pd_lender']; - $pd_applicant_name = strtolower($records['pd_name']); - $pd_applicant_lender_ref = strtolower($records['pd_applicant_id']); - $pd_officer_name = $records['pd_officer']; - $result_data = $this->PD_Model->PDListwithGlobalFilters($pd_type,$pd_status,$pd_from_date,$pd_to_date,$pd_city,$pd_products,$pd_lender,$pd_applicant_name,$pd_applicant_lender_ref,$pd_officer_name); + $pd_status = $records['pd_status']; + $pd_from_date = $records['pd_from_date']; + $pd_to_date = $records['pd_to_date']; + $pd_city = $records['pd_city']; + $pd_products = $records['pd_products']; + $pd_lender = $records['pd_lender']; + $pd_applicant_name = strtolower($records['pd_name']); + $pd_applicant_lender_ref = strtolower($records['pd_applicant_id']); + $pd_officer_name = $records['pd_officer']; + $result_data = $this->PD_Model->PDListwithGlobalFilters($pd_type,$pd_status,$pd_from_date,$pd_to_date,$pd_city,$pd_products,$pd_lender,$pd_applicant_name,$pd_applicant_lender_ref,$pd_officer_name); if(count($result_data)) { @@ -1907,9 +1907,9 @@ class PD_Controller extends REST_Controller { $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 +1926,7 @@ class PD_Controller extends REST_Controller { // 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 +1970,14 @@ class PD_Controller extends REST_Controller { $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); - + $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***************/ @@ -1995,27 +1995,27 @@ class PD_Controller extends REST_Controller { { $template_details = $this->PD_Model->getTemplateForPD($pd_id,$client,$random_string); - if(count($template_details)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $template_details; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + if(count($template_details)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template_details; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'Template Not for PD ID'.$pd_id; $this->response($data,REST_Controller::HTTP_OK); - } + } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_BAD_REQUEST; - $data['msg'] = 'No Param Available'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_BAD_REQUEST; + $data['msg'] = 'No Param Available'; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -2036,20 +2036,20 @@ class PD_Controller extends REST_Controller { { if($record['pd_detail_id'] != "" || $record['pd_detail_id'] != null) - { - - if($record['answers'] != "" || $record['answers'] != null) - { + { + + if($record['answers'] != "" || $record['answers'] != null) + { $answers_array = $record['answers']; unset($record['answers']); - } - - if($record['images'] != "" || $record['images'] != null) - { + } + + 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); @@ -2059,124 +2059,124 @@ class PD_Controller extends REST_Controller { //Deactivate Old Answers - $fields = array('pd_detail_answer_id'); - $where_condition_array = array('fk_pd_id' => $record['fk_pd_id'],'fk_pd_detail_id' => $record['pd_detail_id']); - $old_answers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDANSWER); - foreach($old_answers as $old) - { - $where_condition_array = array('pd_detail_answer_id'=>$old['pd_detail_answer_id']); - $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) + $fields = array('pd_detail_answer_id'); + $where_condition_array = array('fk_pd_id' => $record['fk_pd_id'],'fk_pd_detail_id' => $record['pd_detail_id']); + $old_answers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDANSWER); + foreach($old_answers as $old) + { + $where_condition_array = array('pd_detail_answer_id'=>$old['pd_detail_answer_id']); + $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) { - 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 - { - // Update Current Answer - $where_condition_array = array('pd_detail_answer_id'=>$answer['pd_detail_answer_id']); - $answer['isactive'] = 1; - $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++; } - } + $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 + { + // Update Current Answer + $where_condition_array = array('pd_detail_answer_id'=>$answer['pd_detail_answer_id']); + $answer['isactive'] = 1; + $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++; } + } + + } + } //IMAGES SAVE - pd_document_id, fk_pd_id, fk_pd_detail_id, pd_document_title, pd_document_name, createdon, fk_createdby, updatedon, fk_updatedby - if(count($images_array)) + if(count($images_array)) { 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"; - + $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); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $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 ); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $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++; } - - } + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 5; $i++) { + $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 ); + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $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'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); - } + { + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Something Went Wrong..!Try Later"; + $this->response($data,REST_Controller::HTTP_OK); + } - } - else - { - + } + else + { - - if($record['answers'] != "" || $record['answers'] != null) - { + + + if($record['answers'] != "" || $record['answers'] != null) + { $answers_array = $record['answers']; unset($record['answers']); - } - - if($record['images'] != "" || $record['images'] != null) - { + } + + if($record['images'] != "" || $record['images'] != null) + { $images_array = $record['images']; unset($record['images']); - } + } //print_r($record);die(); $pd_detail_id = $this->PD_Model->saveRecords($record,PDDETAIL); @@ -2196,74 +2196,74 @@ class PD_Controller extends REST_Controller { { 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"; - + $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); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $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 ); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $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++; } - - } + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 5; $i++) { + $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 ); + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $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; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - - + { + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pd_detail_id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Something Went Wrong..!Try Later"; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + + } - + @@ -2273,29 +2273,29 @@ class PD_Controller extends REST_Controller { /************** Get Answers for PD @params question_id, pd_id, template_id, category_id**************/ public function getAnswersForPD_post() { - $question_id = $this->post('question_id'); - $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); + $question_id = $this->post('question_id'); + $pd_id = $this->post('pd_id'); + $template_id = $this->post('template_id'); + $category_id = $this->post('category_id'); - if(count($answers)) - { - - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $answers; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Something Went Wrong..!Try Later"; - $this->response($data,REST_Controller::HTTP_OK); - } + $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; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Something Went Wrong..!Try Later"; + $this->response($data,REST_Controller::HTTP_OK); + } + } @@ -2314,11 +2314,11 @@ class PD_Controller extends REST_Controller { $rental_count_id = isset($records['rental_count_id']) ? $records['rental_count_id'] : null; //print_r($records);die(); $parent_pdid = $records['parent_pdid'];; - $parent_form_index = null; - $parent_forms = $this->config->item('parent_forms'); - $additional_pd_id = $pdid; + $parent_form_index = null; + $parent_forms = $this->config->item('parent_forms'); + $additional_pd_id = $pdid; - $inline_forms_photo_status_check = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid),T_PD_INLINE_PHOTO_FORM_STATUS); + $inline_forms_photo_status_check = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pdid),T_PD_INLINE_PHOTO_FORM_STATUS); // print_r($inline_forms_photo_status_check); // echo count($inline_forms_photo_status_check); @@ -2337,8 +2337,8 @@ class PD_Controller extends REST_Controller { } //Save Any New Applicants Details From General Form - if($formid == 18) - { + if($formid == 18) + { $records = $this->saveCoApplicantsFromGeneralInfoForm($records); if(!count($inline_forms_photo_status_check)) { @@ -2352,16 +2352,16 @@ class PD_Controller extends REST_Controller { - } - - if($formid == 10) - { + } + + if($formid == 10) + { $this->updateSubProductFromLoanDetailsForm($records); - } - + } + //From Business form save Employee Salary as Business Expenses - if($formid == 13) - { + if($formid == 13) + { $this->saveEmpSalaryAsBusinessExpensesFromBusinessForm($records); if(count($inline_forms_photo_status_check) && $inline_forms_photo_status_check[0]['is_business_photo_saved'] != 1) @@ -2369,265 +2369,265 @@ class PD_Controller extends REST_Controller { $records = INLINEPHOTOTRANSFORM::retransformBusinessFormInlinePhotos($records); $this->PD_Model->updateRecords(array('is_business_photo_saved' => 1),T_PD_INLINE_PHOTO_FORM_STATUS,array('fk_pd_id' => $pdid)); } - } - - if($formid == 22) - { + } + + if($formid == 22) + { $this->saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records); - } + } - $fields = array('isactive' => 0); - $where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid); - if($company_id != null) - { - $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; - } - + $fields = array('isactive' => 0); + $where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid); + if($company_id != null) + { + $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) { - switch($formid) - { - case 1: - $processed_json = GETPROCESSEDJSON::convertSupplierForm($records,$formid); - break; - - case 2: - $processed_json = GETPROCESSEDJSON::convertClientForm($records,$formid); - break; - case 4: - $processed_json = GETPROCESSEDJSON::convertOtherAssetForm($records,$formid); + switch($formid) + { + case 1: + $processed_json = GETPROCESSEDJSON::convertSupplierForm($records,$formid); + break; + + case 2: + $processed_json = GETPROCESSEDJSON::convertClientForm($records,$formid); + break; + case 4: + $processed_json = GETPROCESSEDJSON::convertOtherAssetForm($records,$formid); //$processed_json = $records; - break; - case 5: - $processed_json = GETPROCESSEDJSON::convertAddressForm($records,$formid); - break; - - case 6: - $processed_json = GETPROCESSEDJSON::convertOtherFamilyDetailsForm($records,$formid); - break; - case 8: - $processed_json = GETPROCESSEDJSON::convertExistingLoanDetailsForm($records,$formid); - break; - case 7: - $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); - break; - case 9: - $processed_json = GETPROCESSEDJSON::convertOtherIncomeDetailsForm($records,$formid); - break; - case 10: - $processed_json = GETPROCESSEDJSON::convertLoanDetailsForm($records,$formid); - break; - + break; + case 5: + $processed_json = GETPROCESSEDJSON::convertAddressForm($records,$formid); + break; + + case 6: + $processed_json = GETPROCESSEDJSON::convertOtherFamilyDetailsForm($records,$formid); + break; + case 8: + $processed_json = GETPROCESSEDJSON::convertExistingLoanDetailsForm($records,$formid); + break; + case 7: + $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); + break; + case 9: + $processed_json = GETPROCESSEDJSON::convertOtherIncomeDetailsForm($records,$formid); + break; + 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); + $processed_json = GETPROCESSEDJSON::convertStockDetailsForm($records,$formid); //print_r($processed_json);die(); - break; + break; case 12: - $processed_json = $records; - break; - + $processed_json = $records; + break; + case 14: // There is no master Data in Financial Form - $processed_json = $records; - break; - + $processed_json = $records; + break; + case 13: - $processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records,$formid); - break; - case 15: - $processed_json = $records; - break; + $processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records,$formid); + break; + case 15: + $processed_json = $records; + break; case 17: - $processed_json = GETPROCESSEDJSON::convertRentalIncomeDetailsForm($records,$formid); - break; + $processed_json = GETPROCESSEDJSON::convertRentalIncomeDetailsForm($records,$formid); + break; case 18: - $processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records,$formid); - break; - + $processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records,$formid); + break; + case 19: - $processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records,$formid); - break; + $processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records,$formid); + break; case 20: - $processed_json = GETPROCESSEDJSON::convertFinalRemarksForm($records,$formid); - break; - + $processed_json = GETPROCESSEDJSON::convertFinalRemarksForm($records,$formid); + break; + case 21: - $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); - break; - + $processed_json = GETPROCESSEDJSON::convertBankingInfoDetailsForm($records,$formid); + break; + case 22: - $processed_json = GETPROCESSEDJSON::convertBusinessAssetsForm($records,$formid); - break; + $processed_json = GETPROCESSEDJSON::convertBusinessAssetsForm($records,$formid); + break; case 23: - $processed_json = $records; - break; + $processed_json = $records; + break; case 24: - $processed_json = GETPROCESSEDJSON::convertCreditManagerQueriesForm($records,$formid); - $records['docs_to_be_sighted'] = $processed_json['docs_to_be_sighted']; - unset($processed_json['docs_to_be_sighted']); + $processed_json = GETPROCESSEDJSON::convertCreditManagerQueriesForm($records,$formid); + $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']); - unset($records['company_id']); - unset($records['parent_pdid']); + } + + + + /*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/ + + unset($records['pdid']); + unset($records['formid']); + unset($records['fk_createdby']); + unset($records['company_id']); + unset($records['parent_pdid']); //unset($records['rental_count_id']); - $records = json_encode($records); - if($processed_json != null) - { - $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) - { + $records = json_encode($records); + if($processed_json != null) + { + $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; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later..!'; - $this->response($data,REST_Controller::HTTP_OK); - } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later..!'; + $this->response($data,REST_Controller::HTTP_OK); } - - public function getPDFormDetailsJSON_post() - { - $pd_id = $this->post('pd_id'); - $pd_form_id = $this->post('pd_form_id'); +} + + +public function getPDFormDetailsJSON_post() +{ + $pd_id = $this->post('pd_id'); + $pd_form_id = $this->post('pd_form_id'); $parent_pd_id = $this->post('parent_pdid');// ? $this->post('parent_pd_id') : null; $company_id = $this->post('company_id') ? $this->post('company_id') : null; - $parent_form_index = null; + $parent_form_index = null; $parent_forms = $this->config->item('parent_forms'); $is_addtional_pd = 0; $additional_pd_id = null; - if($pd_id != $parent_pd_id) - { - $is_addtional_pd = 1; - $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; - - } + if($pd_id != $parent_pd_id) + { + $is_addtional_pd = 1; + $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); + + $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); //print_r($form_count); - if(!count($form_count)) - { + if(!count($form_count)) + { //echo "dsjsbsdj"; - $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']); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $temp_json; - $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'=>$parent_pd_id); + $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + + if(count($rec)) + { + $temp_json = $this->renewGeneralFormForAddtionalPD($rec[0]['json']); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $temp_json; + $this->response($data,REST_Controller::HTTP_OK); + } + + } } 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']); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { + + $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']); + $this->response($data,REST_Controller::HTTP_OK); + } + else + { //echo "get address details from address form"; - $fields = array('*'); - $where_condition_array = array('assigned_pd' => $pd_id); - $assigned_address = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDADDRESS); - if(count($assigned_address)) - { - $temp_address = $assigned_address[0]; + $fields = array('*'); + $where_condition_array = array('assigned_pd' => $pd_id); + $assigned_address = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDADDRESS); + if(count($assigned_address)) + { + $temp_address = $assigned_address[0]; //print_r($temp_address); //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); - - } - } + $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); + + $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 +2636,10 @@ class PD_Controller extends REST_Controller { // $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,20 +2647,20 @@ class PD_Controller extends REST_Controller { // } // } // } - - - if(count($rec)) - { - $json = null; - if($pd_form_id == 17) - { - - foreach($rec as $r) - { - - $json[] = json_decode($r['json'],true); - } - } + + + if(count($rec)) + { + $json = null; + if($pd_form_id == 17) + { + + foreach($rec as $r) + { + + $json[] = json_decode($r['json'],true); + } + } else if($pd_form_id == 24) //// common form credit managers specific queries { $json = $this->getDocsToBeSightedImagesS3URL( json_decode($rec[0]['json'],true),$pd_id ); @@ -2670,272 +2670,272 @@ class PD_Controller extends REST_Controller { $json = json_decode($rec[0]['json']); } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $json; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $json; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Data Available'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $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 - function getDocsToBeSightedImagesS3URL( $credit_manager_form_data,$pd_id ) - { - $pd_documnets = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'fk_form_id' => 24),PDDOCUMENTS); - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - if(count($pd_documnets)) - { - $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; + function getDocsToBeSightedImagesS3URL( $credit_manager_form_data,$pd_id ) + { + $pd_documnets = $this->PD_Model->selectCustomRecords(array('*'),array('fk_pd_id' => $pd_id,'fk_form_id' => 24),PDDOCUMENTS); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + if(count($pd_documnets)) + { + $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']) - { - $key = 'pd'.$pd_id.'/'.$doc_value['pd_document_name']; + + 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']) + { + $key = 'pd'.$pd_id.'/'.$doc_value['pd_document_name']; //echo $key;die(); - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); //echo $doc_value['pd_document_id'] .'********'.$singed_uri.'*******'; - $credit_manager_form_data['docs_to_be_sighted'][$docs_to_be_sighted_key]['img'] = $singed_uri; + $credit_manager_form_data['docs_to_be_sighted'][$docs_to_be_sighted_key]['img'] = $singed_uri; - } - } - } - } - 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); + } + } + } + } + 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); //echo 'getAddtionalPDAssetsWithLoanFromBusinessAndOtherAssets'; //Get Other Assets $fields = array('json','processed_json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>4,'fk_pd_id'=>$pd_id); - $other_assests = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $where_condition_array = array('isactive' => 1,'fk_form_id'=>4,'fk_pd_id'=>$pd_id); + $other_assests = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); //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) - { + $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); + } + $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') - { + foreach($other_assests['assets_details'] as $other_assest) + { + + if($other_assest['emi'] == 'ýes') + { $converted_data = $this->convertOtherAssetAsExistingLoanParams($other_assest); //print_r($converted_data); $parentpd_existing_loan_details['loan_details'][] = $converted_data; - } + } - } - + } - } - - if(count($business_assests)) - { - $business_assests = json_decode($business_assests[0]['json'],true); + + } + + 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') - { - $data['loan_amount'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $data['current_balance_tenure'] = ""; - $data['elapsed_tenure'] = ""; - $data['label'] = $business_assests['business_assets_for_address'][0]['address_label']; - $parentpd_existing_loan_details['loan_details'][] = $data; - } - } - foreach($business_assests['business_assets_details'] as $business_assest) - { - 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'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $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); - + if(isset($business_assests['business_assets_for_address'])) + { + if($business_assests['business_assets_for_address'][0]['business_emi'] == 'yes') + { + $data['loan_amount'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $data['current_balance_tenure'] = ""; + $data['elapsed_tenure'] = ""; + $data['label'] = $business_assests['business_assets_for_address'][0]['address_label']; + $parentpd_existing_loan_details['loan_details'][] = $data; + } + } + foreach($business_assests['business_assets_details'] as $business_assest) + { + 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'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $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']) - { - case 7 : + switch($business_assest['business_assets_mode']) + { + 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 : + 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 : + break; + + case 6 : $label = $business_assest['business_name_of_the_owner'][0]['name'].' - Life Insurance Policy'; - break; - - case 2 : + 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; - } - $data['label'] = $label; - return $data; - } - - - function convertOtherAssetAsExistingLoanParams($other_assest) - { + break; + } + $data['label'] = $label; + return $data; + } + + + function convertOtherAssetAsExistingLoanParams($other_assest) + { //echo 'convertOtherAssetAsExistingLoanParams'; - $data['loan_amount'] = ""; - $data['frequency'] = ""; - $data['other_frequency'] = ""; - $data['emi'] = ""; - $data['loan_type'] = ""; - $data['others_loan_type'] = ""; - $data['loan_taken_by'] = ""; - $data['lender'] = ""; - $data['others_lender'] = ""; - $data['original_tenure'] = ""; - $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); - + $data['loan_amount'] = ""; + $data['frequency'] = ""; + $data['other_frequency'] = ""; + $data['emi'] = ""; + $data['loan_type'] = ""; + $data['others_loan_type'] = ""; + $data['loan_taken_by'] = ""; + $data['lender'] = ""; + $data['others_lender'] = ""; + $data['original_tenure'] = ""; + $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']) - { - case 7 : + switch($other_assest['assets_mode']) + { + 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 : + break; + + case 4 : $label = $other_assest['name_of_the_owner'][0]['name'].' - Equipment & Machinary ('. ($other_assest['details'][0]['equipment_manufacturing_description']) .')'; - break; - - case 6 : + break; + + case 6 : $label = $other_assest['name_of_the_owner'][0]['name'].' - Life Insurance Policy'; - break; - - case 2 : + break; + + case 2 : $label = $other_assest['name_of_the_owner'][0]['name'].' - Property ('. ($property_types[ $other_assest['details'][0]['property_type'] - 1]['name']) .')'; - break; - + break; + //case - } - $data['label'] = $label; - return $data; - } - - public function renewGeneralFormForAddtionalPD($json) - { + } + $data['label'] = $label; + return $data; + } + + public function renewGeneralFormForAddtionalPD($json) + { //echo 'renewGeneralFormForAddtionalPD'; - $json = json_decode($json,true); - if(array_key_exists('individuals',$json)) - { - foreach($json['individuals'] as $individual_key => $individual) - { - $json['individuals'][$individual_key]['is_person_met'] = false; - } - } - - if(array_key_exists('companies',$json)) - { - foreach($json['companies'] as $company_key => $compnay) - { + $json = json_decode($json,true); + if(array_key_exists('individuals',$json)) + { + foreach($json['individuals'] as $individual_key => $individual) + { + $json['individuals'][$individual_key]['is_person_met'] = false; + } + } + + if(array_key_exists('companies',$json)) + { + foreach($json['companies'] as $company_key => $compnay) + { //print_r($company); - $json['companies'][$company_key]['is_company_applicant'] = false; - $json['companies'][$company_key]['business_entity_type'] = null; - $json['companies'][$company_key]['business_years'] = ""; - $json['companies'][$company_key]['business_month'] = ""; - $json['companies'][$company_key]['business_date_object'] = ""; + $json['companies'][$company_key]['is_company_applicant'] = false; + $json['companies'][$company_key]['business_entity_type'] = null; + $json['companies'][$company_key]['business_years'] = ""; + $json['companies'][$company_key]['business_month'] = ""; + $json['companies'][$company_key]['business_date_object'] = ""; //$json['companies'][$company_key]['business_date_object'] = ""; + } + } + $json['company_with_relationships'][] = array('applicant_name' => "",'company_relationship' => '','relation_to_company' => ""); + $json['general_remark'] = ""; + + return (($json)); + } - } - $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'); - $this->excel->getActiveSheet()->setTitle('Material Master'); - $this->excel->getActiveSheet()->setCellValue('F3', 'SIDDHARTH INDUSTRIES Material Master'); + + public function downloadExcel_get() + { + $this->excel->setActiveSheetIndex(0)->mergeCells('F3:M3'); + $this->excel->getActiveSheet()->setTitle('Material Master'); + $this->excel->getActiveSheet()->setCellValue('F3', 'SIDDHARTH INDUSTRIES Material Master'); $filename = 'MaterialMaster'.'.xls'; //save our workbook as this file name header('Content-Type: application/vnd.ms-excel'); //mime type header('Access-Control-Expose-Headers:Content-Disposition'); //mime type @@ -2945,114 +2945,114 @@ class PD_Controller extends REST_Controller { if (ob_get_contents()) ob_end_clean(); ob_start(); $objWriter->save('php://output'); - } + } //Save Co applicants details from General Form - public function saveCoApplicantsFromGeneralInfoForm($records) - { - + public function saveCoApplicantsFromGeneralInfoForm($records) + { + //print_r($records);die(); - if(count($records['individuals'])) - { + if(count($records['individuals'])) + { //echo 'saveCoApplicantsFromGeneralInfoForm'; - $exist_applicants = $this->PD_Model->getApplicantsDetails($records['pdid']); + $exist_applicants = $this->PD_Model->getApplicantsDetails($records['pdid']); //print_r($exist_applicants); //echo "Yes"; - $index_of_new_applicants = array(); - 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) - { - if($persons_with_relationship['pd_co_applicant_id'] == $current_temp_id) - { - $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) - { - if($company_with_relationship['applicant_name'] == $current_temp_id) - { - $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 #########################*/ - - } - - - - } - + $index_of_new_applicants = array(); + 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) + { + if($persons_with_relationship['pd_co_applicant_id'] == $current_temp_id) + { + $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) + { + if($company_with_relationship['applicant_name'] == $current_temp_id) + { + $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,492 +3060,492 @@ class PD_Controller extends REST_Controller { // $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 #########################*/ - } - } - } - - + + 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']); + + + } + + 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); + $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(); //print_r($fine);die(); - if($fine != null) - { - $fine['purchase_declared_by_customer'] = $result_array['purchase_declared_by_customer']; - $fine['sales_revenue_details'] = $result_array['sales_calculated_by_itemwise']; - $fine['other_business_income_details'] = $result_array['othre_business_income']; - $fine['purchase_details'] = $result_array['purchase_details']; + if($fine != null) + { + $fine['purchase_declared_by_customer'] = $result_array['purchase_declared_by_customer']; + $fine['sales_revenue_details'] = $result_array['sales_calculated_by_itemwise']; + $fine['other_business_income_details'] = $result_array['othre_business_income']; + $fine['purchase_details'] = $result_array['purchase_details']; //$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; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_array; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_array; - $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); - } - else - { - $pk = $this->PD_Model->saveRecords($records,SALESDECLAREDBYCUSTOMER); - } - - if($pk != "" || $pk != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pk; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - } + $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; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_array; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_array; + $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); + } + else + { + $pk = $this->PD_Model->saveRecords($records,SALESDECLAREDBYCUSTOMER); + } + + if($pk != "" || $pk != null) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pk; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } - public function saveAssessedIncomePurchaseDeclaredByCustomer_post() - { - $records = $this->post('records'); - $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); - } - else - { - $pk = $this->PD_Model->saveRecords($records,PURCHASEDECLAREDBYCUSTOMER); - } - - if($pk != "" || $pk != null) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $pk; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - } - - public function saveOtherBusinessIncome_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['pd_business_income_id'] != null || $record['pd_business_income_id'] != "") - { - $where_condition_array = array('pd_business_income_id'=>$record['pd_business_income_id']); - $id = $this->PD_Model->updateRecords($record,PDBUSINESSINCOME,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDBUSINESSINCOME); - if($id != "" || $id != null){$count++;} - } - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - } + public function saveAssessedIncomePurchaseDeclaredByCustomer_post() + { + $records = $this->post('records'); + $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); + } + else + { + $pk = $this->PD_Model->saveRecords($records,PURCHASEDECLAREDBYCUSTOMER); + } + + if($pk != "" || $pk != null) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pk; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } + + public function saveOtherBusinessIncome_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $rec_key => $record) + { + if($record['pd_business_income_id'] != null || $record['pd_business_income_id'] != "") + { + $where_condition_array = array('pd_business_income_id'=>$record['pd_business_income_id']); + $id = $this->PD_Model->updateRecords($record,PDBUSINESSINCOME,$where_condition_array); + if($id != "" || $id != null){$count++;} + } + else + { + $id = $this->PD_Model->saveRecords($record,PDBUSINESSINCOME); + if($id != "" || $id != null){$count++;} + } + } + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } - public function saveAssessedIncomeSalesCalculatedByItemwise_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { + public function saveAssessedIncomeSalesCalculatedByItemwise_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $rec_key => $record) + { - $child_data = array(); - if(array_key_exists('child',$record)) - { - $child_data = $record['child']; - unset($record['child']); - } + $child_data = array(); + if(array_key_exists('child',$record)) + { + $child_data = $record['child']; + unset($record['child']); + } - - if($record['sci_id'] != null || $record['sci_id'] != "") - { - $where_condition_array = array('sci_id'=>$record['sci_id']); - $id = $this->PD_Model->updateRecords($record,SALESCALCULATEDBYITEMWISE,$where_condition_array); - if($id != "" || $id != null){$count++;} - if($record['sales_type'] == 3) - { - foreach($child_data as $ckey => $child) - { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { - $child['fk_sci_id'] = $record['sci_id']; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } - } - } - } - else - { - $id = $this->PD_Model->saveRecords($record,SALESCALCULATEDBYITEMWISE); - if($id != "" || $id != null){$count++;} + + if($record['sci_id'] != null || $record['sci_id'] != "") + { + $where_condition_array = array('sci_id'=>$record['sci_id']); + $id = $this->PD_Model->updateRecords($record,SALESCALCULATEDBYITEMWISE,$where_condition_array); + if($id != "" || $id != null){$count++;} + if($record['sales_type'] == 3) + { + foreach($child_data as $ckey => $child) + { + if($child['simc_id'] != "" || $child['simc_id'] != null) + { + $where_condition_array = array('simc_id'=>$child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); + } + else + { + if(($child['sales_date'] != null || $child['sales_date'] != "")) + { + $child['fk_sci_id'] = $record['sci_id']; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + } + } + } + } + } + else + { + $id = $this->PD_Model->saveRecords($record,SALESCALCULATEDBYITEMWISE); + if($id != "" || $id != null){$count++;} - if($record['sales_type'] == 3) - { - foreach($child_data as $ckey => $child) - { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { - $child['fk_sci_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } - } - } - } - - - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function saveAssessedIncomePurchaseDetails_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - $child_data = ""; - if(array_key_exists('child',$record)) - { - $child_data = $record['child']; - unset($record['child']); - } + if($record['sales_type'] == 3) + { + foreach($child_data as $ckey => $child) + { + if($child['simc_id'] != "" || $child['simc_id'] != null) + { + $where_condition_array = array('simc_id'=>$child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); + } + else + { + if(($child['sales_date'] != null || $child['sales_date'] != "")) + { + $child['fk_sci_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + } + } + } + } + } + + + } + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + public function saveAssessedIncomePurchaseDetails_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $rec_key => $record) + { + $child_data = ""; + if(array_key_exists('child',$record)) + { + $child_data = $record['child']; + unset($record['child']); + } - if($record['purchase_id'] != null || $record['purchase_id'] != "") - { - $where_condition_array = array('purchase_id'=>$record['purchase_id']); - $id = $this->PD_Model->updateRecords($record,PDPURCHASEDETAILS,$where_condition_array); - if($id != "" || $id != null){$count++;} - if($record['purchase_type'] == 3) - { - if($id != "" || $id != null) - { - - foreach($child_data as $ckey => $child) - { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { - $child['fk_purchase_id'] = $record['purchase_id']; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); - } - } - } - } + if($record['purchase_id'] != null || $record['purchase_id'] != "") + { + $where_condition_array = array('purchase_id'=>$record['purchase_id']); + $id = $this->PD_Model->updateRecords($record,PDPURCHASEDETAILS,$where_condition_array); + if($id != "" || $id != null){$count++;} + if($record['purchase_type'] == 3) + { + if($id != "" || $id != null) + { + + foreach($child_data as $ckey => $child) + { + if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) + { + $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); + } + else + { + $child['fk_purchase_id'] = $record['purchase_id']; + $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + } + } + } + } - } - else - { - $id = $this->PD_Model->saveRecords($record,PDPURCHASEDETAILS); - if($id != "" || $id != null){$count++;} - if($record['purchase_type'] == 3) - { - if($id != "" || $id != null) - { - - foreach($child_data as $ckey => $child) - { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { - $child['fk_purchase_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); - } - } - } - } - } - } - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function saveAssessedIncomeBusinessExpenses_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['pd_expense_id'] != null || $record['pd_expense_id'] != "") - { - $where_condition_array = array('pd_expense_id'=>$record['pd_expense_id']); - $id = $this->PD_Model->updateRecords($record,PDBUSINESSEXPENSES,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDBUSINESSEXPENSES); - if($id != "" || $id != null){$count++;} - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - public function saveAssessedIncomeHouseholdExpenses_post() - { - $records = $this->post('records'); - $count = 0; - foreach($records as $rec_key => $record) - { - if($record['household_expense_id'] != null || $record['household_expense_id'] != "") - { - $where_condition_array = array('household_expense_id'=>$record['household_expense_id']); - $id = $this->PD_Model->updateRecords($record,PDHOUSEHOLDEXPENSES,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,PDHOUSEHOLDEXPENSES); - if($id != "" || $id != null){$count++;} - } - } - - if($count == count($records)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = true; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - + } + else + { + $id = $this->PD_Model->saveRecords($record,PDPURCHASEDETAILS); + if($id != "" || $id != null){$count++;} + if($record['purchase_type'] == 3) + { + if($id != "" || $id != null) + { + + foreach($child_data as $ckey => $child) + { + if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) + { + $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); + } + else + { + $child['fk_purchase_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + } + } + } + } + } + } + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + public function saveAssessedIncomeBusinessExpenses_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $rec_key => $record) + { + if($record['pd_expense_id'] != null || $record['pd_expense_id'] != "") + { + $where_condition_array = array('pd_expense_id'=>$record['pd_expense_id']); + $id = $this->PD_Model->updateRecords($record,PDBUSINESSEXPENSES,$where_condition_array); + if($id != "" || $id != null){$count++;} + } + else + { + $id = $this->PD_Model->saveRecords($record,PDBUSINESSEXPENSES); + if($id != "" || $id != null){$count++;} + } + } + + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + public function saveAssessedIncomeHouseholdExpenses_post() + { + $records = $this->post('records'); + $count = 0; + foreach($records as $rec_key => $record) + { + if($record['household_expense_id'] != null || $record['household_expense_id'] != "") + { + $where_condition_array = array('household_expense_id'=>$record['household_expense_id']); + $id = $this->PD_Model->updateRecords($record,PDHOUSEHOLDEXPENSES,$where_condition_array); + if($id != "" || $id != null){$count++;} + } + else + { + $id = $this->PD_Model->saveRecords($record,PDHOUSEHOLDEXPENSES); + if($id != "" || $id != null){$count++;} + } + } + + if($count == count($records)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = true; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $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 @@ -3556,20 +3556,20 @@ class PD_Controller extends REST_Controller { //foreach($records as $key => $record) //{ //$record['sales_type'] - $child_data = array(); - if(array_key_exists('child',$record)) - { - $child_data = $record['child']; - unset($record['child']); - } - $id = ""; + $child_data = array(); + if(array_key_exists('child',$record)) + { + $child_data = $record['child']; + unset($record['child']); + } + $id = ""; //Remove other than DB fields - if(array_key_exists('margin_final_value',$record)) - { - $record['margin_value'] = $record['margin_final_value']; - unset($record['margin_final_value']); - } + if(array_key_exists('margin_final_value',$record)) + { + $record['margin_value'] = $record['margin_final_value']; + unset($record['margin_final_value']); + } // array_key_exists('sales_qty', $record) ? unset($record['sales_qty']) : ''; // array_key_exists('fk_uom_id', $record) ? unset($record['fk_uom_id']) : ''; // array_key_exists('rate_per_unit', $record) ? unset($record['rate_per_unit']) : ''; @@ -3578,52 +3578,52 @@ class PD_Controller extends REST_Controller { // array_key_exists('margin_per_uom', $record) ? unset($record['margin_per_uom']) : ''; // CURD Operations - if($record['sim_id'] != null || $record['sim_id'] != "" ) + if($record['sim_id'] != null || $record['sim_id'] != "" ) + { + $where_condition_array = array('sim_id'=>$record['sim_id']); + $id = $this->PD_Model->updateRecords($record,SALESITEMMONTHWISE,$where_condition_array); + if($id != "" || $id != null) + { + $count++; + foreach($child_data as $ckey => $child) { - $where_condition_array = array('sim_id'=>$record['sim_id']); - $id = $this->PD_Model->updateRecords($record,SALESITEMMONTHWISE,$where_condition_array); - if($id != "" || $id != null) + if($child['simc_id'] != "" || $child['simc_id'] != null) { - $count++; - foreach($child_data as $ckey => $child) + $where_condition_array = array('simc_id'=>$child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); + } + else + { + if(($child['sales_date'] != null || $child['sales_date'] != "")) { - if($child['simc_id'] != "" || $child['simc_id'] != null) - { - $where_condition_array = array('simc_id'=>$child['simc_id']); - $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); - } - else - { - if(($child['sales_date'] != null || $child['sales_date'] != "")) - { - $child['fk_sim_id'] = $record['sim_id']; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } + $child['fk_sim_id'] = $record['sim_id']; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); } } - } - else - { - - $id = $this->PD_Model->saveRecords($record,SALESITEMMONTHWISE); - if($id != "" || $id != null) - { - $count++; + } + + } + else + { + + $id = $this->PD_Model->saveRecords($record,SALESITEMMONTHWISE); + if($id != "" || $id != null) + { + $count++; - foreach($child_data as $ckey => $child) - { - if((($child['sales_date'] != null || $child['sales_date'] != ""))) - { + foreach($child_data as $ckey => $child) + { + if((($child['sales_date'] != null || $child['sales_date'] != ""))) + { //echo 'true'; - $child['fk_sim_id'] = $id; - $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); - } - } - } - + $child['fk_sim_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + } } + } + + } //} if($id != "") @@ -3639,50 +3639,50 @@ class PD_Controller extends REST_Controller { $count = 0; foreach($records as $key => $record) { - - $child_data = array(); - if(array_key_exists('child',$record)) + + $child_data = array(); + if(array_key_exists('child',$record)) + { + $child_data = $record['child']; + unset($record['child']); + } + $id = ""; + if($record['pbw_id'] != null || $record['pbw_id'] != "") + { + $where_condition_array = array('pbw_id'=>$record['pbw_id']); + $id = $this->PD_Model->updateRecords($record,PDPURCHASEBILLWISE,$where_condition_array); + if($id != "" || $id != null) { - $child_data = $record['child']; - unset($record['child']); - } - $id = ""; - if($record['pbw_id'] != null || $record['pbw_id'] != "") - { - $where_condition_array = array('pbw_id'=>$record['pbw_id']); - $id = $this->PD_Model->updateRecords($record,PDPURCHASEBILLWISE,$where_condition_array); - if($id != "" || $id != null) + $count++; + foreach($child_data as $ckey => $child) { - $count++; - foreach($child_data as $ckey => $child) + if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) { - if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) - { - $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); - $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); - } - else - { - $child['fk_pbw_id'] = $record['pbw_id']; - $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); - } + $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); } - } - - } - else - { - $id = $this->PD_Model->saveRecords($record,PDPURCHASEBILLWISE); - if($id != "" || $id != null) - { - $count++; - foreach($child_data as $ckey => $child) + else { - $child['fk_pbw_id'] = $id; + $child['fk_pbw_id'] = $record['pbw_id']; $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); } } } + + } + else + { + $id = $this->PD_Model->saveRecords($record,PDPURCHASEBILLWISE); + if($id != "" || $id != null) + { + $count++; + foreach($child_data as $ckey => $child) + { + $child['fk_pbw_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + } + } + } } if($count == count($records)) @@ -3732,8 +3732,8 @@ class PD_Controller extends REST_Controller { $columns = array('TEMPLATEFORMS.form_id','PDFORMS.pd_form_name'); $table = TEMPLATEFORMS.' as TEMPLATEFORMS'; $joins = array(array('table' => PDFORMS. ' as PDFORMS', - 'condition' =>'TEMPLATEFORMS.form_id = PDFORMS.pd_form_id AND TEMPLATEFORMS.isactive = 1', - 'jointype' => 'INNER')); + 'condition' =>'TEMPLATEFORMS.form_id = PDFORMS.pd_form_id AND TEMPLATEFORMS.isactive = 1', + 'jointype' => 'INNER')); $where_condition_array = array('fk_template_id' => $template_id); $template_form_details = $this->PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,'PDFORMS.pd_form_order'); //print_r($template_form_details); @@ -3762,10 +3762,10 @@ class PD_Controller extends REST_Controller { //$final_data_to_response['question_answers']['form_details'] = array(); $object = new stdClass(); - foreach($final_data_to_response as $key => $value) - { - $object->$key = $value; - } + foreach($final_data_to_response as $key => $value) + { + $object->$key = $value; + } if(count($final_data_to_response)) { $data['dataStatus'] = true; @@ -3805,42 +3805,42 @@ class PD_Controller extends REST_Controller { $current_question_array = array(); if(count($pd_form_raw_data)) { - foreach($pd_form_raw_data as $raw_key => $raw_data) - { - $que_key = $raw_data['column_name']; - if($que_key != null || $que_key != "") + foreach($pd_form_raw_data as $raw_key => $raw_data) { - foreach($question_key_master_data as $master_key => $master) + $que_key = $raw_data['column_name']; + if($que_key != null || $que_key != "") { - if($master['key'] == $que_key) + foreach($question_key_master_data as $master_key => $master) { - if($master['ismaster'] != 1) + if($master['key'] == $que_key) { - $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$raw_data['column_value'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); - } - else - { - $table = constant($master['master_name']); - $temp_fields = array($master_tables_field_names[$master['master_name']].' as name'); - $where_condition_array = array($master_tables_pkid[$master['master_name']] => $raw_data['column_value']); - $result_data = $this->PD_Model->selectCustomRecords($temp_fields,$where_condition_array,$table); - if(count($result_data)) + if($master['ismaster'] != 1) { - //print_r($result_data); - $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$result_data[0]['name'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); + $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$raw_data['column_value'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); } + else + { + $table = constant($master['master_name']); + $temp_fields = array($master_tables_field_names[$master['master_name']].' as name'); + $where_condition_array = array($master_tables_pkid[$master['master_name']] => $raw_data['column_value']); + $result_data = $this->PD_Model->selectCustomRecords($temp_fields,$where_condition_array,$table); + if(count($result_data)) + { + //print_r($result_data); + $current_question_array[] = array('category_id'=>$raw_data['fk_category_id'],'category_name'=>$raw_data['category_name'],'category_weightage' => $raw_data['category_weightage'],'question_weightage' => $raw_data['question_weightage'],'answer_score' => $raw_data['score'],'max_score' => $raw_data['max_score'],'question'=>$master['question'],'answer'=>$result_data[0]['name'],'actual_score'=>$raw_data['actual_score'],'exact_score'=>$raw_data['exact_score']); + } // + } } } } } } - } return $current_question_array ; - + } @@ -3979,18 +3979,18 @@ class PD_Controller extends REST_Controller { // if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 1)//purchase item wise // { - foreach($purchases as $purchase_key => $purchase) - { - - $overall_purchase_total += $purchase['annual_purchase_value']; - } + 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'])) ); // } //} @@ -4005,16 +4005,16 @@ class PD_Controller extends REST_Controller { $temp_netprofit = 0; $temp_grossprofit = 0; $temp_netmargin = 0; - $month_total = 0; - $i = 0; + $month_total = 0; + $i = 0; foreach($sales_calculated_by_itemwise as $itemwise_key => $item) { //print_r($item);die(); // if($item['sales_type'] != 3) // { - $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; - $temp_netprofit = $temp_netprofit + $item['margin_final_value']; + $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; + $temp_netprofit = $temp_netprofit + $item['margin_final_value']; // } // else // { @@ -4023,7 +4023,7 @@ class PD_Controller extends REST_Controller { // // { // //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 +4031,7 @@ class PD_Controller extends REST_Controller { // foreach($item['items'] as $month_key => $month) // { // $temp = 0; - + // $i++; // foreach($month as $key => $m) // { @@ -4040,20 +4040,20 @@ class PD_Controller extends REST_Controller { // $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 +4118,7 @@ class PD_Controller extends REST_Controller { // foreach($sales_by_item_month['items'] as $month_key => $month) // { // $temp = 0; - + // $i++; // foreach($month as $key => $m) // { @@ -4127,19 +4127,19 @@ class PD_Controller extends REST_Controller { // $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 +4149,7 @@ class PD_Controller extends REST_Controller { // $total_sales_monthwise = $total_sales_monthwise + $sale['total']; // } // } - + // //calculation part // //calculatin part // if($gross_profit_calculation_type[0]['mode'] == 1) @@ -4167,7 +4167,7 @@ class PD_Controller extends REST_Controller { // //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 +4176,10 @@ class PD_Controller extends REST_Controller { // $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 +4209,7 @@ class PD_Controller extends REST_Controller { $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); @@ -4321,9 +4321,9 @@ class PD_Controller extends REST_Controller { $is_qc_edited = 0; if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); - } + { + mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + } $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid,$random_string); @@ -4341,112 +4341,112 @@ class PD_Controller extends REST_Controller { if($is_qc_edited == 1 || $is_qc_edited == 2) { //Get Latest PD Report Html file and convert it into PDF - $latest_pd_report_html_file_name = $pd_master_details[0]['pd_report_html_filename']; - $latest_pd_report_html_file_path = $this->external_path.'/pd_reports/'.$pdid.'/'.$latest_pd_report_html_file_name.'.html'; - $temp = file_get_contents($latest_pd_report_html_file_path); + $latest_pd_report_html_file_name = $pd_master_details[0]['pd_report_html_filename']; + $latest_pd_report_html_file_path = $this->external_path.'/pd_reports/'.$pdid.'/'.$latest_pd_report_html_file_name.'.html'; + $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; + + $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 - - + $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"); + $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); - + $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); + + $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) - { + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { //$result_array[0]['content'] - $where_condition_array = array("pd_id" => $pdid); - $temp_array['is_qc_edited'] = 0; - $id = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array); - + $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; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $singed_uri; + + + + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + + if($id != null || $id != "" ) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $singed_uri; //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } - + $this->response($data,REST_Controller::HTTP_OK); } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong..!Try later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } }else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong..!Try later'; + $this->response($data,REST_Controller::HTTP_OK); } } else //If Qc not edited pull PDF uri from S3 { - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - - if($singed_uri != null || $singed_uri != "" ) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $singed_uri; - //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + if($singed_uri != null || $singed_uri != "" ) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $singed_uri; + //$data['records'] = array('pdf_url' => $singed_uri,'zip_url' => $zip_file_uri); + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong..!Try later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + }//funcion end - - + + //Generate Report as HTML File - public function generatePDReport_post() - { + public function generatePDReport_post() + { $records = $this->post('records'); $pdid = $records['pd_id']; $fk_createdby = $records['fk_createdby']; @@ -4454,12 +4454,13 @@ class PD_Controller extends REST_Controller { if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); - } + { + mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + } $data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid,$random_string); $data['pd_master_details'][0]['pd_report_generated_date'] = date('d/m/Y g:i:s A'); + $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $data['pd_master_details'][0]['fk_lender_id'])); $data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); $data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); $data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly($pdid); @@ -4507,18 +4508,18 @@ class PD_Controller extends REST_Controller { //GET ALL PROCESSED JSON - for($i = 1;$i<=30;$i++) - { - $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); - } + for($i = 1;$i<=30;$i++) + { + $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'); - - $temp = $this->load->view('report_templates/JSONTOREPORT',$data,true); + $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'); $pd_report_store = $this->external_path.'/pd_reports/'.$pdid.'/'.$pd_report_time.'.html'; @@ -4528,27 +4529,27 @@ class PD_Controller extends REST_Controller { { //$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); - + + $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 { - $response_data['dataStatus'] = false; - $response_data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $response_data['msg'] = 'Something went wrong..!'; - $this->response($response_data,REST_Controller::HTTP_OK); + $response_data['dataStatus'] = false; + $response_data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $response_data['msg'] = 'Something went wrong..!'; + $this->response($response_data,REST_Controller::HTTP_OK); } - + } public function archivePDImages_post() @@ -4559,9 +4560,9 @@ class PD_Controller extends REST_Controller { $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid,$random_string); if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); - } + { + mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + } $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_master_details[0]['fk_lender_id']; @@ -4574,69 +4575,69 @@ class PD_Controller extends REST_Controller { $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); if($pd_master_details[0]['is_zip_created']) { - $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); + $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucketname,$key,'+30 minutes'); - $response_data['dataStatus'] = true; - $response_data['status'] = REST_Controller::HTTP_OK; - $response_data['records'] = $singed_uri; - $this->response($response_data,REST_Controller::HTTP_OK); + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $singed_uri; + $this->response($response_data,REST_Controller::HTTP_OK); } 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) - { - $form_name[ $form['pd_form_id'] ] = $form['pd_form_name']; - } + + $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) + { + $form_name[ $form['pd_form_id'] ] = $form['pd_form_name']; + } //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->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); + $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) - { + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { //$result_array[0]['content'] - $where_condition_array = array("pd_id" => $pdid); - $temp_array['is_zip_created'] = 1; - $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'); + $where_condition_array = array("pd_id" => $pdid); + $temp_array['is_zip_created'] = 1; + $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; - $response_data['status'] = REST_Controller::HTTP_OK; - $response_data['records'] = $singed_uri; - $this->response($response_data,REST_Controller::HTTP_OK); + $response_data['dataStatus'] = true; + $response_data['status'] = REST_Controller::HTTP_OK; + $response_data['records'] = $singed_uri; + $this->response($response_data,REST_Controller::HTTP_OK); } - - + + } - + @@ -4682,46 +4683,46 @@ class PD_Controller extends REST_Controller { //print_r($pdf_doc); - $output_file2 = APPPATH."/docs/sample.pdf"; - if(file_put_contents($output_file2, $pdf_doc)) - { - $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); + $output_file2 = APPPATH."/docs/sample.pdf"; + if(file_put_contents($output_file2, $pdf_doc)) + { + $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 != "" ) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $urls; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong..!Try later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - - + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + + $urls = $this->getALLPDReportsSingedURLs($bucketname,$key,$pdid); + if($id != null || $id != "" ) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $urls; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong..!Try later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + + //End of convert BLOB as html then pdf then store it s3. + + + } + } - - -} - /********************************************************************************************* *********************************************************************************************/ public function getListOfPDReportVersions_post() @@ -4741,23 +4742,23 @@ class PD_Controller extends REST_Controller { //$key = 'pd'.$pdid; $urls = $this->getALLPDReportsSingedURLs($bucket_name,$key,$pdid); - 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); - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'PD Report Not Generated'; - $this->response($data,REST_Controller::HTTP_OK); - } - - + 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); + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'PD Report Not Generated'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } @@ -4773,10 +4774,10 @@ class PD_Controller extends REST_Controller { $where_condition_array = array('fk_pd_id'=>$pdid); $table = PDREPORTSVERSIONBLOB.' as PDREPORTSVERSIONBLOB'; $joins = array( array('table' => USERPROFILE. ' as USERPROFILE', - 'condition' =>'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid', - 'jointype' => 'INNER') - - ); + 'condition' =>'PDREPORTSVERSIONBLOB.fk_createdby = USERPROFILE.userid', + 'jointype' => 'INNER') + + ); //Get Max No of blob version $max_version = $this->db->SELECT('MAX(version_no) as max_version')->FROM(PDREPORTSVERSIONBLOB)->WHERE('fk_pd_id',$pdid)->GET()->result_array(); @@ -4785,57 +4786,57 @@ class PD_Controller extends REST_Controller { //print_r($max_version); $all_objects = $this->aws_s3->getAllObjectsInaBucket($bucket_name,$key); - $uri = array(); - foreach($all_objects as $obj) - { + $uri = array(); + foreach($all_objects as $obj) + { //print_r($obj); - $uri[]['doc_name'] = $obj['Key']; - } + $uri[]['doc_name'] = $obj['Key']; + } //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'); + 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']); - + $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) - { - if($blob['version_no'] == $version_no) - { - $uri[$uri_key]['createdby'] = $blob['createdby']; - $uri[$uri_key]['createdon'] = $blob['createdon']; - } - $uri[$uri_key]['is_latest'] = 0; - if(($blob['version_no'] == $max_version[0]['max_version']) &&($version_no == $max_version[0]['max_version'])) - { - $uri[$uri_key]['is_latest'] = 1; - } - } - } + $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) + { + if($blob['version_no'] == $version_no) + { + $uri[$uri_key]['createdby'] = $blob['createdby']; + $uri[$uri_key]['createdon'] = $blob['createdon']; + } + $uri[$uri_key]['is_latest'] = 0; + if(($blob['version_no'] == $max_version[0]['max_version']) &&($version_no == $max_version[0]['max_version'])) + { + $uri[$uri_key]['is_latest'] = 1; + } + } + } // if($uri_key == (count($uri)-1)) // { // $uri[$uri_key]['is_latest'] = 1; @@ -4843,10 +4844,10 @@ class PD_Controller extends REST_Controller { // { // $uri[$uri_key]['is_latest'] = 0; // } - } - } - - return $uri; + } + } + + return $uri; } @@ -4864,17 +4865,17 @@ class PD_Controller extends REST_Controller { // $or_where_total = array(array('column_name'=>'profession_name')); // $result_array = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILS,$or_where_total); - $this->db->SELECT('column_name,column_value'); - $this->db->FROM(PDFORMDETAILS); - $this->db->WHERE('isactive',1); - $this->db->WHERE('fk_form_id',13); - $this->db->WHERE('fk_pd_id',$pdid); - $this->db->GROUP_START(); - $this->db->OR_WHERE('column_name','type_of_activity_id'); - $this->db->OR_WHERE('column_name','profession_name'); - $this->db->GROUP_END(); - $result_array = $this->db->GET()->result_array(); - + $this->db->SELECT('column_name,column_value'); + $this->db->FROM(PDFORMDETAILS); + $this->db->WHERE('isactive',1); + $this->db->WHERE('fk_form_id',13); + $this->db->WHERE('fk_pd_id',$pdid); + $this->db->GROUP_START(); + $this->db->OR_WHERE('column_name','type_of_activity_id'); + $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)) @@ -4889,48 +4890,48 @@ class PD_Controller extends REST_Controller { else { if(count($result_array) > 0){ - $final_data['type_of_activity'][] = $res['column_value'];} - } - } + $final_data['type_of_activity'][] = $res['column_value'];} + } + } //print_r($final_data); - - if(array_key_exists('type_of_activity',$final_data)) - { - foreach($final_data['type_of_activity'] as $f_key => $f_value) - { - $fields = array('name'); - $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 - $fields_pro = array('iter_column_name','column_value'); - $where_condition_array_pro = array('column_name'=>'main_products','isactive'=>1,'fk_pd_id' => $pdid, 'fk_form_id'=> 13); - $prodcuts = $this->PD_Model->selectCustomRecords($fields_pro,$where_condition_array_pro,PDFORMDETAILS); - //print_r($prodcuts);die(); if(array_key_exists('type_of_activity',$final_data)) { - foreach($final_data['type_of_activity'] as $activity_key => $activity) + foreach($final_data['type_of_activity'] as $f_key => $f_value) { - //print_r($activity); - if($activity['type_of_activity_id'] == 1) + $fields = array('name'); + $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 + $fields_pro = array('iter_column_name','column_value'); + $where_condition_array_pro = array('column_name'=>'main_products','isactive'=>1,'fk_pd_id' => $pdid, 'fk_form_id'=> 13); + $prodcuts = $this->PD_Model->selectCustomRecords($fields_pro,$where_condition_array_pro,PDFORMDETAILS); + //print_r($prodcuts);die(); + if(array_key_exists('type_of_activity',$final_data)) + { + foreach($final_data['type_of_activity'] as $activity_key => $activity) { - $temp = array(); - foreach($prodcuts as $product_key => $product) + //print_r($activity); + if($activity['type_of_activity_id'] == 1) { - - if($product['iter_column_name'] == 'manufacturing_activity_details') + $temp = array(); + foreach($prodcuts as $product_key => $product) { - $temp[] = array('id' => $product_key,'name' => $product['column_value']); + + if($product['iter_column_name'] == 'manufacturing_activity_details') + { + $temp[] = array('id' => $product_key,'name' => $product['column_value']); + } } + $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; } - $final_data['type_of_activity'][$activity_key]['prodcuts'] =$temp; - } else if($activity['type_of_activity_id'] == 2)//Retail trading { $temp = array(); @@ -4974,44 +4975,44 @@ class PD_Controller extends REST_Controller { } } //Response - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $final_data; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $final_data; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = "Fill Business Details First/ No Data Available!"; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $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; - $data['msg'] = "Fill Business Details First/ No Data Available!"; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = "Fill Business Details First/ No Data Available!"; + $this->response($data,REST_Controller::HTTP_OK); } - + } public function getTypeOfActivetyFromBusinessJSON_post() { - $records = $this->post('records'); - $pd_id = $records['pd_id']; + $records = $this->post('records'); + $pd_id = $records['pd_id']; $company_id = $records['company_id']; - $final_array = array(); - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id'=>13,'fk_pd_id'=>$pd_id,'company_id' => $company_id); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $final_array = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id'=>13,'fk_pd_id'=>$pd_id,'company_id' => $company_id); + $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); //print_r($this->db->last_query()); //print_r($rec); - if(count($rec)) - { - $temp_data = json_decode($rec[0]['json'],true); + if(count($rec)) + { + $temp_data = json_decode($rec[0]['json'],true); // print_r($temp_data); // $final_array['profession_name'] = $temp_data['profession_name']; // $final_array['profession_name_other'] = ""; @@ -5019,9 +5020,9 @@ class PD_Controller extends REST_Controller { // { // $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) + $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'); $where_condition_array = array('type_of_activity_id'=>$f_value['type_of_activity_id'],'isactive'=>1); @@ -5029,17 +5030,17 @@ class PD_Controller extends REST_Controller { $final_array['type_of_activity'][$f_key] = array('type_of_activity_id' => $f_value['type_of_activity_id'],'name' =>$result[0]['name']); if($f_value['type_of_activity_id'] == 2) + { + if(array_key_exists('manufacturing_activity_details',$temp_data)) + { + $temp = array(); + foreach($temp_data['manufacturing_activity_details'] as $product_key => $product) { - if(array_key_exists('manufacturing_activity_details',$temp_data)) - { - $temp = array(); - foreach($temp_data['manufacturing_activity_details'] as $product_key => $product) - { - $temp[] = array('id' => $product_key,'name' => $product['main_products']); - } - $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; - } + $temp[] = array('id' => $product_key,'name' => $product['main_products']); } + $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; + } + } else if($f_value['type_of_activity_id'] == 3)//Retail trading { if(array_key_exists('retail_trading_activity_details',$temp_data)) @@ -5047,7 +5048,7 @@ class PD_Controller extends REST_Controller { $temp = array(); foreach($temp_data['retail_trading_activity_details'] as $product_key => $product) { - $temp[] = array('id' => $product_key,'name' => $product['main_products']); + $temp[] = array('id' => $product_key,'name' => $product['main_products']); } $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; } @@ -5057,8 +5058,8 @@ class PD_Controller extends REST_Controller { $temp = array(); foreach($temp_data['wholesale_trading_activity_details'] as $product_key => $product) { - - $temp[] = array('id' => $product_key,'name' => $product['main_products']); + + $temp[] = array('id' => $product_key,'name' => $product['main_products']); } $final_array['type_of_activity'][$f_key]['prodcuts'] =$temp; } @@ -5068,33 +5069,33 @@ class PD_Controller extends REST_Controller { foreach($temp_data['service_provider_activity_details'] as $product_key => $product) { - $temp[] = array('id' => $product_key,'name' => $product['main_products']); + $temp[] = array('id' => $product_key,'name' => $product['main_products']); } $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 + { + $data['dataStatus'] = false; + $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); + + } + + + + } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $final_array; - $this->response($data,REST_Controller::HTTP_OK); - - } - else - { - $data['dataStatus'] = false; - $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); - - } - - - - - } - /********************************************************************************************* *********************************************************************************************/ @@ -5131,38 +5132,38 @@ class PD_Controller extends REST_Controller { //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 ); - fwrite( $ifp, $result[0]['content'] ); - fclose( $ifp ); - //print_r($output_file); - $file= file_get_contents($output_file); - $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); - //print_r($pdf_doc); + //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 ); + fwrite( $ifp, $result[0]['content'] ); + fclose( $ifp ); + //print_r($output_file); + $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)) @@ -5173,7 +5174,7 @@ class PD_Controller extends REST_Controller { $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) { @@ -5194,37 +5195,37 @@ class PD_Controller extends REST_Controller { } } } - - - - - - - - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Version Not Updated in Master Table! Contact System Admin'; - $this->response($data,REST_Controller::HTTP_OK); - } + + + + + + + } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Version Not Updated!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Version Not Updated in Master Table! Contact System Admin'; + $this->response($data,REST_Controller::HTTP_OK); } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'No older Version Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Version Not Updated!'; + $this->response($data,REST_Controller::HTTP_OK); } + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'No older Version Available for this PD!'; + $this->response($data,REST_Controller::HTTP_OK); + } @@ -5256,25 +5257,25 @@ class PD_Controller extends REST_Controller { // $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; // $this->response($data,REST_Controller::HTTP_OK); - $output_file = APPPATH."/docs/temp.html"; - $ifp = fopen( $output_file, 'wb' ); + $output_file = APPPATH."/docs/temp.html"; + $ifp = fopen( $output_file, 'wb' ); //fwrite( $ifp, $original_template ); - fwrite( $ifp, $fin ); - fclose( $ifp ); + fwrite( $ifp, $fin ); + fclose( $ifp ); //print_r($output_file); - $file= file_get_contents($output_file); - $pdf_doc = $this->pdfgenerator->generate($file, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + $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"; - echo file_put_contents($output_file2, $pdf_doc); + $output_file2 = APPPATH."/docs/sample.pdf"; + echo file_put_contents($output_file2, $pdf_doc); } @@ -5285,9 +5286,9 @@ class PD_Controller extends REST_Controller { $logger = MYLOG::logFunction(null,$pdid); if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0777); - } + { + mkdir($this->external_path.'/pd_reports/'.$pdid,0777); + } $pdmas = $this->PD_Model->getPDMasterDetails($pdid); //print_r($pdmas); //load satellite script from db @@ -5344,74 +5345,74 @@ class PD_Controller extends REST_Controller { 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'))) - { - 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'))) - { - unset($general_score['general'][$gsk]); - } - } - - + + $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'))) + { + 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'))) + { + 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 = ''; + + $data = array(); + $img_name = ''; for($i = 1;$i < 3;$i++) { // 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); - + + $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']; + + $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);} + + $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); - $dsc_script_from_db = str_replace('{{APPPATH}}',$apppath,$dsc_script_from_db); - $dsc_script_from_db = str_replace('{{html_content}}',$html_content,$dsc_script_from_db); - $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}','dsc_business',$dsc_script_from_db) : str_replace('{{img_name}}','dsc_general',$dsc_script_from_db); + $apppath = str_replace('\\','/',APPPATH); + $dsc_script_from_db = str_replace('{{APPPATH}}',$apppath,$dsc_script_from_db); + $dsc_script_from_db = str_replace('{{html_content}}',$html_content,$dsc_script_from_db); + $dsc_script_from_db = $i == 1 ? str_replace('{{img_name}}','dsc_business',$dsc_script_from_db) : str_replace('{{img_name}}','dsc_general',$dsc_script_from_db); //print_r($dsc_script_from_db);die(); //$logger = MYLOG::logFunction(); //$logger->info('Score Card Graphical Representation called',array('card_type' => $i,'script' => $dsc_script_from_db)); //echo $dsc_script_from_db; //echo "*************"; - file_put_contents(APPPATH.'/views/js/phantomdsc.js',$dsc_script_from_db); - + 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); @@ -5419,7 +5420,7 @@ class PD_Controller extends REST_Controller { $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 { @@ -5432,8 +5433,8 @@ class PD_Controller extends REST_Controller { return $data; - } - + } + function getAssessedIncomeForPDReport($pdid) { @@ -5451,45 +5452,45 @@ class PD_Controller extends REST_Controller { } else { - return null; + return null; } } - function demo($var) { - - echo " Before try block"; - try { + function demo($var) { + + echo " Before try block"; + try { - $try = 'THis is declared in side try block'; - echo "\n Inside try block"; - + $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 == 0) + { + // If var is zero then only exception is thrown - throw new Exception('Number is zero.'); - + throw new Exception('Number is zero.'); + // This line will never be executed - echo "\n After throw (It 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) { - echo "\n Exception Caught", $e->getMessage(); - echo "\n Exception Caught", $e->getLine(); - echo "\n Exception Caught", $e->getFile(); - echo $try; - } - + catch(Exception $e) { + echo "\n Exception Caught", $e->getMessage(); + echo "\n Exception Caught", $e->getLine(); + 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)"; - } - + echo "\n After catch (will be always executed)"; + } + public function codeigniterViewTest_post() { @@ -5497,22 +5498,22 @@ class PD_Controller extends REST_Controller { $pdid = $records['pd_id']; //$external_path = $this->config->item('external_data_path'); - if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) - { - mkdir($this->external_path.'/pd_reports/'.$pdid,0761); - } + if(!file_exists($this->external_path.'/pd_reports/'.$pdid)) + { + mkdir($this->external_path.'/pd_reports/'.$pdid,0761); + } // $pd_string = 'PD accessed-'.$pdid; // MYLOG::logFunction(null,$pdid)->info($pd_string,array('data' => 'Test LOg info')); // MYLOG::logFunction()->warning($pd_string,array('data' => 'Test LOg warn')); // MYLOG::logFunction()->error($pd_string,array('data' => 'Test LOg error')); // $this->load->helper('push_notification'); // PUSH_NOTIFICATION::notifyWeb('eT3F2YlSOsU:APA91bEoK7w-_yaoWK8NUYsYwL1gAfIShm70K5t8IrHjiZAw-oNKOOL09bfgfthBoA4EFoVot17Y9ZOhWxO-B3oKVoQdYxUq6JsAdrOwmPTO-9-mJ61zBcifg34EiiUmdnrAQDt7E90t','Test Msg from test api',array()); - // PDALERTS::pdnotification($pdid); - // die(); + //PDALERTS::pdnotification($pdid); + //die(); //$this->demo(5); //$this->demo(0); - + $is_regenerate = 0; if(isset($records['regenerate'])) { @@ -5522,6 +5523,8 @@ class PD_Controller extends REST_Controller { $data['pd_master_details'] = $this->PD_Model->getPDMasterDetails($pdid); $data['applicants_details'] = $this->PD_Model->getApplicantsDetails($pdid); //print_r($data['applicants_details']);die(); + $data['lender_disclaimer'] = $this->PD_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $data['pd_master_details'][0]['fk_lender_id'])); + $data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid); $data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly(); @@ -5534,56 +5537,56 @@ class PD_Controller extends REST_Controller { //$data['dsc_cards'] = $this->getDetailedScoreCardChart( $data['pd_score'] ); if($data['pd_master_details'][0]['is_score_card_enabled'] != 0) { - $data['pd_score'] = $this->calculateScore($pdid); - $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],1) : 0; + $data['pd_score'] = $this->calculateScore($pdid); + $score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],1) : 0; //echo $score_for_chart;die(); //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']; + $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); + + $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();'); - + + 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; + + $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(); //GET ALL PROCESSED JSON - for($i = 1;$i<=30;$i++) - { - $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); - - + for($i = 1;$i<=30;$i++) + { + $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()); - } + } //print_r($data['pd_processed_forms'][24]);die(); //print_r($data['pd_images']);die(); //print_r(json_decode($data['pd_processed_forms'][14][0]['processed_json'],true)); @@ -5605,20 +5608,20 @@ class PD_Controller extends REST_Controller { // substr_replace($t,'X',strpos($t,''),strpos($t, '', strpos($t,''))); for($i = 0 ;$i < $total_replaces;$i++) { - $start_pos = strpos($t,''); - - $end_pos = strpos($t, '', strpos($t,'')); - $end_pos = $end_pos + 14; + $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(''))); - + $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"); @@ -5626,10 +5629,10 @@ class PD_Controller extends REST_Controller { $output_file2 = $this->external_path ."/pd_reports/" . $pdid . "/sample.pdf"; $ti = file_put_contents($output_file2, $pdf_doc); echo $ti; die(); - $dat['dataStatus'] = true; - $dat['status'] = REST_Controller::HTTP_OK; - $dat['records'] = $ti; - $this->response($dat,REST_Controller::HTTP_OK); + $dat['dataStatus'] = true; + $dat['status'] = REST_Controller::HTTP_OK; + $dat['records'] = $ti; + $this->response($dat,REST_Controller::HTTP_OK); @@ -5637,36 +5640,36 @@ class PD_Controller extends REST_Controller { 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 = $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']); - + $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 - { - $pd_form_raw_data[$raw_key]['actual_score'] = null; - $pd_form_raw_data[$raw_key]['exact_score'] = null; - } - } - - return $pd_form_raw_data; - - + } + else + { + $pd_form_raw_data[$raw_key]['actual_score'] = null; + $pd_form_raw_data[$raw_key]['exact_score'] = null; + } + } + + return $pd_form_raw_data; + + + } public function getQCLenderRemarks_post() @@ -5676,7 +5679,7 @@ class PD_Controller extends REST_Controller { $fields = array(); if($records['flag'] == 'QC') { - $fields = array('qc_feedback','qc_rating','pd_status'); + $fields = array('qc_feedback','qc_rating','pd_status'); } else if($records['flag'] == 'LENDER') { @@ -5693,185 +5696,185 @@ class PD_Controller extends REST_Controller { else if($records['flag'] == 'ALL_REMARKS')// Get All Other remarks from pd remarks table { - $this->db->SELECT('PDREMARKS.remark,DATE_FORMAT(PDREMARKS.createdon,"%d/%m/%Y %r") as log_time,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby')->FROM(PDREMARKS.' as PDREMARKS'); - $this->db->JOIN(USERPROFILE.' as USERPROFILE','USERPROFILE.userid = PDREMARKS.createdby','LEFT'); - $this->db->WHERE('PDREMARKS.fk_pd_id',$pdid); - $res = $this->db->GET()->result_array(); + $this->db->SELECT('PDREMARKS.remark,DATE_FORMAT(PDREMARKS.createdon,"%d/%m/%Y %r") as log_time,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby')->FROM(PDREMARKS.' as PDREMARKS'); + $this->db->JOIN(USERPROFILE.' as USERPROFILE','USERPROFILE.userid = PDREMARKS.createdby','LEFT'); + $this->db->WHERE('PDREMARKS.fk_pd_id',$pdid); + $res = $this->db->GET()->result_array(); if(count($res)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $res; - $this->response($data,REST_Controller::HTTP_OK); - } - else + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res; + $this->response($data,REST_Controller::HTTP_OK); + } + else { $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Remarks Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); - - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $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)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Remarks Available for this PD!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Remarks Available for this PD!'; + $this->response($data,REST_Controller::HTTP_OK); } } - - public function getCompaniesListsFromGeneralFormRawJSON_post() + else { - $records = $this->post('records'); - $pd_id = $records['pd_id']; + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $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)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Remarks Available for this PD!'; + $this->response($data,REST_Controller::HTTP_OK); + +} +} - $ai_flag = 0; +public function getCompaniesListsFromGeneralFormRawJSON_post() +{ + $records = $this->post('records'); + $pd_id = $records['pd_id']; + + $ai_flag = 0; //GET TEMPALE ID FROM MASTER - $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); - $lender_short_name = $pd_master_details[0]['lender_short_name']; + $pd_master_details = $this->PD_Model->getPDMasterDetails($pd_id); + $lender_short_name = $pd_master_details[0]['lender_short_name']; //print_r($lender_short_name); - $str = substr($pd_master_details[0]['customer_segment_abbr'],-2); + $str = substr($pd_master_details[0]['customer_segment_abbr'],-2); //echo $str; - if(!strcmp($str,'AI')) { $ai_flag = 1; } + 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); - $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - if(count($rec)) - { - $temp_data = json_decode($rec[0]['json'],true); + + $company_list = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id'=>18,'fk_pd_id'=>$pd_id); + $rec = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + if(count($rec)) + { + $temp_data = json_decode($rec[0]['json'],true); // print_r($temp_data);die(); - foreach($temp_data['companies'] as $company) - { - - if($company['associate_pd_id'] == $pd_id) - { + 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']); - if(isset($company['business_entity_type_other'])) - { + if(isset($company['business_entity_type_other'])) + { $temp_array['business_entity_type_other'] = $company['business_entity_type_other']; - } - $company_list[] = $temp_array; } - } + $company_list[] = $temp_array; + } + } // $company_list = array( array('company_order_id' => 1)); //print_r($company_list); - $form_array = array(); + $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'), - array('form_id' => 21,'form_name' => 'Business Banking'), - array('form_id' => 14,'form_name' => 'Financial Information'), - array('form_id' => 1,'form_name' => 'Supplier Details'), - array('form_id' => 2,'form_name' => 'Client Details'), - array('form_id' => 11,'form_name' => 'Stock Details'), - - ); + + $form_array = array( + array('form_id' => 13,'form_name' => 'About Business'), + array('form_id' => 22,'form_name' => 'Business Assets'), + array('form_id' => 21,'form_name' => 'Business Banking'), + array('form_id' => 14,'form_name' => 'Financial Information'), + 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'), - array('form_id' => 21,'form_name' => 'Business Banking'), - array('form_id' => 14,'form_name' => 'Financial Information'), - array('form_id' => 1,'form_name' => 'Supplier Details'), - array('form_id' => 2,'form_name' => 'Client Details'), - array('form_id' => 11,'form_name' => 'Stock Details'), - array('form_id' => 16,'form_name' => 'Assessed Income') - - ); - - - + + $form_array = array( + array('form_id' => 13,'form_name' => 'About Business'), + array('form_id' => 22,'form_name' => 'Business Assets'), + array('form_id' => 21,'form_name' => 'Business Banking'), + array('form_id' => 14,'form_name' => 'Financial Information'), + array('form_id' => 1,'form_name' => 'Supplier Details'), + 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');} //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) - { - $this->db->SELECT('count(*) as count'); - $this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); - $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pd_id); - $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$form['form_id']); - $this->db->WHERE('PDFORMDETAILSJSON.company_id',$company['company_order_id']); - $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); - $template_forms_count = $this->db->GET()->result_array(); - } - 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); - } + 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) + { + $this->db->SELECT('count(*) as count'); + $this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON'); + $this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pd_id); + $this->db->WHERE('PDFORMDETAILSJSON.fk_form_id',$form['form_id']); + $this->db->WHERE('PDFORMDETAILSJSON.company_id',$company['company_order_id']); + $this->db->WHERE('PDFORMDETAILSJSON.isactive',1); + $template_forms_count = $this->db->GET()->result_array(); + } + 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); + } // print_r($this->db->last_query()); // print_r($template_forms_count);echo $form['form_id']; - if($template_forms_count[0]['count'] != 0) { - + 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) - { - $business_form_status = 1; - } - } + 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) + { + $business_form_status = 1; + } + } - else - { - if($business_form_status == 1){ - - - + else + { + if($business_form_status == 1){ + + + if($form['form_id'] == 1)//if supplier form answered set supplier_form_status = 1 - { + { $supplier_form_status = 1; - } + } if($form['form_id'] == 2)//if client form answered set client_form_status = 1 - { + { $client_form_status = 1; - } - + } + if($form['form_id'] == 11 || $form['form_id'] == 23) { //echo "COUNT YES STOCK" @@ -5884,77 +5887,77 @@ class PD_Controller extends REST_Controller { { $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>true); } - - } + + } else //busienss false { //echo "business false".$form['form_id']; - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>false); + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => true,'isAnswerable'=>false); } - } + } } else //Not previously answered { //echo "else-- " .$form['form_id']; - if($form['form_id'] == 13 || $form['form_id'] == 22) + 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); - + + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); + } - else{ + else{ if($business_form_status == 1){ if($form['form_id'] == 11 || $form['form_id'] == 23) - { + { //echo "BUSISTOCk"; - if($client_form_status == 1 && $supplier_form_status == 1) - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); - } - else - { - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); - } - } - else + if($client_form_status == 1 && $supplier_form_status == 1) { $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); } + else + { + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); + } + } + else + { + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>true); + } - } - else - { - - $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); - - } - } + } + else + { + + $temp[] = array('form_id' => $form['form_id'],'form_name'=> $form['form_name'],'isAnswered' => false,'isAnswerable'=>false); + + } + } } } $company_list[$list_key]['form_status'] = $temp; - - - } - } - - // print_r($company_list);die(); - if(count($company_list)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $company_list; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Comapany Details Found!'; - $this->response($data,REST_Controller::HTTP_OK); + } + } + + // print_r($company_list);die(); + if(count($company_list)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $company_list; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Comapany Details Found!'; + $this->response($data,REST_Controller::HTTP_OK); + + } } @@ -5962,10 +5965,10 @@ class PD_Controller extends REST_Controller { { $pdid = $this->post('pd_id'); $address = $this->PD_Model->getPDAddress($pdid); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $address; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $address; + $this->response($data,REST_Controller::HTTP_OK); } @@ -5978,63 +5981,63 @@ class PD_Controller extends REST_Controller { if($sub_product_id != null) { - $fields = array('*'); - $where_condition_array = array('isactive' => 1,'fk_subproduct_id' => $sub_product_id); - $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN); - if(count($result_data)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Data Found for Selected Sub Product!'; - $this->response($data,REST_Controller::HTTP_OK); - } + $fields = array('*'); + $where_condition_array = array('isactive' => 1,'fk_subproduct_id' => $sub_product_id); + $result_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,ENDUSEOFLOAN); + if(count($result_data)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Data Found for Selected Sub Product!'; + $this->response($data,REST_Controller::HTTP_OK); + } } else { - $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + + if($pd_master_details[0]['fk_subproduct_id'] != "" || $pd_master_details[0]['fk_subproduct_id'] != null) + { - 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); + if(count($result_data)) { - - $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); - if(count($result_data)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Data Found for Selected Sub Product!'; - $this->response($data,REST_Controller::HTTP_OK); - } + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); } 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); - + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Data Found for Selected Sub Product!'; + $this->response($data,REST_Controller::HTTP_OK); } + } + 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); + + } } } @@ -6045,12 +6048,12 @@ class PD_Controller extends REST_Controller { $pdid = $this->post('pd_id'); $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; - $this->response($data,REST_Controller::HTTP_OK); + $id = $this->PD_Model->saveRecords($record_data,PDOFFICERCURRENTLOCATION); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['record'] = $id; + $this->response($data,REST_Controller::HTTP_OK); } @@ -6067,21 +6070,21 @@ class PD_Controller extends REST_Controller { $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; - $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'No Records Found!'; - $this->response($data,REST_Controller::HTTP_OK); - } + + if(count($result_data)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['record'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Records Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -6089,364 +6092,364 @@ class PD_Controller extends REST_Controller { public function getFamilyDetailsFromBusinessAndGeneral_post() { - $pdid = $this->post('pd_id'); + $pdid = $this->post('pd_id'); //echo $pdid; //Get Details From General Full - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); - $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); + $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); //print_r($general_data);die(); - $temp_array = array(); - if(count($general_data)) - { - $json = json_decode($general_data[0]['json'],true); + $temp_array = array(); + if(count($general_data)) + { + $json = json_decode($general_data[0]['json'],true); //print_r($json);die(); + if(array_key_exists('persons_with_relationships',$json)) + { + foreach($json['persons_with_relationships'] as $key => $relation) + { + foreach($json['individuals'] as $ind) + { + if($relation['applicant_name'] == $ind['applicant_name']) + { + $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(); + foreach($business_data as $business_data_key => $business) + { + $json = json_decode($business['json'],true); + //print_r($json); if(array_key_exists('persons_with_relationships',$json)) { - foreach($json['persons_with_relationships'] as $key => $relation) + + + foreach($json['persons_with_relationships'] as $person => $value) { - foreach($json['individuals'] as $ind) - { - if($relation['applicant_name'] == $ind['applicant_name']) + + if(count($general_data)) + { + $genjson = json_decode($general_data[0]['json'],true); + foreach($genjson['companies'] as $company_key =>$company) { - $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(); - foreach($business_data as $business_data_key => $business) - { - $json = json_decode($business['json'],true); - //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); - foreach($genjson['companies'] as $company_key =>$company) - { //print_r($compan); - if($value['relationship_with_company_id'] == $company['company_order_id']) - { - $json['persons_with_relationships'][$person]['company_name'] = $company['company_name']; - $json['persons_with_relationships'][$person]['business_years'] = $company['business_years']; - $json['persons_with_relationships'][$person]['business_month'] = $company['business_month']; - $json['persons_with_relationships'][$person]['business_date_formation'] = $company['business_date_object']; - } - } - } + if($value['relationship_with_company_id'] == $company['company_order_id']) + { + $json['persons_with_relationships'][$person]['company_name'] = $company['company_name']; + $json['persons_with_relationships'][$person]['business_years'] = $company['business_years']; + $json['persons_with_relationships'][$person]['business_month'] = $company['business_month']; + $json['persons_with_relationships'][$person]['business_date_formation'] = $company['business_date_object']; } - $temp_array = array_merge($temp_array,$json['persons_with_relationships']); + } + } } + $temp_array = array_merge($temp_array,$json['persons_with_relationships']); } } - - - $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); - - - + } + + + $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'); - + $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); - $business_assest_data = array(); - $other_assest_data = array(); - $business_address_assest_data = array(); + $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); + $business_assest_data = array(); + $other_assest_data = array(); + $business_address_assest_data = array(); //print_r($assest_data);die(); - if(count($assest_data)) - { - - - + if(count($assest_data)) + { + + + //print_r($property_types);die(); - - foreach($assest_data as $key => $assest) - { - $json = json_decode($assest['json'],true); + + foreach($assest_data as $key => $assest) + { + $json = json_decode($assest['json'],true); //print_r($json);die(); - if(array_key_exists('business_assets_details',$json)) + if(array_key_exists('business_assets_details',$json)) + { + foreach($json['business_assets_details'] as $asset_key => $business_asset) { - foreach($json['business_assets_details'] as $asset_key => $business_asset) - { - + //print_r($business_asset); - if(!strcmp($business_asset['business_emi'],'yes')) + if(!strcmp($business_asset['business_emi'],'yes')) + { + $business_assets_mode_name = ""; + + foreach($assest_types as $asset_type) { - $business_assets_mode_name = ""; - - foreach($assest_types as $asset_type) - { - if($asset_type['id'] == $business_asset['business_assets_mode']) - { + if($asset_type['id'] == $business_asset['business_assets_mode']) + { $business_assets_mode_name = $asset_type['name']; - } - } - - if( $business_asset['business_assets_mode'] == 2) - { + } + } + + if( $business_asset['business_assets_mode'] == 2) + { //echo $business_asset['business_details'][0]['property_type']; - foreach($property_types as $property_type) - { + foreach($property_types as $property_type) + { if( $property_type['id'] == $business_asset['business_details'][0]['property_type']) { $business_asset['business_details'][0]['property_type_name'] = $property_type['name']; } - } - } - - $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']); + } } + $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) - { - if(!strcasecmp($address_asset['business_emi'],'yes')) - { - //echo $address_asset['address_label']; - $business_address_assest_data[] = $address_asset; - } - } - } - - } + + + if(array_key_exists('business_assets_for_address',$json)) + { + foreach($json['business_assets_for_address'] as $address_key => $address_asset) + { + if(!strcasecmp($address_asset['business_emi'],'yes')) + { + //echo $address_asset['address_label']; + $business_address_assest_data[] = $address_asset; + } + } + } + + } - + } + //Get Other Assets with Loan - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>4,'fk_pd_id' => $pdid); - $other_assest = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id' =>4,'fk_pd_id' => $pdid); + $other_assest = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); // print_r($this->db->last_query()); // print_r($other_assest);die(); - if(count($other_assest)) + if(count($other_assest)) + { + foreach($other_assest as $key => $assest) { - foreach($other_assest as $key => $assest) - { - $json = json_decode($assest['json'],true); + $json = json_decode($assest['json'],true); //print_r($json);die(); - if(array_key_exists('assets_details',$json)) + if(array_key_exists('assets_details',$json)) + { + foreach($json['assets_details'] as $asset_key => $asset) { - foreach($json['assets_details'] as $asset_key => $asset) + if(!strcmp($asset['emi'],'yes')) { - if(!strcmp($asset['emi'],'yes')) + $assets_mode_name = ""; + + foreach($assest_types as $asset_type) { - $assets_mode_name = ""; - - foreach($assest_types as $asset_type) - { - if($asset_type['id'] == $asset['assets_mode']) - { + if($asset_type['id'] == $asset['assets_mode']) + { $assets_mode_name = $asset_type['name']; - } - } - - if($asset['assets_mode'] == 2) - { + } + } + + if($asset['assets_mode'] == 2) + { //echo $business_asset['business_details'][0]['property_type']; - foreach($property_types as $property_type) - { + foreach($property_types as $property_type) + { if( $property_type['id'] == $asset['details'][0]['property_type']) { $asset['details'][0]['property_type_name'] = $property_type['name']; } - } - } - - $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']); + } } + $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); - $this->response($data,REST_Controller::HTTP_OK); + } + + $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); + $this->response($data,REST_Controller::HTTP_OK); } public function getProductsWithTypeofActivityFromBusiness_post() { - $pdid = $this->post('pd_id'); - $company_id = $this->post('company_id'); + $pdid = $this->post('pd_id'); + $company_id = $this->post('company_id'); //echo $pdid.$company_id;die(); //Get Details From General Full - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid,'company_id' => $company_id); - $business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - $final_data_from_business = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id' =>13,'fk_pd_id' => $pdid,'company_id' => $company_id); + $business_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $final_data_from_business = array(); //print_r($business_data); - if(count($business_data)) - { - $json = json_decode($business_data[0]['json'],true); + if(count($business_data)) + { + $json = json_decode($business_data[0]['json'],true); //print_r($json); - if(array_key_exists('manufacturing_activity_details',$json)) + if(array_key_exists('manufacturing_activity_details',$json)) + { + $temp_data['type_of_activity_id'] = 2; + $temp_data['name'] = 'Manufacturing'; + foreach($json['manufacturing_activity_details'] as $key => $manufacturing_activity_details) { - $temp_data['type_of_activity_id'] = 2; - $temp_data['name'] = 'Manufacturing'; - foreach($json['manufacturing_activity_details'] as $key => $manufacturing_activity_details) - { - $temp_data['products'][] = $manufacturing_activity_details['main_products']; - } - - $final_data_from_business[] = $temp_data; - $temp_data = array(); + $temp_data['products'][] = $manufacturing_activity_details['main_products']; } - if(array_key_exists('retail_trading_activity_details',$json)) - { - $temp_data['type_of_activity_id'] = 3; - $temp_data['name'] = 'Retail trading'; - foreach($json['retail_trading_activity_details'] as $key => $retail_trading_activity_details) - { - $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; - $temp_data['name'] = 'Wholesale Trade'; - foreach($json['wholesale_trading_activity_details'] as $key => $wholesale_trading_activity_details) - { - $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; - $temp_data['name'] = 'Service Provider'; - foreach($json['service_provider_activity_details'] as $key => $service_provider_activity_details) - { - $temp_data['products'][] = $service_provider_activity_details['main_products']; - } - - $final_data_from_business[] = $temp_data; - $temp_data = array(); - } - - + $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; + $temp_data['name'] = 'Retail trading'; + foreach($json['retail_trading_activity_details'] as $key => $retail_trading_activity_details) + { + $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; + $temp_data['name'] = 'Wholesale Trade'; + foreach($json['wholesale_trading_activity_details'] as $key => $wholesale_trading_activity_details) + { + $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; + $temp_data['name'] = 'Service Provider'; + foreach($json['service_provider_activity_details'] as $key => $service_provider_activity_details) + { + $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); - $supplier_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); - $final_data_from_supplier = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id' =>1,'fk_pd_id' => $pdid,'company_id' => $company_id); + $supplier_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $final_data_from_supplier = array(); //print_r($supplier_data); - if(count($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)) { - $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) { - - foreach($supplier_data['manufacturing_details'] as $manufacturing_activity_detail_key => $manufacturing_activity_detail) - { - $temp_data = $manufacturing_activity_detail['main_raw_materials']; + $temp_data = $manufacturing_activity_detail['main_raw_materials']; //print_r($temp_data);die(); // print_r(count($temp_data)); // print_r($temp_data[0]); // print_r($temp_data[1]); - if($temp_data != "" || $temp_data != null) + if($temp_data != "" || $temp_data != null) + { + foreach($temp_data as $raw_material) { - foreach($temp_data as $raw_material) - { //print_r($raw_material); - $final_data_from_supplier['raw_material'][] = $raw_material['manufacturing_raw_material_name']; - } + $final_data_from_supplier['raw_material'][] = $raw_material['manufacturing_raw_material_name']; } } - } - 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']; - //print_r($temp_data);die(); - // print_r(count($temp_data)); - // print_r($temp_data[0]); - // print_r($temp_data[1]); - if($temp_data != "" || $temp_data != null) - { - foreach($temp_data as $trade) - { - //print_r($raw_material); - $final_data_from_supplier['trading_product'][] = $trade['trade_product_name']; - } - } - } - - } } - - $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); + 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']; + //print_r($temp_data);die(); + // print_r(count($temp_data)); + // print_r($temp_data[0]); + // print_r($temp_data[1]); + if($temp_data != "" || $temp_data != null) + { + foreach($temp_data as $trade) + { + //print_r($raw_material); + $final_data_from_supplier['trading_product'][] = $trade['trade_product_name']; + } + } + } + + } + } + + $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); + + + } @@ -6456,99 +6459,99 @@ class PD_Controller extends REST_Controller { $pdid = $this->post('pd_id'); //echo $pdid; //Get Details From General Form - $final_names = array(); - $fields = array('json'); - $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); - $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); + $final_names = array(); + $fields = array('json'); + $where_condition_array = array('isactive' => 1,'fk_form_id' =>18,'fk_pd_id' => $pdid); + $general_data = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDFORMDETAILSJSON); //print_r($general_data);die(); - if(count($general_data)) - { - $json = json_decode($general_data[0]['json'],true); + if(count($general_data)) + { + $json = json_decode($general_data[0]['json'],true); //print_r($json); - if(array_key_exists('individuals',$json)) + if(array_key_exists('individuals',$json)) + { + foreach($json['individuals'] as $key => $persons) { - foreach($json['individuals'] as $key => $persons) - { // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) // { // $type = 1; // } - $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) - { - // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) - // { - // $type = 1; - // } - $final_names[] = array('applicant_name' => $persons['company_name'],'applicant_type' => 2,'applicant_id'=>$persons['company_name']); - } + $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) + { + // if($persons['is_applicant'] == true || $persons['is_person_met'] == true) + // { + // $type = 1; + // } + $final_names[] = array('applicant_name' => $persons['company_name'],'applicant_type' => 2,'applicant_id'=>$persons['company_name']); + } + } + } + //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); - + $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)) + + if(count($business_data)) + { + foreach($business_data as $business_data_key => $business) { - foreach($business_data as $business_data_key => $business) - { - $json = json_decode($business['json'],true); + $json = json_decode($business['json'],true); //print_r($json); - if(array_key_exists('persons_with_relationships',$json)) + if(array_key_exists('persons_with_relationships',$json)) + { + foreach($json['persons_with_relationships'] as $key => $persons) { - foreach($json['persons_with_relationships'] as $key => $persons) + $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); + // echo "familty"; + // 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)) + { + foreach($family['family_members_details'] as $key => $persons) { - $final_names[] = array('applicant_name' => $persons['family_member_name'],'applicant_type' => 3,'applicant_id'=>$persons['family_member_name']); + $final_names[] = array('applicant_name' => $persons['applicant_name'],'applicant_type' => 3,'applicant_id'=>$persons['applicant_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); - // echo "familty"; - // 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)) - { - foreach($family['family_members_details'] as $key => $persons) - { - $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; - $this->response($data,REST_Controller::HTTP_OK); + } + + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['record'] = $final_names; + $this->response($data,REST_Controller::HTTP_OK); } @@ -6560,10 +6563,10 @@ class PD_Controller extends REST_Controller { $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(CITY.' as CITY','PDTRIGGER.fk_city = CITY.city_id'); $city = $this->db->GET()->result_array(); - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $city; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $city; + $this->response($data,REST_Controller::HTTP_OK); } @@ -6577,22 +6580,22 @@ class PD_Controller extends REST_Controller { //$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; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $res['count']; - $data['msg'] = $res['msg']; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NO_CONTENT; - $data['msg'] = 'Something Went Wrong!'; - $this->response($data,REST_Controller::HTTP_OK); - } + + if(count($res)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res['count']; + $data['msg'] = $res['msg']; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'Something Went Wrong!'; + $this->response($data,REST_Controller::HTTP_OK); + } } @@ -6600,61 +6603,61 @@ class PD_Controller extends REST_Controller { { $records = $this->post('records'); $result_data = $this->PD_Model->getSignedPDDocsURL($records['pd_id'],isset($records['form_id']) ? $records['form_id']: null ,isset($records['company_id']) ? $records['company_id'] : null,isset($records['is_common']) ? $records['is_common'] : null,isset($records['rental_count_id']) ? $records['rental_count_id'] : null); - if(count($result_data)) - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $result_data; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'No Data Available'; - $this->response($data,REST_Controller::HTTP_OK); - } + if(count($result_data)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'No Data Available'; + $this->response($data,REST_Controller::HTTP_OK); + } } public function saveBase64Images($pd_id,$form_id = null,$company_id = null,$rental_count_id = null,$data) { - - - $count = 0; - $result = array(); - $pks = array(); - $pd_details = $this->PD_Model->getPDMasterDetails($pd_id); + + + $count = 0; + $result = array(); + $pks = array(); + $pd_details = $this->PD_Model->getPDMasterDetails($pd_id); //print_r($data);die(); - EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id); - foreach($data as $iter => $doc) - { - $temp_base64_string = $doc['image']; - $title = $doc['Name']; - $is_show_report = isset($doc['is_show_report']) ? $doc['is_show_report'] : null; + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id); + foreach($data as $iter => $doc) + { + $temp_base64_string = $doc['image']; + $title = $doc['Name']; + $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"; - + $output_file = $this->external_path."/pd_reports/". $pd_id ."/temp_base64_image.jpeg"; + //Generate Random File Name - $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - $charactersLength = strlen($characters); - $randomString = ''; - for ($i = 0; $i < 5; $i++) { - $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 ); - + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < 5; $i++) { + $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']; + $imagetobewatermark = imagecreatefromstring(file_get_contents($output_file)); + $location_watermarktext="Location: ".$doc['link']; $font = APPPATH."docs/robold.ttf"; //metion font and it's location $fontsize="12"; $x = imagesy($imagetobewatermark); @@ -6674,198 +6677,198 @@ class PD_Controller extends REST_Controller { $sx = imagesx($curret_file); $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 ); - + 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']; - $key = 'pd'.$pd_id.'/'.$tempdocname; + + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $bucketname = LENDER_BUCKET_NAME_PREFIX.$pd_details[0]['fk_lender_id']; + $key = 'pd'.$pd_id.'/'.$tempdocname; // if($form_id != null) // { // $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']); - $record_data['company_id'] = $company_id ? $company_id : null; - $id = $this->PD_Model->saveRecords($record_data,PDDOCUMENTS); - if($id != null || $id != "") { $count++; $pks[] = $id;} + $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']); + $record_data['company_id'] = $company_id ? $company_id : null; + $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)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['msg'] = "All Images Saved Successfully"; + } + else + { + //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); + $result['status'] = true; + $result['count'] = $count; + $result['pks'] = $pks; + $result['msg'] = "Some Images Not Saved!"; + } + return $result; } - if($count == count($data)) + public function calculateScore($pdid) { - //$logger->info('All Images Saved Sucessfully',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['msg'] = "All Images Saved Successfully"; - } - else - { - //$logger->info('Some Images Not Saved',array($pd_id,$form_id,$company_id)); - $result['status'] = true; - $result['count'] = $count; - $result['pks'] = $pks; - $result['msg'] = "Some Images Not Saved!"; - } - return $result; - } - - public function calculateScore($pdid) - { - + //echo $pdid;die(); //GET JSON FORM DATA - $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); + $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); //print_r($pd_master_details); - $form_data = $this->PD_Model->getScorablePDFormDetailsJSON($pdid); + $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']; + $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']; //echo $loan_amt_from_loam_form; //seperate PD Scorable quesitons from JSON - $score_questions = $this->seperateScoreQuestions($form_data,$pd_master_details[0]['is_otp_done']); + $score_questions = $this->seperateScoreQuestions($form_data,$pd_master_details[0]['is_otp_done']); //print_r($score_questions);die(); // echo "###################################"; //Get Pesrsonal Assets Grid Masters Details - if((int)$loan_amt_from_loam_form >= 100000000 ) - { - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRID); - $this->db->WHERE('isactive',1); - $this->db->ORDER_BY('personal_asset_grid_id','DESC'); - $this->db->LIMIT(1) ; - $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); - } - else - { - - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRID); - $this->db->WHERE('isactive',1); - $this->db->WHERE('loan_amount_from<=',(int)$loan_amt_from_loam_form); - $this->db->WHERE('loan_amount_to>=',(int)$loan_amt_from_loam_form); - $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); - } + if((int)$loan_amt_from_loam_form >= 100000000 ) + { + $this->db->SELECT('*'); + $this->db->FROM(PERSONALASSETGRID); + $this->db->WHERE('isactive',1); + $this->db->ORDER_BY('personal_asset_grid_id','DESC'); + $this->db->LIMIT(1) ; + $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); + } + else + { + + $this->db->SELECT('*'); + $this->db->FROM(PERSONALASSETGRID); + $this->db->WHERE('isactive',1); + $this->db->WHERE('loan_amount_from<=',(int)$loan_amt_from_loam_form); + $this->db->WHERE('loan_amount_to>=',(int)$loan_amt_from_loam_form); + $personal_asset_grid['master_grid'] = $this->db->GET()->result_array(); + } // print_r($this->db->last_query()); // print_r($personal_asset_grid['master_grid']); // die(); - $this->db->SELECT('*'); - $this->db->FROM(PERSONALASSETGRIDVARIANCE); - $this->db->WHERE('isactive',1); - $personal_asset_grid['variance_grid'] = $this->db->GET()->result_array(); - + $this->db->SELECT('*'); + $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']) + $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 4: - case 5: - case 6: - case 7: - $score_questions = PDSCORE::genericDI($score_questions,$loan_amt_from_loam_form,$personal_asset_grid); + case 111111: + PDSCORE::calculatePDScore111($score_questions,$loan_amt_from_loam_form,$personal_asset_grid); break; + + default: + switch($pd_master_details[0]['fk_customer_segment']) + { + case 4: + case 5: + case 6: + case 7: + $score_questions = PDSCORE::genericDI($score_questions,$loan_amt_from_loam_form,$personal_asset_grid); + break; + } } - } - - return $score_questions; - - - } - - + + return $score_questions; + + + } + + //Get All Score able Question from various PD Forms - 3 Questions Pending - public function seperateScoreQuestions($form_data,$OTP) - { - $score_questions = array(); - + public function seperateScoreQuestions($form_data,$OTP) + { + $score_questions = array(); + #####General Form Questions######## - $general_form = (json_decode($form_data[18][0]['processed_json'],true)); + $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'; + + $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) - { + $qualification_temp_array = array(); + + $score_questions['general']['person_met_is_applicant'] = 'no'; + foreach($general_form['individuals'] as $person) + { //print_r($person); - $qualification_temp_array = array_merge($qualification_temp_array,array($person['qualification'])); - if($person['is_applicant'] == true && $person['is_person_met'] == true) - { + $qualification_temp_array = array_merge($qualification_temp_array,array($person['qualification'])); + if($person['is_applicant'] == true && $person['is_person_met'] == true) + { //echo $person['applicant_name']; - $score_questions['general']['person_met_is_applicant'] = 'yes'; - } - } + $score_questions['general']['person_met_is_applicant'] = 'yes'; + } + } //print_r($qualification_temp_array); - $qualification_temp_array = array_map(function($item){ - return $item != "" || $item != null ? $item : 6; - },$qualification_temp_array); + $qualification_temp_array = array_map(function($item){ + return $item != "" || $item != null ? $item : 6; + },$qualification_temp_array); //print_r($qualification_temp_array); - $min = count($qualification_temp_array) ? min($qualification_temp_array) : 6; - + $min = count($qualification_temp_array) ? min($qualification_temp_array) : 6; + //die(); - - + + // 2 - QNO(1.8) - Qualification - $score_questions['general']['qualification'] = $min; - + $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; - } + 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)); + $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) - { + + if(isset($address_form['is_pd_done_on_initiated_address']) && $address_form['is_pd_done_on_initiated_address'] != 1) + { // 4 - QNO(1.2) - Comment on locality - $score_questions['general']['comment_locality'] = $address_form['alternative_addresses'][0]['comment_locality_master']; + $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']; - - } + $score_questions['general']['pd_location_approach'] = $address_form['alternative_addresses'][0]['pd_location_master']; + + } else //get it from alternative address { // 4 - QNO(1.2) - Comment on locality - $score_questions['general']['comment_locality'] = $address_form['addresses'][0]['comment_locality_master']; + $score_questions['general']['comment_locality'] = $address_form['addresses'][0]['comment_locality_master']; // 5 - QNO(1.3) - pd location approach - $score_questions['general']['pd_location_approach'] = $address_form['addresses'][0]['pd_location_master']; + $score_questions['general']['pd_location_approach'] = $address_form['addresses'][0]['pd_location_master']; } @@ -6931,7 +6934,7 @@ class PD_Controller extends REST_Controller { $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; @@ -6964,188 +6967,188 @@ class PD_Controller extends REST_Controller { #####supplier Form Questions######## $supplier_form = isset($form_data[1][0]['processed_json'])?(json_decode($form_data[1][0]['processed_json'],true)):array(); - $supplier_count = 0; - if(count($supplier_form)) + $supplier_count = 0; + if(count($supplier_form)) + { + if($supplier_form['supplier_info_available'] == 1) + { + if(array_key_exists('manufacturing_details',$supplier_form)) { - if($supplier_form['supplier_info_available'] == 1) - { - if(array_key_exists('manufacturing_details',$supplier_form)) - { - if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) - { - - - foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) - { - - - if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" ) - { - $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'] != "" ) - { - $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'] != "" ) - { - $supplier_count ++; - } - } - - } - - } - - $score_questions['business']['minimum_supplier_info'] = $supplier_count ? 'Provided':'Not Provided'; - - } - else + if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) { - $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; + + + foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) + { + + + if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" ) + { + $supplier_count ++; + } + } } - }else - { - $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; + } + + 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'] != "" ) + { + $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'] != "" ) + { + $supplier_count ++; + } + } + + } + + } + + $score_questions['business']['minimum_supplier_info'] = $supplier_count ? 'Provided':'Not Provided'; + + } + else + { + $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; + } + }else + { + $score_questions['business']['minimum_supplier_info'] = 'Not Applicable'; + } #####End of supplier Form Questions######## #####client Form Questions######## - $client_form = isset($form_data[2][0]['processed_json'])?(json_decode($form_data[2][0]['processed_json'],true)):array(); - $client_count = 0; + $client_form = isset($form_data[2][0]['processed_json'])?(json_decode($form_data[2][0]['processed_json'],true)):array(); + $client_count = 0; //print_r($client_form);die(); - if(count($client_form)) - { - 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'] != "" ) - { $client_count++; } - } - } - } - - 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(); - if($value['trade_product_name'] != "" && (isset($value['trade_client_name'])) && $value['trade_client_name'] != "" ) - { - $client_count++; - } - - } - - } - } - - if(array_key_exists('service_provider_details',$client_form)) - { - if(isset($client_form['service_provider_details'][0]['service_products'])) - { - foreach ($client_form['service_provider_details'][0]['service_products'] as $key => $value) - { - - 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'; - } - + if(count($client_form)) + { + 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'] != "" ) + { $client_count++; } + } + } + } + + 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(); + if($value['trade_product_name'] != "" && (isset($value['trade_client_name'])) && $value['trade_client_name'] != "" ) + { + $client_count++; + } + + } + + } + } + + if(array_key_exists('service_provider_details',$client_form)) + { + if(isset($client_form['service_provider_details'][0]['service_products'])) + { + foreach ($client_form['service_provider_details'][0]['service_products'] as $key => $value) + { + + 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######## $stock_form = isset($form_data[11][0]['processed_json'])?(json_decode($form_data[11][0]['processed_json'],true)):array(); //print_r($stock_form); - if(count($stock_form)) - { + if(count($stock_form)) + { //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'; - } - else + if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != "")) { - $score_questions['business']['stock_raw_material_enough'] = 'Not Applicable'; - $score_questions['business']['stock_finished_goods_enough'] = 'Not Applicable'; + + $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'; + } + else + { + $score_questions['business']['stock_raw_material_enough'] = 'Not Applicable'; + $score_questions['business']['stock_finished_goods_enough'] = 'Not Applicable'; //$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)); + $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)) - { + + $over_all_asset_value = 0; + if(array_key_exists('assets_details',$other_asset_form)) + { //print_r($other_asset_form['assets_details']);die(); - foreach($other_asset_form['assets_details'] as $asset) - { + foreach($other_asset_form['assets_details'] as $asset) + { //echo 'Value - '.$asset['approximate_market_value']; - $over_all_asset_value += is_numeric($asset['approximate_market_value']) ? $asset['approximate_market_value'] : 0 ; + $over_all_asset_value += is_numeric($asset['approximate_market_value']) ? $asset['approximate_market_value'] : 0 ; if($asset['assets_mode'] == 6)//LIC { $over_all_asset_value += $asset['details'][0]['sum_assured']; @@ -7162,203 +7165,203 @@ class PD_Controller extends REST_Controller { //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)); + $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)) - { - foreach($business_bank_form['banking_details'] as $banking) - { - $year = $banking['vintage_year'] ? $banking['vintage_year'] : 0 ; - $month = $banking['vintage_month'] ? $banking['vintage_month'] : 0; - $temp = $year.'.'.$month; - $vintage = array_merge($vintage,array($temp)); - } - } - - $score_questions['business']['vintage_of_business_account'] = count($vintage)? max($vintage) : 0; + + $vintage = array(); + if(array_key_exists('banking_details',$business_bank_form)) + { + foreach($business_bank_form['banking_details'] as $banking) + { + $year = $banking['vintage_year'] ? $banking['vintage_year'] : 0 ; + $month = $banking['vintage_month'] ? $banking['vintage_month'] : 0; + $temp = $year.'.'.$month; + $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) - { + 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']); $temp = array('fk_subproduct_id' => $new_sub_product,'fk_updatedby' => $records['fk_createdby']); $pk_id = $this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array); - } - - } - - public function saveEmpSalaryAsBusinessExpensesFromBusinessForm($records) - { + } + + } + + public function saveEmpSalaryAsBusinessExpensesFromBusinessForm($records) + { //echo "FROM saveEmpSalaryAsBusinessExpensesFromBusinessForm"; - if(isset($records['employees_appx_salary']) && ($records['employees_appx_salary'] != null|| $records['employees_appx_salary'] != '')) - { + 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); + + $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); - + + $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)) - { + + if(count($business_expenses)) + { //echo "Update"; - $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); - $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); - } - else - { + $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); + $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); + } + else + { //echo "insert"; - $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); + $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); + } + + + + + + + } } - - - - - } - } - - - public function saveAssetRentAsBusinessExpensesFromBusinessAssestForm($records) - { + 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)) - { - foreach($records['business_assets_for_address'] as $business_asset) - { - if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) + + $over_all_rent_amt = 0; + if(isset($records['business_assets_for_address']) && ($records['business_assets_for_address'] != "" || $records['business_assets_for_address'] != null)) { - $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; + foreach($records['business_assets_for_address'] as $business_asset) + { + if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) + { + $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; + } + } } - } - } - - if(isset($records['business_assets_details']) && ($records['business_assets_details'] != "" || $records['business_assets_details'] != null)) - { - foreach($records['business_assets_details'] as $business_asset) - { - if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) + + if(isset($records['business_assets_details']) && ($records['business_assets_details'] != "" || $records['business_assets_details'] != null)) { - $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; + foreach($records['business_assets_details'] as $business_asset) + { + if($business_asset['business_monthly_rented_amt'] != "" || $business_asset['business_monthly_rented_amt'] != null) + { + $over_all_rent_amt+=$business_asset['business_monthly_rented_amt']; + } + } } - } - } - + //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); - + + + $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)) - { + + if(count($business_expenses)) + { //echo "Update"; - $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); - $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); - } - else - { + $where_condition_array = array('pd_expense_id' => $business_expenses[0]['pd_expense_id']); + $this->PD_Model->updateRecords($temp_array,$table,$where_condition_array); + } + else + { //echo "insert"; - $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); + $this->PD_Model->saveRecords($temp_array,PDBUSINESSEXPENSES); + } + + + } - - - - } - - public function saveHTMLReport_post() - { - - $records = $this->post('records'); - $pdid = $records['pdid']; - $content = $records['content']; - $fk_createdby = $records['fk_createdby']; - $random_string = $records['random_string']; - $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); - + + public function saveHTMLReport_post() + { + + $records = $this->post('records'); + $pdid = $records['pdid']; + $content = $records['content']; + $fk_createdby = $records['fk_createdby']; + $random_string = $records['random_string']; + $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 = $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)); - + $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); - $logger->info('QC Edit Called',array('Edited by' => $fk_createdby,'DB Result' => $update .'-'. $update_reports_version_blob .'-'. $pd_reports_version_blob_new)); - $dat['dataStatus'] = true; - $dat['status'] = REST_Controller::HTTP_OK; - $dat['msg'] = 'Report Generated Sucessfully..!'; - $this->response($dat,REST_Controller::HTTP_OK); - } - } + $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); + $logger->info('QC Edit Called',array('Edited by' => $fk_createdby,'DB Result' => $update .'-'. $update_reports_version_blob .'-'. $pd_reports_version_blob_new)); + $dat['dataStatus'] = true; + $dat['status'] = REST_Controller::HTTP_OK; + $dat['msg'] = 'Report Generated Sucessfully..!'; + $this->response($dat,REST_Controller::HTTP_OK); + } + } - public function getPDReportHTML_get() - { - $pdid = $this->uri->segment(3); - $random_string = $this->uri->segment(2); - $this->getLatestPDReportHTMLFile($pdid,$random_string); - - } + public function getPDReportHTML_get() + { + $pdid = $this->uri->segment(3); + $random_string = $this->uri->segment(2); + $this->getLatestPDReportHTMLFile($pdid,$random_string); + + } - function getLatestPDReportHTMLFile($pdid,$random_string,$return_type = false) - { + function getLatestPDReportHTMLFile($pdid,$random_string,$return_type = false) + { if(($pdid != null || $pdid != "")) //&& (strlen($pdid) == 16) &&(is_string($pdid))) { - $pd_data = $this->PD_Model->selectCustomRecords(array('pd_id','pd_report_html_filename'),array('random_string' => $random_string,'pd_id' => $pdid),PDTRIGGER); + $pd_data = $this->PD_Model->selectCustomRecords(array('pd_id','pd_report_html_filename'),array('random_string' => $random_string,'pd_id' => $pdid),PDTRIGGER); if(count($pd_data)) { @@ -7431,25 +7434,25 @@ class PD_Controller extends REST_Controller { $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 % >>"); + + $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 - $pd_images = array(); - $form_data = array(); - 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'); - } - - $incomplete_details = array(); - // print_r($pd_images);die(); + $pd_images = array(); + $form_data = array(); + 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'); + } + + $incomplete_details = array(); + // print_r($pd_images);die(); + #####General Form Questions######## @@ -7457,7 +7460,7 @@ class PD_Controller extends REST_Controller { // echo "seperateScoreQuestions"; //print_r($general_form);die(); - + $person_met_is_applicant_count = 0; $person_met_selfie_count = 0; $person_met_id_proof_count = 0; @@ -7520,83 +7523,83 @@ class PD_Controller extends REST_Controller { if($pd_master_details[0]['customer_segment_abbr'] == 'SE-AI' || $pd_master_details[0]['customer_segment_abbr'] == 'SE-DI') { #####Business Form Questions######## - $business_form = (json_decode($form_data[13][0]['processed_json'],true)); + $business_form = (json_decode($form_data[13][0]['processed_json'],true)); //print_r($business_form);die(); //print_r(($business_form['shop_eat_act_cert']));die(); - $is_manufacturing_selected = 0; - $selected_type_of_activity = array(); - foreach ($business_form['select_business_activity_type'] as $key => $value) { - if($value['type_of_activity_id'] == 2){ $is_manufacturing_selected = 1; } - array_push($selected_type_of_activity,$value['type_of_activity_id']); + $is_manufacturing_selected = 0; + $selected_type_of_activity = array(); + foreach ($business_form['select_business_activity_type'] as $key => $value) { + if($value['type_of_activity_id'] == 2){ $is_manufacturing_selected = 1; } + array_push($selected_type_of_activity,$value['type_of_activity_id']); - } - $is_name_board_seen = false; - if($business_form['was_the_company_name_board_sighted'] == "") - { - $incomplete_details[] = 'Business Section - Name Board Seen Not answered'; + } + $is_name_board_seen = false; + if($business_form['was_the_company_name_board_sighted'] == "") + { + $incomplete_details[] = 'Business Section - Name Board Seen Not answered'; - } - else if($business_form['was_the_company_name_board_sighted'] == "yes") - { - $is_name_board_seen = true; - } + } + else if($business_form['was_the_company_name_board_sighted'] == "yes") + { + $is_name_board_seen = true; + } - if( !is_numeric($business_form['employees_temporary']) || !is_numeric($business_form['employees_permanent']) || !is_numeric($business_form['employees_appx_salary']) || !is_numeric($business_form['officer_total'])) - { - $incomplete_details[] = 'Business Section - Company Employees Details Not Filled'; - } + if( !is_numeric($business_form['employees_temporary']) || !is_numeric($business_form['employees_permanent']) || !is_numeric($business_form['employees_appx_salary']) || !is_numeric($business_form['officer_total'])) + { + $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])) + $certificate_count = 0; + $name_board_image_count = 0; + + if(count($pd_images[13])) + { + foreach ($pd_images[13] as $key => $value) { + if(substr_count(strtolower($value['pd_document_title']),strtolower('Name board Seen'))) { - foreach ($pd_images[13] as $key => $value) { - if(substr_count(strtolower($value['pd_document_title']),strtolower('Name board Seen'))) - { - $name_board_image_count++; - } - } + $name_board_image_count++; } - 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'] == "") - { - $certificate_count++; + } } - } else { $certificate_count++; } + 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'] == "") + { + $certificate_count++; + } + } else { $certificate_count++; } - if(isset($business_form['gst_Regn_cert'])) - { - if(strtoupper($business_form['gst_Regn_cert'])=='YES' && $business_form['gst_Regn_cert_pic'] == "") + if(isset($business_form['gst_Regn_cert'])) { - $certificate_count++; - } - } else { $certificate_count++; } + if(strtoupper($business_form['gst_Regn_cert'])=='YES' && $business_form['gst_Regn_cert_pic'] == "") + { + $certificate_count++; + } + } else { $certificate_count++; } - if(isset($business_form['pf_regn'])) - { - if(strtoupper($business_form['pf_regn'])=='YES' && $business_form['pf_regn_pic'] == "") + if(isset($business_form['pf_regn'])) { - $certificate_count++; - } - } else { $certificate_count++; } + if(strtoupper($business_form['pf_regn'])=='YES' && $business_form['pf_regn_pic'] == "") + { + $certificate_count++; + } + } else { $certificate_count++; } - if(isset($business_form['esic_regn'])) - { - if(strtoupper($business_form['esic_regn'])=='YES' && $business_form['esic_regn_pic'] == "") + if(isset($business_form['esic_regn'])) { - $certificate_count++; - } - } else { $certificate_count++; } + if(strtoupper($business_form['esic_regn'])=='YES' && $business_form['esic_regn_pic'] == "") + { + $certificate_count++; + } + } else { $certificate_count++; } @@ -7611,7 +7614,7 @@ class PD_Controller extends REST_Controller { } } //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)) { @@ -7641,8 +7644,8 @@ class PD_Controller extends REST_Controller { if($certificate_count){ $incomplete_details[] = 'Business Section - Images for Document Sighted Not Sufficient'; } - } - + } + #####End of Business Form Questions######## @@ -7710,38 +7713,38 @@ class PD_Controller extends REST_Controller { } 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(); + $supplier_form = isset($form_data[1][0]['processed_json'])?(json_decode($form_data[1][0]['processed_json'],true)):array(); //print_r($supplier_form);die(); - $supplier_count = 0; - $insufficient_supplier_info = 0; - $supplier_images = isset($pd_images[1]) ? $pd_images[1] : array(); + $supplier_count = 0; + $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) - { - if(array_key_exists('manufacturing_details',$supplier_form)) - { - if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) + + if(count($supplier_form)) + { + if($supplier_form['supplier_info_available'] == 1) + { + if(array_key_exists('manufacturing_details',$supplier_form)) { - - - foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) + if(isset($supplier_form['manufacturing_details'][0]['main_raw_materials'])) { - - - if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" && $manu_value['manufacturing_contact_person_name'] != "" && ($manu_value['manufacturing_contact_person_mobile_number'] != "" || $manu_value['person_landline'] != "")) + + + foreach ($supplier_form['manufacturing_details'][0]['main_raw_materials'] as $manu_key => $manu_value) { - $supplier_count ++; + + + if($manu_value['manufacturing_raw_material_name'] != "" && $manu_value['manufacturing_supplier_name'] != "" && $manu_value['manufacturing_contact_person_name'] != "" && ($manu_value['manufacturing_contact_person_mobile_number'] != "" || $manu_value['person_landline'] != "")) + { + $supplier_count ++; //$cureent_supplier_images_count = 0 ; //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) @@ -7759,36 +7762,36 @@ class PD_Controller extends REST_Controller { // { // $incomplete_details[] = 'Supplier Section - '.$supplier_name.' - Images Not Found'; // } - } - else if($manu_value['manufacturing_raw_material_name'] == "" || $manu_value['manufacturing_supplier_name'] == "" ) - { - $insufficient_supplier_info++; - } + } + else if($manu_value['manufacturing_raw_material_name'] == "" || $manu_value['manufacturing_supplier_name'] == "" ) + { + $insufficient_supplier_info++; + } // else // { // $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'])) + + + + if(array_key_exists('trade_details',$supplier_form)) { - foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value) + if(isset($supplier_form['trade_details'][0]['trading_products'])) { - 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'] != "")) + + foreach ($supplier_form['trade_details'][0]['trading_products'] as $trading_key => $trading_value) { - $supplier_count ++; + 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'] != "")) + { + $supplier_count ++; // $cureent_supplier_images_count = 0 ; @@ -7809,35 +7812,35 @@ class PD_Controller extends REST_Controller { // { // $incomplete_details[] = 'Supplier Section - '.$supplier_name.' - Images Not Found'; // } - - else if($trading_value['trade_product_name'] == "" || $trading_value['trade_supplier_name'] == "" ) - { - $insufficient_supplier_info++; - } + + else if($trading_value['trade_product_name'] == "" || $trading_value['trade_supplier_name'] == "" ) + { + $insufficient_supplier_info++; + } // else // { // $incomplete_details[] = 'Supplier Section - Supplier (Trading Product '.($key+1).') Details not sufficient'; // } + } + + } - - - } //echo 'IN trade-'.$supplier_count; - } + } - if(array_key_exists('servicing_details',$supplier_form)) - { - - if(isset($supplier_form['servicing_details'][0]['service_providers'])) + if(array_key_exists('servicing_details',$supplier_form)) { - foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value) + if(isset($supplier_form['servicing_details'][0]['service_providers'])) { - 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'] != "")) + + foreach ($supplier_form['servicing_details'][0]['service_providers'] as $serivce_key => $service_value) { - $supplier_count ++; + 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'] != "")) + { + $supplier_count ++; // $cureent_supplier_images_count = 0 ; @@ -7858,31 +7861,31 @@ class PD_Controller extends REST_Controller { // { // $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++; - } + + else if($service_value['service_provider_name'] == "" || $service_value['service_provider_supplier_name'] == "" ) + { + $insufficient_supplier_info++; + } // else // { // $incomplete_details[] = 'Supplier Section - Supplier (Trading Product '.($key+1).') Details not sufficient'; // } + } + + } - - - } //echo 'IN trade-'.$supplier_count; - } - - - + } + + + - } - } + } + } //echo $supplier_count. count($supplier_images);die(); //echo $insufficient_supplier_info; - if($supplier_form['bill_info'] == 'yes' && $supplier_count && (count($supplier_images) < 3) ){ $incomplete_details[] = 'Supplier Section - Images Not sufficient'; } - if($insufficient_supplier_info){ $incomplete_details[] = 'Supplier Section - Information Not sufficient'; + if($supplier_form['bill_info'] == 'yes' && $supplier_count && (count($supplier_images) < 3) ){ $incomplete_details[] = 'Supplier Section - Images Not sufficient'; } + if($insufficient_supplier_info){ $incomplete_details[] = 'Supplier Section - Information Not sufficient'; } @@ -7902,7 +7905,7 @@ class PD_Controller extends REST_Controller { if(count($client_form)) { if($client_form['client_info_available'] == 1) - { + { if(array_key_exists('manufacturing_details',$client_form)) { @@ -7937,9 +7940,9 @@ class PD_Controller extends REST_Controller { } else if($value['manufacturing_product_name'] == "" || $value['manufacturing_client_name'] == "" ) - { - $insufficient_client_info++; - } + { + $insufficient_client_info++; + } // else // { // $incomplete_details[] = 'Client Section - Client (Manufacturing Product '.($key+1).') Details not sufficient'; @@ -8043,21 +8046,21 @@ class PD_Controller extends REST_Controller { 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(); //print_r($stock_form);die(); - if(count($stock_form)) - { + if(count($stock_form)) + { //print_r($stock_form);die(); - if(isset($stock_form['manufacturing_details']) && ($stock_form['manufacturing_details'] != null || $stock_form['manufacturing_details'] != "")) - { - + 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'; @@ -8068,57 +8071,57 @@ class PD_Controller extends REST_Controller { // } // else // { - - $total_stock_observed = 0; + + $total_stock_observed = 0; - if( isset($stock_form['manufacturing_details'][0]['manufacturing_raw_materials']) && count($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'])) - { - foreach ($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'] as $key => $value) - { + if( isset($stock_form['manufacturing_details'][0]['manufacturing_raw_materials']) && count($stock_form['manufacturing_details'][0]['manufacturing_raw_materials'])) + { + 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++; } + + if((strcasecmp($value['stock_observed'],'no'))) { $total_stock_observed++; } - } - } + } + } - if( isset($stock_form['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'])) - { - foreach ($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'] as $key => $value) - { - if((strcasecmp($value['goods_observed'],'no'))) { $total_stock_observed++; } - - } - } + if( isset($stock_form['manufacturing_details'][0]['manufacturing_finished_goods']) && count($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'])) + { + foreach ($stock_form['manufacturing_details'][0]['manufacturing_finished_goods'] as $key => $value) + { + if((strcasecmp($value['goods_observed'],'no'))) { $total_stock_observed++; } + + } + } - if( isset($stock_form['retail_details'][0]['retail_traded_goods']) && count($stock_form['retail_details'][0]['retail_traded_goods'])) - { - foreach ($stock_form['retail_details'][0]['retail_traded_goods'] as $key => $value) - { - if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; } - - } - } + if( isset($stock_form['retail_details'][0]['retail_traded_goods']) && count($stock_form['retail_details'][0]['retail_traded_goods'])) + { + foreach ($stock_form['retail_details'][0]['retail_traded_goods'] as $key => $value) + { + if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; } + + } + } - if( isset($stock_form['trade_details'][0]['trading_traded_goods']) && count($stock_form['trade_details'][0]['trading_traded_goods'])) - { - foreach ($stock_form['trade_details'][0]['trading_traded_goods'] as $key => $value) - { - if((strcasecmp($value['traded_goods_observed'],'no'))) { $total_stock_observed++; } - - } - } - + if( isset($stock_form['trade_details'][0]['trading_traded_goods']) && count($stock_form['trade_details'][0]['trading_traded_goods'])) + { + 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') { @@ -8131,12 +8134,12 @@ class PD_Controller extends REST_Controller { } - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $incomplete_details; - $data['msg'] = count($incomplete_details) ? 'PD Details are incomplete' : 'All forms were answered'; - $this->response($data,REST_Controller::HTTP_OK); - + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $incomplete_details; + $data['msg'] = count($incomplete_details) ? 'PD Details are incomplete' : 'All forms were answered'; + $this->response($data,REST_Controller::HTTP_OK); + } @@ -8147,20 +8150,20 @@ class PD_Controller extends REST_Controller { $b64image = base64_encode(file_get_contents($img_url)); if($b64image) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $b64image; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $b64image; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong / Can`t convet given URL'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong / Can`t convet given URL'; + $this->response($data,REST_Controller::HTTP_OK); } - + } @@ -8174,52 +8177,52 @@ class PD_Controller extends REST_Controller { $temp_file_name = $records['pd_document_name']; $ifp = fopen( $output_file, 'wb' ); - $temp_data = explode( ',', $records['image']); - fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); - fclose( $ifp ); - $tempdoc = $output_file; - $tempdocname = $temp_file_name; - $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']); - if(isset($records['is_show_report'])){ $record_data['is_show_report'] = $records['is_show_report']; } - if(isset($records['pd_document_title'])){ $record_data['pd_document_title'] = $records['pd_document_title']; } + $temp_data = explode( ',', $records['image']); + fwrite( $ifp, base64_decode( $temp_data[ 1 ] ) ); + fclose( $ifp ); + $tempdoc = $output_file; + $tempdocname = $temp_file_name; + $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']); + if(isset($records['is_show_report'])){ $record_data['is_show_report'] = $records['is_show_report']; } + if(isset($records['pd_document_title'])){ $record_data['pd_document_title'] = $records['pd_document_title']; } - $where_condition_array = array('pd_document_id' => $records['pd_document_id']); - $id = $this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array); - if($id != null || $id != "") - { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); - } - - - - + $where_condition_array = array('pd_document_id' => $records['pd_document_id']); + $id = $this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array); + if($id != null || $id != "") + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + + + } @@ -8247,17 +8250,17 @@ class PD_Controller extends REST_Controller { $id = $this->PD_Model->saveRecords($insert_data,USERNOTIFICATIONTOKENS); if($id) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); } } else @@ -8276,17 +8279,17 @@ class PD_Controller extends REST_Controller { $id = $this->PD_Model->updateRecords($update_data,USERNOTIFICATIONTOKENS,$where_condition_array); if($id) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -8303,44 +8306,44 @@ class PD_Controller extends REST_Controller { $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; - $this->response($data,REST_Controller::HTTP_OK); + + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $t; + $this->response($data,REST_Controller::HTTP_OK); } public function savePDRemark_post() { - $pd_id = $this->post('pd_id'); - $remark = $this->post('remark'); - $createdby = $this->post('createdby'); + $pd_id = $this->post('pd_id'); + $remark = $this->post('remark'); + $createdby = $this->post('createdby'); if($pd_id != null && $remark != null && $createdby != null) { $res = $this->PD_Model->saveRecords(array('fk_pd_id' => $pd_id,'remark' => $remark,'createdby' => $createdby),PDREMARKS); if($res) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $res; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $res; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something Went Wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); } } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'In Appropriate call!'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'In Appropriate call!'; + $this->response($data,REST_Controller::HTTP_OK); } } @@ -8351,17 +8354,17 @@ class PD_Controller extends REST_Controller { $lender_contact_persons = $this->PD_Model->getLenderContactPersons($records['fk_lender_id'],$records['pd_branch_id']); if(count($lender_contact_persons)) { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] =$lender_contact_persons; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] =$lender_contact_persons; + $this->response($data,REST_Controller::HTTP_OK); } else { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'No Lender Profile was found under selected branch. Create Lender profile in this branch'; - $this->response($data,REST_Controller::HTTP_OK); + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'No Lender Profile was found under selected branch. Create Lender profile in this branch'; + $this->response($data,REST_Controller::HTTP_OK); } } diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php index 871848ff..c4bcbbff 100644 --- a/api/application/helpers/pdalerts_helper.php +++ b/api/application/helpers/pdalerts_helper.php @@ -30,23 +30,27 @@ class PDALERTS /*********************************************/ /*******Get PD Master Details*****************/ /*********************************************/ - $CI->db->SELECT("PDTRIGGER.fk_lender_id,ENTITY.short_name,PDTRIGGER.lender_applicant_id,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.pd_date_of_initiation,PDTRIGGER.scheduled_on,PDTRIGGER.updatedon,PDTRIGGER.fk_pd_allocated_to,ALLOCATED.email as allocated_email,ALLOCATED.mobile_no as allocated_mobile_no,concat(ALLOCATED.first_name,' ',ALLOCATED.last_name) as pdofficer_name,PDTRIGGER.executive_id,EXECUTIVE.email as executive_email,EXECUTIVE.mobile_no as executive_mobile_no,PDTRIGGER.central_pd_officer_id,CENTRALPDOFFICER.mobile_no as centralpdofficer_mobile_no,CENTRALPDOFFICER.email as centralpdofficer_mail,PDTRIGGER.pd_agency_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,CREATED.fk_entity_type_id,CREATED.email as created_email,PDTRIGGER.pd_contact_person_mail,PDAPPLICANTSDETAILS.applicant_name,PDAPPLICANTSDETAILS.mobile_no as customer_mobile_no,PDTRIGGER.encrypted_url,PDOFFICER.web_token as pdofficer_webtoken,PDOFFICER.mob_token as pdofficer_mobtoken,PDEXECUTIVE.web_token as pdexecutive_webtoken,PDEXECUTIVE.mob_token as pdexecutive_mobtoken,CENTRALPDOFFICERTOKEN.web_token as centralpdofficer_webtoken,CENTRALPDOFFICERTOKEN.mob_token as centralpdofficer_mobtoken"); + $CI->db->SELECT("PDTRIGGER.fk_lender_id,ENTITY.short_name,PDTRIGGER.lender_applicant_id,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.pd_date_of_initiation,PDTRIGGER.scheduled_on,PDTRIGGER.updatedon,PDTRIGGER.fk_pd_allocated_to,ALLOCATED.email as allocated_email,ALLOCATED.mobile_no as allocated_mobile_no,concat(ALLOCATED.first_name,' ',ALLOCATED.last_name) as pdofficer_name,PDTRIGGER.executive_id,EXECUTIVE.email as executive_email,EXECUTIVE.mobile_no as executive_mobile_no,PDTRIGGER.central_pd_officer_id,CENTRALPDOFFICER.mobile_no as centralpdofficer_mobile_no,CENTRALPDOFFICER.email as centralpdofficer_mail,PDTRIGGER.pd_agency_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,CREATED.fk_entity_type_id,CREATED.email as created_email,PDTRIGGER.pd_contact_person_mail,PDAPPLICANTSDETAILS.applicant_name,PDAPPLICANTSDETAILS.mobile_no as customer_mobile_no,PDTRIGGER.encrypted_url,PDOFFICER.web_token as pdofficer_webtoken,PDOFFICER.mob_token as pdofficer_mobtoken,PDEXECUTIVE.web_token as pdexecutive_webtoken,PDEXECUTIVE.mob_token as pdexecutive_mobtoken,CENTRALPDOFFICERTOKEN.web_token as centralpdofficer_webtoken,CENTRALPDOFFICERTOKEN.mob_token as centralpdofficer_mobtoken,concat(LENDERSALESPERSON.first_name,' ',LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,concat(LENDERCREDITPERSON.first_name,' ',LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,LENDERSALESPERSONTOKEN.web_token as lender_sales_web_token,LENDERSALESPERSONTOKEN.mob_token as lender_sales_mob_token,LENDERCREDITPERSONTOKEN.web_token as lender_credit_web_token,LENDERCREDITPERSONTOKEN.mob_token as lender_credit_mob_token,"); $CI->db->FROM(PDTRIGGER." as PDTRIGGER"); $CI->db->JOIN(USERPROFILE." as CREATED","PDTRIGGER.fk_createdby = CREATED.userid",'LEFT'); $CI->db->JOIN(ENTITY." as ENTITY","PDTRIGGER.fk_lender_id = ENTITY.entity_id",'LEFT'); $CI->db->JOIN(USERPROFILE." as ALLOCATED","PDTRIGGER.fk_pd_allocated_to = ALLOCATED.userid",'LEFT'); $CI->db->JOIN(USERPROFILE." as EXECUTIVE","PDTRIGGER.executive_id = EXECUTIVE.userid",'LEFT'); $CI->db->JOIN(USERPROFILE." as CENTRALPDOFFICER","PDTRIGGER.central_pd_officer_id = CENTRALPDOFFICER.userid",'LEFT'); + $CI->db->JOIN(USERPROFILE.' as LENDERSALESPERSON','PDTRIGGER.lender_sales_person = LENDERSALESPERSON.userid','LEFT'); + $CI->db->JOIN(USERPROFILE.' as LENDERCREDITPERSON','PDTRIGGER.lender_credit_person = LENDERCREDITPERSON.userid','LEFT'); $CI->db->JOIN(PDAPPLICANTSDETAILS." as PDAPPLICANTSDETAILS","PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id AND PDAPPLICANTSDETAILS.applicant_type = 1",'LEFT'); $CI->db->JOIN(USERNOTIFICATIONTOKENS." as PDOFFICER","PDTRIGGER.fk_pd_allocated_to = PDOFFICER.fk_user_id",'LEFT'); $CI->db->JOIN(USERNOTIFICATIONTOKENS." as PDEXECUTIVE","PDTRIGGER.executive_id = PDEXECUTIVE.fk_user_id",'LEFT'); $CI->db->JOIN(USERNOTIFICATIONTOKENS." as CENTRALPDOFFICERTOKEN","PDTRIGGER.central_pd_officer_id = CENTRALPDOFFICERTOKEN.fk_user_id",'LEFT'); + $CI->db->JOIN(USERNOTIFICATIONTOKENS." as LENDERSALESPERSONTOKEN","PDTRIGGER.lender_sales_person = LENDERSALESPERSONTOKEN.fk_user_id",'LEFT'); + $CI->db->JOIN(USERNOTIFICATIONTOKENS." as LENDERCREDITPERSONTOKEN","PDTRIGGER.lender_credit_person = LENDERCREDITPERSONTOKEN.fk_user_id",'LEFT'); $CI->db->WHERE("PDTRIGGER.pd_id",$pdid); $core_details = $CI->db->GET()->result_array(); // print_r($core_details); - // die(); + //die(); if(count($core_details)) { $additional_data_for_logs['pd_status'] = $core_details[0]['pd_status']; @@ -113,6 +117,8 @@ class PDALERTS if($pd_notification_configs[0]['sms_lender'] == 1) { $lender_sms = (string)$core_details[0]['pd_contact_mobileno']; + $lender_sales_contact_mobileno = (string)$core_details[0]['lender_sales_contact_mobileno']; + $lender_credit_person_contact_mobileno = (string)$core_details[0]['lender_credit_person_contact_mobileno']; if($pd_notification_msg[0]['lender'] != null) { @@ -120,8 +126,15 @@ class PDALERTS $msg = self::stringReplace($msg,$core_details); //echo $msg; $msg = str_replace('
','',$msg); + $additional_data_for_logs['to_whom'] = 'LEDNER'; SMS_GUPSHUP::sendSMS($msg,$lender_sms,$additional_data_for_logs); + + $additional_data_for_logs['to_whom'] = 'LEDNERSALES'; + SMS_GUPSHUP::sendSMS($msg,$lender_sales_contact_mobileno,$additional_data_for_logs); + + $additional_data_for_logs['to_whom'] = 'LEDNERCREDIT'; + SMS_GUPSHUP::sendSMS($msg,$lender_credit_person_contact_mobileno,$additional_data_for_logs); } @@ -129,11 +142,13 @@ class PDALERTS /*********************************************/ - /*******Send Mail Notification to Lender*****/ + /*******Send Mail Notification to Lender*****/ // currently Mail disabled /*********************************************/ if($pd_notification_configs[0]['mail_lender'] == 1) { $lender_email = null; + $lender_sales_person_email = $core_details[0]['lender_sales_person_email']; + $lender_credit_person_email = $core_details[0]['lender_credit_person_email']; if($core_details[0]['fk_entity_type_id'] == 2 ) { @@ -144,24 +159,44 @@ class PDALERTS $lender_email = $core_details[0]['pd_contact_person_mail']; } - + $msg = $pd_notification_msg[0]['lender']; + $msg = self::stringReplace($msg,$core_details); if($lender_email != null) { - $msg = $pd_notification_msg[0]['lender']; - $msg = self::stringReplace($msg,$core_details); - self::sendMail($CI,$lender_email,$msg,$core_details); + // self::sendMail($CI,$lender_email,$msg,$core_details); // currently Mail disabled } + //self::sendMail($CI,$lender_sales_person_email,$msg,$core_details);// currently Mail disabled + //self::sendMail($CI,$lender_credit_person_email,$msg,$core_details);// currently Mail disabled + } /*********************************************/ - /*******Send Push Notification to Lender(WEB/MOB)***** HOLDED TEMPORARY/ + /*******Send Push Notification to Lender(WEB/MOB)***** /*********************************************/ if($pd_notification_configs[0]['app_lender'] == 1) { - $lender_web_token = (string)$core_details[0]['pd_contact_mobileno']; - $lender_mob_token = (string)$core_details[0]['pd_contact_mobileno']; + //$lender_web_token = (string)$core_details[0]['pd_contact_mobileno']; + //$lender_mob_token = (string)$core_details[0]['pd_contact_mobileno']; + $msg = $pd_notification_msg[0]['lender']; + $msg = self::stringReplace($msg,$core_details); + + $lender_sales_web_token = (string)$core_details[0]['lender_sales_web_token']; + $lender_sales_mob_token = (string)$core_details[0]['lender_sales_mob_token']; + + $additional_data_for_logs['to_whom'] = 'LEDNERSALES'; + PUSH_NOTIFICATION::sendNotification($lender_sales_web_token,$lender_sales_mob_token,$msg,$additional_data_for_logs); + + + $lender_credit_web_token = (string)$core_details[0]['lender_credit_web_token']; + $lender_credit_mob_token = (string)$core_details[0]['lender_credit_mob_token']; + + $additional_data_for_logs['to_whom'] = 'LEDNERCREDIT'; + PUSH_NOTIFICATION::sendNotification($lender_credit_web_token,$lender_credit_mob_token,$msg,$additional_data_for_logs); + + + } @@ -206,8 +241,8 @@ class PDALERTS $msg = $pd_notification_msg[0]['pdofficer']; $msg = self::stringReplace($msg,$core_details); - PUSH_NOTIFICATION::sendNotification($pd_offcier_mob_token,$pd_offcier_web_token,$msg,$additional_data_for_logs); - PUSH_NOTIFICATION::sendNotification($pd_executive_mob_token,$pd_executive_web_token,$msg,$additional_data_for_logs); + PUSH_NOTIFICATION::sendNotification($pd_offcier_web_token,$pd_offcier_mob_token,$msg,$additional_data_for_logs); + PUSH_NOTIFICATION::sendNotification($pd_executive_web_token,$pd_executive_mob_token,$msg,$additional_data_for_logs); } @@ -257,7 +292,7 @@ class PDALERTS $central_offcier_mob_token = $core_details[0]['centralpdofficer_mobtoken']; $msg = $pd_notification_msg[0]['pdincharge']; $msg = self::stringReplace($msg,$core_details); - PUSH_NOTIFICATION::sendNotification($central_offcier_mob_token,$central_offcier_web_token,$msg,$additional_data_for_logs); + PUSH_NOTIFICATION::sendNotification($central_offcier_web_token,$central_offcier_mob_token,$msg,$additional_data_for_logs); } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 4c104d43..d9270a5e 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -759,7 +759,7 @@ class PD_Model extends SPARQ_Model { */ public function getPDMasterDetails($pdid,$random_string = null) { - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled, 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.pd_date_of_initiation as pd_date_of_initiation_sqlformat, 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 %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") 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.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,PDTRIGGER.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note'); + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.pd_sno,PDTRIGGER.fk_lender_id,PDTRIGGER.imgc_fin_institute,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,ENTITY.is_score_card_enabled,ENTITY.is_otp_enabled, 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.pd_date_of_initiation as pd_date_of_initiation_sqlformat, 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 %p") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i %p") 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.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,PDTRIGGER.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,PDTRIGGER.scheduled_on as scheduled_on_for_validation,DATE_FORMAT(PDTRIGGER.scheduled_on,"%dth %b %Y ") as scheduled_date_for_log,DATE_FORMAT(PDTRIGGER.scheduled_on,"%h:%i %p") as scheduled_time_for_log,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks,PDTRIGGER.bounce_reason,PDTRIGGER.bounce_reason_others,BOUNCEMASTER.bounce_reason_name,PDTRIGGER.is_original_report_created,PDTRIGGER.pd_report_latest_version,PDAPPLICANTSDETAILS.applicant_name as main_applicant,PDTRIGGER.pd_branch_id,ENTITYLENDERBRANCH.branch_name,PDTRIGGER.qc_feedback,PDTRIGGER.qc_rating,PDTRIGGER.qc_remarks,PDTRIGGER.lender_rating,PDTRIGGER.lender_feedback,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name,PDTRIGGER.pd_contact_landline,PDTRIGGER.other_pincode,PDTRIGGER.is_otp_done,OTPREJECTION.rejection_reason,PDTRIGGER.otp_reject_other_reason,PDTRIGGER.encrypted_url,PDTRIGGER.is_child,PDTRIGGER.parent_pd_id,PDTRIGGER.fk_primary_address_id,PDTRIGGER.fk_address_id,PDTRIGGER.start_location,PDTRIGGER.satellite_image_base64_blob,DATE_FORMAT(PDTRIGGER.pd_report_generated_date,"%d/%m/%Y %h:%i:%s %p") as pd_report_generated_date,DATE_FORMAT(PDTRIGGER.pd_visit_date,"%d/%m/%Y %h:%i:%s %p") as pd_visit_date,PDTRIGGER.random_string,PDTRIGGER.pd_report_html_filename,PDTRIGGER.is_qc_edited,PDTRIGGER.is_zip_created,PDTRIGGER.pd_qc_note'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT'); $this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT'); diff --git a/api/application/views/js/phantomchart.js b/api/application/views/js/phantomchart.js index c73502b9..f875551a 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 = 76.3;var url = 'http://localhost/sparqapi/api?'+score;var image_url = 'C:/xampp/htdocs/ssa_external_data/development/pd_reports/900views/report_templates/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 = 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 diff --git a/api/application/views/report_templates/JSONTOREPORT.php b/api/application/views/report_templates/JSONTOREPORT.php index d224f125..c68f890b 100644 --- a/api/application/views/report_templates/JSONTOREPORT.php +++ b/api/application/views/report_templates/JSONTOREPORT.php @@ -504,14 +504,13 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo "

"; echo "

"; - if($pd_master_details[0]['lender_short_name'] == 'CLIX') + if($lender_disclaimer[0]['disclaimer'] != '') { - echo '

Disclaimer: The information contained in this report (a) is provided for the benefit of Clix Capital Services Private Limited (hereinafter referred to as Clix) only, and is not for the benefit of any other parties; (b) has been compiled by Sineedge Consulting Private Limited (Hereinafter referred as SCPL) in accordance with the instructions given, by Clix; (c) has been obtained during the visit done at premises as instructed by Clix. Some of the information in this report, by the very nature of it, might have been obtained through informal sources. SCPL wishes to mention that all due care has been exercised by SCPL in collecting information and putting together this report. However, given the nature of some of these verifications, SCPL cannot be held liable for any financial or other loss to Clix on account of any errors or omissions in the report. SCPL does not guarantee absolute accuracy of information contained herein. SCPL does not take any responsibility for any action(s) that the client may take based on the contents of this report.

'; - - echo '

Registered / Corporate Office: SineEdge Consulting Private Limited. A-211, Pioneer Urban Square, Golf Course Extension Road, Sector 62, Gurgaon, Haryana - 122002

'; + echo '

Disclaimer: '. $lender_disclaimer[0]['disclaimer'] .'

'; + } - + echo '

Registered / Corporate Office: SineEdge Consulting Private Limited. A-211, Pioneer Urban Square, Golf Course Extension Road, Sector 62, Gurgaon, Haryana - 122002

'; ?> @@ -3110,7 +3109,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); '.$stock_form_remarks.'

'; + //echo '

'.$stock_form_remarks.'

'; //else {?> -

As per the loan applicants, they do not have any other source of Income.

+

As per the loan applicants, they do not have any other source of Income.

'. $other_source_income_common_remarks.'

'; }