SANJEEV CODE MERGE

This commit is contained in:
velz 2018-10-04 20:31:52 +05:30
parent 906ddf08cb
commit 9fdbb65519
7 changed files with 374 additions and 90 deletions

View File

@ -265,5 +265,8 @@ defined('PDLOGSID') OR define('PDLOGSID','pd_trigger_id');
defined('PDAPPLICANTSLOGS') OR define('PDAPPLICANTSLOGS','h_pd_co_applicants_details');
defined('PDAPPLICANTSLOGSID') OR define('PDAPPLICANTSLOGSID','pd_co_applicant_trigger_id');
defined('PDSCHEDULE') OR define('PDSCHEDULE','t_pd_schedule');
defined('PDSCHEDULEID') OR define('PDSCHEDULEID','pd_schedule_id');

View File

@ -71,9 +71,13 @@ $route['saveBranch'] = 'Common_Masters_Controller/saveBranch';
$route['getListOfMaster'] = 'Common_Masters_Controller/getListOfMaster';
$route['saveMaster'] = 'Common_Masters_Controller/saveMaster';
$route['savePDAllocationType'] = 'Common_Masters_Controller/savePDAllocationType';
$route['savePDNotifications'] = 'Common_Masters_Controller/savePDNotifications';
$route['savePDNotification'] = 'Common_Masters_Controller/savePDNotification';
$route['getPDNotificationsList'] = 'Common_Masters_Controller/getPDNotificationsList';
$route['saveCompany'] = 'Common_Masters_Controller/saveCompany';
$route['saveCompany'] = 'Common_Masters_Controller/saveCompany';
$route['getListOfPDTeam'] = 'Common_Masters_Controller/getListOfPDTeam';
$route['getListOfPDTeamMap'] = 'Common_Masters_Controller/getListOfPDTeamMap';
$route['savePDTeam'] = 'Common_Masters_Controller/savePdTeam';
$route['deletePdTeamMapping'] = 'Common_Masters_Controller/deletePdTeamMapping';
@ -101,10 +105,11 @@ $route['updateAnswerStatus'] = 'Question_Management_Controller/updateAnswerStatu
$route['(listAllEntites/:any)'] = 'Entity_Management_Controller/listAllEntites/';
$route['saveNewEntity'] = 'Entity_Management_Controller/saveNewEntity';
$route['saveExistEntity'] = 'Entity_Management_Controller/saveExistEntity';
$route['getLocationHierarchy'] = 'Entity_Management_Controller/getLocationHierarchy';
//PD RELATED
$route['triggerNewPD'] = 'PD_Controller/triggerNewPD';
$route['updateExistPD'] = 'PD_Controller/updateExistPD';
$route['updatePDMaster'] = 'PD_Controller/updatePDMaster';
$route['(listLessPDDetails/:any)'] = 'PD_Controller/listLessPDDetails/';
$route['getListOfProducts'] = 'PD_Controller/getListOfProducts';
$route['getListOfLenders'] = 'PD_Controller/getListOfLenders';
@ -112,4 +117,6 @@ $route['getListOfCustomerSegments'] = 'PD_Controller/getListOfCustomerSegments';
$route['getListOfPDAllocationTypes'] = 'PD_Controller/getListOfPDAllocationTypes';
$route['getListOfStatesAndCities'] = 'PD_Controller/getListOfStatesAndCities';
$route['getFullPDDetails'] = 'PD_Controller/getFullPDDetails';
$route['updatePDDocs'] = 'PD_Controller/updatePDDocs';
$route['updatePDApplicants'] = 'PD_Controller/updatePDApplicants';

View File

@ -380,7 +380,7 @@ class Common_Masters_Controller extends REST_Controller {
$result = $this->Common_Masters_Model->saveRecords($records,'COMPANY');
$result = $this->Common_Masters_Model->saveRecords($records,COMPANY);
if(count($result) > 0)
{

View File

@ -55,7 +55,12 @@ class Entity_Management_Controller extends REST_Controller {
if($this->post('entity')){ $entity = $this->post('entity'); }
if($this->post('entity_child')){ $entity_child = $this->post('entity_child'); }
if(array_key_exists('entity_child',$entity))
{
$entity_child = $entity['entity_child'];
unset($entity['entity_child']);
}
if($entity != "")
{
@ -66,7 +71,7 @@ class Entity_Management_Controller extends REST_Controller {
{
foreach($entity_child as $child)
{
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'createdon'=>$child['createdon'],'fk_createdby'=>$child['fk_createdby']);
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'createdon'=>$entity['createdon'],'fk_createdby'=>$entity['fk_createdby']);
$this->User_Management_Model->saveRecords($entity_child_array,ENTITYCHILD);
}
}
@ -92,7 +97,7 @@ class Entity_Management_Controller extends REST_Controller {
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_NOT_MODIFIED);
$this->response($data,REST_Controller::HTTP_OK);
}
@ -116,7 +121,11 @@ class Entity_Management_Controller extends REST_Controller {
if($this->post('entity')){ $entity = $this->post('entity'); }
if($this->post('entity_child')){ $entity_child = $this->post('entity_child'); }
if(array_key_exists('entity_child',$entity))
{
$entity_child = $entity['entity_child'];
unset($entity['entity_child']);
}
if($entity != "")
{
@ -128,7 +137,7 @@ class Entity_Management_Controller extends REST_Controller {
{
foreach($entity_child as $child)
{
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'updatedon'=>$child['updatedon'],'fk_updatedby'=>$child['fk_updatedby'],'isactive'=>$child['isactive']);
$entity_child_array = array('contact_person'=>$child['contact_person'],'contact_email'=>$child['contact_email'],'contact_mobile_no'=>$child['contact_mobile_no'],'fk_entity_id'=>$entity_id,'updatedon'=>$entity['updatedon'],'fk_updatedby'=>$entity['fk_updatedby'],'isactive'=>$child['isactive']);
$where_condition_array = array('entity_child_id'=>$child['entity_child_id']);
$this->User_Management_Model->updateRecords($entity_child_array,ENTITYCHILD,$where_condition_array);
}
@ -147,7 +156,7 @@ class Entity_Management_Controller extends REST_Controller {
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_NOT_MODIFIED);
$this->response($data,REST_Controller::HTTP_OK);
}
@ -159,6 +168,66 @@ class Entity_Management_Controller extends REST_Controller {
}
/*
* Get Location Hierarchy as Region,state,city, and branch - wrapped as one array
*/
public function getLocationHierarchy_get()
{
$fields = array('region_id','name as region_name');
$where_condition_array = array('isactive' => 1);
$region_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,REGIONS);
if(count($region_data))
{
foreach($region_data as $region_key => $region)
{
$fields = array('state_id','name as state_name','code');
$where_condition_array = array('isactive' => 1,'fk_region_id'=>$region['region_id']);
$state_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,STATE);
if(count($state_data))
{
foreach($state_data as $state_key => $state)
{
$fields = array('city_id','name as city_name');
$where_condition_array = array('isactive' => 1,'fk_state_id' => $state['state_id']);
$city_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,CITY);
if(count($city_data))
{
foreach($city_data as $city_key => $city)
{
$fields = array('branch_id','name as branch_name');
$where_condition_array = array('isactive' => 1,'fk_city_id' => $city['city_id']);
$branch_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,BRANCH);
$city_data[$city_key]['branch_data'] = $branch_data;
}
$state_data[$state_key]['city_data'] = $city_data;
}
}
$region_data[$region_key]['state_data'] = $state_data;
}
}
}
if(count($region_data))
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = $region_data;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Records Not Found';
$this->response($data,REST_Controller::HTTP_OK);
}
}

View File

@ -278,8 +278,8 @@ class PD_Controller extends REST_Controller {
{
$tempdoc = $file['pddocuments']['tmp_name'];
$tempdocname = $file['pddocuments']['name'];
$bucketname = $pd_details['fk_lender_id'].$pd_id;
$key = $pd_id ;
$bucketname = 'lender'.$pd_details['fk_lender_id'];
$key = 'pd'.$pd_id.'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
@ -317,7 +317,7 @@ class PD_Controller extends REST_Controller {
if($pd_id != null || $pd_id != '' && $count != 0)
{
// CALL pdnotification Helper function to send pd alerts @ params pdid,pdstatus
//PDALERTS::pdnotification($pd_id,$pd_details['fk_pd_status']);
PDALERTS::pdnotification($pd_id);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@ -335,29 +335,16 @@ class PD_Controller extends REST_Controller {
public function updateExistPD_post()
/*
*
*Update PD trigger Master Details(Web app only) from PD trigger Edit/view page
*/
public function updatePDMaster_post()
{
$pd_details = $this->post('pd_details');
$pd_applicant_details = $this->post('pd_applicant_details');
$count = 0;
$where_condition_array = array('pd_id' => $pd_details['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($pd_details,PDTRIGGER,$where_condition_array);
if($pd_id_modified != null || $pd_id_modified != '')
{
foreach($pd_applicant_details as $pd_applicant_detail)
{
$where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']);
$co_applicant_id_modified = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array);
if($co_applicant_id_modified != null || $co_applicant_id_modified != '')
{
$count = $count + 1;
}
}
}
if($pd_id_modified != null || $pd_id_modified != '' && $count != 0)
{
$data['dataStatus'] = true;
@ -375,10 +362,225 @@ class PD_Controller extends REST_Controller {
}
/*
*
*Update PD trigger Applicats Details(Web app only) from PD trigger Edit/view page
*/
public function updatePDApplicants_post()
{
$pd_applicant_details = $this->post('pd_applicant_details');
$count = 0;
$pd_id = 0;
foreach($pd_applicant_details as $pd_applicant_detail)
{
if($pd_applicant_detail['pd_co_applicant_id'] != null || $pd_applicant_detail['pd_co_applicant_id'] != "")
{
$pd_id = $pd_applicant_detail['fk_pd_id'];
$where_condition_array = array('pd_co_applicant_id' => $pd_applicant_detail['pd_co_applicant_id']);
$co_applicant_id = $this->PD_Model->updateRecords($pd_applicant_detail,PDAPPLICANTSDETAILS,$where_condition_array);
if($co_applicant_id != null || $co_applicant_id != '')
{
$count = $count + 1;
}
}
else
{
$pd_applicant_detail['fk_pd_id'] = $pd_id;
$co_applicant_id = $this->PD_Model->saveRecords(PDAPPLICANTSDETAILS,$pd_applicant_detail);
if($co_applicant_id != null || $co_applicant_id != '')
{
$count = $count + 1;
}
}
}
if($count != 0 && count($pd_applicant_details) == $count)
{
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*
*Update PD Documents details from PD Trigger(Web application only) edit/view page
*/
public function updatePDDocs_post()
{
$pd_document_titles = json_decode($this->post('pd_document_titles'),true);
if(count($pd_document_titles))
{
//Get Lender id from PD Master
$pdid = $pd_document_titles[0]['fk_pd_id'];
$fields = array('fk_lender_id');
$where_condition_array = array('pd_id' => $pdid);
$lender_id = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDTRIGGER);
foreach($pd_document_titles as $iter => $doc)
{
if($doc['pd_document_id'] != null || $doc['pd_document_id'] != '')
{
$tempdoc = $_FILES['pddocuments']['tmp_name'][$iter];
$tempdocname = $_FILES['pddocuments']['name'][$iter];
$bucketname = 'lender'.$lender_id[0]['fk_lender_id'];
$key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
//delete old doc from s3 bucket_data
$fields = array('pd_document_name');
$where_condition_array1 = array('pd_document_id' => $doc['pd_document_id']);
$old_doc_name = $this->PD_Model->selectCustomRecords($fields,$where_condition_array1,PDDOCUMENTS);
if($old_doc_name != "" || $old_doc_name != null)
{
$key = 'pd'.$doc['fk_pd_id'].'/'.$old_doc_name[0]['pd_document_name'];
$this->aws_s3->deleteSingleObjFromBucket($bucketname,$key);
}
//Update entry in PD Doc table
$record_data = array('pd_document_name'=>$tempdocname);
$where_condition_array = array('pd_document_id' => $doc['pd_document_id']);
$this->PD_Model->updateRecords($record_data,PDDOCUMENTS,$where_condition_array);
}
}
else
{
$tempdoc = $_FILES['pddocuments']['tmp_name'][$iter];
$tempdocname = $_FILES['pddocuments']['name'][$iter];
$bucketname = 'lender'.$lender_id;
$key = 'pd'.$doc['fk_pd_id'].'/'.$tempdocname ;
$sourcefile = $tempdoc;
$bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile);
$s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data);
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
$record_data = array('fk_pd_id' => $pdid,'pd_document_title'=>$doc['pd_document_title'],'pd_document_name'=>$tempdocname);
$this->PD_Model->saveRecords($record_data,PDDOCUMENTS);
}
}
}
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*Allocate PD to Some PD officer
*/
public function allocatePD_post()
{
$records = $this->post('records');
if($records['fk_pd_allocated_to'] != "" || $records['fk_pd_allocated_to'] != null)
{
$records['fk_pd_status'] = ALLOCATED;
}
$where_condition_array = array('pd_id' => $records['pd_id']);
$pd_id_modified = $this->PD_Model->updateRecords($records,PDTRIGGER,$where_condition_array);
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Not Updated! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
/*
*Schedule PD by PD officer(only on Manual Schedule)
*/
public function schdulePD_post()
{
$records = $this->post('records');
if($records['schedule_time'] != "" || $records['schedule_time'] != null)
{
$id = $this->PD_Model->saveRecords($records,PDSCHEDULE);
if($id != '' || $id != null)
{
$where_condition_array = array('pd_id' => $records['fk_pd_id']);
$temp_array = array('fk_pd_status' => SCHEDULED,'fk_updatedby'=>$records['fk_scheduled_by'],'updatedon'=>$records['createdon']);
$pd_id_modified = $this->PD_Model->updateRecords($temp_array,PDTRIGGER,$where_condition_array);
if($pd_id_modified != "" || $pd_id_modified != null)
{
PDALERTS::pdnotification($records['fk_pd_id']);
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
$data['records'] = true;
$this->response($data,REST_Controller::HTTP_OK);
}
else
{
$data['dataStatus'] = false;
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
$data['msg'] = 'Not Updated! Try Later';
$this->response($data,REST_Controller::HTTP_OK);
}
}
}
}
/*
*GET List of PD officers for PD edit/view page for manual allocation
*@param pd
*/
public function getListPDOfficers_post()
{
//select list of pd officers based on pd type, product, customer segment, and team from table (t_pd_officiers_details) and choose minimun allocated one and assign pd Officer and change status form TRIGGERED to ALLOCATED
$fields = array('fk_user_id,allocated');
$where_condition_array = array('fk_pd_type_id' => $pd_details['fk_pd_type'],'fk_team_id' => $temp_city_id[0]['fk_team_id'],'fk_customer_segment' => $pd_details['fk_customer_segment'],'fk_product_id' => $pd_details['fk_product_id'],'isactive' => 1);
$list_of_pd_officers = $this->PD_Model->selectCustomRecords($fields,$where_condition_array,PDOFFICIERSDETAILS);
}
/* PD_Triggerd and PD_Co_Applocants Details only for Listing Page
@param page/offset
@param limit
@param sorting order(ASC/DESC)
@param cid for category_id for filter question with category wise.
*/
public function listLessPDDetails_get()
{

View File

@ -119,70 +119,72 @@ class PDALERTS
*/
if(count($core_details))
{
// if(count($core_details))
// {
//pd cretaed entity type is 2 then sent mail only for that email
if($core_details['created_entity_type'] == 2) // 2 - Lender Type
{
if($pd_notification_configs['mail_lender'] == 1)
{
array_push($email_ids_to_send_notification,$core_details['created_mail']);
}
}
else //sent email to all lender contacts associated to lender id
{
if($pd_notification_configs['mail_lender'] == 1)
{
// //pd cretaed entity type is 2 then sent mail only for that email
// if($core_details['created_entity_type'] == 2) // 2 - Lender Type
// {
// if($pd_notification_configs['mail_lender'] == 1)
// {
// array_push($email_ids_to_send_notification,$core_details['created_mail']);
// }
// }
// else //sent email to all lender contacts associated to lender id
// {
// if($pd_notification_configs['mail_lender'] == 1)
// {
$CI->db->SELECT("contact_email");
$CI->db->FROM(ENTITYCHILD);
$CI->db->WHERE("fk_entity_id",$core_details['fk_lender_id']);
$lender_emails = $CI->db->GET()->result_array();
if(count($lender_mobile_nos))
{
foreach($lender_emails as $lender_email)
{
array_push($email_ids_to_send_notification,$lender_email);
}
}
}
}
// $CI->db->SELECT("contact_email");
// $CI->db->FROM(ENTITYCHILD);
// $CI->db->WHERE("fk_entity_id",$core_details['fk_lender_id']);
// $lender_emails = $CI->db->GET()->result_array();
// if(count($lender_mobile_nos))
// {
// foreach($lender_emails as $lender_email)
// {
// array_push($email_ids_to_send_notification,$lender_email);
// }
// }
// }
// }
//add pd officer email
if($pd_notification_configs['mail_pdofficer'] == 1)
{
array_push($email_ids_to_send_notification,$core_details['allocated_email']);
}
// //add pd officer email
// if($pd_notification_configs['mail_pdofficer'] == 1)
// {
// array_push($email_ids_to_send_notification,$core_details['allocated_email']);
// }
//add pd incharge emails
if($pd_notification_configs['mail_pdincharge'] == 1)
{
$CI->db->DISTINCT();
$CI->db->SELECT("email");
$CI->db->FROM(USERPROFILE." as USERPROFILE");
$CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1");
$CI->db->WHERE("USERPROFILEROLES.user_role",'PDINCHAGRE');
$inchagre_email = $CI->db->GET()->result_array();
if(count($inchagre_email))
{
foreach($inchagre_email as $email)
{
array_push($email_ids_to_send_notification,$email);
}
}
}
// //add pd incharge emails
// if($pd_notification_configs['mail_pdincharge'] == 1)
// {
// $CI->db->DISTINCT();
// $CI->db->SELECT("email");
// $CI->db->FROM(USERPROFILE." as USERPROFILE");
// $CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1");
// $CI->db->WHERE("USERPROFILEROLES.user_role",'PDINCHAGRE');
// $inchagre_email = $CI->db->GET()->result_array();
// if(count($inchagre_email))
// {
// foreach($inchagre_email as $email)
// {
// array_push($email_ids_to_send_notification,$email);
// }
// }
// }
//$msg = "PD for Lender Applicant ID:".$core_details['lender_applicant_id']."has been".$core_details['pd_status_name']; // status base configurable
foreach($email_ids_to_send_notification as $email)
{
// //$msg = "PD for Lender Applicant ID:".$core_details['lender_applicant_id']."has been".$core_details['pd_status_name']; // status base configurable
// foreach($email_ids_to_send_notification as $email)
// {
//email SES have to config
//$CI->aws_ses->sendMail($email);
}
// //email SES have to config
// //$CI->aws_ses->sendMail($email);
// }
}
// }
/*End of Email Functionality*/
}

View File

@ -104,12 +104,13 @@ class PD_Model extends SPARQ_Model {
{
$bucket_name = 'lender'.$lender_id[0]['fk_lender_id'];
$profilepics3path = 'pd'.$pdid;
foreach($document_lists as $key => $value)
{
$profilepics3path .=$value['pd_document_name'];
$profilepics3path = 'pd'.$pdid.'/'.$value['pd_document_name'];
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$profilepics3path,'+30 minutes');
$document_lists['doc_url'] = $singed_uri;
$document_lists[$key]['doc_url'] = $singed_uri;
}
}