PROCESS JSON ADDED

This commit is contained in:
velz 2019-01-07 19:29:31 +05:30
parent 41c74b5ed6
commit a75b63ddd7
5 changed files with 197 additions and 18 deletions

View File

@ -463,6 +463,9 @@ defined('BUSINESSINCOMEID') OR define('BUSINESSINCOMEID','business_income_id');
defined('PDBUSINESSINCOME') OR define('PDBUSINESSINCOME','t_pd_business_income');
defined('PDBUSINESSINCOMEID') OR define('PDBUSINESSINCOMEID','pd_business_income_id');
defined('COUNTRY') OR define('COUNTRY','m_countries');
defined('COUNTRYID') OR define('COUNTRYID','country_id');

View File

@ -140,6 +140,7 @@ $route['saveLenderBranches'] = 'Entity_Management_Controller/saveLenderBranches'
$route['listLenderBranches'] = 'Entity_Management_Controller/listLenderBranches';
$route['getFullTATInfo'] = 'Entity_Management_Controller/getFullTATInfo';
$route['saveTATInfo'] = 'Entity_Management_Controller/saveTATInfo';
$route['deleteTATCombimaion'] = 'Entity_Management_Controller/deleteTATCombimaion';
//PD RELATED
$route['triggerNewPD'] = 'PD_Controller/triggerNewPD';

View File

@ -610,7 +610,7 @@ class Entity_Management_Controller extends REST_Controller {
//echo "dssd";
$records = $this->post('records');
$entity_id = $records['fk_entity_id'];
$entity_tat_master_id = $records['entity_tat_master_id'];
//$entity_tat_master_id = $records['entity_tat_master_id'];
//print_r($this->post('records'));
$fields = array('entity_tat_master_id', 'fk_entity_id', 'tat1', 'tat2');
$where_condition_array = array('fk_entity_id' => $entity_id,'isactive'=>1);
@ -672,8 +672,8 @@ class Entity_Management_Controller extends REST_Controller {
{
$records = $this->post('records');
$count = 0;
// if($records['entity_tat_master_id'] == "" || $records['entity_tat_master_id'] == null)
// {
if($records['entity_tat_master_id'] == "" || $records['entity_tat_master_id'] == null)
{
$temp = array('fk_entity_id'=>$records['fk_entity_id'],'tat1'=>$records['tat1'],'tat2'=>$records['tat2'],'fk_createdby'=>$records['fk_createdby']);
$id = $this->Entity_Management_Model->saveRecords($temp,ENTITYTAT);
if($id != null || $id != "")
@ -695,11 +695,60 @@ class Entity_Management_Controller extends REST_Controller {
$data['records'] = $count;
$this->response($data,REST_Controller::HTTP_OK);
}
// }
// else
// {
}
else
{
$temp = array('fk_entity_id'=>$records['fk_entity_id'],'tat1'=>$records['tat1'],'tat2'=>$records['tat2'],'fk_updatedby'=>$records['fk_updatedby']);
$where_condition_array = array('entity_tat_master_id' => $records['entity_tat_master_id']);
$id = $this->Entity_Management_Model->updateRecords($temp,ENTITYTAT,$where_condition_array);
if($id != null || $id != "")
{
foreach($records['child'] as $key => $child)
{
$temp = array('fk_city_id'=>substr($child,0,1),'fk_product_id'=>substr($child,1,1),'fk_pd_type_id'=>substr($child,2,1),'fk_tat_master_id'=>$records['entity_tat_master_id']);
$cid = $this->Entity_Management_Model->saveRecords($temp,ENTITYTATCHILD);
if($cid != "" || $cid != null) { $count++; }
}
}
if($count != 0 && ($count == count($records['child'])))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $count;
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
public function deleteTATCombimaion_post()
{
$records = $this->post('records');
$entity_tat_master_id = $records['entity_tat_master_id'];
$fk_entity_id = $records['fk_entity_id'];
$entity_tat_child_id_details = $records['entity_tat_child_id_details'];
$this->db->SET('isactive',0);
//$this->db->SET('fk_updatedby',$records['fk_updatedby']);
$this->db->where('fk_tat_master_id',$entity_tat_master_id);
//$this->db->where('fk_entity_id',$fk_entity_id);
$this->db->where_in('entity_tat_child_id',$entity_tat_child_id_details);
$this->db->update(ENTITYTATCHILD);
//print_r($this->db->last_query());
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
// }
}

View File

@ -24,6 +24,7 @@ class PD_Controller extends REST_Controller {
$this->load->library('AWS_S3');
$this->load->library('AWS_SNS');
$this->load->helper('GETPDFORMDETAILS');
$this->load->helper('GETPROCESSEDJSON');
$this->load->library('pdfgenerator');
$this->load->library('excel');
//$this->load->library('pdfgen_tcpdf');
@ -2032,25 +2033,22 @@ class PD_Controller extends REST_Controller {
public function savePDFormDetailsJSON_post()
{
$records = $this->post('records');
//echo "dnkd";
$pdid = $records['pdid'];
$formid = $records['formid'];
$createdby = $records['fk_createdby'];
$company_id = null;
$processed_json = null;
if(isset($records['company_id']))
{
$company_id = $records['company_id'];
}
//print_r($records);echo "\n\n\n";
//Save Any New Applicants Details From General Form
if($records['formid'] == 18)
if($formid == 18)
{
$records = $this->saveCoApplicantsFromGeneralInfoForm($records);
}
$fields = array('isactive' => 0);
$where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid);
@ -2058,8 +2056,22 @@ class PD_Controller extends REST_Controller {
{
$where_condition_array = array('fk_form_id'=>$formid,'fk_pd_id'=>$pdid,'company_id' => $company_id);
}
$id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array);
// $id = $this->PD_Model->updateRecords($fields,PDFORMDETAILSJSON,$where_condition_array);
/*****Call Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA******/
switch($formid)
{
case 1:
$processed_json = GETPROCESSEDJSON::convertSupplierForm($records,$formid);
break;
default:
echo "Something Wrong! Form ID did not match, Contact System Administrator";
}
//die();
/*****End of Form Specific funcitons to convert RAW JSON Data to Processed JSON DATA*******/
unset($records['pdid']);
unset($records['formid']);
@ -2067,7 +2079,9 @@ class PD_Controller extends REST_Controller {
unset($records['company_id']);
$records = json_encode($records);
$temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records);
$temp_array = array('fk_form_id'=>$formid,'company_id' => $company_id,'fk_pd_id'=>$pdid,'fk_createdby'=>$createdby,'json'=>$records,'$processed_json' => $processed_json);
$id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILSJSON);
if($id != "" || $id != null)
{
@ -3776,8 +3790,7 @@ class PD_Controller extends REST_Controller {
public function codeigniterViewTest_post()
{
$CI =& get_instance();
print_r($CI);die();
/* $data['pdid'] = '1256';
$data['main_applicant_name'] = 'Mr.Ram Kumar';
$data['cus_seg'] = 'SENP-AI';
@ -3797,7 +3810,8 @@ class PD_Controller extends REST_Controller {
//End of PDF Gen using DOM PDF
$output_file2 = APPPATH."/docs/sample.pdf";
echo file_put_contents($output_file2, $pdf_doc); */
echo "sdkjnsd";
die();
$records = $this->post('records');
$t = $this->load->view('report_templates/JSONTOREPORT',$records,true);
@ -3911,7 +3925,7 @@ class PD_Controller extends REST_Controller {
foreach($company_list as $list_key => $company)
{
$form_array = array(
array('form_id' => 13,'form_name' => 'Business Informations'),
array('form_id' => 13,'form_name' => 'Business Information'),
array('form_id' => 14,'form_name' => 'Financial Information'),
array('form_id' => 1,'form_name' => 'Supplier Details'),
array('form_id' => 2,'form_name' => 'Client Details'),

View File

@ -0,0 +1,112 @@
<?php
class GETPROCESSEDJSON
{
public static function convertSupplierForm($raw_json,$formid)
{
$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);
if(!empty($raw_json) && !empty($master_keys))
{
// Handling manufacturing_details subarry
foreach($raw_json['manufacturing_details'][0]['main_raw_materials'] as $manufacturing_details_key => $manufacturing_details)
{
foreach($manufacturing_details as $key => $value)
{
if($value != "" || $value != null)
{
//compare with master_keys array
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['master_name']);
$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'];
}
}
}
}
}
}
// Handling manufacturing_details subarry
foreach($raw_json['trade_details'][0]['trading_products'] as $trading_products_key => $trading_products)
{
foreach($trading_products as $key => $value)
{
if($value != "" || $value != null)
{
//compare with master_keys array
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['master_name']);
$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['trade_details'][0]['trading_products'][$trading_products_key][$key] = $result_data[0]['name'];
}
}
}
}
}
}
}
return $raw_json;
}
}
?>