G-Sheet Lender Credit Person : ps

This commit is contained in:
VE10-Sanjeev 2023-02-24 11:58:20 +05:30
parent 600e0b6c56
commit ea0f7d782d

View File

@ -192,7 +192,7 @@ class Data_Dump_Controller extends REST_Controller
if (count($applicant_title_name) > 1) { if (count($applicant_title_name) > 1) {
$pd_applicant_details[$j]['applicant_name'] = $applicant_title_name[1]; $pd_applicant_details[$j]['applicant_name'] = $applicant_title_name[1];
$pd_applicant_details[$j]['applicant_title_name'] = $this->Data_Dump_Model->getId(10, $applicant_title_name[0]); $pd_applicant_details[$j]['applicant_title_name'] = $this->Data_Dump_Model->getId(10, $applicant_title_name[0]);
$this->Data_Dump_Model->getId(10, $GSdata["LenderCreditName"]); // $this->Data_Dump_Model->getId(10, $GSdata["LenderCreditName"]);
} else { } else {
$pd_applicant_details[$j]['applicant_name'] = $applicatantParts[$j]; $pd_applicant_details[$j]['applicant_name'] = $applicatantParts[$j];
} }
@ -342,10 +342,10 @@ class Data_Dump_Controller extends REST_Controller
$pd_details['remarks'] = $GSdata["Remarks"]; $pd_details['remarks'] = $GSdata["Remarks"];
log_message('ERROR', "G-Sheet For PD Step 2.14 (Remarks) : " . $pd_details['remarks']); log_message('ERROR', "G-Sheet For PD Step 2.14 (Remarks) : " . $pd_details['remarks']);
} }
if (isset($GSdata["LenderCreditName"]) && $GSdata["LenderCreditName"] != "") { // if (isset($GSdata["LenderCreditName"]) && $GSdata["LenderCreditName"] != "") {
$pd_details['lender_credit_person'] = $this->Data_Dump_Model->getId(8, $GSdata["LenderCreditName"]); // $pd_details['lender_credit_person'] = $this->Data_Dump_Model->getId(8, $GSdata["LenderCreditName"]);
log_message('ERROR', "G-Sheet For PD Step 2.15 (Lender Credit Person) GSheet data : " . $GSdata["LenderCreditName"]); // log_message('ERROR', "G-Sheet For PD Step 2.15 (Lender Credit Person) GSheet data : " . $GSdata["LenderCreditName"]);
} // }
## Default Status section; ## Default Status section;
$pd_details['pd_status'] = TRIGGERED; $pd_details['pd_status'] = TRIGGERED;
@ -570,132 +570,163 @@ class Data_Dump_Controller extends REST_Controller
public function renamingExistingPDinfo_get() public function renamingExistingPDinfo_get()
{ {
log_message('ERROR', "renamingExistingPDinfo Fns Called"); log_message('ERROR', "renamingExistingPDinfo Fns Called");
$_90th_date = date("d/m/Y", strtotime('-90 days')); $day_limit = "";
$pdsno = $this->get('pdsno'); $pdsno = $this->get('pdsno');
$from_date = $this->get('from_date'); $from_date = $this->get('from_date');
$to_date = $this->get('to_date'); $to_date = $this->get('to_date');
$entity = $this->get('lender_id'); $entity = $this->get('lender_id');
$pdid_arr = array(); // testing purpose $pdid_arr = array(); // testing purpose
$msg = '';
$columns = array('PDTRIGGER.pd_id', 'PDTRIGGER.addressline1', 'PDTRIGGER.addressline2', 'PDTRIGGER.addressline3', 'PDTRIGGER.pd_contact_mobileno', 'PDTRIGGER.pd_contact_landline', 'PDTRIGGER.pd_sno', 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','DATE_FORMAT(PDTRIGGER.completed_on, "%d/%m/%Y") as completedon','PDAPPLICANTSDETAILS.pd_co_applicant_id', 'PDTRIGGER.pd_contact_person_mail', 'PDTRIGGER.fk_lender_id');
$table = PDTRIGGER . ' as PDTRIGGER';
$joins = array(array(
'table' => PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS',
'condition' => 'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1',
'jointype' => 'LEFT'
));
$columns = array('PDTRIGGER.pd_id', 'PDTRIGGER.addressline1', 'PDTRIGGER.addressline2', 'PDTRIGGER.addressline3', 'PDTRIGGER.pd_contact_mobileno', 'PDTRIGGER.pd_contact_landline', 'PDTRIGGER.pd_sno', 'DATE_FORMAT(PDTRIGGER.createdon, "%d/%m/%Y") as createdon','DATE_FORMAT(PDTRIGGER.completed_on, "%d/%m/%Y") as completedon','PDAPPLICANTSDETAILS.pd_co_applicant_id', 'PDTRIGGER.pd_contact_person_mail', 'PDTRIGGER.fk_lender_id'); if(empty($pdsno) && empty($from_date) && empty($to_date) && empty($entity)){
$table = PDTRIGGER . ' as PDTRIGGER'; $msg = "";
$joins = array(array( $to_get_entity_id = $this->PD_Model->selectCustomRecords(array('fk_lender_id'), array('pd_status' => QC_COMPLETED),PDTRIGGER, array(), '', '', '', 'fk_lender_id');
'table' => PDAPPLICANTSDETAILS . ' as PDAPPLICANTSDETAILS', print_r($this->db->last_query());
'condition' => 'PDAPPLICANTSDETAILS.fk_pd_id = PDTRIGGER.pd_id AND PDAPPLICANTSDETAILS.isactive = 1 AND PDAPPLICANTSDETAILS.applicant_type = 1', print_r($to_get_entity_id);die();
'jointype' => 'LEFT' for ($i = 0; $i < count($to_get_entity_id); $i++) {
)); $entity = $to_get_entity_id[$i]['fk_lender_id'];
if(!empty($entity)){ $select = array('data_purge_days');
$lender_where = array('PDTRIGGER.fk_lender_id' => $entity); $condit = array('isactive' => 1,'fk_entity_type_id'=> 2,'entity_id'=>$entity);
} $value = $this->PD_Model->selectCustomRecords($select, $condit, ENTITY);
else{ // print_r($value);
$data['dataStatus'] = false; if(!empty($value)){
$data['message'] = 'Lender Not Found'; $days = $value[0]['data_purge_days'];
$this->response($data, REST_Controller::HTTP_OK); }
} $where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'PDTRIGGER.fk_lender_id' => $entity, '(SELECT
if (!empty($pdsno)) { MAX(DATE_FORMAT(logmaster.createdon, "%d/%m/%Y"))
$msg = "PD Serial No => " . $pdsno; FROM h_common_masters as logmaster
log_message('ERROR', $msg); WHERE logmaster.new_value = "QC_COMPLETED" AND PDTRIGGER.pd_id = logmaster.primary_key) <=' => date("d/m/Y", strtotime("-".$days." days")));
$where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'PDTRIGGER.pd_sno' => $pdsno); // 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11
}else if(($from_date != "" || $from_date != null) && ($to_date != "" || $to_date != null)){
$newDate1 = date("Y-m-d", strtotime($from_date)); $result[] = $this->PD_Model->getJoinRecords($columns, $table, $joins, $where_arr);
$newDate2 = date("Y-m-d", strtotime($to_date)); echo "---------------------------";
$msg = "PD QC-Completed Date Given Format => " . $from_date ." to ".$to_date; print_r($this->db->last_query());
log_message('ERROR', $msg." Changed ".$newDate1." to ".$newDate2); // print_r($result);
// $where = 'DATE(PDTRIGGER.completed_on) BETWEEN ' ."'$newDate1'". ' AND ' ."'$newDate2'"; $msg = $msg." PD QC-Completed Given Entity =>". $entity ." ". $days." days and lastdate ".$day_limit;
$where = '(SELECT
MAX(DATE(logmaster.createdon))
FROM h_common_masters as logmaster
WHERE logmaster.new_value = "QC_COMPLETED" AND PDTRIGGER.pd_id = logmaster.primary_key)
BETWEEN ' ."'$newDate1'". ' AND ' ."'$newDate2'";
$where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, $where => null);
}
else{
$msg = "90th date => " . $_90th_date;
log_message('ERROR', $msg);
$where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, '(SELECT
MAX(DATE_FORMAT(logmaster.createdon, "%d/%m/%Y"))
FROM h_common_masters as logmaster
WHERE logmaster.new_value = "QC_COMPLETED" AND PDTRIGGER.pd_id = logmaster.primary_key) <=' => $_90th_date);
}
$tgr_cond_arr = array_merge($lender_where,$where_arr);
// 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11
$tgr_dtls = $this->PD_Model->getJoinRecords($columns, $table, $joins, $tgr_cond_arr);
log_message('ERROR', "Trigger Details Total Records => " . count($tgr_dtls));
// echo count($tgr_dtls);
// print_r($tgr_dtls);
// print_r($this->db->last_query());die();
// $i = 0; // testing Purpose only
// for($i = 0 ;$i < 3;$i++){ // testing purpose only.
if(!empty($tgr_dtls)){
for ($i = 0; $i < count($tgr_dtls); $i++) {
$pdid = $tgr_dtls[$i]['pd_id'];
log_message('ERROR', "trigger details for Loop inx = " . $i . " PDID = " . $pdid);
$earliest['trigger_details'] = $tgr_dtls[$i];
if (!empty($pdid)) {
$apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name', 'applicant_name');
$apcnt_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
$apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields, $apcnt_cond_arr, PDAPPLICANTSDETAILS);
log_message('ERROR', "Total Applicant Details for " . $pdid . " = " . count($apcnt_dtls));
if (!empty($apcnt_dtls)) {
$earliest['applicant_details'] = $apcnt_dtls;
} }
$addr_fields = array('pd_address_id', 'addressline1'); // print_r($result);
$addr_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); $tgr_dtls = array_merge(...$result);
$addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields, $addr_cond_arr, PDADDRESS);
log_message('ERROR', "Total Address Details for " . $pdid . " = " . count($addr_dtls));
if (!empty($addr_dtls)) { log_message('ERROR', "Trigger Details Total Records => " . count($tgr_dtls));
$earliest['address_details'] = $addr_dtls;
}
else{
if (!empty($pdsno)) {
$msg = "PD Serial No => " . $pdsno;
log_message('ERROR', $msg);
$where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'PDTRIGGER.pd_sno' => $pdsno);
}else if(($from_date != "" || $from_date != null) && ($to_date != "" || $to_date != null)){
$newDate1 = date("Y-m-d", strtotime($from_date));
$newDate2 = date("Y-m-d", strtotime($to_date));
$msg = "PD QC-Completed Date Given Format => " . $from_date ." to ".$to_date;
log_message('ERROR', $msg." Changed ".$newDate1." to ".$newDate2);
// $where = 'DATE(PDTRIGGER.completed_on) BETWEEN ' ."'$newDate1'". ' AND ' ."'$newDate2'";
$where = '(SELECT
MAX(DATE(logmaster.createdon))
FROM h_common_masters as logmaster
WHERE logmaster.new_value = "QC_COMPLETED" AND PDTRIGGER.pd_id = logmaster.primary_key)
BETWEEN ' ."'$newDate1'". ' AND ' ."'$newDate2'";
$where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, $where => null);
} }
$json_fields = array('pd_form_detail_json_id', 'json', 'processed_json', 'fk_pd_id', 'fk_form_id'); else if(!empty($entity)){
$json_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid); $condit = array('isactive' => 1,'fk_entity_type_id'=> 2,'entity_id'=>$entity);
$json_dtls = $this->PD_Model->selectCustomRecords($json_fields, $json_cond_arr, PDFORMDETAILSJSON); $value = $this->PD_Model->selectCustomRecords($select, $condit, ENTITY);
log_message('ERROR', "Total JSON Details for " . $pdid . " = " . count($json_dtls)); if(!empty($value)){
if (!empty($json_dtls)) { $days = $value[0]['data_purge_days'];
$earliest['json_details'] = $json_dtls; $day_limit = date("d/m/Y", strtotime("-".$days." days"));
} $where_arr = array('PDTRIGGER.pd_status' => QC_COMPLETED, 'PDTRIGGER.fk_lender_id' => $entity, '(SELECT
$previous_json_fields = array('pd_form_detail_json_id'); MAX(DATE_FORMAT(logmaster.createdon, "%d/%m/%Y"))
$previous_json_cond_arr = array('isactive' => 0, 'fk_pd_id' => $pdid); FROM h_common_masters as logmaster
$previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields, $previous_json_cond_arr, PDFORMDETAILSJSON); WHERE logmaster.new_value = "QC_COMPLETED" AND PDTRIGGER.pd_id = logmaster.primary_key) <=' => $day_limit);
log_message('ERROR', "Total IN-Active JSON Details for " . $pdid . " = " . count($previous_json_dtls));
if (!empty($previous_json_dtls)) { $msg = "PD QC-Completed Given Entity =>". $entity ." ". $days." days and lastdate ".$day_limit;
foreach ($previous_json_dtls as $val) {
$result[] = $val['pd_form_detail_json_id'];
} }
$this->db->where_in('pd_form_detail_json_id', $result);
$this->db->delete(PDFORMDETAILSJSON);
}
$docs_fields = array('pd_document_id', 'pd_document_title', 'pd_document_name');
$docs_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
$docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields, $docs_cond_arr, PDDOCUMENTS);
log_message('ERROR', "Total Document Details for " . $pdid . " = " . count($docs_dtls));
if (!empty($docs_dtls)) {
$earliest['docs_details'] = $docs_dtls;
} }
// 'PDTRIGGER.fk_customer_segment'=> 11 // 1 4 5 8 9 10 11
$tgr_dtls = $this->PD_Model->getJoinRecords($columns, $table, $joins, $where_arr);
log_message('ERROR', "Trigger Details Total Records => " . count($tgr_dtls));
} }
$return = $this->renamingProcess($earliest); // print_r($tgr_dtls);die();
// if(!empty($return)){ if(!empty($tgr_dtls)){
// array_push($pdid_arr['updated pdid'],$return); // for ($i = 0; $i < count($tgr_dtls); $i++) {
// array_push($pdid_arr['data'],$earliest);} // $pdid = $tgr_dtls[$i]['pd_id'];
array_push($pdid_arr,$pdid); // log_message('ERROR', "trigger details for Loop inx = " . $i . " PDID = " . $pdid);
} // $earliest['trigger_details'] = $tgr_dtls[$i];
// if (!empty($pdid)) {
// array_push($img_response, $pdid); // $apcnt_fields = array('pd_co_applicant_id', 'mobile_no', 'additional_mobile_no', 'landline', 'email', 'addressline1', 'addressline2', 'addressline3', 'company_name', 'applicant_name');
$data['dataStatus'] = true; // $apcnt_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
$data['records'] = $pdid_arr; // $apcnt_dtls = $this->PD_Model->selectCustomRecords($apcnt_fields, $apcnt_cond_arr, PDAPPLICANTSDETAILS);
$data['message'] = $msg; // log_message('ERROR', "Total Applicant Details for " . $pdid . " = " . count($apcnt_dtls));
// $data['earliest'] = $earliest; // if (!empty($apcnt_dtls)) {
$data['totalDetailsInCount'] =count($tgr_dtls); // $earliest['applicant_details'] = $apcnt_dtls;
// $data['before 90 days data'] = $tgr_dtls; // }
}else{ // $addr_fields = array('pd_address_id', 'addressline1');
$data['dataStatus'] = false; // $addr_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
$data['message'] = 'There is no data in QC-Completed '.$msg; // $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields, $addr_cond_arr, PDADDRESS);
$data['totalDetailsInCount'] = count($tgr_dtls); // log_message('ERROR', "Total Address Details for " . $pdid . " = " . count($addr_dtls));
} // if (!empty($addr_dtls)) {
$this->response($data, REST_Controller::HTTP_OK); // $earliest['address_details'] = $addr_dtls;
// }
// $json_fields = array('pd_form_detail_json_id', 'json', 'processed_json', 'fk_pd_id', 'fk_form_id');
// $json_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
// $json_dtls = $this->PD_Model->selectCustomRecords($json_fields, $json_cond_arr, PDFORMDETAILSJSON);
// log_message('ERROR', "Total JSON Details for " . $pdid . " = " . count($json_dtls));
// if (!empty($json_dtls)) {
// $earliest['json_details'] = $json_dtls;
// }
// $previous_json_fields = array('pd_form_detail_json_id');
// $previous_json_cond_arr = array('isactive' => 0, 'fk_pd_id' => $pdid);
// $previous_json_dtls = $this->PD_Model->selectCustomRecords($previous_json_fields, $previous_json_cond_arr, PDFORMDETAILSJSON);
// log_message('ERROR', "Total IN-Active JSON Details for " . $pdid . " = " . count($previous_json_dtls));
// if (!empty($previous_json_dtls)) {
// foreach ($previous_json_dtls as $val) {
// $result[] = $val['pd_form_detail_json_id'];
// }
// $this->db->where_in('pd_form_detail_json_id', $result);
// $this->db->delete(PDFORMDETAILSJSON);
// }
// $docs_fields = array('pd_document_id', 'pd_document_title', 'pd_document_name');
// $docs_cond_arr = array('isactive' => 1, 'fk_pd_id' => $pdid);
// $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields, $docs_cond_arr, PDDOCUMENTS);
// log_message('ERROR', "Total Document Details for " . $pdid . " = " . count($docs_dtls));
// if (!empty($docs_dtls)) {
// $earliest['docs_details'] = $docs_dtls;
// }
// }
// $return = $this->renamingProcess($earliest);
// // if(!empty($return)){
// // array_push($pdid_arr['updated pdid'],$return);
// // array_push($pdid_arr['data'],$earliest);}
// array_push($pdid_arr,$pdid);
// }
// array_push($img_response, $pdid);
// $data['dataStatus'] = true;
// $data['records'] = $pdid_arr;
// $data['message'] = $msg;
// // $data['earliest'] = $earliest;
// $data['totalDetailsInCount'] =count($tgr_dtls);
// $data['before 90 days data'] = $tgr_dtls;
}else{
$data['dataStatus'] = false;
$data['message'] = 'There is no data in QC-Completed '.$msg;
$data['totalDetailsInCount'] = count($tgr_dtls);
}
$this->response($data, REST_Controller::HTTP_OK);
} }
public function renamingProcess($details) public function renamingProcess($details)
@ -1056,7 +1087,7 @@ class Data_Dump_Controller extends REST_Controller
$this->response($dat, REST_Controller::HTTP_OK); $this->response($dat, REST_Controller::HTTP_OK);
} }
public function deleteS3Images($pdLenId,$pdid){ public function deleteS3Images($pdLenId,$pdid){
// public function deleteS3Images_get(){ // public function deleteS3Images_get(){
// $pdid = $this->get('pdid');$rs = $this->get('rs'); // $pdid = $this->get('pdid');$rs = $this->get('rs');
// $master = $this->PD_Model->getPDMasterDetails($pdid,$rs); // $master = $this->PD_Model->getPDMasterDetails($pdid,$rs);
@ -1090,4 +1121,4 @@ class Data_Dump_Controller extends REST_Controller
} }
} }
} }