diff --git a/api/application/config/routes.php b/api/application/config/routes.php
index 1a2ef931..95ac4609 100644
--- a/api/application/config/routes.php
+++ b/api/application/config/routes.php
@@ -256,5 +256,5 @@ $route['(getRawData/:any)'] = 'Data_Dump_Controller/getRawData';
$route['loadSalesPDTemplate'] = 'Sales_PD_Controller/loadSalesPDTemplate';
$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';
diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php
index 5fbf8b2e..7c44b47a 100644
--- a/api/application/controllers/PD_Controller.php
+++ b/api/application/controllers/PD_Controller.php
@@ -5952,8 +5952,8 @@ public function getPDFormDetailsJSON_post()
file_put_contents(APPPATH.'/views/js/phantomchart.js',$exact_script,LOCK_EX);
$str = 'phantomjs '.APPPATH.'/views/js/phantomchart.js';
- // exec($str,$ou);
- // exec('phantom.exit();');
+ exec($str,$ou);
+ exec('phantom.exit();');
//print_r($ou);
diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php
index 4680c1a9..a029daf0 100644
--- a/api/application/controllers/Sales_PD_Controller.php
+++ b/api/application/controllers/Sales_PD_Controller.php
@@ -55,36 +55,41 @@ class Sales_PD_Controller extends REST_Controller {
$applicant_name = '';
$applicant_id = '';
$officer = '';
- // foreach ($records['pd_json']['sections'] as $key => $value)
- // {
- // if($value['section_id'] == 1)
- // {
- // foreach ($value as $g_key => $g_value)
- // {
- // if($g_value['question_key'] == 'application_id')
- // {
- // $applicant_name = $g_value['answer_value'];
- // }
- // if($g_value['question_key'] == 'person_met_during_visit')
- // {
- // $applicant_id = '';
- // }
- // }
- // }
- // if($value['section_id'] == 8)
- // {
- // echo "OFFICE";
- // }
- // }
- //print_r($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
- //$json_data = (json_decode($records['pd_json']['sections'][0],true));
- // print_r($records['pd_json']['sections'][0]['questions']);die();
+ foreach ($records['pd_json'] as $key => $value)
+ {
+ //print_r($value);die();
+ if($value['section_id'] == 1)
+ {
+ foreach ($value['questions'] as $g_key => $g_value)
+ {
+ if($g_value['question_key'] == 'application_id')
+ {
+ $applicant_id = $g_value['answer_value'];
+ }
+ if($g_value['question_key'] == 'person_met_during_visit')
+ {
+ $applicant_name = $g_value['answer_value'];
+
+ }
+ }
+ }
+ if($value['section_id'] == 8)
+ {
+ foreach ($value['questions'] as $g_key => $g_value)
+ {
+ if($g_value['question_key'] == 'name_of_sales_team_member')
+ {
+ $officer = $g_value['answer_value'];
+ }
+
+ }
+ }
+ }
+
+ $records['applicant_id'] = $applicant_name;
+ $records['applicant_name'] = $applicant_id;
+ $records['officer_name'] = $officer;
$id = null;
if(!$records['sales_pd_id'])
{
@@ -134,7 +139,11 @@ class Sales_PD_Controller extends REST_Controller {
if($sales_pd_data)
{
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$sales_pd_data[0]['lender_id'];
- $key = 'sales_pd/'.$sales_pd_id.'/'.$sales_pd_id.'.pdf';
+ $pdf_name = strtolower(trim($sales_pd_data[0]['applicant_name']));
+ $pdf_name = str_replace(' ', '_', $pdf_name);
+
+
+ $key = 'sales_pd/'.$sales_pd_id.'/'.$pdf_name.'.pdf';
if(!file_exists($this->external_path.'/sales_pd/'.$sales_pd_id))
{
@@ -144,20 +153,16 @@ class Sales_PD_Controller extends REST_Controller {
if(!$sales_pd_data[0]['is_pdf'] || $sales_pd_data[0]['is_edited'])
{
- //echo 'FIRST';
- //Get Data from DB and process
- //print_r(json_decode($sales_pd_data[0]['pd_json'],true));die();
+
$json_data = (json_decode($sales_pd_data[0]['pd_json'],true));
$view_data = array();
foreach ($json_data as $sec_key => $section)
{
$view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section);
}
- //die();
- //print_r($json_data);die();
-
- //End of JSON processing
- $view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr'];
+
+ //$view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr'];
+ $view_name = $sales_pd_data[0]['short_name'];
$html_content = $this->load->view('sale_pd_templates/'.$view_name,$view_data,true);
//echo $html_content;die();
$pdf_doc = $this->pdfgenerator->generate($html_content, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait");
@@ -170,9 +175,8 @@ class Sales_PD_Controller extends REST_Controller {
if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200)
{
- //echo 'SUCESS';
- $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1,'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
-
+
+ $this->Sales_PD_Model->updateRecords(array('is_pdf' => 1, 'is_edited' => 0),SALES_PD_DATA,array('sales_pd_id' => $sales_pd_id));
$singed_uri = $this->aws_s3->getSingleObjectInaBucketAsSignedURI($bucket_name,$key,'30 minutes');
$data['dataStatus'] = true;
$data['status'] = REST_Controller::HTTP_OK;
@@ -195,8 +199,8 @@ class Sales_PD_Controller extends REST_Controller {
public function listSalesPD_get()
{
- $lender_id = $this->uri->segment(2);//sales_pd_id, pd_json, lender_id, product_id, createdby, updatedby, createdon, updatedon, isactive, is_pdf, is_edited, length(pd_json)
-
+ $lender_id = $this->uri->segment(2);
+ $user_id = $this->uri->segment(3);
$columns = array('SALES_PD_DATA.sales_pd_id','SALES_PD_DATA.applicant_name','SALES_PD_DATA.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');
$table = SALES_PD_DATA.' as SALES_PD_DATA';
$joins = array(
@@ -213,6 +217,10 @@ class Sales_PD_Controller extends REST_Controller {
{
$where_condition_array = array('SALES_PD_DATA.lender_id' => $lender_id);
}
+ if($user_id && is_numeric($user_id))
+ {
+ $where_condition_array = 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);
if(count($sales_pd_data))
@@ -270,6 +278,10 @@ class Sales_PD_Controller extends REST_Controller {
{
$temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']);
}
+ if(isset($question['subfield_key']))
+ {
+ $temp_array[ $question['question_key'] ] = $question['subfield_value'];
+ }
}
else if($question['is_repeatable'] == 1 )
{
@@ -285,6 +297,8 @@ class Sales_PD_Controller extends REST_Controller {
//print_r($q_value);die();
//echo $group_key;
$group_temp[ $q_value['question_key'] ] = $q_value['answer_value'];
+
+ if(isset($q_value['subfield_key'])){ $group_temp[ $q_value['question_key'] ] = $q_value['"subfield_value"']; }
//print_r($group_temp);
}
//print_r($group_temp);
@@ -299,7 +313,8 @@ class Sales_PD_Controller extends REST_Controller {
foreach ($question['questions_group'] as $group_key => $group_value)
{
- $temp_array[ $group_value['questions'][0]['question_key'] ][] = $group_value['questions'][0]['answer_value'];
+ $temp_array[ $group_value['questions'][0]['question_key'] ][] = isset($group_value['questions'][0]['subfield_key']) ? $group_value['questions'][0]['subfield_value'] : $group_value['questions'][0]['answer_value'];
+
}
}
}
diff --git a/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php b/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php
deleted file mode 100644
index b8eb5161..00000000
--- a/api/application/views/sale_pd_templates/OMONEYWISE_LFMP.php
+++ /dev/null
@@ -1,256 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Personal Discussion Sheet - LFMP (For Sales Team)
-
-
- Application ID
- SAMPLEDATA
-
-
- Name of the Company/Firm
- SAMPLEDATA
-
-
- Name of Person Met during visit
- SAMPLEDATA
-
-
- Address Visited
- SAMPLEDATA
-
-
- City
- SAMPLEDATA
- State
- SAMPLEDATA
- PIN
- SAMPLEDATA
-
-
-
-
-
-
-
- Fund Requirement
-
-
- Loan Amount Applied for (Rs)
- SAMPLEDATA
- Total Fund Requirement (Rs)
- SAMPLEDATA
-
-
- Loan Tenure (Months)
- SAMPLEDATA
- Loan Purpose (End-Use)
- SAMPLEDATA
-
-
-
-
-
-
- Details of Key Stakeholders in the Business
-
-
- Name
- Share Holding
- Vintage in Current Biz
- Total Work Exp
- Previous Experience Details
- Started Biz (Yes / No)
-
-
- Kumaralingam
- 100%
- 5yrs & 2 Mns
- 10 yrs & 6 Mns
- >SAMPLEDATA >SAMPLEDATA SAMPLEDATASAMPLEDATA
- Yes
-
-
-
- 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 1
- FY 2
- FY 3
-
-
- Sales / Revenue (Rs)
- SAMPLEDATA
- SAMPLEDATA
- SAMPLEDATA
- SAMPLEDATA
-
-
- Net Profit / (Net Loss) (Rs)
- SAMPLEDATA
- SAMPLEDATA
- SAMPLEDATA
- SAMPLEDATA
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/api/application/views/sale_pd_templates/SMC_LFMP.php b/api/application/views/sale_pd_templates/SMC.php
similarity index 65%
rename from api/application/views/sale_pd_templates/SMC_LFMP.php
rename to api/application/views/sale_pd_templates/SMC.php
index 3380c921..e7d5c770 100644
--- a/api/application/views/sale_pd_templates/SMC_LFMP.php
+++ b/api/application/views/sale_pd_templates/SMC.php
@@ -128,7 +128,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
-
+
@@ -148,18 +148,19 @@ defined('BASEPATH') OR exit('No direct script access allowed');
+
- Details of Key Stakeholders in the Business
+ Details of Key Stakeholders in the Business
- Name
+ Name
Share Holding
- Vintage in Current Biz
+ Vintage in Current Business
Total Work Exp
Previous Experience Details
- Started Biz (Yes / No)
+ Started Business
'.$section3_value['vintage_in_current_biz'].''.
''.$section3_value['total_work_exp'].' '.
''.$section3_value['previous_experience_details'].' '.
- ''.$section3_value['started_biz'].' '.
+ ''.$section3_value['started_biz'].' '.
'';
}
@@ -190,14 +191,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
-
+
Financial Information
- Name of the Company / Firm whose financials are noted >>
-
+ Name of the Company / Firm whose financials are noted
+
@@ -249,11 +250,12 @@ defined('BASEPATH') OR exit('No direct script access allowed');
Net Profit or (Net Loss) to Sales %
$fy_value)
{
if(is_numeric($fy_key))
{
- echo ''.($fy_value['net_profit'] ).' ';
+ echo ''.round((($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ),2).' ';
}
}
?>
@@ -262,11 +264,25 @@ defined('BASEPATH') OR exit('No direct script access allowed');
% (↑ /↓) in Sales over PY
$fy_value)
{
if(is_numeric($fy_key))
{
- echo 'NA ';
+
+
+ if($fy_key == 0)
+ {
+ echo 'NA ';
+ }
+ else
+ {
+ //echo $pre_year_sales;
+ $sales_over_py = round( ((($fy_value['sales_revenue'] - $pre_year_sales) / $pre_year_sales ) * 100),2);
+ echo ''. (($sales_over_py > 0 )? '↑ ' : '↓ ').' ( ' . $sales_over_py. ' ) ';
+
+ }
+ $pre_year_sales = $fy_value['sales_revenue'];
}
}
?>
@@ -275,11 +291,22 @@ defined('BASEPATH') OR exit('No direct script access allowed');
% (↑ /↓) in Net Profit over PY
$fy_value)
{
if(is_numeric($fy_key))
{
- echo 'NA ';
+ if($fy_key == 0)
+ {
+ echo 'NA ';
+ }
+ else
+ {
+ $net_profit_over_py = round( ((($fy_value['net_profit'] - $pre_year_net_profit) / $pre_year_net_profit ) * 100),2);
+ echo ''. (($net_profit_over_py > 0 )? '↑ ' : '↓ ').' ( ' . $net_profit_over_py. ' ) ';
+
+ }
+ $pre_year_net_profit = $fy_value['net_profit'];
}
}
?>
@@ -288,25 +315,39 @@ defined('BASEPATH') OR exit('No direct script access allowed');
% (↑ /↓) in Net Profit % over PY
$fy_value)
{
if(is_numeric($fy_key))
{
- echo 'NA ';
+ if($fy_key == 0)
+ {
+ echo 'NA ';
+ }
+ else
+ {
+ $year_net_pro_loss_per_over_py = round( ((( (($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 ) - $pre_year_net_pro_loss_per) / $pre_year_net_pro_loss_per ) * 100),2);
+ echo ''. (($year_net_pro_loss_per_over_py > 0 )? '↑ ' : '↓ ').' ( ' . $year_net_pro_loss_per_over_py. ' ) '; //(($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 )
+
+ }
+ $pre_year_net_pro_loss_per = (($fy_value['net_profit'] / $fy_value['sales_revenue'] ) * 100 );
}
}
?>
+
+
+
- Income to be Considered (Rs Per Annum) >>
-
- Income Considered (Rs Per Mth) >>
+ Income to be Considered (Rs Per Annum)
+
+ Income Considered (Rs Per Mth)
- Income assessment Program Recommended >>
+ Income assessment Program Recommended
- Fixed Obligations (Rs per month) >>
+ Fixed Obligations (Rs per month)
@@ -316,41 +357,43 @@ if(isset($section6))
{
?>
+
Property Information
- Property Address (With Landmark & PIN)
-
+ Property Address (With Landmark & PIN)
+
- Property Type
+ Property Type
- Occupancy Status
-
+ Occupancy Status
+
- >Permitted Property Usage
+ Permitted Property Usage
- Actual Property Usage
-
+ Actual Property Usage
+
- Built-Up Area (Sq. Ft.)
+ Built-Up Area (Sq. Ft.)
- Approx Mkt. Val (Rs)
-
+ Approx Mkt. Val (Rs)
+
- Property Ownership Status (Enter the names of the Property Owner(s) and their relationships)
-
+ Property Ownership Status (Enter the names of the Property Owner(s) and their relationships)
+
+
@@ -369,7 +412,7 @@ if(isset($section6))
- Any Other remarks >>
+ Any Other remarks
@@ -378,35 +421,36 @@ if(isset($section6))
- Name of Sales Team Member >>
+ Name of Sales Team Member
- Designation of Sales Team Member >>
+ Designation of Sales Team Member
- Date of PD Visit >>
+ Date of PD Visit
- Signature of PD Officer >>
+ Signature of PD Officer
-
- Photograph`s
-
-
+
+
+ $img_value)
{
if(!is_array($img_value))
{
- echo ''.''.$img_key.' '.' ';
+ array_push($photos, array('name' => $img_key, 'img' => $img_value)) ;
}
else
{
@@ -414,16 +458,38 @@ if(isset($section6))
{
if($value)
{
- echo ''.''.$img_key.'-'.($key+1).' '.' ';
+ array_push($photos, array('name' => $img_key, 'img' => $value)) ;
}
}
}
}
+ }
+
+ //print_r($photos);die();
+?>
+
+
+ 'Selfie with person met','approach_to_pd_location' => 'Approach to pd location','name_board_seen' => 'Name board seen', 'stock_image' => 'Stock image','workplace_interior_image' => 'Workplace interior image');
+ if(count($photos))
+ {
+ echo '';
+
+ foreach ($photos as $p_key => $p_value)
+ {
+
+ if(!($iter % 5)) { echo ''; }
+ echo ' '.$photo_names [ $p_value['name'] ].' ';
+
+ if(!($iter % 5) && $iter != 0) { echo ' '; }
+ $iter++;
+ }
+ echo '
';
}
?>
-
-
+