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,SALES_PD_DATA.sales_pd_type,SALES_PD_DATA.rand_string'); $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); } if(!empty($sales_pd_officer_id)) { $this->db->WHERE('SALES_PD_DATA.createdby',$sales_pd_officer_id); } $this->db->WHERE('SALES_PD_DATA.isactive',1); $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; } function getSMCTemplateForPD($pd_id,$product_id,$client,$random_string,$api) { //echo $product_id;die(); // $master_forms = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'),array('isactive' => 1),SMC_CREDIT_PD_FORMS); // print_r($master_forms); $table = CREDITPDTEMPLATE.' as CREDITPDTEMPLATE'; // $table = SMC_CREDIT_PD_FORMS.' as SMC_CREDIT_PD_FORMS'; $fields = array('SMC_CREDIT_PD_FORMS.form_name','CREDITPDTEMPLATE.pd_form_id as fk_form_id','CREDITPDTEMPLATE.fk_product_id','SMC_CREDIT_PD_SECTION_DATA.fk_pd_id','if(SMC_CREDIT_PD_SECTION_DATA.json is not null,true,false) as is_answered','SMC_CREDIT_PD_SECTION_DATA.is_reupload_data_fetched','SMC_CREDIT_PD_FORMS.complete_check_enabled'); $joins = array( array('table'=>SMC_CREDIT_PD_SECTION_DATA." as SMC_CREDIT_PD_SECTION_DATA",'condition'=>"SMC_CREDIT_PD_SECTION_DATA.fk_form_id = CREDITPDTEMPLATE.pd_form_id AND CREDITPDTEMPLATE.fk_product_id = $product_id AND SMC_CREDIT_PD_SECTION_DATA.fk_pd_id = $pd_id and SMC_CREDIT_PD_SECTION_DATA.isactive = 1 " ,'jointype'=>'LEFT'), array('table'=>SMC_CREDIT_PD_FORMS." as SMC_CREDIT_PD_FORMS",'condition'=>"CREDITPDTEMPLATE.pd_form_id = SMC_CREDIT_PD_FORMS.form_id" ,'jointype'=>'INNER JOIN') ); $where_condition_array = array('CREDITPDTEMPLATE.isactive' => 1,'CREDITPDTEMPLATE.fk_product_id' => $product_id); return $master_forms = $this->getJoinRecords($fields,$table,$joins,$where_condition_array,'CREDITPDTEMPLATE.pd_form_id','ASC'); print_r($this->db->last_query());die(); } function getSMCFlowUsers($city,$role) { $fields = array('USERPROFILE.userid','USERPROFILE.first_name','USERPROFILE.last_name','USERPROFILEROLES.user_role'); $table = USERPROFILE.' as USERPROFILE'; $where_condition_array = array('USERPROFILE.fk_city' => $city); $joins = array( array('table'=>USERPROFILEROLES.' as USERPROFILEROLES','condition'=>"USERPROFILE.userid = USERPROFILEROLES.fk_userid and USERPROFILEROLES.user_role = $role and USERPROFILEROLES.isactive = 1" ,'jointype'=>'INNER JOIN') ); $users = $this->SMC_Credit_PD_Model->getJoinRecords($fields,$table,$joins,$where_condition_array); // print_r($this->db->last_query()); return $users; } }