From 0dfc99616b0eb8412ea472fe6688f2b36e5fdc7b Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Tue, 14 Jul 2020 01:15:20 +0530 Subject: [PATCH] 1307 DELIVERY RELEASE --- api/application/config/constants.php | 2 + api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 404 +++++++++++++----- api/application/helpers/pdalerts_helper.php | 4 +- .../helpers/pdcompletenesscheck_helper.php | 26 +- api/application/libraries/AWS_S3.php | 64 +++ .../report_templates/JSONTOREPORT_DI_AI.php | 2 +- .../report_templates/JSONTOREPORT_SAL.php | 5 +- 8 files changed, 403 insertions(+), 105 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index b88a2242..034fb716 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -626,5 +626,7 @@ defined('CUS_LINK_META_DATA') OR define('CUS_LINK_META_DATA','t_cus_link_meta_da defined('CUS_VIDEO') OR define('CUS_VIDEO','t_cus_video'); +defined('CREDITPDTEMPLATE') OR define('CREDITPDTEMPLATE','m_credit_pd_template'); + diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 0c780c51..cb6841c1 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -231,6 +231,7 @@ $route['getListOfvendors'] = 'PD_Controller/getListOfvendors'; $route['(getListVendorPDOfficers/:num)'] = 'PD_Controller/getListVendorPDOfficers'; $route['duplicatePD'] = 'PD_Controller/duplicatePD'; $route['saveApplicantImgFromVendorForm'] = 'PD_Controller/saveApplicantImgFromVendorForm'; +$route['loadCreditPDTemplate'] = 'PD_Controller/loadCreditPDTemplate'; // $route['getPDFormDetailsJSON'] = 'PD_Controller/getPDFormDetailsJSON'; $route['smartyTestFunction'] = 'PD_Controller/smartyTestFunction'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index d5f006cd..58332e65 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -5988,8 +5988,9 @@ public function getPDFormDetailsJSON_post() public function codeigniterViewTest_post() { + //$this->dupAssessedIncomeInfo(1192,9999,1);die(); //print_r($this->aws_s3->getAllObjectsInaBucket('test-lender1','pd114'));die(); - //print_r($this->aws_s3->copyS3Object('test-lender1','test-lender1','pd114','pd114-copy'));die(); + //print_r($this->aws_s3->dupSinglePDImages('test-lender24','pd1247','pd1247dup'));die(); //satellite_image::getSatelliteImage(1704);die(); //echo $this->assignPDTempalate(1325);die(); //$this->getSatelliteImage(342);die();//velmurugan.s@venbainfotech.com @@ -9278,7 +9279,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() { foreach ($docs_to_be_collected as $key => $value) { - $final_data[] = array('img_key' => 'docs_to_be_collected','img_name' => $value['doc_name'],'img_url' => "",'fk_form_id' => "24","is_multiple" => 1); + $final_data[] = array('img_key' => 'docs_to_be_collected','img_name' => $value['doc_name'],'img_url' => "",'fk_form_id' => "24","is_multiple" => 0); } } } @@ -9634,30 +9635,27 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $lender_applicant_id = $this->post('lender_applicant_id'); $fk_createdby = $this->post('fk_createdby'); $new_pd_id = null; + $address_id = null; + $applicants_ids_array = array(); - // $logger = MYLOG::logFunction(null,$pd_id); - // $logger->info("duplicatePD_post called: ".$pd_id,array('ENV'=>ENVIRONMENT,'DATA' => $lender_applicant_id)); + $logger = MYLOG::logFunction(null,$pdid); + $logger->info("duplicatePD_post called: ".$pdid,array('ENV'=>ENVIRONMENT,'DATA' => $lender_applicant_id)); // Get All PD Masters Details log_message('ERROR','####duplicatePD_post called:-'.$pdid.'-'.$lender_applicant_id); - $pd_master_details = $this->PD_Model->selectCustomRecords(array('*'),array('pd_id' => $pdid),PDTRIGGER); + $pd_fields = array('fk_lender_id', 'sub_entity_id', 'imgc_fin_institute', 'fk_entity_billing_id','fk_product_id', 'fk_subproduct_id', 'fk_pd_type','fk_pd_template_id', 'fk_customer_segment','loan_amount', 'addressline1', 'fk_city', 'fk_state', 'pincode','lender_sales_person', 'lender_credit_person', 'pd_contact_person', 'pd_contact_mobileno', 'pd_contact_person_mail','pd_branch_id', 'pd_contact_landline','other_pincode','is_notify_enabled'); + $pd_master_details = $this->PD_Model->selectCustomRecords($pd_fields,array('pd_id' => $pdid),PDTRIGGER); if(count($pd_master_details)) { $pd_master_details = $pd_master_details[0]; - - unset($pd_master_details['pd_id']); - unset($pd_master_details['pd_sno']); - unset($pd_master_details['createdon']); - unset($pd_master_details['updatedon']); - unset($pd_master_details['fk_updatedby']); - - $pd_master_details['lender_applicant_id'] = $lender_applicant_id; $pd_master_details['pd_date_of_initiation'] = date('Y-m-d H-i-s'); + //$pd_master_details['pd_date_of_initiation'] = '2020-07-07 12:24:00'; + $pd_master_details['createdon'] = date('Y-m-d H-i-s'); $pd_master_details['pd_status'] = 'TRIGGERED'; - $pd_master_details['pd_status'] = $fk_createdby; + $pd_master_details['fk_createdby'] = $fk_createdby; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~$_'; $charactersLength = strlen($characters); @@ -9671,116 +9669,301 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $pd_master_details['encrypted_url'] = $url; //print_r($pd_master_details); - //$new_pd_id = $this->PD_Model->saveRecords($pd_master_details,PDTRIGGER); - //$logger->info("NEW PD Trigged by dup funciton : ".$new_pd_id,array('ENV'=>ENVIRONMENT)); - log_message('ERROR','####NEW PD Trigged by dup funciton:-'.$new_pd_id); + $new_pd_id = $this->PD_Model->saveRecords($pd_master_details,PDTRIGGER); + log_message('ERROR','####NEW PD Trigged by dup funciton:-'.$new_pd_id); } - // Get All Applicant's Details - $applicants_details = $this->PD_Model->selectCustomRecords(array('applicant_name', 'applicant_type', 'mobile_no','relation', 'company_name', 'applicant_title_name'),array('fk_pd_id' => $pdid),PDAPPLICANTSDETAILS); + // Get All Applicant's Details + $applicants_details = $this->PD_Model->selectCustomRecords(array('pd_co_applicant_id','applicant_name', 'applicant_type', 'mobile_no','relation', 'company_name', 'applicant_title_name','landline'),array('fk_pd_id' => $pdid),PDAPPLICANTSDETAILS); - //print_r($applicants_details); - if(!$new_pd_id && count($applicants_details)) - { - log_message('ERROR','####Copying Applicants started:-'.$new_pd_id); - foreach ($applicants_details as $key => $value) + //print_r($applicants_details); + if($new_pd_id && count($applicants_details)) { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDAPPLICANTSDETAILS); - //print_r($value); + log_message('ERROR','####Copying Applicants started:-'.$new_pd_id); + foreach ($applicants_details as $key => $value) + { + $current_applicant_id = $value['pd_co_applicant_id'];unset($value['pd_co_applicant_id']); + $value['fk_pd_id'] = $new_pd_id; + $new_applicant_id = $this->PD_Model->saveRecords($value,PDAPPLICANTSDETAILS); + //$new_applicant_id = $current_applicant_id + 10; + $applicants_ids_array[$current_applicant_id] = $new_applicant_id; + //print_r($value); + } + log_message('ERROR','####Copying Applicants end:-'.$new_pd_id); } - log_message('ERROR','####Copying Applicants end:-'.$new_pd_id); - } - // Get All PD Related Documents - $pd_documnets = $this->PD_Model->selectCustomRecords(array('fk_pd_id','fk_form_id', 'co_applicant_id', 'img_type', 'pd_document_title', 'pd_document_name','company_id', 'is_show_report', 'rental_count_id','location', 'isactive'),array('isactive' => 1,'fk_pd_type' => $pdid),PDDOCUMENTS); - if(!$new_pd_id && count($applicants_details)) - { - log_message('ERROR','####Copying ALl Images started:-'.$new_pd_id); - foreach ($pd_documnets as $key => $value) - { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDDOCUMENTS); - //print_r($value); - } - log_message('ERROR','####Copying All Images END:-'.$new_pd_id); + // Get All PD Related Documents + // $pd_documnets = $this->PD_Model->selectCustomRecords(array('fk_pd_id','fk_form_id', 'co_applicant_id', 'img_type', 'pd_document_title', 'pd_document_name','company_id', 'is_show_report', 'rental_count_id','location', 'isactive'),array('isactive' => 1,'fk_pd_type' => $pdid),PDDOCUMENTS); + // if(!$new_pd_id && count($applicants_details)) + // { + // log_message('ERROR','####Copying ALl Images started:-'.$new_pd_id); + // foreach ($pd_documnets as $key => $value) + // { + // $value['fk_pd_id'] = $new_pd_id; + // $this->PD_Model->saveRecords($value,PDDOCUMENTS); + // //print_r($value); + // } + // log_message('ERROR','####Copying All Images END:-'.$new_pd_id); - log_message('ERROR','####Copying S3 started:-'.$new_pd_id); + // // log_message('ERROR','####Copying S3 started:-'.$new_pd_id); + + // // 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); + } - log_message('ERROR','####Copying S3 END:-'.$new_pd_id); - } - - - - //Get All PD Address - $pd_address = $this->PD_Model->selectCustomRecords(array('addressline1', 'fk_city', 'fk_state', 'pincode', 'isactive', 'is_visited','other_pincode', 'is_primary'),array('isactive' => 1,'fk_pd_id' => $pdid),PDADDRESS); - if(!$new_pd_id && count($pd_address)) - { - log_message('ERROR','####Copying address started:-'.$new_pd_id); - foreach ($pd_address as $key => $value) + //Get All PD Address + $pd_address = $this->PD_Model->selectCustomRecords(array('addressline1', 'fk_city', 'fk_state', 'pincode', 'isactive', 'is_visited','other_pincode', 'is_primary'),array('isactive' => 1,'fk_pd_id' => $pdid),PDADDRESS); + if($new_pd_id && count($pd_address)) { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDADDRESS); - //print_r($value); + log_message('ERROR','####Copying address started:-'.$new_pd_id); + foreach ($pd_address as $key => $value) + { + $value['fk_pd_id'] = $new_pd_id; + $value['assigned_pd'] = $new_pd_id; + $address_id = $this->PD_Model->saveRecords($value,PDADDRESS); + //print_r($value); + } + log_message('ERROR','####Copying address end:-'.$new_pd_id); } - log_message('ERROR','####Copying address end:-'.$new_pd_id); - } - - //Get Addtional Requirements details - $pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('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) + + //Get Addtional Requirements details + $pd_additional_requirements = $this->PD_Model->selectCustomRecords(array('add_requirement','isactive'),array('isactive' => 1,'fk_pd_id' =>$pdid),PDADDTIONALREQUIREMENTS); + if($new_pd_id && count($pd_additional_requirements)) { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS); - //print_r($value); + log_message('ERROR','####Copying Additional Req started:-'.$new_pd_id); + foreach ($pd_additional_requirements as $key => $value) + { + $value['fk_pd_id'] = $new_pd_id; + $this->PD_Model->saveRecords($value,PDADDTIONALREQUIREMENTS); + //print_r($value); + } + log_message('ERROR','####Copying Addtional Req end:-'.$new_pd_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); - 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) + + + //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); + if($new_pd_id && count($docs_to_be_collected)) { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED); - //print_r($value); + log_message('ERROR','####Copying Docs to be collected started:-'.$new_pd_id); + foreach ($docs_to_be_collected as $key => $value) + { + $value['fk_pd_id'] = $new_pd_id; + $this->PD_Model->saveRecords($value,PDDOCSTOBECOLLECTED); + //print_r($value); + } + log_message('ERROR','####Copying Docs to be collected end:-'.$new_pd_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)) - { - log_message('ERROR','####Copying All JSON Data started:-'.$new_pd_id); - foreach ($json_data as $key => $value) + //Get all JSON + $json_data = $this->PD_Model->getAllJSONFormData($pdid); + if($new_pd_id && count($json_data)) { - $value['fk_pd_id'] = $new_pd_id; - $this->PD_Model->saveRecords($value,PDFORMDETAILSJSON); - //print_r($value); + 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) + { + //print_r($applicants_ids_array); + $gen_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); + } + + //replace pd id + $gen_form_string = str_replace( $pdid, $new_pd_id, $gen_form_string); + $value['json'] = $gen_form_string; + // print_r($gen_form_string); + // die(); + } + $this->PD_Model->saveRecords($value,PDFORMDETAILSJSON); + //print_r($value); + } + log_message('ERROR','####Copying ALL JSON END:-'.$new_pd_id); } - log_message('ERROR','####Copying ALL JSON END:-'.$new_pd_id); - } + // die(); //copy all s3 into new pd folder + if($new_pd_id) + { - + //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)); + 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); + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $new_pd_id; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Something Went Wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } - // PDALERTS::pdnotification($pd_id); + + + + + } + + function dupAssessedIncomeInfo($pdid,$new_pd_id,$fk_createdby) + { + //$new_pd_id = 9999; + //echo $pdid.'/'.$new_pd_id;//die(); + + $grossprofittype = $this->PD_Model->selectCustomRecords(array('mode', 'margin','company_id', 'purchase_type'),array('fk_pd_id' => $pdid),PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + + if(count($grossprofittype)) + { + $grossprofittype = $grossprofittype[0]; + $grossprofittype['fk_createdby'] = $fk_createdby; + $grossprofittype['fk_pd_id'] = $new_pd_id; + //print_r($grossprofittype); + $this->PD_Model->saveRecords($grossprofittype,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); + } + + $purchasedeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('purchase_declared_by_customer', 'comments','company_id'),array('fk_pd_id' => $pdid,'isactive' => 1),PURCHASEDECLAREDBYCUSTOMER); + + if(count($purchasedeclaredbycustomer)) + { + $purchasedeclaredbycustomer = $purchasedeclaredbycustomer[0]; + $purchasedeclaredbycustomer['fk_pd_id'] = $new_pd_id; + $purchasedeclaredbycustomer['fk_createdby'] = $fk_createdby; + $this->PD_Model->saveRecords($purchasedeclaredbycustomer,PURCHASEDECLAREDBYCUSTOMER); + //print_r($purchasedeclaredbycustomer); + } + + $salesdeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('sales_declared_by_customer', 'margin_per','company_id','margin_value','comments'),array('fk_pd_id' => $pdid,'isactive' => 1),SALESDECLAREDBYCUSTOMER); + + if(count($salesdeclaredbycustomer)) + { + $salesdeclaredbycustomer = $salesdeclaredbycustomer[0]; + $salesdeclaredbycustomer['fk_pd_id'] = $new_pd_id; + $salesdeclaredbycustomer['fk_createdby'] = $fk_createdby; + $this->PD_Model->saveRecords($salesdeclaredbycustomer,SALESDECLAREDBYCUSTOMER); + //print_r($salesdeclaredbycustomer); + } + + // $salesdeclaredbycustomer = $this->PD_Model->selectCustomRecords(array('sales_declared_by_customer', 'margin_per','company_id','margin_value','comments'),array('fk_pd_id' => $pdid,'isactive' => 1),SALESDECLAREDBYCUSTOMER); + + // if(count($salesdeclaredbycustomer)) + // { + // $salesdeclaredbycustomer = $salesdeclaredbycustomer[0]; + // $salesdeclaredbycustomer['fk_pd_id'] = $new_pd_id; + // $salesdeclaredbycustomer['fk_createdby'] = $fk_createdby; + // $this->PD_Model->saveRecords($salesdeclaredbycustomer,SALESDECLAREDBYCUSTOMER); + // //print_r($salesdeclaredbycustomer); + // } + + + $pdhouseholdexpenses = $this->PD_Model->selectCustomRecords(array('expense_item', 'expense_value','fk_frequency_id','annual_expense_value','comments','company_id'),array('fk_pd_id' => $pdid,'isactive' => 1),PDHOUSEHOLDEXPENSES); + + if(count($pdhouseholdexpenses)) + { + + foreach ($pdhouseholdexpenses as $key => $value) + { + + $value['fk_pd_id'] = $new_pd_id; + $value['fk_createdby'] = $fk_createdby; + $this->PD_Model->saveRecords($value,PDBUSINESSEXPENSES); + //print_r($value); + } + } + + + $pdbusinessexpenses = $this->PD_Model->selectCustomRecords(array('expense_item_id', 'expense_value','fk_frequency_id','annual_expenses_value','comments','company_id','other_expense_item'),array('fk_pd_id' => $pdid,'isactive' => 1),PDBUSINESSEXPENSES); + + if(count($pdbusinessexpenses)) + { + + foreach ($pdbusinessexpenses as $key => $value) + { + + $value['fk_pd_id'] = $new_pd_id; + $value['fk_createdby'] = $fk_createdby; + $this->PD_Model->saveRecords($value,PDBUSINESSEXPENSES); + //print_r($value); + } + } + + //sales itemwise + $salescalculatedbyitemwise = $this->PD_Model->selectCustomRecords(array('sci_id','sales_item','sales_qty','fk_uom_id','rate_per_unit', 'fk_frequency_id','annual_sale_value','margin_per','margin_per_uom','margin_final_value','company_id', 'uom_other', 'comments', 'sales_type', 'other_sales_item'),array('fk_pd_id' => $pdid,'isactive' => 1),SALESCALCULATEDBYITEMWISE); + + if(count($salescalculatedbyitemwise)) + { + foreach ($salescalculatedbyitemwise as $salescalculatedbyitemwise_key => $salescalculatedbyitemwise_value) + { + $pre_sci_id = $salescalculatedbyitemwise_value['sci_id']; unset($salescalculatedbyitemwise_value['sci_id']); + $salescalculatedbyitemwise_value['fk_pd_id'] = $new_pd_id; + $salescalculatedbyitemwise_value['fk_createdby'] = $fk_createdby; + $new_sci_id = $this->PD_Model->saveRecords($salescalculatedbyitemwise_value,SALESCALCULATEDBYITEMWISE); + //get child values if any + if($salescalculatedbyitemwise_value['sales_type'] == 3) + { + $salesitemmonthwisechild = $this->PD_Model->selectCustomRecords(array('sales_date', 'sales_value','fk_frequency_id', 'frequency_value'),array('fk_sci_id' => $pre_sci_id,'isactive' => 1),SALESITEMMONTHWISECHILD); + + if(count($salesitemmonthwisechild)) + { + foreach ($salesitemmonthwisechild as $child_key => $child_value) + { + $child_value['fk_sci_id'] = $new_sci_id; + $this->PD_Model->saveRecords($child_value,SALESITEMMONTHWISECHILD); + } + } + } + } + } + + //purchase details + $pdpurchasedetails = $this->PD_Model->selectCustomRecords(array('purchase_id','purchase_item','purchase_qty', 'fk_uom_id', 'rate_per_unit', 'fk_frequency_id', 'annual_purchase_value','company_id', 'uom_other', 'comments','purchase_type', 'other_purchase_item'),array('fk_pd_id' => $pdid,'isactive' => 1),PDPURCHASEDETAILS); + + if(count($pdpurchasedetails)) + { + foreach ($pdpurchasedetails as $pdpurchasedetails_key => $pdpurchasedetails_value) + { + $pre_purchase_id = $pdpurchasedetails_value['purchase_id']; unset($pdpurchasedetails_value['purchase_id']); + $pdpurchasedetails_value['fk_pd_id'] = $new_pd_id; + $pdpurchasedetails_value['fk_createdby'] = $fk_createdby; + $new_purchase_id = $this->PD_Model->saveRecords($pdpurchasedetails_value,PDPURCHASEDETAILS); + //get child values if any + if($pdpurchasedetails_value['purchase_type'] == 3) + { + $pdpurchasebillwisechild = $this->PD_Model->selectCustomRecords(array('purchase_date', 'purchase_value'),array('fk_purchase_id' => $pre_purchase_id,'isactive' => 1),PDPURCHASEBILLWISECHILD); + + if(count($pdpurchasebillwisechild)) + { + foreach ($pdpurchasebillwisechild as $child_key => $child_value) + { + $child_value['fk_purchase_id'] = $new_purchase_id; + $this->PD_Model->saveRecords($child_value,PDPURCHASEBILLWISECHILD); + } + } + } + } + } @@ -9966,6 +10149,35 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() } + + public function loadCreditPDTemplate_post() + { + + $where_condition_array = array('isactive' => 1); + + if($this->post('fk_entity_id')){ $where_condition_array['fk_entity_id'] = $this->post('fk_entity_id'); } + if($this->post('fk_product_id')){ $where_condition_array['fk_product_id'] = $this->post('fk_product_id'); } + if($this->post('pd_form_id')){ $where_condition_array['pd_form_id'] = $this->post('pd_form_id'); } + //print_r($where_condition_array);die(); + + $template = $this->PD_Model->selectCustomRecords(array('credit_pd_template_id', 'template_name', 'template_desc', 'template', 'fk_entity_id', 'fk_product_id', 'pd_form_id'),$where_condition_array,CREDITPDTEMPLATE); + + if(count($template)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template[0]; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_FOUND; + $data['msg'] = 'Template Not Found!'; + $this->response($data,REST_Controller::HTTP_OK); + } + } + } diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php index fcaac30a..ebf91f50 100644 --- a/api/application/helpers/pdalerts_helper.php +++ b/api/application/helpers/pdalerts_helper.php @@ -18,7 +18,7 @@ class PDALERTS public static function pdnotification($pdid) { - + log_message('ERROR','####PD notification for:-'.$pdid); if($pdid != "" || $pdid != null) { //echo $pdid; @@ -206,7 +206,7 @@ class PDALERTS self::sendMail($CI,'komalmittal@sinemanagement.com',$msg,$core_details); - if($core_details[0]['pd_status'] != 'TRIGGERED') + if($core_details[0]['pd_status'] != 'TRIGGERED' && ENVIRONMENT == 'production') { self::sendMail($CI,'sinepd@sinemanagement.com',$msg,$core_details); } diff --git a/api/application/helpers/pdcompletenesscheck_helper.php b/api/application/helpers/pdcompletenesscheck_helper.php index 808c08f7..fd07ed33 100644 --- a/api/application/helpers/pdcompletenesscheck_helper.php +++ b/api/application/helpers/pdcompletenesscheck_helper.php @@ -151,7 +151,7 @@ class pdcompletenesscheck { $certificate_count = 0; $name_board_image_count = 0; - + $certificate_text = ''; if(count($pd_images[13])) { foreach ($pd_images[13] as $key => $value) { @@ -169,6 +169,7 @@ class pdcompletenesscheck if(strtoupper($business_form['shop_eat_act_cert'])=='YES' && $business_form['shop_eat_act_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Shop and Est Act Certificate ,"; } } else { $certificate_count++; } @@ -177,6 +178,7 @@ class pdcompletenesscheck if(strtoupper($business_form['gst_Regn_cert'])=='YES' && $business_form['gst_Regn_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "GST Regn Certificate ,"; } } else { $certificate_count++; } @@ -186,6 +188,7 @@ class pdcompletenesscheck if(strtoupper($business_form['pf_regn'])=='YES' && $business_form['pf_regn_pic'] == "") { $certificate_count++; + $certificate_text .= "GST Regn Certificate ,"; } } else { $certificate_count++; } @@ -194,6 +197,7 @@ class pdcompletenesscheck if(strtoupper($business_form['esic_regn'])=='YES' && $business_form['esic_regn_pic'] == "") { $certificate_count++; + $certificate_text .= "ESIC Regn Certificate ,"; } } else { $certificate_count++; } @@ -207,6 +211,7 @@ class pdcompletenesscheck if(strtoupper($business_form['factory_cert'])=='YES' && $business_form['factory_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Factory Certificate ,"; } } //else { $certificate_count++; } } @@ -219,6 +224,7 @@ class pdcompletenesscheck if(strtoupper($business_form['export_import_cert'])=='YES' && $business_form['export_import_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Export Iimport Certificate ,"; } } else { $certificate_count++; } } @@ -232,13 +238,14 @@ class pdcompletenesscheck if(strtoupper($business_form['practice_cert'])=='YES' && (!isset($business_form['practice_cert_pic']) || $business_form['practice_cert_pic']== "")) { $certificate_count++; + $certificate_text .= "Practice Certificate ,"; } } //else { $certificate_count++; } //echo $certificate_count;die(); } - - if($certificate_count){ $incomplete_details[] = 'Business Section - Images for Document Sighted Not Sufficient'; } + if($certificate_text != ''){ $certificate_text = rtrim($certificate_text, ","); } + if($certificate_count){ $incomplete_details[] = "Business Section - $certificate_text images(s) not captured"; } } @@ -899,7 +906,7 @@ class pdcompletenesscheck { $certificate_count = 0; $name_board_image_count = 0; - + $certificate_text = ''; if(count($pd_images[13])) { foreach ($pd_images[13] as $key => $value) { @@ -917,6 +924,7 @@ class pdcompletenesscheck if(strtoupper($business_form['shop_eat_act_cert'])=='YES' && $business_form['shop_eat_act_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Shop and Est Act Certificate ,"; } } else { $certificate_count++; } @@ -925,6 +933,8 @@ class pdcompletenesscheck if(strtoupper($business_form['gst_Regn_cert'])=='YES' && $business_form['gst_Regn_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "GST Regn Certificate ,"; + } } else { $certificate_count++; } @@ -942,6 +952,7 @@ class pdcompletenesscheck if(strtoupper($business_form['esic_regn'])=='YES' && $business_form['esic_regn_pic'] == "") { $certificate_count++; + $certificate_text .= "ESIC Regn Certificate ,"; } } else { $certificate_count++; } @@ -955,6 +966,8 @@ class pdcompletenesscheck if(strtoupper($business_form['factory_cert'])=='YES' && $business_form['factory_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Factory Certificate ,"; + } } //else { $certificate_count++; } } @@ -967,6 +980,7 @@ class pdcompletenesscheck if(strtoupper($business_form['export_import_cert'])=='YES' && $business_form['export_import_cert_pic'] == "") { $certificate_count++; + $certificate_text .= "Export Iimport Certificate ,"; } } else { $certificate_count++; } } @@ -980,13 +994,15 @@ class pdcompletenesscheck if(strtoupper($business_form['practice_cert'])=='YES' && (!isset($business_form['practice_cert_pic']) || $business_form['practice_cert_pic']== "")) { $certificate_count++; + $certificate_text .= "Practice Certificate ,"; } } //else { $certificate_count++; } //echo $certificate_count;die(); } - if($certificate_count){ $incomplete_details[] = 'Business Section - Images for Document Sighted Not Sufficient'; } + if($certificate_text != ''){ $certificate_text = rtrim($certificate_text, ","); } + if($certificate_count){ $incomplete_details[] = "Business Section - $certificate_text images(s) not captured"; } } diff --git a/api/application/libraries/AWS_S3.php b/api/application/libraries/AWS_S3.php index 7d533a3a..dbad067d 100644 --- a/api/application/libraries/AWS_S3.php +++ b/api/application/libraries/AWS_S3.php @@ -5,6 +5,7 @@ include_once APPPATH.'/vendor/autoload.php'; use Aws\S3\S3Client; use Aws\Exception\AwsException; +use Aws\CommandPool; class AWS_S3 { @@ -226,6 +227,69 @@ return $result; print($res); } + + public function dupSinglePDImages($bucketName,$sourceKey,$targetKey) + { + //first get all images/s3 obj from source bucket$objects = array(); + $existingS3Objects = array(); + $copied_objects = 0; + try { + + $existingS3Objects =$this->S3->listObjects(['Bucket' => $bucketName,'Prefix' => $sourceKey]); + if(isset($existingS3Objects['Contents']) && count($existingS3Objects['Contents'])) + { + // Perform a batch of CopyObject operations. + $batch = array(); + foreach($existingS3Objects['Contents'] as $obj_key => $obj_vale) + { + $key = ($obj_vale['Key']); + $fulltargetKey = (function() use ($targetKey,$key){ + $res = ''; + $t = explode('/',$key);unset($t[0]); + foreach ($t as $index => $value) { $res .= (count($t) == ($index+1) ? $value.'/' : $value); } + return $targetKey.'/'.$res; + + }); + $fulltargetKey = $fulltargetKey(); + //echo $fulltargetKey.'###'.$bucketName.'/'.$key.'~~~'; + $batch[] = $this->S3->getCommand('CopyObject', [ + 'Bucket' => $bucketName, + 'Key' => $fulltargetKey, + 'CopySource' => "$bucketName/$key", + 'MetadataDirective' => 'REPLACE' + ]); + } + + try { + $results = CommandPool::batch($this->S3, $batch); + foreach($results as $result) { + if ($result instanceof ResultInterface) + { + $copied_objects++; + echo 'DONE'; + } + if ($result instanceof AwsException) { + log_message('ERROR','###Error in Batch result - '.$result->getAwsErrorMessage()); + + } + } + } catch (Exception $e) + { + log_message('ERROR','###Error in executing Copy Batch Operation'); + log_message('ERROR',$e->getMessage()); + echo $e->getMessage() . PHP_EOL; + } + } + }catch (S3Exception $e) + { + log_message('ERROR','###Error in getting all exist s3 keys'); + log_message('ERROR',$e->getMessage()); + //echo $e->getMessage() . PHP_EOL; + } + + echo $copied_objects; + + } } ?> \ No newline at end of file diff --git a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php index c8847f4e..ca44b5a0 100644 --- a/api/application/views/report_templates/JSONTOREPORT_DI_AI.php +++ b/api/application/views/report_templates/JSONTOREPORT_DI_AI.php @@ -1538,7 +1538,7 @@ if($total_no_of_business > 0) { { foreach($pd_images[13] as $img_key => $img_value) { - if( !strcasecmp($getDocument_value['key_name'],$img_value['pd_document_title'] )) + if( !strcasecmp($getDocument_value['key_name'],$img_value['pd_document_title'] ) && $img_value['company_id'] == ($business_count+1)) { $getDocuments[$getDocument_key]['img'] = $img_value['doc_url']; break; diff --git a/api/application/views/report_templates/JSONTOREPORT_SAL.php b/api/application/views/report_templates/JSONTOREPORT_SAL.php index 55b33dc3..55bc2f87 100644 --- a/api/application/views/report_templates/JSONTOREPORT_SAL.php +++ b/api/application/views/report_templates/JSONTOREPORT_SAL.php @@ -914,7 +914,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo '

'; echo 'The PD visit was done at '. $address_type. 'Address Form - Type of Address of the loan applicants. '; //echo 'The '.$address_type.'Address Form - Type of Address is '.$property_owner_type.'Business Assest Form - Owner of the Property and the business has been in operation from here for the last '.$yrs_being_run.'Business Assest Form - Business running Yrs in this premise .'; - echo '

The '.$address_type.'Address Form - Type of Address is located in '.$locality.'Address Form - Locality of Address and the estimated area of the '.$address_type.'Address Form - Type of Address is '.$estimated_area.'Address Form - Estimated Area .'; + echo '

The '.$address_type.'Address Form - Type of Address is located in '.$locality.'.Address Form - Locality of Address '; echo '

The PD location was '. $pd_address['pd_location_master'].'Address Form - Approach to PD location . ' . 'As Per PD Officer, the '.$address_type .'Address Form - Type of Address is situated in '.$comment_locality_master .'Address Form - Comment on locality Locality.'; // echo '

The PD officer also made the following observations:' ; // echo '