DUP PD ISSUES

This commit is contained in:
Velz2020 2020-07-17 00:09:05 +05:30
parent 0dfc99616b
commit a697784e41
2 changed files with 66 additions and 20 deletions

View File

@ -9637,6 +9637,9 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$new_pd_id = null;
$address_id = null;
$applicants_ids_array = array();
$docs_to_be_uploads_ids_array = array();
$add_req_ids_array = array();
$form_ids_to_replace_new_co_applicants_id = array(18,4,6,7,8,9,10,13,19,21,22);
$logger = MYLOG::logFunction(null,$pdid);
$logger->info("duplicatePD_post called: ".$pdid,array('ENV'=>ENVIRONMENT,'DATA' => $lender_applicant_id));
@ -9714,12 +9717,6 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
// // log_message('ERROR','####Copying S3 END:-'.$new_pd_id);
// }
//copy Assessed Income Tables
if($pd_master_details['fk_customer_segment'] == 4 && $new_pd_id)//AI
{
$this->dupAssessedIncomeInfo($pdid,$new_pd_id,$fk_createdby);
}
//Get All PD Address
@ -9738,35 +9735,41 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
}
//Get Addtional Requirements details
$pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_requirement','isactive'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDADDTIONALREQUIREMENTS);
$pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_req_id','add_requirement','isactive'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDADDTIONALREQUIREMENTS);
if($new_pd_id && count($pd_additional_requirements))
{
log_message('ERROR','####Copying Additional Req started:-'.$new_pd_id);
foreach ($pd_additional_requirements as $key => $value)
{
$current_add_req_id = $value['add_req_id'];unset($value['add_req_id']);
$value['fk_pd_id'] = $new_pd_id;
$this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS);
$new_add_req_id = $this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS);
//print_r($value);
//$new_add_req_id = $current_add_req_id + 100;
$add_req_ids_array[$current_add_req_id] = $new_add_req_id;
}
log_message('ERROR','####Copying Addtional Req end:-'.$new_pd_id);
}
//Get Docs to be collected array
$docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('doc_name'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDDOCSTOBECOLLECTED);
$docs_to_be_collected = $this->PD_Model->selectCustomRecords(array('pd_doc_to_be_collect_id','doc_name'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDDOCSTOBECOLLECTED);
if($new_pd_id && count($docs_to_be_collected))
{
log_message('ERROR','####Copying Docs to be collected started:-'.$new_pd_id);
foreach ($docs_to_be_collected as $key => $value)
{
$current_doc_id = $value['pd_doc_to_be_collect_id'];unset($value['pd_doc_to_be_collect_id']);
$value['fk_pd_id'] = $new_pd_id;
$this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED);
$new_doc_id = $this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED);
//print_r($value);
//$new_doc_id = $current_doc_id + 100;
$docs_to_be_uploads_ids_array[$current_doc_id] = $new_doc_id;
}
log_message('ERROR','####Copying Docs to be collected end:-'.$new_pd_id);
}
//Get all JSON
$json_data = $this->PD_Model->getAllJSONFormData($pdid);
if($new_pd_id && count($json_data))
@ -9774,29 +9777,72 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
log_message('ERROR','####Copying All JSON Data started:-'.$new_pd_id);
foreach ($json_data as $key => $value)
{
$value['fk_pd_id'] = $new_pd_id;
if($value['fk_form_id'] == 18)
if(in_array($value['fk_form_id'], $form_ids_to_replace_new_co_applicants_id))
{
// echo '*****************************************BEFORE***';
// print_r(json_decode($value['json']));
//print_r($applicants_ids_array);
$gen_form_string = ($value['json']);
$current_form_string = ($value['json']);
//print_r($gen_form_string);
//replace old applicant id with new applicant id in gen form
foreach ($applicants_ids_array as $old_value => $new_value)
{
$gen_form_string = str_replace( $old_value, $new_value, $gen_form_string);
$current_form_string = str_replace( $old_value, $new_value, $current_form_string);
}
//replace pd id
$gen_form_string = str_replace( $pdid, $new_pd_id, $gen_form_string);
$value['json'] = $gen_form_string;
$current_form_string = str_replace( $pdid, $new_pd_id, $current_form_string);
$value['json'] = $current_form_string;
// print_r($gen_form_string);
// die();
// echo '##########################################################################################################';
// print_r(json_decode($value['json']));
// echo '**************************************************************************************************************';
}
if($value['fk_form_id'] == 24)//credit managers query form
{
// print_r($docs_to_be_uploads_ids_array);print_r($add_req_ids_array);
// echo '*****************************************BEFORE***';
// print_r(json_decode($value['json']));
//print_r($applicants_ids_array);
$current_form_string = ($value['json']);
//print_r($gen_form_string);
//
foreach ($docs_to_be_uploads_ids_array as $old_value => $new_value)
{
$current_form_string = str_replace( $old_value, $new_value, $current_form_string);
}
foreach ($add_req_ids_array as $old_value => $new_value)
{
$current_form_string = str_replace( $old_value, $new_value, $current_form_string);
}
$current_form_string = str_replace( $pdid, $new_pd_id, $current_form_string);
$value['json'] = $current_form_string;
// print_r($gen_form_string);
// die();
//echo '##########################################################################################################';
//print_r(json_decode($value['json']));
//echo '**************************************************************************************************************';
}
$this->PD_Model->saveRecords($value,PDFORMDETAILSJSON);
//print_r($value);
}
log_message('ERROR','####Copying ALL JSON END:-'.$new_pd_id);
}
//copy Assessed Income Tables
if($pd_master_details['fk_customer_segment'] == 4 && $new_pd_id)//AI
{
$this->dupAssessedIncomeInfo($pdid,$new_pd_id,$fk_createdby);
}
// die();
//copy all s3 into new pd folder
@ -9805,7 +9851,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
{
//update some master info
$this->PD_Model->updateRecords(array('parent_pd_id' => $new_pd_id,'fk_primary_address_id' => $address_id,'fk_address_id' => $address_id),PDTRIGGER,array('pd_id' => $new_pd_id));
$this->PD_Model->updateRecords(array('parent_pd_id' => $new_pd_id,'fk_primary_address_id' => $address_id,'fk_address_id' => $address_id'dupof' => $pdid),PDTRIGGER,array('pd_id' => $new_pd_id));
log_message('ERROR','####UPDATE PD:-'.$new_pd_id);
$logger->info("NEW PD Trigged by dup funciton : ".$new_pd_id,array('ENV'=>ENVIRONMENT));
PDALERTS::pdnotification($new_pd_id);
@ -9888,7 +9934,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post()
$value['fk_pd_id'] = $new_pd_id;
$value['fk_createdby'] = $fk_createdby;
$this->PD_Model->saveRecords($value,PDBUSINESSEXPENSES);
$this->PD_Model->saveRecords($value,PDHOUSEHOLDEXPENSES);
//print_r($value);
}
}

View File

@ -401,7 +401,7 @@ class PD_Model extends SPARQ_Model {
$parent_pd_id = $pdmaster_details[0]['parent_pd_id'];
//Get all AddtionalPD's ID
$addtional_pd_ids = $this->getAddtionalPDIDs($parent_pd_id);
$addtional_pd_ids = $parent_pd_id ? $this->getAddtionalPDIDs($parent_pd_id) : array();
//print_r($addtional_pd_ids);
$addtional_pd_ids_string = array();
if(count($addtional_pd_ids))