SALESPD ALMOST

This commit is contained in:
Velz2020 2019-11-14 21:28:53 +05:30
parent a3ba12eae3
commit 253e2fdd89
2 changed files with 251 additions and 125 deletions

View File

@ -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;
}
}
}
}

View File

@ -104,27 +104,27 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</tr>
<tr>
<td colspan="3"> Application ID</td>
<td colspan="7"> SAMPLEDATA </td>
<td colspan="7"> <?php echo $section1['application_id']?> </td>
</tr>
<tr>
<td colspan="3"> Name of the Company/Firm</td>
<td colspan="7"> SAMPLEDATA</td>
<td colspan="7"> <?php echo $section1['company_name']?></td>
</tr>
<tr>
<td colspan="3">Name of Person Met during visit</td>
<td colspan="7">SAMPLEDATA</td>
<td colspan="7"><?php echo $section1['person_met_during_visit']?></td>
</tr>
<tr>
<td colspan="3" rowspan="2" >Address Visited</td>
<td colspan="7">SAMPLEDATA</td>
<td colspan="7"><?php echo $section1['address_visited']?></td>
</tr>
<tr>
<td>City</td>
<td>SAMPLEDATA</td>
<td><?php echo $section1['state']?></td>
<td>State</td>
<td>SAMPLEDATA</td>
<td><?php echo $section1['city']?></td>
<td>PIN</td>
<td colspan="2">SAMPLEDATA</td>
<td colspan="2"><?php echo $section1['pincode']?></td>
</tr>
</tbody>
</table>
@ -136,15 +136,15 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</tr>
<tr>
<td colspan="3" >Loan Amount Applied for (Rs)</td>
<td colspan="3" >SAMPLEDATA</td>
<td colspan="3" ><?php echo $section2['loan_amount_applied']?></td>
<td colspan="2">Total Fund Requirement (Rs)</td>
<td colspan="2"> SAMPLEDATA</td>
<td colspan="2"> <?php echo $section2['total_fund_requirement']?></td>
</tr>
<tr>
<td colspan="3" >Loan Tenure (Months)</td>
<td colspan="3" >SAMPLEDATA</td>
<td colspan="3" ><?php echo $section2['loan_tenure']?></td>
<td colspan="2" >Loan Purpose (End-Use)</td>
<td colspan="2" >SAMPLEDATA</td>
<td colspan="2" ><?php echo $section2['loan_purpose']?></td>
</tr>
</tbody>
</table>
@ -161,51 +161,30 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<th colspan="3" >Previous Experience Details</th>
<th colspan="2">Started Biz (Yes / No)</th>
</tr>
<?php
if($section3)
{
foreach ($section3 as $section3_key => $section3_value)
{
echo '<tr><td colspan="2">'.$section3_value['name'] .'</td>'.
'<td colspan="1">'.$section3_value['share_holding'].'</td>'.
'<td colspan="1">'.$section3_value['vintage_in_current_biz'].'</td>'.
'<td colspan="1">'.$section3_value['total_work_exp'].'</td>'.
'<td colspan="3">'.$section3_value['previous_experience_details'].'</td>'.
'<td colspan="1">'.$section3_value['started_biz'].'</td>'.
'</tr>';
}
}
?>
<tr>
<td colspan="2" >Kumaralingam</td>
<td colspan="1" >100%</td>
<td colspan="1" >5yrs & 2 Mns</td>
<td colspan="1"> 10 yrs & 6 Mns</td>
<td colspan="3" > >SAMPLEDATA >SAMPLEDATA SAMPLEDATASAMPLEDATA</td>
<td colspan="2">Yes</td>
</tr>
<!-- <tr>
<td colspan="2" height="31" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
</tr>
<tr>
<td colspan="2" height="31" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
</tr>
<tr>
<td colspan="2" height="31" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
</tr>
<tr>
<td colspan="2" height="31" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td colspan="2" >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
</tr> -->
<tr>
<th colspan="10" >Brief of the Business / Service</th>
<th colspan="10" >Brief of the Business / Service</th>
</tr>
<tr>
<td colspan="10" >SAMPLEDATA</td>
<td colspan="10" ><?php echo $section4['brief_business_service']?></td>
</tr>
<!-- <tr></tr><tr></tr><tr></tr> -->
</tbody></table>
@ -214,78 +193,129 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<table class="scorecard_table">
<tr>
<th colspan="10" >Financial Information</th>
<th colspan="10" >Financial Information</th>
</tr>
<tr>
<td colspan="6" >Name of the Company / Firm whose financials are noted &gt;&gt;</td>
<td colspan="4" >SAMPLEDATA</td>
<td colspan="4" ><?php echo $section5['name_of_the_company']?></td>
</tr>
<tr>
<th colspan="7">Particulars of Financials as per books of Accounts (Can be captured prior to PD)</th>
<th colspan="1" >FY 1</th>
<th colspan="1">FY 2</th>
<th colspan="1">FY 3</th>
<?php
//print_r($section5[0]);die();
$totol = 0;
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
$totol++;
echo '<th colspan="1" >FY - '.($fy_value['fy']).'</th>';
}
}
?>
</tr>
<tr>
<td colspan="7">Sales / Revenue (Rs) </td>
<!-- <td colspan="3">SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >'.($fy_value['sales_revenue'] ).'</td>';
}
}
?>
</tr>
<tr>
<td colspan="7" >Net Profit / (Net Loss) (Rs) </td>
<!-- <td colspan="3" >SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >'.($fy_value['net_profit'] ).'</td>';
}
}
?>
</tr>
<tr>
<td colspan="7" >Net Profit or (Net Loss) to Sales % </td>
<!-- <td colspan="3" >SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >'.($fy_value['net_profit'] ).'</td>';
}
}
?>
</tr>
<tr>
<td colspan="7" >% ( /) in Sales over PY </td>
<!-- <td colspan="3" >SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >NA</td>';
}
}
?>
</tr>
<tr>
<td colspan="7" >% ( /) in Net Profit over PY </td>
<!-- <td colspan="3" >SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >NA</td>';
}
}
?>
</tr>
<tr>
<td colspan="7" >% ( /) in Net Profit % over PY </td>
<!-- <td colspan="3" >SAMPLEDATA</td> -->
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<td >SAMPLEDATA</td>
<?php
foreach ($section5 as $fy_key => $fy_value)
{
if(is_numeric($fy_key))
{
echo '<td colspan="1" >NA</td>';
}
}
?>
</tr>
<tr>
<td colspan="3">Income to be Considered (Rs Per Annum) &gt;&gt;</td>
<td colspan="2">SAMPLEDATA</td>
<td colspan="2"><?php echo $section5['income_to_be_considered']?></td>
<td colspan="3" >Income Considered (Rs Per Mth) &gt;&gt;</td>
<td colspan="2">SAMPLEDATA</td>
<td colspan="2"><?php echo $section5['income_considered']?></td>
</tr>
<tr>
<td colspan="3">Income assessment Program Recommended &gt;&gt;</td>
<td colspan="2">SAMPLEDATA</td>
<td colspan="2"><?php echo $section5['income_assessment_program_recommended']?></td>
<td colspan="3" >Fixed Obligations (Rs per month) &gt;&gt;</td>
<td colspan="2">SAMPLEDATA</td>
<td colspan="2"><?php echo $section5['fixed_obligations']?></td>
</tr>
</tbody></table>
<?php
if(isset($section6))
{
?>
<table class="scorecard_table">
<tbody>
<tr>
@ -293,32 +323,34 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</tr>
<tr>
<td colspan="3" >Property Address (With Landmark &amp; PIN)</td>
<td colspan="7" >SAMPLEDATA</td>
<td colspan="7" ><?php echo $section6['property_address']?></td>
</tr>
<tr>
<td colspan="2" >Property Type</td>
<td colspan="4" >Bungalow / Apartment / Row House / Builder Floor / Others (Specify)</td>
<td colspan="4" ><?php echo $section6['property_type']?></td>
<td colspan="2" >Occupancy Status</td>
<td colspan="2" >Self-Occupied / Rented / Vacant</td>
<td colspan="2" ><?php echo $section6['occupancy_status']?></td>
</tr>
<tr>
<td colspan="2" >>Permitted Property Usage</td>
<td colspan="4" >Residential / Commercial / Industrial</td>
<td colspan="4" ><?php echo $section6['permitted_property_usage']?></td>
<td colspan="2" >Actual Property Usage</td>
<td colspan="2" >Residential / Commercial / Industrial</td>
<td colspan="2" ><?php echo $section6['actual_property_usage']?></td>
</tr>
<tr>
<td colspan="2" >Built-Up Area (Sq. Ft.)</td>
<td colspan="4" ></td>
<td colspan="4" ><?php echo $section6['built_up_area']?></td>
<td colspan="2" >Approx Mkt. Val (Rs)</td>
<td colspan="2" >As declared by Applicant</td>
<td colspan="2" ><?php echo $section6['approx_mkt_val']?></td>
</tr>
<tr>
<td colspan="6" >Property Ownership Status (Enter the names of the Property Owner(s) and their relationships)</td>
<td colspan="4"> SAMPLEDATA </td>
<td colspan="4"><?php echo $section6['Property_Ownership_Status']?></td>
</tr>
</tbody>
</table>
<?php }
?>
<table class="scorecard_table">
<tbody>
<tr>
@ -326,19 +358,19 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</tr>
<tr>
<td colspan="4" >Business activity seen during visit (Yes / No)</td>
<td >SAMPLEDATA</td>
<td ><?php echo $section7['business_activity_seen']?></td>
<td colspan="4" >Location of workplace suits the business (Yes/No)</td>
<td >SAMPLEDATA</td>
<td ><?php echo $section7['location_workplace_suits_business']?></td>
</tr>
<tr>
<td colspan="4" >Overall Assessment (Positive / Negative)</td>
<td >SAMPLE GAVSHS</td>
<td ><?php echo $section7['overall_assessment']?></td>
<td colspan="4" >Recommended ROI for the case</td>
<td >SAMPLEDATA</td>
<td ><?php echo $section7['recommended_roi']?></td>
</tr>
<tr>
<td colspan="2" >Any Other remarks &gt;&gt;</td>
<td colspan="8" >SAMPLEDATA</td>
<td colspan="8" ><?php echo $section7['any_other_remarks']?></td>
</tr>
</tbody>
</table>
@ -347,24 +379,51 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<tbody>
<tr>
<td colspan="3" >Name of Sales Team Member &gt;&gt;</td>
<td colspan="7" >SAMPLEDATA</td>
<td colspan="7" ><?php echo $section8['name_of_sales_team_member']?></td>
</tr>
<tr>
<td colspan="3" >Designation of Sales Team Member &gt;&gt;</td>
<td colspan="7" >SAMPLEDATA</td>
<td colspan="7" ><?php echo $section8['designation']?></td>
</tr>
<tr>
<td colspan="3" >Date of PD Visit &gt;&gt;</td>
<td colspan="7" >SAMPLEDATA</td>
<td colspan="7" ><?php echo $section8['date']?></td>
</tr>
<tr>
<td colspan="3">Signature of PD Officer &gt;&gt;</td>
<td colspan="7" >SAMPLEDATA</td>
<td colspan="7" ></td>
</tr>
</tbody>
</table>
<table class="scorecard_table">
<tr><th colspan="10">Photograph`s</th></tr>
<tbody>
<?php
if(isset($section9) && count($section9))
{
foreach ($section9 as $img_key => $img_value)
{
if(!is_array($img_value))
{
echo '<tr>'.'<td colspan="3" >'.$img_key.'</td>'.'<td colspan="7" ><img src="'.$img_value.'" height = "100" width="100"></td></tr>';
}
else
{
foreach ($img_value as $key => $value)
{
if($value)
{
echo '<tr>'.'<td colspan="3" >'.$img_key.'-'.($key+1).'</td>'.'<td colspan="7" ><img src="'.$value.'" height = "100" width="100"></td></tr>';
}
}
}
}
}
?>
</tbody>
</table>
</body>
</html>