diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index 8b51ae60..d00b7b20 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -2170,7 +2170,7 @@ class PD_Controller extends REST_Controller { // $processed_json = $records; // break; // case 5: - // $processed_json = $records; + // $processed_json = GETPROCESSEDJSON::convertAddressForm($records,$formid); // break; // case 6: @@ -2229,7 +2229,7 @@ class PD_Controller extends REST_Controller { // //echo "Something Wrong! Form ID did not match, Contact System Administrator"; // } - // die(); + //die(); /*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/ unset($records['pdid']); diff --git a/api/application/helpers/getprocessedjson_helper.php b/api/application/helpers/getprocessedjson_helper.php index 29c67f9f..043d8c26 100644 --- a/api/application/helpers/getprocessedjson_helper.php +++ b/api/application/helpers/getprocessedjson_helper.php @@ -1099,7 +1099,7 @@ class GETPROCESSEDJSON /*****************########## Other ASSETS FORM DETAILS ##########**************/ public static function convertOtherAssetForm($raw_json,$formid) { - echo "OA CALLED"; + //echo "OA CALLED"; $CI =& get_instance(); $master_tables_field_names = $CI->config->item('master_tables_field_names'); $master_tables_pkid = $CI->config->item('master_tables_pkid'); @@ -1193,6 +1193,107 @@ class GETPROCESSEDJSON } /*****************########## END OF CLIENT FORM DETAILS ##########**************/ + + + + + /*****************########## ADDRESS FORM DETAILS ##########********************/ + + public static function convertAddressForm($raw_json,$formid) + { + //echo "ADDRESS FORM 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); + + if(array_key_exists('address_type',$raw_json)) + { + $CI->db->SELECT( $master_tables_field_names['ADDRESSTYPE'] ); + $CI->db->FROM(ADDRESSTYPE); + $CI->db->WHERE('isactive',1); + $CI->db->WHERE($master_tables_pkid['ADDRESSTYPE'] ,$raw_json['address_type']); + $adress_type_name= $CI->db->GET()->result_array(); + //print_r($CI->db->last_query()); + if(count($adress_type_name)) + { + $raw_json['address_type_master'] = $adress_type_name[0][$master_tables_field_names['ADDRESSTYPE']]; + } + } + + + if(array_key_exists('locality',$raw_json)) + { + $CI->db->SELECT( $master_tables_field_names['LOCALITY'] ); + $CI->db->FROM(LOCALITY); + $CI->db->WHERE('isactive',1); + $CI->db->WHERE($master_tables_pkid['LOCALITY'] ,$raw_json['locality']); + $locality_name= $CI->db->GET()->result_array(); + //print_r($CI->db->last_query()); + if(count($locality_name)) + { + $raw_json['locality_master'] = $locality_name[0][$master_tables_field_names['LOCALITY']]; + } + } + + + if(array_key_exists('pd_location',$raw_json)) + { + $CI->db->SELECT( $master_tables_field_names['PDLOCATIONAPPROACH'] ); + $CI->db->FROM(PDLOCATIONAPPROACH); + $CI->db->WHERE('isactive',1); + $CI->db->WHERE($master_tables_pkid['PDLOCATIONAPPROACH'] ,$raw_json['pd_location']); + $pd_location_approach= $CI->db->GET()->result_array(); + //print_r($CI->db->last_query()); + if(count($pd_location_approach)) + { + $raw_json['pd_location_master'] = $pd_location_approach[0][$master_tables_field_names['PDLOCATIONAPPROACH']]; + } + } + + + if(array_key_exists('comment_locality',$raw_json)) + { + $CI->db->SELECT( $master_tables_field_names['COMMENTSONLOCALITY'] ); + $CI->db->FROM(COMMENTSONLOCALITY); + $CI->db->WHERE('isactive',1); + $CI->db->WHERE($master_tables_pkid['COMMENTSONLOCALITY'] ,$raw_json['comment_locality']); + $comments_on_locality= $CI->db->GET()->result_array(); + //print_r($CI->db->last_query()); + if(count($comments_on_locality)) + { + $raw_json['comment_locality_master'] = $comments_on_locality[0][$master_tables_field_names['COMMENTSONLOCALITY']]; + } + } + + if(array_key_exists('additional_address_units',$raw_json)) + { + + foreach($raw_json['additional_address_units'] as $additional_address_unit_key => $additional_address_unit) + { + $CI->db->SELECT( $master_tables_field_names['ADDRESSTYPE'] ); + $CI->db->FROM(ADDRESSTYPE); + $CI->db->WHERE('isactive',1); + $CI->db->WHERE($master_tables_pkid['ADDRESSTYPE'] ,$additional_address_unit['premises_type']); + $premises_type= $CI->db->GET()->result_array(); + //print_r($CI->db->last_query()); + if(count($premises_type)) + { + $raw_json['additional_address_units'][$additional_address_unit_key]['premises_type_master'] = $premises_type[0][$master_tables_field_names['ADDRESSTYPE']]; + } + } + } + + return $raw_json; + + } + /*****************########## END OF ADDRESS FORM DETAILS ##########**************/ }