diff --git a/api/application/controllers/Flyhi_Controller.php b/api/application/controllers/Flyhi_Controller.php index 0cb5b36f..4d847901 100644 --- a/api/application/controllers/Flyhi_Controller.php +++ b/api/application/controllers/Flyhi_Controller.php @@ -22,12 +22,21 @@ class Flyhi_Controller extends REST_Controller { $this->load->library('phpmailer_library'); } + public function getUserAndItsLender(){ + $headersData = getallheaders(); + $td = jwt::decode($headersData['Token']); + $current_user_id = $td->locale; + $default_lender = $this->Flyhi_Model->getEntityFromUserdetails($current_user_id); + return $default_lender; + } + + ## filterFlyPDList 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_lender = $this->getUserAndItsLender(); $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 ; @@ -49,13 +58,13 @@ class Flyhi_Controller extends REST_Controller { } public function getMasterForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); $default_product = $FHFSL_product; - $default_lender = $FHFSL_lender; + $pd_lender = $this->getUserAndItsLender(); $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $pd_lender); $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); if(count($result_data)) { @@ -86,21 +95,20 @@ class Flyhi_Controller extends REST_Controller { 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; $or_where = array(); - $lender_contact_persons = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,array('USERPROFILE.fk_entity_id' => $FHFSL_lender),$order_by,'DESC','',$or_where); + $lender_contact_persons = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,array('USERPROFILE.fk_entity_id' => $pd_lender),$order_by,'DESC','',$or_where); $lender_contact_persons = count($lender_contact_persons)>0 ? $lender_contact_persons : 'Credit Person Lender Profile was not found?. Create Credit Person Lender profile'; // isset($records['pd_branch_id']) ? $records['pd_branch_id'] : null $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = array('lender'=> $result_data,'products' =>$product,'lender_contact_persons'=>$lender_contact_persons,'default_lender' =>$FHFSL_lender,'default_product' =>$FHFSL_product); + $data['records'] = array('lender'=> $result_data,'products' =>$product,'lender_contact_persons'=>$lender_contact_persons,'default_lender' =>$pd_lender,'default_product' =>$FHFSL_product); $this->response($data,REST_Controller::HTTP_OK); } public function lenderMasterForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $default_lender = $FHFSL_lender; - + $pd_lender = $this->getUserAndItsLender(); + $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $pd_lender); $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); $result_data = count($result_data)>0 ? $result_data : 'Lender was not found'; @@ -125,10 +133,10 @@ class Flyhi_Controller extends REST_Controller { } public function branchMasterForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $pd_lender = $this->getUserAndItsLender(); $branches = array(); $lender_fields = array('entity_id','full_name','short_name'); - $lender_where_condition_array = array('isactive' => 1,'entity_id' => $FHFSL_lender); + $lender_where_condition_array = array('isactive' => 1,'entity_id' => $pd_lender); $result_data = $this->Flyhi_Model->selectCustomRecords($lender_fields,$lender_where_condition_array,ENTITY,array(),'','full_name'); if(count($result_data)) { @@ -150,7 +158,7 @@ class Flyhi_Controller extends REST_Controller { } public function lenderCreditPersonForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $pd_lender = $this->getUserAndItsLender(); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); @@ -162,7 +170,7 @@ class Flyhi_Controller extends REST_Controller { 'condition' =>'ROLES.role_id = USERPROFILEROLES.user_role', 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; - $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; + $where_condition_array['USERPROFILE.fk_entity_id'] = $pd_lender; $key_date="ROLES.role_name LIKE '%credit%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -177,7 +185,7 @@ class Flyhi_Controller extends REST_Controller { } public function lenderSalesPersonForFlyhiPD_get(){ - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $pd_lender = $this->getUserAndItsLender(); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); $columns = array('USERPROFILE.userid','concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as user_name','USERPROFILE.fk_entity_id','USERPROFILE.fk_city','USERPROFILEROLES.user_role','USERPROFILE.fk_entity_type_id','ROLES.role_name','if( POSITION("credit" IN ROLES.role_name),"CREDIT","SALES") as role_type'); @@ -190,7 +198,7 @@ class Flyhi_Controller extends REST_Controller { 'jointype' => 'INNER')); $order_by = 'USERPROFILE.userid'; $or_where = array(); - $where_condition_array['USERPROFILE.fk_entity_id'] = $FHFSL_lender; + $where_condition_array['USERPROFILE.fk_entity_id'] = $pd_lender; $key_date="ROLES.role_name LIKE '%sale%'"; $condition_value=null; $where_condition_array[$key_date] = $condition_value; @@ -206,7 +214,7 @@ class Flyhi_Controller extends REST_Controller { public function listFlyhiPD_get(){ - $user_id = $this->uri->segment(1); + $user_id = $this->uri->segment(2); $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.is_pdf','SALES_PD_DATA.is_edited','ENTITY.full_name','ENTITY.short_name','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', @@ -248,11 +256,15 @@ class Flyhi_Controller extends REST_Controller { $where_condition_array[$key_date] = $condition_value; // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); + $pd_lender = $this->getUserAndItsLender(); + $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 31); + 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 not in (1,2,3,4)'] = null; // comment this + + if($pd_lender == $FHFSL_lender) $where_condition_array['SALES_PD_DATA.sales_pd_type in (3,4)'] = null; + else $where_condition_array['SALES_PD_DATA.sales_pd_type in (5)'] = null; $order_by = 'SALES_PD_DATA.sales_pd_id'; $Flyhi_pd_data = $this->Flyhi_Model->getJoinRecords($columns,$table,$joins,$where_condition_array,$order_by,'DESC','',$or_where); @@ -411,7 +423,7 @@ class Flyhi_Controller extends REST_Controller { } } - + public function getFlyhiPDReport_get() { $pd_id = $this->uri->segment(2); @@ -507,7 +519,6 @@ class Flyhi_Controller extends REST_Controller { $singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name, $bucket_key,'30 minutes'); $view_data['satellite_image'] = $singed_uri; // $view_data['satellite_image'] = $this->Flyhi_Model->selectCustomRecords(array('*'),array('fk_sales_pd_id' => $pd_id,'img_name' => 'satellite','isactive' => 1),SALEPD_DOCS); - // die(); //$view_name = $flyhipd_data[0]['short_name'].'_'.$flyhipd_data[0]['abbr']; $view_name = $flyhipd_data[0]['short_name']; $html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true); @@ -1098,8 +1109,8 @@ class Flyhi_Controller extends REST_Controller { { $records = $this->post('records'); $FHFSL_product = (ENVIRONMENT == 'production' ? 27 : 26); - $FHFSL_lender = (ENVIRONMENT == 'production' ? 19 : 49); - $lender = isset($records['lender_id']) ? $records['lender_id'] : $FHFSL_lender; + $pd_lender = $this->getUserAndItsLender(); + $lender = isset($records['lender_id']) ? $records['lender_id'] : $pd_lender; $product = isset($records['product_id']) ? $records['product_id'] : $FHFSL_product; $records['lender_id'] = $lender; $records['product_id'] = $product; diff --git a/api/application/views/sale_pd_templates/DemoFSL.php b/api/application/views/sale_pd_templates/DFSL.php similarity index 99% rename from api/application/views/sale_pd_templates/DemoFSL.php rename to api/application/views/sale_pd_templates/DFSL.php index 98056163..b093affc 100644 --- a/api/application/views/sale_pd_templates/DemoFSL.php +++ b/api/application/views/sale_pd_templates/DFSL.php @@ -220,7 +220,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');