From 253e2fdd89a6558edee2091d282022703458b144 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Thu, 14 Nov 2019 21:28:53 +0530 Subject: [PATCH] SALESPD ALMOST --- .../controllers/Sales_PD_Controller.php | 109 +++++-- .../views/sale_pd_templates/SMC_LFMP.php | 267 +++++++++++------- 2 files changed, 251 insertions(+), 125 deletions(-) diff --git a/api/application/controllers/Sales_PD_Controller.php b/api/application/controllers/Sales_PD_Controller.php index b91fa156..4680c1a9 100644 --- a/api/application/controllers/Sales_PD_Controller.php +++ b/api/application/controllers/Sales_PD_Controller.php @@ -52,11 +52,39 @@ class Sales_PD_Controller extends REST_Controller { public function saveSalesPD_post() { $records = $this->post('records'); + $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(); $id = null; if(!$records['sales_pd_id']) { @@ -120,17 +148,18 @@ class Sales_PD_Controller extends REST_Controller { //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) { - $data[$section['section_name'] ] = $this->processSalesPDJSON($section); + $view_data['section'.$section['section_id'] ] = $this->processSalesPDJSON($section); } //die(); - print_r($data);die(); + //print_r($json_data);die(); //End of JSON processing $view_name = $sales_pd_data[0]['short_name'].'_'.$sales_pd_data[0]['abbr']; - $html_content = $this->load->view('sale_pd_templates/'.$view_name,$data,true); - + $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"); //End of PDF Gen using DOM PDF $output_file = $this->external_path ."/sales_pd/" . $sales_pd_id . "/temp.pdf"; @@ -168,7 +197,7 @@ class Sales_PD_Controller extends REST_Controller { { $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) - $columns = array('SALES_PD_DATA.sales_pd_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'); + $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( array('table' => ENTITY. ' as ENTITY', @@ -208,15 +237,15 @@ class Sales_PD_Controller extends REST_Controller { function processSalesPDJSON($section_array) { // - echo '###'.$section_array['section_id'].'####'; - if($section_array['section_id'] == 3) + //echo '###'.$section_array['section_id'].'####'; + if($section_array['section_id'] == 9) { - //print_r($section_array); + //print_r($section_array); die(); } - if($section_array['section_id'] != 8) + if($section_array['section_id']) { - //print_r($section_array); - return $this->processSalesPDQuestions($section_array['questions']); + //print_r($section_array);//die(); + return $this->processSalesPDQuestions($section_array['questions'],$section_array['section_id']); } // die(); @@ -227,33 +256,71 @@ class Sales_PD_Controller extends REST_Controller { //} } - function processSalesPDQuestions($questions) + function processSalesPDQuestions($questions,$section_id) { $temp_array = array(); foreach ($questions as $ques_key => $question) { - if($question['is_repeatable'] == null && ($question['type'] == 1 || $question['type'] == 2 || $question['type'] == 3))//text,radio,SDD + //if($question['section_id']){} + if($question['is_repeatable'] == null && ($question['type'] == 1 || $question['type'] == 2 || $question['type'] == 3 || $question['type'] == 6))//text,radio,SDD { - $temp_array[ $question['question_key'] ] = $question['answer_value']; + + $temp_array[ $question['question_key'] ] = isset($question['answer_value']) ? $question['answer_value'] : null; + if($question['question_key'] == 'state' || $question['question_key'] == 'city' || $question['question_key'] == 'pincode') + { + $temp_array[ $question['question_key'] ] = $this->getMasterData($question['answer_value'],$question['answers']); + } } - else if($question['is_repeatable'] == 1) + else if($question['is_repeatable'] == 1 ) { //print_r($question['questions_group']);die(); - foreach ($question['questions_group'] as $group_key => $group_value) + if($section_id != 9) { - //print_r($group_value['']);die(); - foreach ($group_value['questions'] as $q_key => $q_value) + foreach ($question['questions_group'] as $group_key => $group_value) { - //print_r($q_value);die(); - $temp_array[ $group_key ][ $q_value['question_key'] ] = $q_value['answer_value']; + //print_r($group_value['questions']);//die(); + $group_temp = array(); + foreach ($group_value['questions'] as $q_key => $q_value) + { + //print_r($q_value);die(); + //echo $group_key; + $group_temp[ $q_value['question_key'] ] = $q_value['answer_value']; + //print_r($group_temp); + } + //print_r($group_temp); + $temp_array[ $group_key ] = $group_temp; + + } + } + else + { +//echo "SDKJHKSJ**"; + $group_temp = array(); + foreach ($question['questions_group'] as $group_key => $group_value) + { + + $temp_array[ $group_value['questions'][0]['question_key'] ][] = $group_value['questions'][0]['answer_value']; } - } } } //print_r($temp_array);die(); return $temp_array; } + + function getMasterData($id,$array) + { + + foreach($array as $value) + { + if($id == $value['answer_id']) + { + return $value['answer']; + break; + } + } + + } } diff --git a/api/application/views/sale_pd_templates/SMC_LFMP.php b/api/application/views/sale_pd_templates/SMC_LFMP.php index 56c552d4..3380c921 100644 --- a/api/application/views/sale_pd_templates/SMC_LFMP.php +++ b/api/application/views/sale_pd_templates/SMC_LFMP.php @@ -104,27 +104,27 @@ defined('BASEPATH') OR exit('No direct script access allowed'); 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 + @@ -136,15 +136,15 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Loan Amount Applied for (Rs) - SAMPLEDATA + Total Fund Requirement (Rs) - SAMPLEDATA + Loan Tenure (Months) - SAMPLEDATA + Loan Purpose (End-Use) - SAMPLEDATA + @@ -161,51 +161,30 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Previous Experience Details Started Biz (Yes / No) + $section3_value) + { + echo ''.$section3_value['name'] .''. + ''.$section3_value['share_holding'].''. + ''.$section3_value['vintage_in_current_biz'].''. + ''.$section3_value['total_work_exp'].''. + ''.$section3_value['previous_experience_details'].''. + ''.$section3_value['started_biz'].''. + ''; + } + + } + + ?> + - Kumaralingam - 100% - 5yrs & 2 Mns - 10 yrs & 6 Mns - >SAMPLEDATA >SAMPLEDATA SAMPLEDATASAMPLEDATA - Yes - - - - Brief of the Business / Service + Brief of the Business / Service - SAMPLEDATA + @@ -214,78 +193,129 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + - + - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + $totol++; + echo ''; + } + } + ?> + - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - - - - + $fy_value) + { + if(is_numeric($fy_key)) + { + echo ''; + } + } + ?> - + - + - + - +
Financial InformationFinancial 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 3FY - '.($fy_value['fy']).'
Sales / Revenue (Rs) SAMPLEDATASAMPLEDATASAMPLEDATA'.($fy_value['sales_revenue'] ).'
Net Profit / (Net Loss) (Rs) SAMPLEDATASAMPLEDATASAMPLEDATA'.($fy_value['net_profit'] ).'
Net Profit or (Net Loss) to Sales % SAMPLEDATASAMPLEDATASAMPLEDATA'.($fy_value['net_profit'] ).'
% (↑ /↓) in Sales over PY SAMPLEDATASAMPLEDATASAMPLEDATANA
% (↑ /↓) in Net Profit over PY SAMPLEDATASAMPLEDATASAMPLEDATANA
% (↑ /↓) in Net Profit % over PY SAMPLEDATASAMPLEDATASAMPLEDATANA
Income to be Considered (Rs Per Annum) >>SAMPLEDATA Income Considered (Rs Per Mth) >>SAMPLEDATA
Income assessment Program Recommended >>SAMPLEDATA Fixed Obligations (Rs per month) >>SAMPLEDATA
+ + @@ -293,32 +323,34 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + - + - + - + - + - + - + - +
Property Address (With Landmark & PIN)SAMPLEDATA
Property TypeBungalow / Apartment / Row House / Builder Floor / Others (Specify) Occupancy StatusSelf-Occupied / Rented / Vacant
>Permitted Property UsageResidential / Commercial / Industrial Actual 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
+ @@ -326,19 +358,19 @@ defined('BASEPATH') OR exit('No direct script access allowed'); - + - + - + - + - +
Business activity seen during visit (Yes / No)SAMPLEDATA Location of workplace suits the business (Yes/No)SAMPLEDATA
Overall Assessment (Positive / Negative)SAMPLE GAVSHS Recommended ROI for the caseSAMPLEDATA
Any Other remarks >>SAMPLEDATA
@@ -347,24 +379,51 @@ defined('BASEPATH') OR exit('No direct script access allowed'); Name of Sales Team Member >> - SAMPLEDATA + Designation of Sales Team Member >> - SAMPLEDATA + Date of PD Visit >> - SAMPLEDATA + Signature of PD Officer >> - SAMPLEDATA + - + + + + $img_value) + { + if(!is_array($img_value)) + { + echo ''.''.''; + } + else + { + foreach ($img_value as $key => $value) + { + if($value) + { + echo ''.''.''; + } + } + } + } + } + ?> + + +
Photograph`s
'.$img_key.'
'.$img_key.'-'.($key+1).'