Flyhi api : ps
This commit is contained in:
parent
8ce79cfc4e
commit
20e0a945d8
@ -375,3 +375,7 @@ $route['getCreditPDReportforCETApp'] = 'SMC_Credit_PD_Controller/getCreditPDRep
|
||||
|
||||
$route['faceMarkImage'] = 'PD_Controller/toMakeFaceBoundingBox';
|
||||
|
||||
$route['saveFlyHiSalesPD'] = 'Flyhi_Controller/saveFlyHiSalesPD';
|
||||
$route['listFlyhiSalesPD'] = 'Flyhi_Controller/listFlyhiSalesPD';
|
||||
|
||||
|
||||
|
||||
92
api/application/controllers/Flyhi_Controller.php
Normal file
92
api/application/controllers/Flyhi_Controller.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||
require APPPATH . 'vendor/autoload.php';
|
||||
|
||||
class Flyhi_Controller extends REST_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('Flyhi_Model','Flyhi_Model');
|
||||
$this->load->model('Sales_PD_Model','Sales_PD_Model');
|
||||
}
|
||||
|
||||
public function listFlyhiSalesPD_get(){
|
||||
|
||||
$lender_id = $this->uri->segment(2);
|
||||
$user_id = $this->uri->segment(3);
|
||||
$role = $this->uri->segment(4);
|
||||
|
||||
$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.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',
|
||||
'(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');
|
||||
$table = SALES_PD_DATA.' as SALES_PD_DATA';
|
||||
|
||||
$joins = array(
|
||||
array('table' => ENTITY. ' as ENTITY',
|
||||
'condition' =>'SALES_PD_DATA.lender_id = ENTITY.entity_id',
|
||||
'jointype' => 'INNER'),
|
||||
array('table' => PRODUCTS. ' as PRODUCT',
|
||||
'condition' =>'SALES_PD_DATA.product_id = PRODUCT.product_id',
|
||||
'jointype' => 'INNER'),
|
||||
array('table' => CITY. ' as CITY',
|
||||
'condition' =>'SALES_PD_DATA.city_id = CITY.city_id',
|
||||
'jointype' => 'LEFT'),
|
||||
array('table' => USERPROFILE. ' as USERPROFILE',
|
||||
'condition' =>'SALES_PD_DATA.createdby = USERPROFILE.userid',
|
||||
'jointype' => 'LEFT')
|
||||
);
|
||||
|
||||
$or_where = array();
|
||||
$where_condition_array['SALES_PD_DATA.isactive'] = 1;
|
||||
if(is_numeric($lender_id))
|
||||
{
|
||||
$where_condition_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 60 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---
|
||||
|
||||
$MWISELender = (ENVIRONMENT == 'production' ? 7 : 35);
|
||||
if($role && is_numeric($role) && $role == 11 && $MWISELender == $lender_id){
|
||||
// $where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22);
|
||||
}else{
|
||||
if($role && is_numeric($role) && $role == 15) //if role area sales head the pull all meq cases
|
||||
{
|
||||
$where_condition_array['SALES_PD_DATA.product_id'] = (ENVIRONMENT == 'production' ? 23 : 22);
|
||||
$or_where['SALES_PD_DATA.createdby'] = $user_id;
|
||||
}
|
||||
else if($user_id && is_numeric($user_id))
|
||||
{
|
||||
$where_condition_array['SALES_PD_DATA.createdby'] = $user_id;
|
||||
}
|
||||
}
|
||||
$where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null;
|
||||
$order_by = 'SALES_PD_DATA.sales_pd_id';
|
||||
$sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where);
|
||||
//print_r($this->db->last_query());die();
|
||||
|
||||
if(count($sales_pd_data))
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $sales_pd_data;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
||||
$data['msg'] = 'Something went wrong! Try Later';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}// Class Ends
|
||||
91
api/application/models/Flyhi_Model.php
Normal file
91
api/application/models/Flyhi_Model.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
require_once APPPATH . '/libraries/SPARQ_Model.php';
|
||||
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 = '') {
|
||||
// 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,
|
||||
(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');
|
||||
$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'" );
|
||||
if($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" ){
|
||||
$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'" );
|
||||
$this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') 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);
|
||||
if($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" ){
|
||||
$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);
|
||||
$this->db->or_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($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" ){
|
||||
$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);
|
||||
$this->db->or_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);
|
||||
}
|
||||
if(!empty($sales_pd_type) && count($sales_pd_type)) {
|
||||
$this->db->WHERE_IN('SALES_PD_DATA.sales_pd_type',$sales_pd_type);
|
||||
}
|
||||
$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();}
|
||||
//echo $this->db->last_query();die();
|
||||
return $result;
|
||||
}
|
||||
public function testSaleSection($id){
|
||||
$this->db->SELECT('*')->FROM("t_salespd_section_data")->WHERE('sales_pd_id',$id)->WHERE('isactive',1);
|
||||
$query = $this->db->get();
|
||||
return $query->result();
|
||||
// $sql = 'insert into sineedgeprod.t_salespd_section_data(sales_pd_id, section_id, status, section_data, createdby, isactive) select sales_pd_id, section_id, status, section_data, createdby, isactive from sineedgeprod.t_salespd_section_data WHERE sales_pd_id = 1768 and section_id = 1 and isactive = 1;';
|
||||
// $modified = $this->db->query($sql);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user