From a43c4a84de64a548bcb3295339b18533dcb460a8 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 30 Jan 2019 16:32:28 +0530 Subject: [PATCH] ASSEST BUSINESS AND OTHER --- api/application/config/database.php | 2 +- api/application/controllers/PD_Controller.php | 85 +++++++++++++++---- .../helpers/getprocessedjson_helper.php | 57 ++++++++++++- 3 files changed, 124 insertions(+), 20 deletions(-) diff --git a/api/application/config/database.php b/api/application/config/database.php index 6ab0f361..99da2c96 100644 --- a/api/application/config/database.php +++ b/api/application/config/database.php @@ -70,7 +70,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | The $query_builder variables lets you determine whether or not to load | the query builder class. */ -$active_group = 'dev'; +$active_group = 'test'; $query_builder = TRUE; $db['dev'] = array( diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 9614403b..e86354d2 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -2143,7 +2143,7 @@ class PD_Controller extends REST_Controller { //Save Any New Applicants Details From General Form if($formid == 18) { - $records = $this->saveCoApplicantsFromGeneralInfoForm($records); + $records = $this->saveCoApplicantsFromGeneralInfoForm($records); } @@ -2202,7 +2202,7 @@ class PD_Controller extends REST_Controller { // break; // case 13: - // $processed_json = GETPROCESSEDJSON::convertBusinessFormDetailsForm($records,$formid); + // $processed_json = GETPROCESSEDJSON::convertBusinessDetailsForm($records,$formid); // break; // case 15: // $processed_json = $records; @@ -2210,9 +2210,9 @@ class PD_Controller extends REST_Controller { // case 17: // $processed_json = $records; // break; - // case 18: - // $processed_json = $records; - // break; + //case 18: + // $processed_json = GETPROCESSEDJSON::convertGeneralDetailsForm($records,$formid); + //break; // case 19: // $processed_json = GETPROCESSEDJSON::convertNeighbourDetailsForm($records,$formid); @@ -2496,7 +2496,7 @@ class PD_Controller extends REST_Controller { $count = 0; foreach($records as $rec_key => $record) { - if($record['sci_id'] != null || $record['sci_id'] != "") + if($recordrecordrecordrecord['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); @@ -4363,15 +4363,8 @@ class PD_Controller extends REST_Controller { public function getAssetsWithLoanFromBusiness_post() { $pdid = $this->post('pd_id'); - $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); - $final_data = array(); - //print_r($assest_data); - if(count($assest_data)) - { - - // GET Assest Types and Properties type from Master + + // 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); @@ -4380,6 +4373,18 @@ class PD_Controller extends REST_Controller { $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(); + //print_r($assest_data); + if(count($assest_data)) + { + + + //print_r($property_types);die(); foreach($assest_data as $key => $assest) @@ -4414,7 +4419,7 @@ class PD_Controller extends REST_Controller { } } - $final_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']['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']['name']); } } @@ -4422,10 +4427,56 @@ class PD_Controller extends REST_Controller { } } + //Get Other Assets with Loan + $fields = array('json','company_id'); + $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); + + if(count($other_assest)) + { + foreach($other_assest as $key => $assest) + { + $json = json_decode($assest['json'],true); + //print_r($json); + if(array_key_exists('assets_details',$json)) + { + foreach($json['assets_details'] as $asset_key => $asset) + { + if(!strcmp($asset['emi'],'yes')) + { + $assets_mode_name = ""; + + foreach($assest_types as $asset_type) + { + if($asset_type['id'] == $asset['assets_mode']) + { + $assets_mode_name = $asset_type['name']; + } + } + + if($asset['assets_mode'] == 2) + { + //echo $business_asset['business_details'][0]['property_type']; + foreach($property_types as $property_type) + { + if( $property_type['id'] == $asset['details'][0]['property_type']) + { + $business_asset['business_details'][0]['property_type_name'] = $property_type['name']; + } + } + } + + $other_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']['name']); + } + + } + } + } + } $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['record'] = $final_data; + $data['record'] = array('business_assets' =>$business_assest_data, 'other_assests'=> $other_assest_data); $this->response($data,REST_Controller::HTTP_OK); } diff --git a/api/application/helpers/getprocessedjson_helper.php b/api/application/helpers/getprocessedjson_helper.php index d312b74e..23ca4755 100644 --- a/api/application/helpers/getprocessedjson_helper.php +++ b/api/application/helpers/getprocessedjson_helper.php @@ -38,7 +38,7 @@ class GETPROCESSEDJSON { //GET MASASTER DATA - $table = constant($master_value['master_name']); + $table = constant($master_value['family_details']); $temp_fields = array($master_tables_field_names[$master_value['master_name']].' as name'); @@ -656,7 +656,7 @@ class GETPROCESSEDJSON /*****************########## BUSINESS FORM DETAILS ##########**************/ - public static function convertBusinessFormDetailsForm($raw_json,$formid) + public static function convertBusinessDetailsForm($raw_json,$formid) { $CI =& get_instance(); @@ -845,6 +845,59 @@ class GETPROCESSEDJSON /*****************########## END BUSINESS FORM DETAILS ##########**************/ + /*****************########## START GENERAL FORM DETAILS ##########**************/ + public static function convertGeneralDetailsForm($raw_json,$formid) + { + echo "called"; + $CI =& get_instance(); + $master_tables_field_names = $CI->config->item('master_tables_field_names'); + $master_tables_pkid = $CI->config->item('master_tables_pkid'); + + //print_r($raw_json); + + // GET KEYS FROM MASTER TABLE FOR SUPPLIER FORM + $fields = array('question', 'key', 'ismaster', 'master_name'); + $where_condition_array = array('fk_form_id' => $formid,'isactive' => 1); + $master_keys = $CI->PD_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONKEYMAPPING); + + print_r($master_keys);die(); + echo "****************"; + if(!empty($raw_json) && !empty($master_keys)) + { + + if(array_key_exists('individuals',$raw_json)) + { + foreach($raw_json['individuals'] as $individuals_key => $individual) + { + foreach($master_keys as $master_key => $master_value) + { + if(!strcmp($key,$master_value['key']) && $master_value['ismaster'] == 1) + { + //GET MASASTER DATA + + $table = constant($master_value['family_details']); + + $temp_fields = array($master_tables_field_names[$master_value['master_name']].' as name'); + + $where_condition_array = array($master_tables_pkid[$master_value['master_name']] => $value); + + $result_data = $CI->PD_Model->selectCustomRecords($temp_fields,$where_condition_array,$table); + if(count($result_data)) + { + //print_r($result_data[0]['name']); + $key = $key . '_master'; + $raw_json['manufacturing_details'][0]['main_raw_materials'][$manufacturing_details_key][$key] = $result_data[0]['name']; + + } + } + } + } + } + } + die(); + } + /*****************########## END GENERAL FORM DETAILS ##########**************/ + }