From 2d06c4c735ced865a5f5d1095175514bb7d76521 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Wed, 30 Dec 2020 16:01:23 +0530 Subject: [PATCH] MEQ ROLE ADDED --- api/application/config/routes.php | 1 + .../controllers/Sales_PD_Controller.php | 15 +++++-- .../User_Management_Controller.php | 44 +++++++++++++++++-- api/application/libraries/SPARQ_Model.php | 11 ++++- .../models/User_Management_Model.php | 5 +++ .../views/sale_pd_templates/MEQ.php | 5 ++- .../views/smc_creditpd_reports/MWISE.php | 30 ++++++------- 7 files changed, 86 insertions(+), 25 deletions(-) diff --git a/api/application/config/routes.php b/api/application/config/routes.php index 0e14166e..dab459e3 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -288,6 +288,7 @@ $route['saveSalesPD'] = 'Sales_PD_Controller/saveSalesPD'; $route['(downloadSalesPDReport/:any)'] = 'Sales_PD_Controller/getSalesPDReport'; $route['listSalesPD/(:any)'] = 'Sales_PD_Controller/listSalesPD'; $route['listSalesPD/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD'; +$route['listSalesPD/(:any)/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD'; $route['saveSalesPDImage'] = 'Sales_PD_Controller/saveSalesPDImage'; $route['saveSalesPDsection'] = 'Sales_PD_Controller/saveSalesPDsection'; $route['getSalesPDSectionData'] = 'Sales_PD_Controller/getSalesPDSectionData'; diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index adeef492..aca2d1ab 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -257,6 +257,7 @@ class Sales_PD_Controller extends REST_Controller { { $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.createdon','SALES_PD_DATA.status','SALES_PD_DATA.sales_pd_type','SALES_PD_DATA.rand_string','SALES_PD_DATA.isactive' // ,"DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') as modify","DATE_ADD(CURDATE(),INTERVAL '-10' DAY) as currd", // "(CURDATE()) as daye10" @@ -274,6 +275,7 @@ class Sales_PD_Controller extends REST_Controller { 'jointype' => 'LEFT') ); + $or_where = array(); $where_condition_array['SALES_PD_DATA.isactive'] = 1; if(is_numeric($lender_id)) { @@ -288,14 +290,21 @@ class Sales_PD_Controller extends REST_Controller { // ----END OF FILTERING THE LAST 10 DAYS RECORDS--- - if($user_id && is_numeric($user_id)) + 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; } + $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'); + $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(); + // print_r($this->db->last_query());die(); + // print_r(count($sales_pd_data));die(); if(count($sales_pd_data)) { $data['dataStatus'] = true; diff --git a/api/application/controllers/User_Management_Controller.php b/api/application/controllers/User_Management_Controller.php index c49d749f..2a97d523 100644 --- a/api/application/controllers/User_Management_Controller.php +++ b/api/application/controllers/User_Management_Controller.php @@ -52,11 +52,11 @@ class User_Management_Controller extends REST_Controller { $roles = ""; $lender_hierarchy = ""; $pdofficer = ""; + $user_config = ""; if($this->post('roles')){ $roles = json_decode($this->post('roles'),true); } if($this->post('pdofficer')){ $pdofficer = json_decode($this->post('pdofficer'),true); } - - + if($this->post('user_config')){ $user_config = json_decode($this->post('user_config'),true); } $records = json_decode($this->post('records'),true); @@ -152,8 +152,22 @@ class User_Management_Controller extends REST_Controller { //print_r($pdofficer); $this->User_Management_Model->saveRecords($pdofficer,PDOFFICIERSDETAILS); - } - } + } + } + + //save user configs + if($user_config) + { + if(array_key_exists('salespd_products', $user_config)) + { + $salespd_products = (implode(',',$user_config['salespd_products'])); + $arr = array('fk_user_id' => $user_id,'config_type' => 1,'data' => $salespd_products); + $this->db->set($arr); + $res = $this->db->insert(USERCONFIG); + //print_r($res); + } + } + if($user_id != '' || $user_id != null) { @@ -180,15 +194,21 @@ class User_Management_Controller extends REST_Controller { $roles = ""; $lender_hierarchy = ""; $pdofficer = ""; + $user_config = ""; if($this->post('pdofficer')){ $pdofficer = json_decode($this->post('pdofficer'),true);} if($this->post('lender_hierarchy')){ $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true); } + if($this->post('user_config')){ $user_config = json_decode($this->post('user_config'),true); } $records = json_decode($this->post('records'),true); // $records = array_filter($recordsData); $roles = json_decode($this->post('roles'),true); + + + + // $lender_hierarchy = json_decode($this->post('lender_hierarchy'),true); if(!empty($_FILES['profilepic']['tmp_name'])) @@ -280,6 +300,22 @@ class User_Management_Controller extends REST_Controller { $this->User_Management_Model->updateRecords($pdofficer,PDOFFICIERSDETAILS,$arr); } } + + + //update user configs + if($user_config) + { + if(array_key_exists('salespd_products', $user_config)) + { + $salespd_products = (implode(',',$user_config['salespd_products'])); + $arr = array('fk_user_id' => $records['userid'],'config_type' => 1,'data' => $salespd_products); + $this->db->set($arr); + $this->db->where('fk_user_id', $records['userid']); + $res = $this->db->update(USERCONFIG); + //print_r($res); + } + } + if($modified != '' || $modified != null || $modified != 0) { diff --git a/api/application/libraries/SPARQ_Model.php b/api/application/libraries/SPARQ_Model.php index a1cc2b90..209a036e 100644 --- a/api/application/libraries/SPARQ_Model.php +++ b/api/application/libraries/SPARQ_Model.php @@ -93,7 +93,7 @@ class SPARQ_Model extends CI_Model { } - public function getJoinRecords($columns,$table,$joins,$where_condition_array = array(),$order_by_cloumn = '',$order_by = 'ASC',$print_query = '') + public function getJoinRecords($columns,$table,$joins,$where_condition_array = array(),$order_by_cloumn = '',$order_by = 'ASC',$print_query = '',$or_where) { @@ -112,6 +112,15 @@ class SPARQ_Model extends CI_Model { $this->db->WHERE($key,$condition); } } + if(count($or_where)) + { + $this->db->or_group_start(); + foreach($or_where as $key => $condition) + { + $this->db->WHERE($key,$condition); + } + $this->db->group_end(); + } if($order_by != '') { diff --git a/api/application/models/User_Management_Model.php b/api/application/models/User_Management_Model.php index ba2354d6..b616b1f5 100644 --- a/api/application/models/User_Management_Model.php +++ b/api/application/models/User_Management_Model.php @@ -45,6 +45,11 @@ class User_Management_Model extends SPARQ_Model { // print_r($result);die; if(count($result) > 0 ) { + foreach ($result as $key => $value) + { + $result[$key]['user_config'] = $this->getUserConfigDetails($value['userid']); + } + $result_data['data_status'] = true; $result_data['data'] = $result; return $result_data; diff --git a/api/application/views/sale_pd_templates/MEQ.php b/api/application/views/sale_pd_templates/MEQ.php index 6e475006..c37085c7 100644 --- a/api/application/views/sale_pd_templates/MEQ.php +++ b/api/application/views/sale_pd_templates/MEQ.php @@ -259,6 +259,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''; ?> +
@@ -290,9 +291,9 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + - + diff --git a/api/application/views/smc_creditpd_reports/MWISE.php b/api/application/views/smc_creditpd_reports/MWISE.php index ab39a43c..258a316d 100644 --- a/api/application/views/smc_creditpd_reports/MWISE.php +++ b/api/application/views/smc_creditpd_reports/MWISE.php @@ -256,7 +256,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); echo ''; if(isset($pd_section_data[8]['is_business_address']) && strtolower($pd_section_data[8]['is_business_address']) == 'yes') { - echo ''; + echo ''; } echo ''; echo ''; @@ -1288,28 +1288,28 @@ Business run by the applicant
Institution Details
Number of beds Occupancy ratio
Address Type / Ownership '.$pd_section_data[2]['address_type']['address_type'].$ownership_type.'
Business operating duration
from this address
'.($pd_section_data[8]['business_years'].' Year(s)'.(isset($pd_section_data[8]['business_months']) && $pd_section_data[8]['business_months'] != '' ? ' & ' . $pd_section_data[8]['business_months'] .' Month(s)': '')).'
Period for which business has been
in operation from this address
'.($pd_section_data[8]['business_years'].' Year(s)'.(isset($pd_section_data[8]['business_months']) && $pd_section_data[8]['business_months'] != '' ? ' & ' . $pd_section_data[8]['business_months'] .' Month(s)': '')).'
PD locality '.$pd_section_data[2]['pd_locality']['locality_name'].'
Location Approach '.$pd_section_data[2]['pd_location']['description'].'
- + - - - - - - - - - + + + + + + + + + -
+