diff --git a/api/application/config/routes.php b/api/application/config/routes.php index c4bbd5d4..de062273 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -314,4 +314,5 @@ $route['loadDataFromExcel'] = 'SMC_Credit_PD_Controller/loadDataFromExcel'; $route['getSMCPDImgSectionData'] = 'SMC_Credit_PD_Controller/getSMCPDImgSectionData'; $route['smcCreditPDReport'] = 'SMC_Credit_PD_Controller/smcCreditPDReport'; $route['getCMUsers'] = 'SMC_Credit_PD_Controller/getCMUsers'; +$route['smcCreditPDMisReport'] = 'SMC_Credit_PD_Controller/smcCreditPDMisReport'; diff --git a/api/application/controllers/SMC_Credit_PD_Controller.php b/api/application/controllers/SMC_Credit_PD_Controller.php index f361d9e2..7fffda91 100644 --- a/api/application/controllers/SMC_Credit_PD_Controller.php +++ b/api/application/controllers/SMC_Credit_PD_Controller.php @@ -1001,7 +1001,7 @@ class SMC_Credit_PD_Controller extends REST_Controller { // file_put_contents('test.jpg', file_get_contents($url)); } - public function salesPDMisReport_post() + public function smcCreditPDMisReport_post() { //$lender_id = $this->uri->segment(2); $officer_name = $this->post('officer_name'); @@ -1009,38 +1009,38 @@ class SMC_Credit_PD_Controller extends REST_Controller { $to_date = $this->post('to_date'); - $columns = array('SMC_CREDIT_PD.smc_credit_pd','SMC_CREDIT_PD.sales_pd_sno','SMC_CREDIT_PD.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SMC_CREDIT_PD.applicant_id','SMC_CREDIT_PD.lender_id','SMC_CREDIT_PD.product_id','SMC_CREDIT_PD.is_pdf','SMC_CREDIT_PD.is_edited','ENTITY.short_name','PRODUCT.abbr','SMC_CREDIT_PD.createdon','SMC_CREDIT_PD.status','SMC_CREDIT_PD.mail_status','SMC_CREDIT_PD.sales_pd_type','IF(SMC_CREDIT_PD.sales_pd_type = 1 ,"physical pd","tele pd") as sales_pd_type_name'); - $table = SMC_CREDIT_PD.' as SMC_CREDIT_PD'; + $columns = array('PDTRIGGER.pd_id','PDTRIGGER.pd_sno','PDTRIGGER.lender_applicant_id','PDTRIGGER.fk_product_id','PRODUCT.abbr','PDTRIGGER.pd_status','PDTRIGGER.pd_status as officer_name','PDAPPLICANTSDETAILS.applicant_name','COMMONMASTER.createdon',('(SELECT createdon FROM h_common_masters where PDTRIGGER.pd_id = primary_key AND field_name = "pd_status" order by log_id DESC limit 1) as updatedon')); + $table = PDTRIGGER.' as PDTRIGGER'; $joins = array( - array('table' => ENTITY. ' as ENTITY', - 'condition' =>'SMC_CREDIT_PD.lender_id = ENTITY.entity_id', - 'jointype' => 'INNER'), array('table' => PRODUCTS. ' as PRODUCT', - 'condition' =>'SMC_CREDIT_PD.product_id = PRODUCT.product_id', + 'condition' =>'PDTRIGGER.fk_product_id = PRODUCT.product_id', 'jointype' => 'INNER'), - array('table' => USERPROFILE. ' as USERPROFILE', - 'condition' =>'SMC_CREDIT_PD.createdby = USERPROFILE.userid', - 'jointype' => 'LEFT') + array('table' => PDAPPLICANTSDETAILS. ' as PDAPPLICANTSDETAILS', + 'condition' =>'PDTRIGGER.pd_id = PDAPPLICANTSDETAILS.fk_pd_id and applicant_type = 1', + 'jointype' => 'LEFT'), + array('table' => COMMONMASTER. ' as COMMONMASTER', + 'condition' =>'PDTRIGGER.pd_id = COMMONMASTER.primary_key and COMMONMASTER.table_name = "'.PDTRIGGER.'" and COMMONMASTER.field_name = "pd_status" and COMMONMASTER.new_value = "COMPLETED"', + 'jointype' => 'LEFT'), ); - $where_condition_array = array(); + $where_condition_array = array('PDTRIGGER.pd_status' => 'COMPLETED'); if($officer_name) { //$where_condition_array[] = array('SMC_CREDIT_PD.officer_name like' => '%'.$officer_name.'%'); - $where_condition_array['SMC_CREDIT_PD.officer_name like'] = '%'.$officer_name.'%'; + //$where_condition_array['PDTRIGGER.officer_name like'] = '%'.$officer_name.'%'; } if($from_date) { - $where_condition_array['date(SMC_CREDIT_PD.createdon) >='] = $from_date; + $where_condition_array['date(PDTRIGGER.createdon) >='] = $from_date; } if($to_date) { - $where_condition_array['date(SMC_CREDIT_PD.createdon) <='] = $to_date; + $where_condition_array['date(PDTRIGGER.createdon) <='] = $to_date; } - $order_by = 'SMC_CREDIT_PD.smc_credit_pd'; + $order_by = 'PDTRIGGER.pd_id'; $SMC_CREDIT_PD = $this->SMC_Credit_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC'); //print_r($this->db->last_query()); if(count($SMC_CREDIT_PD))