From 1a0a1da1b13a6a56ef593f66273ef54a34adb14a Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Wed, 13 Nov 2019 21:12:26 +0530 Subject: [PATCH] SMC SALEPD VIEW --- api/application/config/constants.php | 3 + api/application/config/routes.php | 7 +- api/application/controllers/PD_Controller.php | 12 +- .../controllers/Sales_PD_Controller.php | 145 +++++++ .../helpers/external_dir_check_helper.php | 2 +- api/application/models/Sales_PD_Model.php | 15 + .../sale_pd_templates/MONEYWISE_LFMP.php | 371 ++++++++++++++++++ .../sale_pd_templates/OMONEYWISE_LFMP.php | 256 ++++++++++++ 8 files changed, 801 insertions(+), 10 deletions(-) create mode 100644 api/application/controllers/Sales_PD_Controller.php create mode 100644 api/application/models/Sales_PD_Model.php create mode 100644 api/application/views/sale_pd_templates/MONEYWISE_LFMP.php create mode 100644 api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 18cc4bfa..0ad4d91f 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -605,5 +605,8 @@ defined('D_BUSINESS_FORM') OR define('D_BUSINESS_FORM','d_business_form'); defined('D_BUSINESS_RELATINSHIP') OR define('D_BUSINESS_RELATINSHIP','d_business_relatinship'); defined('D_BUSINESS_PARTNERS') OR define('D_BUSINESS_PARTNERS','d_business_partners'); +defined('SALESPDTEMPLATE') OR define('SALESPDTEMPLATE','m_sales_pd_template'); +defined('SALES_PD_DATA') OR define('SALES_PD_DATA','t_sales_pd_data'); + diff --git a/api/application/config/routes.php b/api/application/config/routes.php index d16728d6..7062f4f8 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -252,7 +252,8 @@ $route['testCognito'] = 'Branch_Controller/testCognito'; $route['(getRawData/:any)'] = 'Data_Dump_Controller/getRawData'; -//$route['(getPDReportHTML/:any)'] = 'Welcome/getPDReportHTML'; -//miscellanous -//$route['showBusinessScorecard'] = 'PD_Controller/'; +$route['loadSalesPDTemplate'] = 'Sales_PD_Controller/loadSalesPDTemplate'; +$route['saveSalesPD'] = 'Sales_PD_Controller/saveSalesPD'; +$route['(downloadSalesPDReport/:any)'] = 'Sales_PD_Controller/getSalesPDReport'; + diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index f77e904f..94227712 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -4801,7 +4801,7 @@ public function getPDFormDetailsJSON_post() //Get Common Images $data['pd_images']['common_images'] = $this->PD_Model->getSignedPDDocsURL($pdid,null,null,'common',null,'report'); $temp = 'DEFAULT DATA'; - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MONEYWISE' && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'SMC' && $data['pd_master_details'][0]['product_abbr'] == 'BL')) { $temp = $this->load->view('report_templates/JSONTOREPORT_CLIX',$data,true); } @@ -5897,10 +5897,10 @@ public function getPDFormDetailsJSON_post() // die(); // foreach($u as $v) // { - $this->aws_cognito->adminSetUserPassword('harshita.nadigatla@imgc.com'); + //$this->aws_cognito->adminSetUserPassword('harshita.nadigatla@imgc.com'); // } - die(); + //die(); $is_regenerate = 0; @@ -6024,7 +6024,7 @@ public function getPDFormDetailsJSON_post() $t = ""; if(!count($add_on_pd)) { - if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'MONEYWISE' && $data['pd_master_details'][0]['product_abbr'] == 'BL')) + if($data['pd_master_details'][0]['lender_short_name'] == 'CLIX' || ($data['pd_master_details'][0]['lender_short_name'] == 'SMC' && $data['pd_master_details'][0]['product_abbr'] == 'BL')) { $t = $this->load->view('report_templates/JSONTOREPORT_CLIX',$data,true); } @@ -6240,7 +6240,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $form_array[] = array('form_id' => 1,'form_name' => 'Supplier Details'); $form_array[] = array('form_id' => 2,'form_name' => 'Client Details'); $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details'); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MONEYWISE')) && !strcasecmp($product_abbr,'BL')) + if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'SMC')) && !strcasecmp($product_abbr,'LFMP')) { $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments'); } @@ -6257,7 +6257,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $form_array[] = array('form_id' => 2,'form_name' => 'Client Details'); $form_array[] = array('form_id' => 11,'form_name' => 'Stock Details'); $form_array[] = array('form_id' => 16,'form_name' => 'Assessed Income'); - if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'MONEYWISE')) && !strcasecmp($product_abbr,'BL')) + if(!strcasecmp($lender_short_name, 'CLIX') || (!strcasecmp($lender_short_name, 'SMC')) && !strcasecmp($product_abbr,'LFMP')) { $form_array[] = array('form_id' => 23,'form_name' => 'Future Plans & Business Environments'); } diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php new file mode 100644 index 00000000..ee191f98 --- /dev/null +++ b/api/application/controllers/Sales_PD_Controller.php @@ -0,0 +1,145 @@ +load->model('Sales_PD_Model'); + $this->external_path = $this->config->item('external_data_path'); + $this->load->library('AWS_S3'); + $this->load->library('pdfgenerator'); + + } + + public function loadSalesPDTemplate_post() + { + $records = $this->post('records'); + $lender_id = $records['lender_id']; + $product = $records['product_id']; + + $template = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('lender_id' => $lender_id,'product_id' => $product,'isactive' => 1),SALESPDTEMPLATE); + if(is_array($template) && count($template)) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $template[0]; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['msg'] = 'No Tempate Found!'; + $this->response($data,REST_Controller::HTTP_OK); + + } + } + + + public function saveSalesPD_post() + { + $records = $this->post('records'); + // $pd_data = $records['pd_json']; + // $lender_id = $records['lender_id']; + // $product_id = $records['product_id']; + // $created_by = $records['created_by'];// + //sales_pd_id, pd_json, lender_id, product_id, createdby, updatedby, createdon, updatedon, isactive + $id = null; + if(!$records['sales_pd_id']) + { + $id = $this->Sales_PD_Model->saveRecords($records,SALES_PD_DATA); + } + else + { + $id = $this->Sales_PD_Model->updateRecords($records,SALES_PD_DATA,array('sales_pd_id' => $records['sales_pd_id'])); + } + + if($id) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $id; + $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); + } + + } + + public function getSalesPDReport_get() + { + $sales_pd_id = $this->uri->segment(2); + + $columns = array('SALES_PD_DATA.*','ENTITY.short_name','PRODUCT.abbr'); + $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') + ); + + $where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $sales_pd_id); + $sales_pd_data = $this->Sales_PD_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); + print_r($sales_pd_data);//die(); + + if($sales_pd_data) + { + $bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id']; + $key = 'sales_pd/'.$sales_pd_id; + + if(!file_exists($this->external_path.'/sales_pd/'.$sales_pd_id)) + { + mkdir($this->external_path.'/sales_pd/'.$sales_pd_id,0761); + } + + if(!$sales_pd_data[0]['is_pdf'] || $sales_pd_data[0]['is_edited']) + { + $view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; + $html_content = $this->load->view('sale_pd_templates/'.$view_name,$data = array(),true); + + $pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); + //End of PDF Gen using DOM PDF + $output_file = $this->external_path ."/sales_pd/" . $sales_pd_id . "/temp.pdf"; + $bytes = file_put_contents($output_file, $pdf_doc); + die(); + $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key.'/1.pdf','sourcefile'=>$this->external_path.'/sales_pd/'.$sales_pd_id.'/temp.pdf'); + $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); + + if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) + { + echo 'SUCESS'; + } + } + else + { + + } + } + + } + +} + + + \ No newline at end of file diff --git a/api/application/helpers/external_dir_check_helper.php b/api/application/helpers/external_dir_check_helper.php index c5a0199c..c876b689 100644 --- a/api/application/helpers/external_dir_check_helper.php +++ b/api/application/helpers/external_dir_check_helper.php @@ -21,7 +21,7 @@ class EXTERNAL_DIR_CHECK mkdir($path,0761); } - $array = array($path.'/ci_logs',$path.'/api_request_logs',$path.'/app_logs',$path.'/pd_reports'); + $array = array($path.'/ci_logs',$path.'/api_request_logs',$path.'/app_logs',$path.'/pd_reports',$path.'/sales_pd'); foreach ($array as $key => $value) { if(!file_exists($value)) diff --git a/api/application/models/Sales_PD_Model.php b/api/application/models/Sales_PD_Model.php new file mode 100644 index 00000000..34a78e11 --- /dev/null +++ b/api/application/models/Sales_PD_Model.php @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Personal Discussion Sheet - LFMP (For Sales Team)
Application ID SAMPLEDATA
Name of the Company/Firm SAMPLEDATA
Name of Person Met during visitSAMPLEDATA
Address VisitedSAMPLEDATA
CitySAMPLEDATAStateSAMPLEDATAPINSAMPLEDATA
+ + + + + + + + + + + + + + + + + + + +
Fund Requirement
Loan Amount Applied for (Rs)SAMPLEDATATotal Fund Requirement (Rs) SAMPLEDATA
Loan Tenure (Months)SAMPLEDATALoan Purpose (End-Use)SAMPLEDATA
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Details of Key Stakeholders in the Business
NameShare HoldingVintage in Current BizTotal Work ExpPrevious Experience DetailsStarted Biz (Yes / No)
Kumaralingam100%5yrs & 2 Mns 10 yrs & 6 Mns >SAMPLEDATA >SAMPLEDATA SAMPLEDATASAMPLEDATAYes
Brief of the Business / Service
SAMPLEDATA
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Financial Information
Name of the Company / Firm whose financials are noted >>SAMPLEDATA
Particulars of Financials as per books of Accounts (Can be captured prior to PD)FY 1FY 2FY 3
Sales / Revenue (Rs) SAMPLEDATASAMPLEDATASAMPLEDATA
Net Profit / (Net Loss) (Rs) SAMPLEDATASAMPLEDATASAMPLEDATA
Net Profit or (Net Loss) to Sales % SAMPLEDATASAMPLEDATASAMPLEDATA
% (↑ /↓) in Sales over PY SAMPLEDATASAMPLEDATASAMPLEDATA
% (↑ /↓) in Net Profit over PY SAMPLEDATASAMPLEDATASAMPLEDATA
% (↑ /↓) in Net Profit % over PY SAMPLEDATASAMPLEDATASAMPLEDATA
Income to be Considered (Rs Per Annum) >>SAMPLEDATAIncome Considered (Rs Per Mth) >>SAMPLEDATA
Income assessment Program Recommended >>SAMPLEDATAFixed Obligations (Rs per month) >>SAMPLEDATA
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Property Information
Property Address (With Landmark & PIN)SAMPLEDATA
Property TypeBungalow / Apartment / Row House / Builder Floor / Others (Specify)Occupancy StatusSelf-Occupied / Rented / Vacant
>Permitted Property UsageResidential / Commercial / IndustrialActual Property UsageResidential / Commercial / Industrial
Built-Up Area (Sq. Ft.)Approx Mkt. Val (Rs)As declared by Applicant
Property Ownership Status (Enter the names of the Property Owner(s) and their relationships) SAMPLEDATA
+ + + + + + + + + + + + + + + + + + + + + + +
Final Remarks of PD officer
Business activity seen during visit (Yes / No)SAMPLEDATALocation of workplace suits the business (Yes/No)SAMPLEDATA
Overall Assessment (Positive / Negative)SAMPLE GAVSHSRecommended ROI for the caseSAMPLEDATA
Any Other remarks >>SAMPLEDATA
+

+ + + + + + + + + + + + + + + + + + + + +
Name of Sales Team Member >>SAMPLEDATA
Designation of Sales Team Member >>SAMPLEDATA
Date of PD Visit >>SAMPLEDATA
Signature of PD Officer >>SAMPLEDATA
+ + + + + + \ No newline at end of file diff --git a/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php b/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php new file mode 100644 index 00000000..b8eb5161 --- /dev/null +++ b/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php @@ -0,0 +1,256 @@ + + + + + + + + + + + + +
+ + +
+
+ Powered by PDGenie +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Personal Discussion Sheet - LFMP (For Sales Team)
Application ID SAMPLEDATA
Name of the Company/Firm SAMPLEDATA
Name of Person Met during visitSAMPLEDATA
Address VisitedSAMPLEDATA
CitySAMPLEDATAStateSAMPLEDATAPINSAMPLEDATA
+ + + + + + + + + + + + + + + + + + + +
Fund Requirement
Loan Amount Applied for (Rs)SAMPLEDATATotal Fund Requirement (Rs) SAMPLEDATA
Loan Tenure (Months)SAMPLEDATALoan Purpose (End-Use)SAMPLEDATA
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Details of Key Stakeholders in the Business
NameShare HoldingVintage in Current BizTotal Work ExpPrevious Experience DetailsStarted Biz (Yes / No)
Kumaralingam100%5yrs & 2 Mns 10 yrs & 6 Mns >SAMPLEDATA >SAMPLEDATA SAMPLEDATASAMPLEDATAYes
Brief of the Business / Service

SAMPLEDATA
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Financial Information
Name of the Company / Firm whose financials are noted >>
SAMPLEDATA
Particulars of Financials as per books of Accounts (Can be captured prior to PD)FY 1FY 2FY 3
Sales / Revenue (Rs) SAMPLEDATA
SAMPLEDATA

SAMPLEDATA

SAMPLEDATA
Net Profit / (Net Loss) (Rs) SAMPLEDATA
SAMPLEDATA

SAMPLEDATA

SAMPLEDATA
+ + + + + +
\ No newline at end of file