SMC CHGS 1
This commit is contained in:
parent
479e3942e0
commit
1cbce13e1a
@ -665,6 +665,7 @@ defined('SMC_CREDITPD_IMGS') OR define('SMC_CREDITPD_IMGS','m_smc_creditpd_imgs'
|
||||
defined('SALESVENDORLIST') OR define('SALESVENDORLIST','m_smcvendorlist');
|
||||
defined('SALESEQUIPMENTLIST') OR define('SALESEQUIPMENTLIST','m_smc_equipmentlist');
|
||||
defined('USERCONFIG') OR define('USERCONFIG','m_user_config');
|
||||
defined('SMC_TEMP_ADDRESS') OR define('SMC_TEMP_ADDRESS','t_smc_temp_address');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ $route['getCommonConfig'] = 'Common_Masters_Controller/getCommonConfig';
|
||||
$route['getServerInfo'] = 'Common_Masters_Controller/getServerInfo';
|
||||
$route['getVideoChatAccessKey'] = 'Common_Masters_Controller/getVideoChatAccessKey';
|
||||
$route['uploadSMCDataFile'] = 'Common_Masters_Controller/uploadSMCDataFile';
|
||||
$route['getSMCTempAddresses'] = 'Common_Masters_Controller/getSMCTempAddresses';
|
||||
|
||||
|
||||
|
||||
|
||||
@ -18,6 +18,7 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
// Construct the parent class
|
||||
parent::__construct();
|
||||
$this->load->model('Common_Masters_Model');
|
||||
$this->load->model('PD_Model');
|
||||
$this->load->library('AWS_S3');
|
||||
|
||||
}
|
||||
@ -1295,16 +1296,20 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
public function uploadSMCDataFile_post()
|
||||
{
|
||||
$records = json_decode($this->post('records'),true);
|
||||
//print_r($records);
|
||||
// print_r($records);
|
||||
$is_bucket_upload_sucess = false;
|
||||
$id = null;
|
||||
//die();
|
||||
// echo date('Y-m-d_h:i:s');
|
||||
// die();
|
||||
if(!empty($_FILES['pd_excel_data']))
|
||||
{
|
||||
$folder_to_check = XLPATH.'/tmp';
|
||||
// $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name']));
|
||||
$modified_fname = str_replace(' ','_',($_FILES['pd_excel_data']['name']));
|
||||
|
||||
$modified_fname = (explode('.',$_FILES['pd_excel_data']['name']));
|
||||
$modified_fname = $modified_fname[0].'_'.date('Y-m-d_h-i-s').'.'.$modified_fname[1];
|
||||
// echo $modified_fname;
|
||||
// die();
|
||||
// #TEMP
|
||||
// $sourcefile = $folder_to_check.'/'.$modified_fname;
|
||||
// $result_data = readexceldata::getExcelSectionData($sourcefile);
|
||||
@ -1340,18 +1345,29 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
$fields_to_insert['fk_pd_id'] = $records['fk_pd_id'];
|
||||
}
|
||||
$is_bucket_upload_sucess = 1;
|
||||
// disable old entries
|
||||
$this->Common_Masters_Model->updateRecords(array('isactive' => 0),SMC_EXCEL_FILELIST,array('fk_pd_id' => $records['fk_pd_id']));
|
||||
|
||||
//have to do disable key 'is_reupload_data_fetched' to 0 in section data table
|
||||
$this->Common_Masters_Model->updateRecords(array('is_reupload_data_fetched' => 0),SMC_CREDIT_PD_SECTION_DATA,array('fk_pd_id' => $records['fk_pd_id']));
|
||||
|
||||
//insert new records
|
||||
$id = $this->Common_Masters_Model->saveRecords($fields_to_insert,SMC_EXCEL_FILELIST);
|
||||
|
||||
|
||||
if(!isset($records['fk_pd_id']))
|
||||
{
|
||||
//read excel file get trigger data
|
||||
$result_data = readexceldata::getExcelSectionData($sourcefile);
|
||||
$result_data = readexceldata::getExcelSectionData($sourcefile,null,null,$id);
|
||||
}
|
||||
|
||||
unlink($sourcefile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('ERROR','###File Upload Failed'.$modified_fname);
|
||||
}
|
||||
|
||||
|
||||
if($is_bucket_upload_sucess && $id)
|
||||
@ -1380,5 +1396,38 @@ class Common_Masters_Controller extends REST_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
public function getSMCTempAddresses_get()
|
||||
{
|
||||
$pdid = $this->get('pdid');
|
||||
if($pdid)
|
||||
{
|
||||
$pd_master_details = $this->PD_Model->getPDMasterDetails($pdid);
|
||||
// print_r($pd_master_details);die();
|
||||
$addresses = $this->Common_Masters_Model->getSMCTempAddresses($pd_master_details[0]['excel_file_id']);
|
||||
if(count($addresses))
|
||||
{
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['records'] = $addresses;
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'No Data Found!';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_NOT_FOUND;
|
||||
$data['msg'] = 'No Data Found!';
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -2065,24 +2065,24 @@ public function assignPDTempalate($data)
|
||||
if($this->get('createdby')) { $createdby = $this->get('createdby'); }
|
||||
if($this->get('lenderid'))
|
||||
{
|
||||
$lenderid = $this->get('lenderid');
|
||||
$smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo
|
||||
if($lenderid == $smc_lender_id)
|
||||
{
|
||||
// $lenderid = $this->get('lenderid');
|
||||
// $smc_lender_id = ENVIRONMENT == 'production' ? 7 : 35; //pk id of SMC in live and demo
|
||||
// if($lenderid == $smc_lender_id)
|
||||
// {
|
||||
|
||||
$this->load->model('User_Management_Model');
|
||||
$user_details = $this->User_Management_Model->getUserDetails($createdby);
|
||||
if($user_details['data'][0]['user_role'] == 26)//Credit Manager
|
||||
{
|
||||
$pdofficerid = $createdby;
|
||||
// $this->load->model('User_Management_Model');
|
||||
// $user_details = $this->User_Management_Model->getUserDetails($createdby);
|
||||
// if($user_details['data'][0]['user_role'] == 26)//Credit Manager
|
||||
// {
|
||||
// $pdofficerid = $createdby;
|
||||
|
||||
}
|
||||
else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager
|
||||
{
|
||||
$lender_details = array('city' => $user_details['data'][0]['fk_city']);
|
||||
// }
|
||||
// else if($user_details['data'][0]['user_role'] == 27)//Reg Credit Manager
|
||||
// {
|
||||
// $lender_details = array('city' => $user_details['data'][0]['fk_city']);
|
||||
|
||||
}
|
||||
$createdby = '';
|
||||
// }
|
||||
// $createdby = '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1308,7 +1308,7 @@ public function filterSalesPDList_post() {
|
||||
$records = $this->post('records');
|
||||
$pd_master_data = $this->PD_Model->getPDMasterDetails($records['pd_id'],$records['random_string']);
|
||||
$cur_section_data = array();
|
||||
// print_r($pd_master_data);die();
|
||||
// print_r($pd_master_data);die();
|
||||
// echo $records['form_id'];die();
|
||||
//check excel file in local, otherwise get it from s3 and store locallly
|
||||
$filename = ($pd_master_data[0]['re_uploaded'] ? XLPATH.'/tmp/'.$pd_master_data[0]['re_uploaded_file_name'] : XLPATH.'/tmp/'.$pd_master_data[0]['modified_fname']);
|
||||
@ -1553,7 +1553,7 @@ public function filterSalesPDList_post() {
|
||||
|
||||
$score_card_questions['pd_officer_recommendation'] = array('answer_id' => $view_data['pd_section_data'][19]['pd_officer_recommendation'],'answer' => $over_all[ $view_data['pd_section_data'][19]['pd_officer_recommendation'] ]);
|
||||
|
||||
$score_card_questions['neighbourhood_status'] = array('answer_id' => $view_data['pd_section_data'][17]['neighbourhood_status'],'answer' => $view_data['pd_section_data'][17]['neighbourhood_status']);
|
||||
//$score_card_questions['neighbourhood_status'] = array('answer_id' => $view_data['pd_section_data'][17]['neighbourhood_status'],'answer' => $view_data['pd_section_data'][17]['neighbourhood_status']);
|
||||
|
||||
$score_card_questions['business_seasonality'] = array('answer_id' => $view_data['pd_section_data'][4]['seasonality'],'answer' => $view_data['pd_section_data'][4]['seasonality']);
|
||||
|
||||
|
||||
@ -546,6 +546,7 @@ class PDALERTS
|
||||
$mail_id = 'cpa@smcfinance.com';
|
||||
$mail->addBCC("neville@sinemanagement.com");
|
||||
$mail->addBCC("ssa@venbainfotech.com");
|
||||
$mail->addAddress('cpumumbai@smcfinance.com');
|
||||
//$mail->addBCC("vitvelz@gmail.com");
|
||||
} // Name is optional }
|
||||
$mail->addAddress($mail_id);
|
||||
|
||||
@ -3,11 +3,13 @@
|
||||
class readexceldata
|
||||
{
|
||||
private static $current_section_id = null;
|
||||
public static function getExcelSectionData($file_path_withname,$section_id = null,$pd_id = null)
|
||||
private static $current_excel_file_id = 9999;
|
||||
public static function getExcelSectionData($file_path_withname,$section_id = null,$pd_id = null,$excel_file_id = null)
|
||||
{
|
||||
$CI =&get_instance();
|
||||
$CI->load->library('myspreadsheet');
|
||||
SELF::$current_section_id = $section_id;
|
||||
SELF::$current_excel_file_id = $excel_file_id;
|
||||
|
||||
|
||||
// echo is_numeric($section_id);
|
||||
@ -98,6 +100,35 @@ class readexceldata
|
||||
else
|
||||
{
|
||||
$return_data = SELF::getTriggerData($sheetData,$section_ref_data);
|
||||
//store address details in temp table SMC_TEMP_ADDRESS
|
||||
if(array_key_exists('address_details', $return_data))
|
||||
{
|
||||
foreach ($return_data['address_details'] as $key => $address)
|
||||
{
|
||||
$display = $address['address'].', '.$address['city'].', '.$address['state'].', '.$address['pincode'];
|
||||
|
||||
$pincode = $CI->PD_Model->selectCustomRecords(array('*'),array('pincode' => $address['pincode']),PINCODE);
|
||||
$city = $CI->PD_Model->selectCustomRecords(array('*'),array('lower(name)' => strtolower($address['city'])),CITY);
|
||||
// print_r($CI->db->last_query());
|
||||
// $state = $CI->PD_Model->selectCustomRecords(array('*'),array('pincode' => $address['pincode']),PINCODE,1);
|
||||
$fields_to_insert = array('file_id' => SELF::$current_excel_file_id,'addressline' => $address['address']);
|
||||
if(is_array($pincode) && count($pincode))
|
||||
{
|
||||
$fields_to_insert['pincode'] = $pincode[0]['pincode_id'];
|
||||
}
|
||||
if(is_array($city) && count($city))
|
||||
{
|
||||
$fields_to_insert['city'] = $city[0]['city_id'];
|
||||
$fields_to_insert['state'] = $city[0]['fk_state_id'];
|
||||
}
|
||||
|
||||
// print_r($fields_to_insert);
|
||||
$temp_add_id = $CI->PD_Model->saveRecords($fields_to_insert,SMC_TEMP_ADDRESS);
|
||||
$fields_to_insert['address_id'] = $temp_add_id;
|
||||
$return_data['address_details'][ $key ]['display'] = $display;
|
||||
$return_data['address_details'][ $key ]['id'] = $fields_to_insert;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ($return_data);
|
||||
@ -155,11 +186,15 @@ class readexceldata
|
||||
return ($return_data);
|
||||
|
||||
}
|
||||
|
||||
static function getTriggerData($sheetData,$section_ref_data)
|
||||
{
|
||||
// echo 'worked';die();
|
||||
// echo 'worked';
|
||||
|
||||
$return_data = array();
|
||||
unset($sheetData[1]);
|
||||
// print_r($sheetData);
|
||||
// die();
|
||||
$main_applicant_column_name = '';
|
||||
foreach ($sheetData as $key => $value)
|
||||
{
|
||||
@ -167,16 +202,30 @@ class readexceldata
|
||||
$value = SELF::trimExcelEmptyCells($value);
|
||||
//print_r($value);//die();
|
||||
$tmp = SELF::returnMatchedData($section_ref_data,$value);
|
||||
// print_r($tmp);
|
||||
// $temp = array();
|
||||
if(is_array($tmp) && isset($tmp['key_name']))
|
||||
{
|
||||
$temp[$tmp['key_name']] = $value['C'];
|
||||
//$temp['value'] = $value['C'];
|
||||
$return_data = $temp;
|
||||
}
|
||||
if($key == 8)
|
||||
// $return_data[$tmp['key_name']] = $value['C'];
|
||||
//$temp['value'] = $value['C'];
|
||||
// print_r($return_data);
|
||||
// echo '################';
|
||||
if(isset($tmp['parent_key']))// & !array_key_exists($tmp['parent_key'], $return_data))
|
||||
{
|
||||
if($tmp['parent_key'] == 'address_details')
|
||||
{ $return_data[$tmp['parent_key']][] = array('city' => $value['C'],'address' =>$value['B'],'state' => $value['D'],'pincode' => $value['E']); }
|
||||
}
|
||||
else{ $return_data[$tmp['key_name']] = $value['C']; }
|
||||
// print_r($temp);
|
||||
// echo '@@@@@@@@@@@@@';
|
||||
// $return_data = $temp;
|
||||
|
||||
if($key == 8)
|
||||
{
|
||||
//print_r($value);
|
||||
// print_r($value);
|
||||
//getting co applicants only
|
||||
$value = (array_splice(($value),3));$value = array_reverse($value);
|
||||
// print_r($value);
|
||||
foreach ($value as $val)
|
||||
{
|
||||
$return_data['co_applicants'][] = array('applicant_name' => $val);
|
||||
@ -184,22 +233,27 @@ class readexceldata
|
||||
|
||||
|
||||
}
|
||||
if($key == 9)
|
||||
{break;}
|
||||
|
||||
}
|
||||
|
||||
// if($key == 9)
|
||||
// {break;}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// print_r($return_data);die();
|
||||
return ($return_data);
|
||||
}
|
||||
|
||||
static function returnMatchedData($arr,$val)
|
||||
static function returnMatchedData($arr,$val)//$arr is sheetdata where $val is section column ref's
|
||||
{
|
||||
foreach ($arr as $key => $value)
|
||||
{
|
||||
if(!$value['parent_key'] && ($val['A'] == $value['ref']))
|
||||
if(!$value['parent_key'] && (isset($val['A'])) && ($val['A'] == $value['ref']))
|
||||
{
|
||||
return array('key_name' => $value['key_name']);
|
||||
}
|
||||
else if($value['parent_key'] && ($val['A'] == $value['ref']))
|
||||
else if($value['parent_key'] && (isset($val['A'])) && ($val['A'] == $value['ref']))
|
||||
{
|
||||
return array('key_name' => $value['key_name'],'parent_key' => $value['parent_key']);
|
||||
}
|
||||
|
||||
@ -163,4 +163,31 @@ class Common_Masters_Model extends SPARQ_Model {
|
||||
}
|
||||
|
||||
|
||||
function getSMCTempAddresses($excel_file_id)
|
||||
{
|
||||
$columns = array('SMC_TEMP_ADDRESS.*',"concat(SMC_TEMP_ADDRESS.addressline,', ',CITY.name,', ',STATE.name,', ',PINCODE.pincode) as display",'CITY.name as city_name','STATE.name as state_name','PINCODE.pincode');
|
||||
$table = SMC_TEMP_ADDRESS.' as SMC_TEMP_ADDRESS';
|
||||
$where_condition_array = array('SMC_TEMP_ADDRESS.file_id' => $excel_file_id);
|
||||
$joins = array(
|
||||
array(
|
||||
'table' => CITY. ' as CITY',
|
||||
'condition' => 'SMC_TEMP_ADDRESS.city = CITY.city_id ',
|
||||
'jointype' => 'INNER'
|
||||
),
|
||||
array(
|
||||
'table' => STATE. ' as STATE',
|
||||
'condition' => 'SMC_TEMP_ADDRESS.state = STATE.state_id ',
|
||||
'jointype' => 'INNER'
|
||||
),
|
||||
array(
|
||||
'table' => PINCODE. ' as PINCODE',
|
||||
'condition' => 'SMC_TEMP_ADDRESS.pincode = PINCODE.pincode_id ',
|
||||
'jointype' => 'INNER'
|
||||
)
|
||||
);
|
||||
|
||||
return $result = $this->getJoinRecords($columns,$table,$joins,$where_condition_array);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user