From eb17048f7af2f5e0ce5d0627fe2b4ac172c03340 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Mon, 2 Dec 2019 13:06:05 +0530 Subject: [PATCH] LATEST STATUS DATE FROM HISTORY --- api/application/controllers/PD_Controller.php | 33 ++++++++++++------- api/application/models/PD_Model.php | 11 ++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index a4d61792..6c0eeaca 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -708,6 +708,7 @@ class PD_Controller extends REST_Controller { public function savePDAdditionalRequiremets_post() { $records = $this->post('records'); + //print_r($records);die(); $pd_addtional_requirements = $records['addtional_requirements']; $count = 0; @@ -715,21 +716,23 @@ class PD_Controller extends REST_Controller { { foreach($pd_addtional_requirements as $requirement_key => $pd_addtional_requirement) { - if($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "" && ($pd_addtional_requirement['add_requirement'] != null) ) - { - $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); - $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS,$where_condition_array); - if($pk_id != "" || $pk_id != null){ $count++; } - } - else - { - if( $pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") + + + if($pd_addtional_requirement['add_req_id'] != null || $pd_addtional_requirement['add_req_id'] != "")// && ($pd_addtional_requirement['add_requirement'] != null) ) { - $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; - $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); + $where_condition_array = array('add_req_id' => $pd_addtional_requirement['add_req_id']); + $pk_id = $this->PD_Model->updateRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS,$where_condition_array); if($pk_id != "" || $pk_id != null){ $count++; } } - } + else + { + if( $pd_addtional_requirement['add_requirement'] != null || $pd_addtional_requirement['add_requirement'] != "") + { + $pd_addtional_requirement['fk_pd_id'] = $records['pdid']; + $pk_id = $this->PD_Model->saveRecords($pd_addtional_requirement,PDADDTIONALREQUIREMENTS); + if($pk_id != "" || $pk_id != null){ $count++; } + } + } } } if($count != 0 && $count == count($pd_addtional_requirements)) @@ -2021,6 +2024,12 @@ public function assignPDTempalate($data) //Get All PD Logs $result_data['pd_logs'] = $this->PD_Model->getPDLogs($pdid); //print_r($result_data['pd_logs']);die(); + if(count($result_data['pd_logs'])) + { + $result_data['pd_master_details'][0]['maser_updatedon'] = $result_data['pd_master_details'][0]['updatedon']; + $result_data['pd_master_details'][0]['updatedon'] = DATE_FORMAT(date_create_from_format("Y-m-d H:i:s",$result_data['pd_logs']['last_status_update_date']),"d/m/Y h:i:s a"); + } + //print_r($result_data['pd_master_details']);die(); $applicant_msg = ''; $pd_docs_msg = ''; $pd_question_answer_msg = ''; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 373a8ca9..dd02f206 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -490,7 +490,7 @@ class PD_Model extends SPARQ_Model { $arrayForText = array("fk_lender_id" => "Lender", "fk_entity_billing_id" => "Billing ID", "lender_applicant_id" => "Applicant Ref ID", "pd_date_of_initiation" => "PD Date of Initiation", "fk_product_id" => "Product", "fk_subproduct_id" => "Sub Product","fk_pd_type" => "PD Type", "pd_status" => "PD Status", "pd_specific_clarification"=> "PD Specific Clarification","fk_pd_allocation_type" => "Allocation Type", "fk_pd_allocated_to" => "Allocated Person", "fk_pd_template_id" => "PD Tempale", "fk_customer_segment" => "Customer Segment", "pd_officier_final_judgement" => "PD Officer Finale Judgement", "pd_agency_id" => "PD Agency", "loan_amount" => "Loan Amount", "addressline1" => "Addressline1", "addressline2" => "Addressline1", "addressline3" => "Addressline1", "fk_city" => "City", "fk_state" => "State", "pincode" => "Pincode", "bounce_reason" => "Bounce Reason", "executive_id" => "PD Executive","central_pd_officer_id"=>"Central PD Officer","pd_contact_person" => "Lender Contact Person", "pd_contact_mobileno" => "Lender Contact Mobile Number", "scheduled_on" => "Scheduled On", "completed_on" => "Completed On",'fk_address_id' => 'PD Address Map','fk_primary_address_id' => 'Primary Address'); - $this->db->SELECT('COMMONMASTER.log_id, COMMONMASTER.primary_key, COMMONMASTER.table_name, COMMONMASTER.field_name, COMMONMASTER.old_value, COMMONMASTER.new_value, COMMONMASTER.fk_createdby, DATE_FORMAT(COMMONMASTER.createdon,"%D %b %Y at %h:%i:%s %p") as createdon,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,ENTITYBILLINGOLD.billing_name as old_billing_name,ENTITYBILLINGNEW.billing_name as new_billing_name,ENTITYOLD.full_name as old_entity_name,ENTITYNEW.full_name as new_entity_name,PRODUCTSOLD.abbr as old_product,PRODUCTSNEW.abbr as new_product,SUBPRODUCTSOLD.abbr as old_sub_product,SUBPRODUCTSNEW.abbr as new_sub_product,PDTYPEOLD.type_name as old_type_name,PDTYPENEW.type_name as new_type_name,concat(ALLOCATEDOLD.first_name," ",ALLOCATEDOLD.last_name) as old_allocated_to,concat(ALLOCATEDNEW.first_name," ",ALLOCATEDNEW.last_name) as new_allocated_to,TEMPLATEOLD.template_name as old_template_name,TEMPLATENEW.template_name as new_template_name,CUSTOMERSEGMENTOLD.name as old_cs_name,CUSTOMERSEGMENTNEW.name as new_cs_name,AGENCYOLD.full_name as old_agencyname,AGENCYNEW.full_name as new_agencyname,CITYOLD.name as old_city,CITYNEW.name as new_city,STATEOLD.name as old_state,STATENEW.name as new_state,concat(EXECUTIVEOLD.first_name," ",EXECUTIVEOLD.last_name) as old_executive,concat(EXECUTIVENEW.first_name," ",EXECUTIVENEW.last_name) as new_executive,concat(CENTRALPDOLD.first_name," ",CENTRALPDOLD.last_name) as old_central_pd_officer_id,concat(CENTRALPDNEW.first_name," ",CENTRALPDNEW.last_name) as new_central_pd_officer_id,ALLOCATIONOLD.pd_allocation_type_name as old_allocation_type,ALLOCATIONNEW.pd_allocation_type_name as new_allocation_type,BOUNCEMASTEROLD.bounce_reason_name as old_bounce_reason,BOUNCEMASTERNEW.bounce_reason_name as new_bounce_reason,PINCODEOLD.pincode as old_pincode,PINCODENEW.pincode as new_pincode,PDTRIGGER.other_pincode'); + $this->db->SELECT('COMMONMASTER.log_id, COMMONMASTER.primary_key, COMMONMASTER.table_name, COMMONMASTER.field_name, COMMONMASTER.old_value, COMMONMASTER.new_value, COMMONMASTER.fk_createdby, DATE_FORMAT(COMMONMASTER.createdon,"%D %b %Y at %h:%i:%s %p") as createdon,COMMONMASTER.createdon raw_date_createdon,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,ENTITYBILLINGOLD.billing_name as old_billing_name,ENTITYBILLINGNEW.billing_name as new_billing_name,ENTITYOLD.full_name as old_entity_name,ENTITYNEW.full_name as new_entity_name,PRODUCTSOLD.abbr as old_product,PRODUCTSNEW.abbr as new_product,SUBPRODUCTSOLD.abbr as old_sub_product,SUBPRODUCTSNEW.abbr as new_sub_product,PDTYPEOLD.type_name as old_type_name,PDTYPENEW.type_name as new_type_name,concat(ALLOCATEDOLD.first_name," ",ALLOCATEDOLD.last_name) as old_allocated_to,concat(ALLOCATEDNEW.first_name," ",ALLOCATEDNEW.last_name) as new_allocated_to,TEMPLATEOLD.template_name as old_template_name,TEMPLATENEW.template_name as new_template_name,CUSTOMERSEGMENTOLD.name as old_cs_name,CUSTOMERSEGMENTNEW.name as new_cs_name,AGENCYOLD.full_name as old_agencyname,AGENCYNEW.full_name as new_agencyname,CITYOLD.name as old_city,CITYNEW.name as new_city,STATEOLD.name as old_state,STATENEW.name as new_state,concat(EXECUTIVEOLD.first_name," ",EXECUTIVEOLD.last_name) as old_executive,concat(EXECUTIVENEW.first_name," ",EXECUTIVENEW.last_name) as new_executive,concat(CENTRALPDOLD.first_name," ",CENTRALPDOLD.last_name) as old_central_pd_officer_id,concat(CENTRALPDNEW.first_name," ",CENTRALPDNEW.last_name) as new_central_pd_officer_id,ALLOCATIONOLD.pd_allocation_type_name as old_allocation_type,ALLOCATIONNEW.pd_allocation_type_name as new_allocation_type,BOUNCEMASTEROLD.bounce_reason_name as old_bounce_reason,BOUNCEMASTERNEW.bounce_reason_name as new_bounce_reason,PINCODEOLD.pincode as old_pincode,PINCODENEW.pincode as new_pincode,PDTRIGGER.other_pincode'); $this->db->FROM(COMMONMASTER.' as COMMONMASTER'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','COMMONMASTER.fk_createdby = USERPROFILE.userid','LEFT'); $this->db->JOIN(ENTITYBILLING.' as ENTITYBILLINGOLD','COMMONMASTER.old_value = ENTITYBILLINGOLD.entity_billing_id','LEFT'); @@ -534,12 +534,20 @@ class PD_Model extends SPARQ_Model { //$sql = 'SELECT * FROM '.COMMONMASTER.' WHERE table_name = "'.PDTRIGGER.'" AND primary_key = '.$pdid; //$logs = $this->db->query($sql)->result_array(); + $last_status_update_date = null; $actual_logs = array(); $revert_remark_iteration = 0; if(count($logs)) { foreach($logs as $log_key => $log) { + + + if($log_key == (count($logs) - 1) && $log['field_name'] == 'pd_status') + { + $last_status_update_date = $log['raw_date_createdon']; + //echo $last_status_update_date;die(); + } if($log_key == 0 && $log['field_name'] == 'pd_status') { @@ -823,6 +831,7 @@ class PD_Model extends SPARQ_Model { $result_data['child'] = array('testkey'=>'testvalue'); $result_data['master'] = $actual_logs; + $result_data['last_status_update_date'] = $last_status_update_date ; //print_r($result_data['master']);die(); // Child History Start // $this->db->SELECT('PDAPPLICANTSDETAILS.pd_co_applicant_id, PDAPPLICANTSDETAILS.fk_pd_id, PDAPPLICANTSDETAILS.applicant_name, PDAPPLICANTSDETAILS.applicant_type, PDAPPLICANTSDETAILS.mobile_no, PDAPPLICANTSDETAILS.email, PDAPPLICANTSDETAILS.isactive, PDAPPLICANTSDETAILS.relation');