From 3ff91ccedaee65eda98c7ee04ecffa7c7c54427e Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Tue, 3 Mar 2020 15:55:18 +0530 Subject: [PATCH] Fairoj : Sales PD Advanced list features implemented and salespd list records limit changed to last 10 days --- api/application/config/routes.php | 3 +- .../controllers/Sales_PD_Controller.php | 41 +++++++++++++++++-- api/application/models/Sales_PD_Model.php | 39 +++++++++++++++++- 3 files changed, 78 insertions(+), 5 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index d1981d70..56b63fc5 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -268,5 +268,6 @@ $route['saveSalesPDImage'] = 'Sales_PD_Controller/saveSalesPDImage'; $route['saveSalesPDsection'] = 'Sales_PD_Controller/saveSalesPDsection'; $route['getSalesPDSectionData'] = 'Sales_PD_Controller/getSalesPDSectionData'; $route['testAPISalesPD'] = 'Sales_PD_Controller/testAPISalesPD'; -$route['salesPDMisReport'] = 'Sales_PD_Controller/salesPDMisReport'; +$route['salesPDMisReport'] = 'Sales_PD_Controller/salesPDMisReport'; +$route['filterSalesPDList']='Sales_PD_Controller/filterSalesPDList'; diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index 66b17375..292dd1b8 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -257,7 +257,10 @@ class Sales_PD_Controller extends REST_Controller { { $lender_id = $this->uri->segment(2); $user_id = $this->uri->segment(3); - $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.createdon','SALES_PD_DATA.status'); + $columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.sales_pd_sno','SALES_PD_DATA.applicant_name','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name','SALES_PD_DATA.applicant_id','SALES_PD_DATA.lender_id','SALES_PD_DATA.product_id','SALES_PD_DATA.is_pdf','SALES_PD_DATA.is_edited','ENTITY.short_name','PRODUCT.abbr','SALES_PD_DATA.createdon','SALES_PD_DATA.status' + // ,"DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') as modify","DATE_ADD(CURDATE(),INTERVAL '-10' DAY) as currd", + // "(CURDATE()) as daye10" + ); $table = SALES_PD_DATA.' as SALES_PD_DATA'; $joins = array( array('table' => ENTITY. ' as ENTITY', @@ -276,6 +279,15 @@ class Sales_PD_Controller extends REST_Controller { { $where_condition_array = array('SALES_PD_DATA.lender_id' => $lender_id); } + // FILTERING THE LAST 10 DAYS RECORDS + + $key_date='SALES_PD_DATA.createdon BETWEEN DATE_SUB(NOW(), INTERVAL 10 DAY) AND NOW()'; + $condition_value=null; + $where_condition_array[$key_date] = $condition_value; + // print_r ($where_condition_array); + + // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- + if($user_id && is_numeric($user_id)) { $where_condition_array = array('SALES_PD_DATA.createdby' => $user_id); @@ -901,8 +913,31 @@ class Sales_PD_Controller extends REST_Controller { } - +public function filterSalesPDList_post() { + $records = $this->post('records'); + $pd_status= $records['pd_status']; + $pd_from_date = $records['pd_from_date']; + $pd_to_date = $records['pd_to_date']; + $pd_products = $records['pd_products']; + $pd_lender = $records['pd_lender']; + $pd_applicant_name = strtolower($records['pd_applicant_name']); + $pd_officer_name = isset($records['pd_officer']) ? $records['pd_officer'] : null ; + $result_data=$this->Sales_PD_Model->getSalesPDListwithFilters($pd_status,$pd_from_date,$pd_to_date,$pd_products,$pd_lender,$pd_applicant_name,$pd_officer_name); + // print_r ($result_data); + if(count($result_data)){ + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $result_data; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Records Found'; + $this->response($data,REST_Controller::HTTP_OK); + } +} } - \ No newline at end of file diff --git a/api/application/models/Sales_PD_Model.php b/api/application/models/Sales_PD_Model.php index 34a78e11..400abe50 100644 --- a/api/application/models/Sales_PD_Model.php +++ b/api/application/models/Sales_PD_Model.php @@ -8,7 +8,44 @@ class Sales_PD_Model extends SPARQ_Model { public function __construct() { parent::__construct(); } - + public function getSalesPDListwithFilters($pd_status = '',$pd_from_date = '',$pd_to_date = '',$pd_products = '',$pd_lender = '',$pd_applicant_name = '',$pd_officer_name = '') { + // SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.short_name,PRODUCTS.abbr,DATE_FORMAT(SALES_PD_DATA.createdon, "%d/%m/%Y") as pd_createdon,SALES_PD_DATA.status + $this->db->SELECT(' SALES_PD_DATA.sales_pd_sno, SALES_PD_DATA.sales_pd_id, SALES_PD_DATA.applicant_name,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as officer_name,SALES_PD_DATA.applicant_id,SALES_PD_DATA.lender_id,SALES_PD_DATA.product_id,SALES_PD_DATA.is_pdf,SALES_PD_DATA.is_edited,ENTITY.short_name,PRODUCTS.abbr,SALES_PD_DATA.createdon, + DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status'); + $this->db->from(SALES_PD_DATA.' as SALES_PD_DATA'); + $this->db->join(ENTITY.' as ENTITY','ENTITY.entity_id = SALES_PD_DATA.lender_id','INNER'); + $this->db->join(PRODUCTS.' as PRODUCTS', 'PRODUCTS.product_id = SALES_PD_DATA.product_id','INNER'); + $this->db->join(USERPROFILE.' as USERPROFILE', 'USERPROFILE.userid = SALES_PD_DATA.createdby','INNER'); + if(!empty($pd_status)){ + $this->db->where_in('SALES_PD_DATA.status',$pd_status); + } + if(($pd_from_date != "" || $pd_from_date != null) && ($pd_to_date != "" || $pd_to_date != null)) { + $this->db->where('SALES_PD_DATA.createdon BETWEEN '. "'$pd_from_date'". ' AND '. "'$pd_to_date'" ); + } + else if($pd_from_date != "" && $pd_from_date != null) { + $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date); + } + else if($pd_to_date != "" && $pd_to_date != null) { + $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date); + } + if(!empty($pd_products)){ + $this->db->where_in('SALES_PD_DATA.product_id',$pd_products); + } + if(!empty($pd_lender)) { + $this->db->where_in('SALES_PD_DATA.lender_id',$pd_lender); + } + if(!empty($pd_applicant_name)) { + $this->db->like('SALES_PD_DATA.applicant_name',$pd_applicant_name); + } + if(!empty($pd_officer_name)) { + $this->db->like('SALES_PD_DATA.officer_name',$pd_officer_name); + } + $this->db->order_by('SALES_PD_DATA.sales_pd_id','desc'); + $this->db->limit(1000,0); + $result = $this->db->get()->result_array(); + // if(ENVIRONMENT == 'development'){echo 'LAST QUERY '. $this->db->last_query();} + return $result; + }