filterFlyPDList : ps

This commit is contained in:
VE10-Sanjeev 2022-07-05 11:30:04 +05:30
parent b0cd0ce7e0
commit 5eaa1741c9
3 changed files with 46 additions and 13 deletions

View File

@ -389,3 +389,4 @@ $route['getFlyhiLenderList'] = 'Flyhi_Controller/lenderMasterForFlyhiPD';
$route['saveFlyhiPDImage'] = 'Flyhi_Controller/saveFlyhiPDImage';
$route['getFlyhiPDImgDataCusLink']='Flyhi_Controller/getFlyhiPDImgDataCusLink';
$route['saveFlyhiPDsection'] = 'Flyhi_Controller/saveFlyhiPDsection';
$route['filterFlyPDList']='Flyhi_Controller/filterFlyPDList';

View File

@ -21,6 +21,33 @@ class Flyhi_Controller extends REST_Controller {
$this->load->helper('faceapi');
$this->load->library('phpmailer_library');
}
public function filterFlyPDList_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_lender = (ENVIRONMENT == 'production' ? 19 : 49);
$pd_products = isset($records['pd_products']) ? $records['pd_products'] : (ENVIRONMENT == 'production' ? 27 : 26) ;
$pd_applicant_name = strtolower($records['pd_applicant_name']);
$sales_pd_officer_id = isset($records['sales_pd_officer_id']) ? $records['sales_pd_officer_id'] : null ;
$sales_pd_type = isset($records['sales_pd_type']) ? $records['sales_pd_type'] : null ;
$result_data=$this->Flyhi_Model->getFlyPDListwithFilters($pd_status,$pd_from_date,$pd_to_date,$pd_products,$pd_lender,$pd_applicant_name,$sales_pd_officer_id,$sales_pd_type);
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);
}
}
public function getMasterForFlyhiPD_get(){
$FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49);
$FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26);

View File

@ -8,23 +8,31 @@ class Flyhi_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_officer_id,$sales_pd_type = '') {
public function getFlyPDListwithFilters($pd_status = '',$pd_from_date = '',$pd_to_date = '',$pd_products = '',$pd_lender = '',$pd_applicant_name = '',$sales_pd_officer_id,$sales_pd_type = '') {
// 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,
$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.full_name,ENTITY.short_name,PRODUCTS.abbr,
(CASE WHEN SALES_PD_DATA.status = "STARTED" THEN SALES_PD_DATA.createdon WHEN SALES_PD_DATA.status = "COMPLETED" THEN SALES_PD_DATA.completed_date ELSE NULL END) AS createdon,
DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string');
DATE_FORMAT(SALES_PD_DATA.createdon, "%Y-%m-%d") as pd_createdon, SALES_PD_DATA.status,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string,SALES_PD_DATA.isactive,SALES_PD_DATA.city_id,CITY.name as city_name,
SALES_PD_DATA.lender_sales_person,concat(LENDERSALESPERSON.first_name," ",LENDERSALESPERSON.last_name) as lender_sales_person_name,LENDERSALESPERSON.mobile_no as lender_sales_contact_mobileno,LENDERSALESPERSON.email as lender_sales_person_email,
SALES_PD_DATA.lender_credit_person,concat(LENDERCREDITPERSON.first_name," ",LENDERCREDITPERSON.last_name) as lender_credit_person_name,LENDERCREDITPERSON.mobile_no as lender_credit_person_contact_mobileno,LENDERCREDITPERSON.email as lender_credit_person_email,
SALES_PD_DATA.pd_branch_id,ENTITYLENDERBRANCH.branch_name,SALES_PD_DATA.loan_amount');
$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(ENTITYLENDERBRANCH.' as ENTITYLENDERBRANCH','SALES_PD_DATA.pd_branch_id = ENTITYLENDERBRANCH.entity_lender_branch_id','LEFT');
$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');
$this->db->join(USERPROFILE.' as LENDERSALESPERSON', 'SALES_PD_DATA.lender_sales_person = LENDERSALESPERSON.userid','LEFT');
$this->db->join(USERPROFILE.' as LENDERCREDITPERSON', 'SALES_PD_DATA.lender_credit_person = LENDERCREDITPERSON.userid','LEFT');
$this->db->join(CITY.' as CITY', 'SALES_PD_DATA.city_id = CITY.city_id','LEFT');
// echo $pd_from_date;
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'" );
if($pd_status[0] == "STARTED" ){
if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
}else if($pd_status[0] == "COMPLETED" ){
}else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
}else{
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
@ -33,9 +41,9 @@ class Flyhi_Model extends SPARQ_Model {
}
else if($pd_from_date != "" && $pd_from_date != null) {
// $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date);
if($pd_status[0] == "STARTED" ){
if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date);
}else if($pd_status[0] == "COMPLETED" ){
}else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date);
}else{
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date);
@ -44,9 +52,9 @@ class Flyhi_Model extends SPARQ_Model {
}
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($pd_status[0] == "STARTED" ){
if((!empty($pd_status)) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date);
}else if($pd_status[0] == "COMPLETED" ){
}else if((!empty($pd_status)) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date);
}else{
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date);
@ -62,9 +70,6 @@ class Flyhi_Model extends SPARQ_Model {
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);
}
if(!empty($sales_pd_officer_id)) {
$this->db->WHERE('SALES_PD_DATA.createdby',$sales_pd_officer_id);
@ -77,7 +82,7 @@ class Flyhi_Model extends SPARQ_Model {
$this->db->limit(1000,0);
$result = $this->db->get()->result_array();
// if(ENVIRONMENT == 'development'){echo 'LAST QUERY '. $this->db->last_query();}
//echo $this->db->last_query();die();
// echo $this->db->last_query();die();
return $result;
}
public function testSaleSection($id){