File: /home/cafsindia/lifemaze_in/lp_lib/lp_reports.php
<?php
/**********************************************************
Filename: lp_reports.php
Description: Object for all reports related operation
Author: uday
Created on: AUG, 28 2018
Approved on:
Reviewed on:
------------------------------------------------------------
Modification Details
Changed by:
------------------------------------------------------------
**********************************************************/
class lp_reports{
private $libObject = "";
private $dbObj = null;
private $cust_id;
function __construct() {
$this->libObject = 0;
$this->cust_id = 0;
}
/**** USED TO SET VALID CUSTOMER LIB OBJECT WITH THIS CLASS ****/
function setLibObject($r_libObject) {
if(!$r_libObject)
return false;
$this->libObject = $r_libObject;
$this->dbObj = $this->libObject->getDBObject();
if(!$this->dbObj){
$this->libObject = 0;
return false;
}
}
/**** USED TO SET CUSTOMER ID WITH THIS CLASS ****/
function set_cust_id($cust_id){
if($cust_id){
$this->cust_id = $cust_id;
}
}
/**** OVER ALL FAMILY INCOME ****/
function all_income_chart($income_type=false){
$where = "";
if($income_type){
$where = " and lp_cust_income.income_type = '$income_type'";
}
$income_qry = $this->dbObj->runQuery("SELECT family_id,IFNULL(sum(income_amt),0) as income_amt,family_name,IFNULL(sum(income_yearly),0) as income_yearly FROM lp_cust_income left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_income.income_pay_type left join lp_cust_family on lp_cust_family.family_id = lp_cust_income.income_family where lp_cust_income.status = '1' and lp_cust_income.cust_id = '$this->cust_id' $where GROUP by family_name");
return $this->dbObj->result($income_qry);
}
/**** GET INCOME FAMILY ID ****/
function get_income_family_id($family_id){
$income_qry = $this->dbObj->runQuery("SELECT family_id,IFNULL(income_amt,0) as income_amt,family_name,income_type,IFNULL(sum(income_yearly),0) as income_yearly FROM lp_cust_income left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_income.income_pay_type left join lp_cust_family on lp_cust_family.family_id = lp_cust_income.income_family where lp_cust_income.status = '1' and lp_cust_income.cust_id = '$this->cust_id' and lp_cust_family.family_id = '$family_id' GROUP by income_type");
return $this->dbObj->result($income_qry);
}
/**** GET EXPENSE CATEGORIES GROUP ****/
function get_expense(){
$expense_qry = $this->dbObj->runQuery("SELECT IFNULL(sum(exp_amt),0) as exp_amt,IFNULL(sum(exp_yearly),0) as exp_yearly,expense_name,expense_sub_name,paying_type_name,expense_related,exp_family FROM lp_cust_expense left join lp_expense on lp_expense.expense_id = lp_cust_expense.exp_cat LEFT join lp_expense_sub on lp_expense_sub.expense_sub_id = lp_cust_expense.exp_sub_cat left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_expense.exp_frq where cust_id = '$this->cust_id' and lp_cust_expense.status= '1' GROUP by expense_name");
return $this->dbObj->result($expense_qry);
}
/**** GET EXPENSE SUB CATEGORIES BY NAME ****/
function get_expense_drill($expense_name,$expense_related){
$group = "";
if((int)$expense_related === 1){
$group = "GROUP by exp_sub_cat";
}
if((int)$expense_related === 2){
$group = "GROUP by family_name";
}
$expense_qry = $this->dbObj->runQuery("SELECT IFNULL(exp_amt,0) as exp_amt,IFNULL(sum(exp_yearly),0) as exp_yearly,expense_name,expense_sub_name,paying_type_name,family_name FROM lp_cust_expense left join lp_expense on lp_expense.expense_id = lp_cust_expense.exp_cat LEFT join lp_expense_sub on lp_expense_sub.expense_sub_id = lp_cust_expense.exp_sub_cat left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_expense.exp_frq left join lp_cust_family on lp_cust_family.family_id = lp_cust_expense.exp_family where lp_cust_expense.cust_id = '$this->cust_id' and lp_cust_expense.status= '1' and lp_expense.expense_name = '$expense_name' $group");
return $this->dbObj->result($expense_qry);
}
/**** GET LOAN ****/
function get_loan(){
$loan_qry = $this->dbObj->runQuery("SELECT loan_type_name,IFNULL(sum(loan_outstanding),0) as loan_outstanding,IFNULL(sum(emi_yearly),0) as emi_yearly FROM `lp_cust_loan` left join lp_loan_type on lp_loan_type.loan_type_id = lp_cust_loan.loan_type where cust_id = '$this->cust_id' and lp_cust_loan.status= '1' GROUP by loan_type_name");
return $this->dbObj->result($loan_qry);
}
/**** GET BANK SUM ****/
function get_bank_sum(){
$rd_bank_qry = $this->dbObj->runQuery("SELECT bank_scheme,IFNULL(sum(bank_amt),0) as bank_amt,IFNULL(sum(bank_maturity_amt),0) as bank_maturity_amt,IFNULL(sum(bank_yearly),0) as bank_yearly FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_scheme = '3'");
$rd_info = $this->dbObj->result($rd_bank_qry);
$rd_bank_yearly = $rd_info[0]->bank_yearly;
$other_bank_qry = $this->dbObj->runQuery("SELECT bank_scheme,IFNULL(sum(bank_amt),0) as bank_amt,IFNULL(sum(bank_maturity_amt),0) as bank_maturity_amt,IFNULL(sum(bank_yearly),0) as bank_yearly FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_scheme != '3' and YEAR(bank_startdate) > (YEAR(NOW())-1)");
$other_info = $this->dbObj->result($other_bank_qry);
$other_bank_yearly = $other_info[0]->bank_yearly;
$bank_sum = $rd_bank_yearly + $other_bank_yearly;
return $bank_sum;
}
/**** GET BANK LIST ****/
function get_bank_list(){
$bank_list = array();
$rd_bank_list_qry = $this->dbObj->runQuery("SELECT bank_scheme,IFNULL(sum(bank_amt),0) as bank_amt,IFNULL(sum(bank_maturity_amt),0) as bank_maturity_amt FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_scheme = '3' GROUP by bank_scheme");
$rd_bank_info = $this->dbObj->result($rd_bank_list_qry);
foreach ($rd_bank_info as $bank) {
$bank_list[] = array("bank_scheme"=>$bank->bank_scheme,"bank_amt"=>(int)$bank->bank_amt,"bank_maturity_amt"=>(int)$bank->bank_maturity_amt);
}
$or_bank_list_qry = $this->dbObj->runQuery("SELECT bank_scheme,IFNULL(sum(bank_amt),0) as bank_amt,IFNULL(sum(bank_maturity_amt),0) as bank_maturity_amt FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_scheme != '3' and YEAR(bank_startdate) > (YEAR(NOW())-1) GROUP by bank_scheme");
$or_bank_info = $this->dbObj->result($or_bank_list_qry);
foreach ($or_bank_info as $bank) {
$bank_list[] = array("bank_scheme"=>$bank->bank_scheme,"bank_amt"=>(int)$bank->bank_amt,"bank_maturity_amt"=>(int)$bank->bank_maturity_amt);
}
return json_encode($bank_list);
}
/**** GET INSURANCE SUM ****/
function get_insurance_sum(){
$insurance_qry = $this->dbObj->runQuery("SELECT IFNULL(sum(ins_premium),0) as ins_premium,IFNULL(sum(premium_yearly),0) as premium_yearly,insurance_type_name FROM lp_cust_insurance left join lp_insurance_type on lp_insurance_type.insurance_type_id = lp_cust_insurance.ins_type left join lp_insurance_company on lp_insurance_company.insurance_company_id = lp_cust_insurance.ins_company left join lp_insurance_plan on lp_insurance_plan.insurance_plan_id = lp_cust_insurance.ins_plan where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id'");
return $this->dbObj->result($insurance_qry);
}
/**** GET INSURANCE LIST ****/
function get_insurance_list(){
$insurance_list_qry = $this->dbObj->runQuery("SELECT IFNULL(sum(ins_premium),0) as ins_premium,IFNULL(sum(premium_yearly),0) as premium_yearly,insurance_type_name FROM lp_cust_insurance left join lp_insurance_type on lp_insurance_type.insurance_type_id = lp_cust_insurance.ins_type left join lp_insurance_company on lp_insurance_company.insurance_company_id = lp_cust_insurance.ins_company left join lp_insurance_plan on lp_insurance_plan.insurance_plan_id = lp_cust_insurance.ins_plan where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' GROUP by insurance_type_name");
return $this->dbObj->result($insurance_list_qry);
}
/**** GET MF SUM ****/
function get_mf_sum(){
$mf_qry = $this->dbObj->runQuery("SELECT amc_name,IFNULL(sum(mf_present_val),0) as mf_present_val,IFNULL(sum(mf_live_sip),0) as mf_live_sip,IFNULL(sum(mf_yearly),0) as mf_yearly FROM lp_cust_mf left join lp_amc on lp_amc.amc_id = lp_cust_mf.mf_amc left join lp_fund_name on lp_fund_name.fund_name_id = lp_cust_mf.mf_scheme left join lp_fund_class on lp_fund_class.fund_class_id = lp_cust_mf.mf_fund_class left join lp_cust_family on lp_cust_family.family_id = lp_cust_mf.mf_investor where lp_cust_mf.status = '1' and lp_cust_mf.cust_id = '$this->cust_id'");
return $this->dbObj->result($mf_qry);
}
/**** GET MF LIST ****/
function get_mf_list(){
$mf_list_qry = $this->dbObj->runQuery("SELECT amc_name,IFNULL(sum(mf_present_val),0) as mf_present_val,IFNULL(sum(mf_live_sip),0) as mf_live_sip,IFNULL(sum(mf_yearly),0) as mf_yearly FROM lp_cust_mf left join lp_amc on lp_amc.amc_id = lp_cust_mf.mf_amc left join lp_fund_name on lp_fund_name.fund_name_id = lp_cust_mf.mf_scheme left join lp_fund_class on lp_fund_class.fund_class_id = lp_cust_mf.mf_fund_class left join lp_cust_family on lp_cust_family.family_id = lp_cust_mf.mf_investor where lp_cust_mf.status = '1' and lp_cust_mf.cust_id = '$this->cust_id' GROUP by lp_cust_mf.mf_amc");
return $this->dbObj->result($mf_list_qry);
}
/**** GET GOVERNMENT SCHEME SUM ****/
function get_gov_sum(){
$gov_qry = $this->dbObj->runQuery("SELECT gov_scheme_name,IFNULL(sum(gov_amount),0) as gov_amount,IFNULL(sum(gov_yearly),0) as gov_yearly FROM lp_cust_gov left join lp_cust_family on lp_cust_family.family_id = lp_cust_gov.gov_holder left join lp_gov_scheme on lp_gov_scheme.gov_scheme_id = lp_cust_gov.gov_scheme left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_gov.gov_type where lp_cust_gov.status = '1' and lp_cust_gov.cust_id = '$this->cust_id'");
return $this->dbObj->result($gov_qry);
}
/**** GET GOVERNMENT SCHEME LIST ****/
function get_gov_list(){
$gov_list_qry = $this->dbObj->runQuery("SELECT gov_scheme_name,IFNULL(sum(gov_amount),0) as gov_amount,IFNULL(sum(gov_yearly),0) as gov_yearly FROM lp_cust_gov left join lp_cust_family on lp_cust_family.family_id = lp_cust_gov.gov_holder left join lp_gov_scheme on lp_gov_scheme.gov_scheme_id = lp_cust_gov.gov_scheme left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_gov.gov_type where lp_cust_gov.status = '1' and lp_cust_gov.cust_id = '$this->cust_id' GROUP by gov_scheme_name");
return $this->dbObj->result($gov_list_qry);
}
/**** GET STOCK & BULLION SUM ****/
function get_stock_sum(){
$stock_qry = $this->dbObj->runQuery("SELECT stock_type,bullion_type,IFNULL(sum(stock_current_value),0) as stock_current_value,IFNULL(sum(stock_inflow_value),0) as stock_inflow_value,IFNULL(sum(stock_yearly),0) as stock_yearly FROM lp_cust_stock left join lp_cust_family on lp_cust_family.family_id = lp_cust_stock.stock_investor where lp_cust_stock.status = '1' and lp_cust_stock.cust_id = '$this->cust_id'");
return $this->dbObj->result($stock_qry);
}
/**** GET STOCK & BULLION LIST ****/
function get_stock_list(){
$stock_list_qry = $this->dbObj->runQuery("SELECT stock_type,bullion_type,IFNULL(sum(stock_current_value),0) as stock_current_value,IFNULL(sum(stock_inflow_value),0) as stock_inflow_value,IFNULL(sum(stock_yearly),0) as stock_yearly FROM lp_cust_stock left join lp_cust_family on lp_cust_family.family_id = lp_cust_stock.stock_investor where lp_cust_stock.status = '1' and lp_cust_stock.cust_id = '$this->cust_id' GROUP by stock_type");
return $this->dbObj->result($stock_list_qry);
}
/**** GET OTHERS SUM ****/
function get_other_sum(){
$other_qry = $this->dbObj->runQuery("SELECT IFNULL(sum(others_amt),0) as others_amt,IFNULL(sum(other_yearly),0) as other_yearly FROM lp_cust_others left join lp_cust_family on lp_cust_family.family_id = lp_cust_others.others_investor left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_others.others_type where lp_cust_others.status = '1' and lp_cust_others.cust_id = '$this->cust_id'");
return $this->dbObj->result($other_qry);
}
/**** GET OTHERS LIST ****/
function get_other_list(){
$other_list_qry = $this->dbObj->runQuery("SELECT family_name,IFNULL(sum(others_amt),0) as others_amt,IFNULL(sum(other_yearly),0) as other_yearly FROM lp_cust_others left join lp_cust_family on lp_cust_family.family_id = lp_cust_others.others_investor left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_others.others_type where lp_cust_others.status = '1' and lp_cust_others.cust_id = '$this->cust_id' group by others_investor");
return $this->dbObj->result($other_list_qry);
}
/**** GET IN OUT FLOW ****/
function get_in_out_flow(){
$data = new stdClass;
// TOTAL INCOME
$income_rslt = $this->all_income_chart();
$tot_income = 0;
foreach($income_rslt as $income){
$tot_income += (int)$income->income_yearly;
}
$data->tot_income = $tot_income;
//TOTAL EXPENSE
$expense_rslt = $this->get_expense();
$tot_expence = 0;
foreach($expense_rslt as $expence){
$tot_expence += (int)$expence->exp_yearly;
}
$data->tot_expence = $tot_expence;
//TOTAL LOAN
$loan_list = array();
$loan_qry = $this->dbObj->runQuery("SELECT loan_id,loan_type_name,IFNULL(loan_outstanding,0) as loan_outstanding,IFNULL(emi_yearly,0) as emi_yearly,loan_start,loan_remaining,loan_frq FROM `lp_cust_loan` left join lp_loan_type on lp_loan_type.loan_type_id = lp_cust_loan.loan_type where cust_id = '$this->cust_id' and lp_cust_loan.status= '1'");
$loan_info = $this->dbObj->result($loan_qry);
$in_frq_array = array(1=>1,2=>12,3=>4,4=>2,5=>1);
foreach($loan_info as $loan) {
$loan_id = $loan->loan_id;
$loan_outstanding = $loan->loan_outstanding;
$emi_yearly = $loan->emi_yearly;
$loan_frq = $loan->loan_frq;
$loan_remaining = $loan->loan_remaining;
$loan_type_name = $loan->loan_type_name;
//$loan_start = date('Y-m-d',strtotime($loan->loan_start));
$loan_start = new DateTime($loan->loan_start);
$loan_start = $loan_start->format("Y-m-d");
$maturity_year = explode("-",$loan_start);
$remaining = $in_frq_array[(int)$loan_frq];
$remaining = round($loan_remaining / $remaining);
$maturity_year = $maturity_year[0] + $remaining;
$loan_list[] = array("loan_id"=>$loan_id,"loan_outstanding"=>$loan_outstanding,"emi_yearly"=>$emi_yearly,"loan_remaining"=>$loan_remaining,"loan_start"=>$loan_start,"maturity_year"=>$maturity_year,"loan_type_name"=>$loan_type_name);
}
$data->loan_info = json_encode($loan_list);
//BANK MATURITY AMOUNT WITH YEAR
$bank_in_list = array();
$bank_out_list = array();
$bank_scheme_info = array('1'=>"Bank Fixed Deposit",'2'=>"Company Deposit",'3'=>"Bank Recurring Deposit",'4'=>"Bonds",'5'=>"Other Deposits");
$bank_list_qry = $this->dbObj->runQuery("SELECT bank_id,bank_scheme,IFNULL(bank_amt,0) as bank_amt,IFNULL(bank_maturity_amt,0) as bank_maturity_amt,bank_maturity,IFNULL(bank_yearly,0) as bank_yearly,bank_type,bank_startdate FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id'");
$bank_info = $this->dbObj->result($bank_list_qry);
foreach($bank_info as $bank) {
$bank_id = $bank->bank_id;
//$maturity_year = date('Y',strtotime($bank->bank_maturity));
//$bank_maturity = date('Y-m-d',strtotime($bank->bank_maturity));
$maturity_year = new DateTime($bank->bank_maturity);
$maturity_year = $maturity_year->format("Y");
$bank_maturity = new DateTime($bank->bank_maturity);
$bank_maturity = $bank_maturity->format("Y-m-d");
$bank_amt = (int)$bank->bank_amt;
$bank_maturity_amt = (int)$bank->bank_maturity_amt;
$bank_yearly = (int)$bank->bank_yearly;
$bank_type = $bank->bank_type;
$bank_scheme = $bank->bank_scheme;
$bank_startdate = (int)$bank->bank_startdate;
$bank_scheme_name = $bank_scheme_info[$bank_scheme];
$bank_in_list[] = array("bank_id"=>$bank_id,"bank_amt"=>$bank_amt,"bank_maturity"=>$bank_maturity,"maturity_year"=>$maturity_year,"bank_maturity_amt"=>$bank_maturity_amt,"bank_scheme_name"=>$bank_scheme_name);
if($bank_type === "1"){
//$start_year = date('Y',strtotime($bank->bank_startdate));
$start_year = new DateTime($bank->bank_startdate);
$start_year = $start_year->format("Y");
$this_year = date('Y');
if($start_year === $this_year){
$bank_out_list[] = array("bank_id"=>$bank_id,"bank_amt"=>$bank_amt,"bank_yearly"=>$bank_yearly,"bank_maturity"=>$bank_maturity,"maturity_year"=>$maturity_year,"bank_maturity_amt"=>$bank_maturity_amt,"bank_scheme_name"=>$bank_scheme_name);
}
}else{
$bank_out_list[] = array("bank_id"=>$bank_id,"bank_amt"=>$bank_amt,"bank_yearly"=>$bank_yearly,"bank_maturity"=>$bank_maturity,"maturity_year"=>$maturity_year,"bank_maturity_amt"=>$bank_maturity_amt,"bank_scheme_name"=>$bank_scheme_name);
}
}
$data->bank_in_info = json_encode($bank_in_list);
$data->bank_out_info = json_encode($bank_out_list);
//INSURANCE MATURITY AMOUNT WITH YEAR
$insurance_in_list = array();
$insurance_out_list = array();
$insurance_list_qry = $this->dbObj->runQuery("SELECT insurance_id,ins_type,ins_sum_assured,ins_start_date,ins_issued_date,ins_term,ins_ppt,IFNULL(ins_premium,0) as ins_premium,IFNULL(premium_yearly,0) as premium_yearly,insurance_type_name,ins_frq,pensioner,vesting_date,pen_frq,pen_amt,pen_ror,vesting_corpus,one3rd_corpus,pen_payout,pen_ropen,pension_amount FROM lp_cust_insurance left join lp_insurance_type on lp_insurance_type.insurance_type_id = lp_cust_insurance.ins_type left join lp_insurance_company on lp_insurance_company.insurance_company_id = lp_cust_insurance.ins_company left join lp_insurance_plan on lp_insurance_plan.insurance_plan_id = lp_cust_insurance.ins_plan where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id'");
$insurance_info = $this->dbObj->result($insurance_list_qry);
foreach($insurance_info as $insurance){
$insurance_id = $insurance->insurance_id;
$ins_type = $insurance->ins_type;
$ins_sum_assured = $insurance->ins_sum_assured;
$ins_start_date = new DateTime($insurance->ins_start_date);
$ins_start_date = $ins_start_date->format("Y-m-d");
$ins_issued_date = new DateTime($insurance->ins_issued_date);
$ins_issued_date = $ins_issued_date->format("Y-m-d");
$ins_term = $insurance->ins_term;
$ins_ppt = $insurance->ins_ppt;
$ins_premium = $insurance->ins_premium;
$premium_yearly = $insurance->premium_yearly;
$ins_frq = $insurance->ins_frq;
$insurance_type_name = $insurance->insurance_type_name;
$maturity_dates = "+ $ins_term years";
$ins_issued_date = new DateTime($ins_issued_date);
$maturity_date = $ins_issued_date->modify("$maturity_dates");
$maturity_date = $maturity_date->format("Y-m-d");
$out_maturity_dates = "+ $ins_ppt years";
$out_ins_issued_date = new DateTime($insurance->ins_issued_date);
$out_maturity_date = $out_ins_issued_date->modify("$out_maturity_dates");
$out_maturity_date = $out_maturity_date->format("Y-m-d");
$out_maturity_year = new DateTime($out_maturity_date);
$out_maturity_year = $out_maturity_year->format("Y");
if(($ins_type === "4") || ($ins_type === "5")){
$out_maturity_dates = "+ 100 years";
$out_ins_issued_date = new DateTime();
$out_maturity_date = $out_ins_issued_date->modify("$out_maturity_dates");
$out_maturity_date = $out_maturity_date->format("Y-m-d");
$out_maturity_year = new DateTime($out_maturity_date);
$out_maturity_year = $out_maturity_year->format("Y");
}
$pen_frq = $insurance->pen_frq;
$pen_amt = $insurance->pen_amt;
$pen_ror = $insurance->pen_ror;
$vesting_date = $insurance->vesting_date;
$vesting_corpus = $insurance->vesting_corpus;
$one3rd_corpus = $insurance->one3rd_corpus;
$pen_payout = $insurance->pen_payout;
$pen_ropen = $insurance->pen_ropen;
$pension_amount = $insurance->pension_amount;
if(($ins_type === "1") || ($ins_type === "2") || ($ins_type === "3")){
$maturity_year = new DateTime($maturity_date);
$maturity_year = $maturity_year->format("Y");
$insurance_in_list[] = array("insurance_id"=>$insurance_id,"maturity_year"=>$maturity_year,"maturity_date"=>$maturity_date,"ins_sum_assured"=>$ins_sum_assured,"insurance_type_name"=>$insurance_type_name,"ins_term"=>$ins_term,"ins_ppt"=>$ins_ppt,"premium_yearly"=>$premium_yearly);
}
if($ins_type === "6"){
$in_frq_array = array(1=>1,2=>12,3=>4,4=>2,5=>1);
$multi_value = $in_frq_array[(int)$pen_payout];
$pension_amount = $pension_amount * $multi_value;
$maturity_year = new DateTime($insurance->vesting_date);
$maturity_year = $maturity_year->format("Y");
$maturity_date = new DateTime($insurance->vesting_date);
$maturity_date = $maturity_date->format("Y-m-d");
$insurance_in_list[] = array("insurance_id"=>$insurance_id,"maturity_year"=>$maturity_year,"maturity_date"=>$maturity_date,"ins_sum_assured"=>$one3rd_corpus,"insurance_type_name"=>$insurance_type_name,"pension_amount"=>$pension_amount);
$insurance_out_list[] = array("insurance_id"=>$insurance_id,"maturity_year"=>$maturity_year,"maturity_date"=>$maturity_date,"ins_sum_assured"=>$one3rd_corpus,"insurance_type_name"=>$insurance_type_name,"pension_amount"=>$pension_amount,"premium_yearly"=>$premium_yearly);
}
if($ins_type !== "6"){
if($ins_frq === "1"){
$start_year = new DateTime($insurance->ins_issued_date);
$start_year = $start_year->format("Y");
$this_year = date('Y');
if($start_year === $this_year){
$insurance_out_list[] = array("insurance_id"=>$insurance_id,"ins_sum_assured"=>$ins_sum_assured,"premium_yearly"=>$premium_yearly,"ins_premium"=>$ins_premium,"maturity_year"=>$maturity_year,"maturity_date"=>$maturity_date,"insurance_type_name"=>$insurance_type_name);
}
}else{
$insurance_out_list[] = array("insurance_id"=>$insurance_id,"ins_sum_assured"=>$ins_sum_assured,"premium_yearly"=>$premium_yearly,"ins_premium"=>$ins_premium,"maturity_year"=>$out_maturity_year,"maturity_date"=>$maturity_date,"insurance_type_name"=>$insurance_type_name);
}
}
}
$data->insurance_in_info = json_encode($insurance_in_list);
$data->insurance_out_info = json_encode($insurance_out_list);
//MUTUAL FUND AMOUNT YEARLY
$mf_list = array();
$mf_list_qry = $this->dbObj->runQuery("SELECT mf_id,amc_name,IFNULL(mf_present_val,0) as mf_present_val,IFNULL(mf_live_sip,0) as mf_live_sip,IFNULL(mf_yearly,0) as mf_yearly ,mf_end_date FROM lp_cust_mf left join lp_amc on lp_amc.amc_id = lp_cust_mf.mf_amc left join lp_fund_name on lp_fund_name.fund_name_id = lp_cust_mf.mf_scheme left join lp_fund_class on lp_fund_class.fund_class_id = lp_cust_mf.mf_fund_class left join lp_cust_family on lp_cust_family.family_id = lp_cust_mf.mf_investor where lp_cust_mf.status = '1' and lp_cust_mf.cust_id = '$this->cust_id'");
$mf_info = $this->dbObj->result($mf_list_qry);
foreach($mf_info as $mf) {
$mf_id = $mf->mf_id;
$mf_present_val = $mf->mf_present_val;
$mf_live_sip = $mf->mf_live_sip;
$mf_yearly = $mf->mf_yearly;
$amc_name = $mf->amc_name;
$maturity_year = new DateTime($mf->mf_end_date);
$maturity_year = $maturity_year->format("Y");
$mf_end_date = new DateTime($mf->mf_end_date);
$mf_end_date = $mf_end_date->format("Y-m-d");
$mf_list[] = array("mf_id"=>$mf_id,"mf_present_val"=>$mf_present_val,"mf_live_sip"=>$mf_live_sip,"mf_yearly"=>$mf_yearly,"maturity_year"=>$maturity_year,"mf_end_date"=>$mf_end_date,"amc_name"=>$amc_name);
}
$data->mf_list = json_encode($mf_list);
//GOVERNMENT MATURITY AMOUNT WITH YEAR
$gov_in_list = array();
$gov_out_list = array();
$gov_list_qry = $this->dbObj->runQuery("SELECT gov_id,gov_scheme_name,IFNULL(gov_amount,0) as gov_amount,IFNULL(gov_yearly,0) as gov_yearly,gov_maturity_date,gov_maturity_value,gov_start_date,gov_type FROM lp_cust_gov left join lp_cust_family on lp_cust_family.family_id = lp_cust_gov.gov_holder left join lp_gov_scheme on lp_gov_scheme.gov_scheme_id = lp_cust_gov.gov_scheme left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_gov.gov_type where lp_cust_gov.status = '1' and lp_cust_gov.cust_id = '$this->cust_id'");
$gov_info = $this->dbObj->result($gov_list_qry);
foreach($gov_info as $gov) {
$gov_id = $gov->gov_id;
$maturity_year = new DateTime($gov->gov_maturity_date);
$maturity_year = $maturity_year->format("Y");
$gov_maturity = new DateTime($gov->gov_maturity_date);
$gov_maturity = $gov_maturity->format("Y-m-d");
$gov_start_date = new DateTime($gov->gov_start_date);
$gov_start_date = $gov_start_date->format("Y-m-d");
$gov_amount = (int)$gov->gov_amount;
$gov_maturity_value = (int)$gov->gov_maturity_value;
$gov_type = $gov->gov_type;
$gov_yearly = $gov->gov_yearly;
$gov_scheme_name = $gov->gov_scheme_name;
$gov_in_list[] = array("gov_id"=>$gov_id,"maturity_year"=>$maturity_year,"gov_maturity"=>$gov_maturity,"gov_amount"=>$gov_amount,"gov_maturity_value"=>$gov_maturity_value,"gov_scheme_name"=>$gov_scheme_name);
if($gov_type === "1"){
$start_year = new DateTime($gov_start_date);
$start_year = $start_year->format("Y");
$this_year = date('Y');
if($start_year === $this_year){
$gov_out_list[] = array("gov_id"=>$gov_id,"gov_maturity_value"=>$gov_maturity_value,"gov_yearly"=>$gov_yearly,"gov_amount"=>$gov_amount,"maturity_year"=>$maturity_year,"gov_maturity"=>$gov_maturity,"gov_scheme_name"=>$gov_scheme_name);
}
}else{
$gov_out_list[] = array("gov_id"=>$gov_id,"gov_maturity_value"=>$gov_maturity_value,"gov_yearly"=>$gov_yearly,"gov_amount"=>$gov_amount,"maturity_year"=>$maturity_year,"gov_maturity"=>$gov_maturity,"gov_scheme_name"=>$gov_scheme_name);
}
}
$data->gov_in_info = json_encode($gov_in_list);
$data->gov_out_info = json_encode($gov_out_list);
//OTHERS MATURITY AMOUNT WITH YEAR
$others_in_list = array();
$others_out_list = array();
$others_list_qry = $this->dbObj->runQuery("SELECT others_id,others_descript,others_maturity_date,others_maturity_val,family_name,IFNULL(others_amt,0) as others_amt,IFNULL(other_yearly,0) as other_yearly,others_type,others_startdate FROM lp_cust_others left join lp_cust_family on lp_cust_family.family_id = lp_cust_others.others_investor left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_others.others_type where lp_cust_others.status = '1' and lp_cust_others.cust_id = '$this->cust_id'");
$others_info = $this->dbObj->result($others_list_qry);
foreach($others_info as $others) {
$others_id = $others->others_id;
$maturity_year = new DateTime($others->others_maturity_date);
$maturity_year = $maturity_year->format("Y");
$others_maturity_date = new DateTime($others->others_maturity_date);
$others_maturity_date = $others_maturity_date->format("Y-m-d");
$others_startdate = new DateTime($others->others_startdate);
$others_startdate = $others_startdate->format("Y-m-d");
$others_amt = (int)$others->others_amt;
$others_maturity_val = (int)$others->others_maturity_val;
$others_type = $others->others_type;
$other_yearly = $others->other_yearly;
$others_descript = $others->others_descript;
$others_in_list[] = array("others_id"=>$others_id,"maturity_year"=>$maturity_year,"others_maturity_date"=>$others_maturity_date,"others_amt"=>$others_amt,"others_maturity_val"=>$others_maturity_val,"others_descript"=>$others_descript);
if($others_type === "1"){
$start_year = new DateTime($others_startdate);
$start_year = $start_year->format("Y");
$this_year = date('Y');
if($start_year === $this_year){
$others_out_list[] = array("others_id"=>$others_id,"maturity_year"=>$maturity_year,"others_maturity_date"=>$others_maturity_date,"others_amt"=>$others_amt,"others_maturity_val"=>$others_maturity_val,"other_yearly"=>$other_yearly,"others_amt"=>$others_amt,"others_descript"=>$others_descript);
}
}else{
$others_out_list[] = array("others_id"=>$others_id,"maturity_year"=>$maturity_year,"others_maturity_date"=>$others_maturity_date,"others_amt"=>$others_amt,"others_maturity_val"=>$others_maturity_val,"other_yearly"=>$other_yearly,"others_amt"=>$others_amt,"others_descript"=>$others_descript);
}
}
$data->others_in_info = json_encode($others_in_list);
$data->others_out_info = json_encode($others_out_list);
return $data;
}
/**** GET PROTECTION SUGGESTED ****/
function protection_suggested(){
$family_qry = $this->dbObj->runQuery("SELECT * FROM lp_cust_family left join lp_relation on lp_relation.relation_id = lp_cust_family.family_relation where lp_cust_family.cust_id = '$this->cust_id' and lp_cust_family.status = '1' order by lp_cust_family.family_id asc");
$cust_family = $this->dbObj->result($family_qry);
$profolio = "";
$health = "";
$count_query = $this->dbObj->runQuery("SELECT count(*) as family_count FROM `lp_cust_family` where lp_cust_family.cust_id = '$this->cust_id' and lp_cust_family.status = '1' and family_earning in(1,2)");
$count_info = $this->dbObj->result($count_query);
$family_count = $count_info[0]->family_count;
$exp_query = $this->dbObj->runQuery("SELECT IFNULL(sum(exp_yearly),0) as exp_yearly FROM `lp_cust_expense` where lp_cust_expense.status = '1' and cust_id = '$this->cust_id'");
$exp_info = $this->dbObj->result($exp_query);
$exp_yearly = $exp_info[0]->exp_yearly;
$income_query = $this->dbObj->runQuery("SELECT IFNULL(sum(income_yearly),0) as income_yearly FROM `lp_cust_income` where lp_cust_income.status = '1' and cust_id = '$this->cust_id'");
$income_info = $this->dbObj->result($income_query);
$income_yearly = $income_info[0]->income_yearly;
$loan_query = $this->dbObj->runQuery("SELECT IFNULL(sum(loan_outstanding),0) as loan_outstanding FROM `lp_cust_loan` where lp_cust_loan.status = '1' and cust_id = '$this->cust_id'");
$loan_info = $this->dbObj->result($loan_query);
$loan_outstanding = $loan_info[0]->loan_outstanding;
$goal_query = $this->dbObj->runQuery("SELECT IFNULL(sum(goal_amount),0) as goal_amount FROM `lp_cust_goal` left join lp_cust_family on family_id = goal_family where family_relation != '0' and lp_cust_goal.status = '1' and lp_cust_goal.cust_id = '$this->cust_id'");
$goal_info = $this->dbObj->result($goal_query);
$goal_amount = $goal_info[0]->goal_amount;
$income_sug = round($income_yearly *12 / $family_count);
//$income_sug = round($income_yearly *15);
$inflation_amt = $exp_yearly;
$exp_sug = 0;
$inf_10year = 0;
for($i=1; $i<=10; $i++){
$inflation_info = lp_calculation::compound_interest($inflation_amt,7,1);
$inflation_info = json_decode($inflation_info);
$inflation_amt = $inflation_info->future_value;
$exp_sug += $inflation_amt;
}
$inf_10year = round($exp_sug);
$exp_sug = round($exp_sug/10);
$exp_sug = $exp_sug * 100 / 6;
$inf_6per = round($exp_sug);
$exp_sug = round($exp_sug + $loan_outstanding + $goal_amount);
$sug_array = array($exp_sug,$income_sug);
$suggested = max($sug_array);
$sugg_derive = "<tr>
<td>
<table>
<tr>
<td style='border:1px solid #CCCCCC;'>Yearly Income</td>
<td style='border:1px solid #CCCCCC;'>$income_yearly</td>
</tr>
<tr>
<td style='border:1px solid #CCCCCC;'>$income_yearly *10 Years/ Family count ($family_count)</td>
<td style='border:1px solid #CCCCCC;'>$income_sug</td>
</tr>
</table>
</td>
<td> = $income_sug</td>
</tr>
<tr><td colspan='2' class='center-align' style='font-weight:bold;'>OR</td></tr>
<tr>
<td>
<table>
<tr>
<td style='border:1px solid #CCCCCC;'>Yearly Expense</td>
<td style='border:1px solid #CCCCCC;'>$exp_yearly</td>
</tr>
<tr>
<td style='border:1px solid #CCCCCC;'>7% Inflation for 10 years</td>
<td style='border:1px solid #CCCCCC;'>$inf_10year</td>
</tr>
<tr>
<td style='border:1px solid #CCCCCC;'>Final amount = Inflation Amount / 10 years with 6%</td>
<td style='border:1px solid #CCCCCC;'>$inf_6per</td>
</tr>
<tr>
<td style='border:1px solid #CCCCCC;'>Final amount + Loan Out standing ($loan_outstanding) + Goal amount($goal_amount)</td>
<td style='border:1px solid #CCCCCC;'>$exp_sug</td>
</tr>
</table>
</td>
<td> = $exp_sug</td>
</tr>";
foreach($cust_family as $family){
$family_id = $family->family_id;
$name = $family->family_name;
$dob = new DateTime($family->family_dob);
$dob = $dob->format("d-M-Y");
$age = $family->family_age;
$gender = $family->family_gender;
$earning = $family->family_earning;
$relation = $family->family_relation;
$relation_name = $family->relation_name;
$pro_sum_assured = 0;
$pro_ins_query = $this->dbObj->runQuery("SELECT IFNULL(sum(ins_sum_assured),0) as ins_sum_assured FROM `lp_cust_insurance` where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' and ins_type in(1,2,3) and ins_life_assured = '$family_id ' ");
$pro_ins_info = $this->dbObj->result($pro_ins_query);
$pro_sum_assured = $pro_ins_info[0]->ins_sum_assured;
$hel_sum_assured = 0;
$hel_ins_query = $this->dbObj->runQuery("SELECT IFNULL(sum(ins_sum_assured),0) as ins_sum_assured FROM `lp_cust_insurance` where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' and ins_type in(4) and find_in_set('$family_id',ins_insured)");
$hel_ins_info = $this->dbObj->result($hel_ins_query);
$hel_sum_assured = $hel_ins_info[0]->ins_sum_assured;
$color = "";
$text = "";
if((int)$hel_sum_assured <= 500000){
$color = "style='color:red;'";
$text = "High";
}else
if(((int)$hel_sum_assured > 500000)&&((int)$hel_sum_assured < 1000000)){
$color = "style='color:yellow;'";
$text = "Medium";
}else
if((int)$hel_sum_assured >= 1000000){
$color = "style='color:#43d854;'";
$text = "Good";
}
if(($earning === "1") || ($earning === "2")){
$profolio .= "<tr><td>$name</td><td>$pro_sum_assured</td><td>$suggested</td></tr>";
}
$health .= "<tr><td>$name</td><td>$hel_sum_assured</td><td $color > $text </td></tr>";
}
$general_info = array('1'=>"Car",'2'=>"Bike",'3'=>"Van",'4'=>"Others");
$gen_ins_query = $this->dbObj->runQuery("SELECT ins_general_type,IFNULL(sum(premium_yearly),0) as premium_yearly FROM `lp_cust_insurance` where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' and ins_type in(5) GROUP by ins_general_type");
$gen_ins_info = $this->dbObj->result($gen_ins_query);
$general = "";
foreach($gen_ins_info as $gen_ins){
$ins_general_type = $gen_ins->ins_general_type;
$premium_yearly = $gen_ins->premium_yearly;
$ins_general_name = $general_info[$ins_general_type];
$general .= "<tr><td>$ins_general_name</td><td>$premium_yearly</td></tr>";
}
$content = "<h3 style='text-align:center;'>Protection Suggested</h3>
<div class='col l5 s12'>
<h3 style='text-align:center;color:#000000;'>Life Insurance</h3>
<table class='striped centered'>
<thead>
<tr style='background-color:#ed780e;color:#FFFFFF;'>
<th style='font-weight: normal;'>Name</th>
<th style='font-weight: normal;'>Sum Assured</th>
<th style='font-weight: normal;'>Suggested <a class='modal-trigger' href='#sugg_derive' style='color:#FFFFFF;'><i class='fa fa-paper-plane' aria-hidden='true'></i></a></th>
</tr>
</thead>
<tbody>
$profolio
</tbody>
</table>
<div id='sugg_derive' class='modal'>
<div class='modal-content'>
<table class='striped'>
<thead>
<tr style='background-color:#ed780e;color:#FFFFFF;'>
<th style='font-weight: normal;'>Summary</th>
<th style='font-weight: normal;'>Amount</th>
</tr>
</thead>
<tbody>
$sugg_derive
</tbody>
</table>
</div>
<div class='modal-footer'>
<a href='#!' class='modal-close waves-effect waves-green btn-flat'>Close</a>
</div>
</div>
</div>
<div class='col l5 s12'>
<h3 style='text-align:center;color:#000000;'>Health Insurance</h3>
<table class='striped'>
<thead>
<tr style='background-color:#ed780e;color:#FFFFFF;'>
<th style='font-weight: normal;'>Name</th>
<th style='font-weight: normal;'>Sum Assured</th>
<th style='font-weight: normal;'>Risk</th>
</tr>
</thead>
<tbody>
$health
</tbody>
</table>
</div>
<div class='col l2 s12'>
<h3 style='text-align:center;color:#000000;'>General Insurance</h3>
<table class='striped'>
<thead>
<tr style='background-color:#ed780e;color:#FFFFFF;'>
<th style='font-weight: normal;'>Type</th>
<th style='font-weight: normal;'>Premium Amount</th>
</tr>
</thead>
<tbody>
$general
</tbody>
</table>
</div>";
return json_encode(array('sts' => TRUE,'content' =>"$content"));
}
/**** GET GOAL INFORMATION ****/
function get_goal_info(){
$goal_query = $this->dbObj->runQuery("SELECT goal_id,lp_cust_goal.cust_id,lp_cust_goal.goal_family,goal_name,goal_date,goal_amount,inflation,inflation_amt,family_name,goal_for,goal_map FROM lp_cust_goal left join lp_cust_family on lp_cust_family.family_id = lp_cust_goal.goal_family where lp_cust_goal.status = '1' and lp_cust_goal.cust_id = '$this->cust_id' order by lp_cust_goal.goal_id");
$goal_info = $this->dbObj->result($goal_query);
$goal_for_array = array("1"=>"Education","2"=>"Marriage","3"=>"Retirement","4"=>"Dream Home","5"=>"Dream Car");
$icon_array = array("1"=>"fa-graduation-cap","2"=>"fa-heartbeat","3"=>"fa-bed","4"=>"fa-home","5"=>"fa-car");
$content = "<h1 class='inner_title'>YOUR RISK PROFILE</h1>";
$mf_amount = 0;
foreach($goal_info as $goal){
$goal_id = $goal->goal_id;
$goal_name = $goal->goal_name;
$goal_date = new DateTime($goal->goal_date);
$goal_date = $goal_date->format("d M Y");
$goal_amount = $goal->goal_amount;
$inflation_amt = $goal->inflation_amt;
$family_name = $goal->family_name;
$goal_for = $goal->goal_for;
$goal_map = $goal->goal_map;
$goal_for_name = $goal_for_array[$goal_for];
$icon_name = $icon_array[$goal_for];
$now = new DateTime();
$end = new DateTime($goal->goal_date);
$interval = $now->diff($end);
$years = $interval->format('%y years %m months and %d days');
$goal_year = new DateTime($goal->goal_date);
$goal_year = $goal_year->format("Y");
$tot_goal_amount = 0;
if($goal_map){
$goal_map = explode(",",$goal_map);
foreach ($goal_map as $key => $value){
$goal_list = explode("_",$value);
$inv_mode = $goal_list[0];
$inv_rec_id = $goal_list[1];
if($inv_mode === "BK"){
$bank_list_info = $this->dbObj->runQuery("SELECT bank_id,lp_cust_bank.cust_id,bank_family,bank_scheme,bank_descript,bank_amt,bank_type,bank_startdate,bank_tenure,bank_tenure_type,bank_ror,bank_maturity,bank_maturity_amt,paying_type_name,family_name,bank_yearly FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_id = '$inv_rec_id'");
$bank_info = $this->dbObj->result($bank_list_info);
$bank_maturity = $bank_info[0]->bank_maturity;
$bank_maturity_amt = $bank_info[0]->bank_maturity_amt;
$maturity_year = new DateTime($bank_info[0]->bank_maturity);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $bank_maturity_amt;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$tot_goal_amount += round($inflation);
}else{
$tot_goal_amount += $bank_maturity_amt;
}
}else
if($inv_mode === "INS"){
$ins_list_info = $this->dbObj->runQuery("SELECT insurance_id,lp_cust_insurance.cust_id,ins_type,ins_general_type,ins_proposer,ins_insured,ins_life_assured,ins_company,ins_plan,ins_sum_assured,ins_start_date,ins_issued_date,ins_term,ins_ppt,ins_premium,ins_due_date,insurance_type_name,insurance_company_name,insurance_plan_name,premium_yearly ,pensioner,vesting_date,pen_frq,pen_amt,pen_ror,vesting_corpus,one3rd_corpus,pen_payout,pen_ropen,pension_amount FROM lp_cust_insurance left join lp_insurance_type on lp_insurance_type.insurance_type_id = lp_cust_insurance.ins_type left join lp_insurance_company on lp_insurance_company.insurance_company_id = lp_cust_insurance.ins_company left join lp_insurance_plan on lp_insurance_plan.insurance_plan_id = lp_cust_insurance.ins_plan where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' and insurance_id = '$inv_rec_id'");
$ins_info = $this->dbObj->result($ins_list_info);
$ins_issued_date = $ins_info[0]->ins_issued_date;
$ins_term = $ins_info[0]->ins_term;
$ins_ppt = $ins_info[0]->ins_ppt;
$ins_premium = $ins_info[0]->ins_premium;
$premium_yearly = $ins_info[0]->premium_yearly;
$ins_sum_assured = $ins_info[0]->ins_sum_assured;
$maturity_info = lp_calculation::maturity_date($ins_issued_date,$ins_term,3);
$maturity_info = json_decode($maturity_info);
$maturity_date = $maturity_info->maturity_date;
$maturity_year = new DateTime($maturity_date);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $premium_yearly;
for($i=1; $i<(int)$ins_ppt; $i++){
$interst= $inflation * 0.06;
$inflation=$inflation+$interst+$premium_yearly;
}
for($i=(int)$ins_ppt; $i<=(int)$ins_term; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
for($i=$maturity_year; $i<$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$tot_goal_amount += round($inflation);
}else{
//$tot_goal_amount += $ins_sum_assured;
}
}else
if($inv_mode === "MF"){
$mf_list_info = $this->dbObj->runQuery("SELECT mf_id,lp_cust_mf.cust_id,mf_investor,mf_amc,mf_scheme,mf_fund_class,mf_fund_type,mf_inv_type,mf_present_val,mf_live_sip,amc_name,fund_name,fund_class_name,family_name,mf_yearly,mf_end_date FROM lp_cust_mf left join lp_amc on lp_amc.amc_id = lp_cust_mf.mf_amc left join lp_fund_name on lp_fund_name.fund_name_id = lp_cust_mf.mf_scheme left join lp_fund_class on lp_fund_class.fund_class_id = lp_cust_mf.mf_fund_class left join lp_cust_family on lp_cust_family.family_id = lp_cust_mf.mf_investor where lp_cust_mf.status = '1' and lp_cust_mf.cust_id = '$this->cust_id' and mf_id = '$inv_rec_id'");
$mf_info = $this->dbObj->result($mf_list_info);
$mf_present_val = $mf_info[0]->mf_present_val;
$mf_live_sip = $mf_info[0]->mf_live_sip;
$mf_yearly = $mf_info[0]->mf_yearly;
$mf_end_date = $mf_info[0]->mf_end_date;
$amc_name = $mf_info[0]->amc_name;
$maturity_date = new DateTime($mf_info[0]->mf_end_date);
$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($mf_info[0]->mf_end_date);
$maturity_year = $maturity_year->format("Y");
$inflation = $mf_yearly;
/*
for($i=date("Y"); $i<=$goal_year; $i++){
$interst= $inflation * 0.06;
$inflation=$inflation+$interst+$mf_yearly;
}
*/
for($i=date("Y"); $i<$maturity_year; $i++){
$interst = $inflation * 0.12;
$inflation = $inflation+$interst+$mf_yearly;
}
for($i=$maturity_year; $i<=$goal_year; $i++){
$interst = $inflation * 0.12;
$inflation = $inflation+$interst;
}
$mf_amount += $mf_present_val + round($inflation);
//$tot_goal_amount += $mf_present_val + round($inflation);
$tot_goal_amount += $mf_amount;
}else
if($inv_mode === "GOV"){
$gov_list_info = $this->dbObj->runQuery("SELECT gov_id,lp_cust_gov.cust_id,gov_holder,gov_scheme,gov_type,gov_amount,gov_start_date,gov_maturity_date,gov_ror,gov_maturity_value,family_name,gov_scheme_name,paying_type_name,gov_yearly FROM lp_cust_gov left join lp_cust_family on lp_cust_family.family_id = lp_cust_gov.gov_holder left join lp_gov_scheme on lp_gov_scheme.gov_scheme_id = lp_cust_gov.gov_scheme left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_gov.gov_type where lp_cust_gov.status = '1' and lp_cust_gov.cust_id = '$this->cust_id' and gov_id = '$inv_rec_id'");
$gov_info = $this->dbObj->result($gov_list_info);
$gov_id = $gov_info[0]->gov_id;
$gov_maturity_date = $gov_info[0]->gov_maturity_date;
$gov_maturity_value = $gov_info[0]->gov_maturity_value;
$maturity_year = new DateTime($gov_info[0]->gov_maturity_date);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $bank_maturity_amt;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$tot_goal_amount += round($inflation);
}else{
$tot_goal_amount += $gov_maturity_value;
}
}else
if($inv_mode === "OTH"){
$others_list_info = $this->dbObj->runQuery("SELECT others_id,lp_cust_others.cust_id,others_investor,others_descript,others_amt,others_type,others_startdate,others_tenure,others_tenure_type,others_expected_val,others_maturity_date,others_maturity_val,family_name,paying_type_name,other_yearly FROM lp_cust_others left join lp_cust_family on lp_cust_family.family_id = lp_cust_others.others_investor left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_others.others_type where lp_cust_others.status = '1' and lp_cust_others.cust_id = '$this->cust_id' and others_id = '$inv_rec_id'");
$others_info = $this->dbObj->result($others_list_info);
$others_maturity_date = $others_info[0]->others_maturity_date;
$others_maturity_val = $others_info[0]->others_maturity_val;
$maturity_year = new DateTime($others_info[0]->others_maturity_date);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $others_maturity_val;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$tot_goal_amount += round($inflation);
}else{
$tot_goal_amount += $others_maturity_val;
}
}
}
}
if((int)$goal_for === 3){
$req_corp = ($inflation_amt * 12) / 6 * 100;
$req_amount = $req_corp - $tot_goal_amount;
$percentage = round(($tot_goal_amount/$req_corp)*100,2);
}else{
$req_amount = $inflation_amt - $tot_goal_amount;
$percentage = round(($tot_goal_amount/$inflation_amt)*100,2);
}
if($percentage >= 100){
$req_amount = abs($req_amount);
$req_info = "<label>Deficit</label> 0<br/><label>In Hand</label> $req_amount";
$percent_icon = "<div style='color:#43d854;padding-right:6%;'>100% <i class='fa fa-thumbs-o-up fa-2x' aria-hidden='true'></i></div>";
}else{
$req_info = "<label>Deficit</label><br/>$req_amount";
$percent_icon = "<div style='color:#e31e2b;padding-right:6%;'>$percentage% <i class='fa fa-thumbs-o-down fa-2x' aria-hidden='true'></i></div>";
}
$content .= "<div class='col l4 s12'>
<div class='row mg0 goal_holder'>
<table>
<tr>
<td class='goal_td_left'>
<span style='color:#ed780e;'><i class='fa $icon_name fa-3x' aria-hidden='true'></i></span>
<span style='font-size:20px;'>$goal_name</span>
</td>
<td class='goal_td_right'>
<label>Goal Date</label><br/>
$goal_date
</td>
</tr>
<tr>
<td class='goal_td_left'>
<label>Years to go</label><br/>
$years
</td>
<td class='goal_td_right'>
<label>Goal Status</label><br/>
$percent_icon
</td>
</tr>
<tr>
<td class='goal_td_left'>
<label>Current Expence</label><br/>
$goal_amount
</td>
<td class='goal_td_right'>
<label>Goal Amount</label><br/>
$inflation_amt
</td>
</tr>
<tr>
<td class='goal_td_left'>
$req_info
</td>
<td class='goal_td_right'>
<a class='waves-effect waves-light btn btn-floating' onclick=goal_data('$goal_id')><i class='material-icons'>near_me</i></a>
</td>
</tr>
</table>
</div>
<div class='col l12 s12 pd0 split'></div>
</div>";
}
return json_encode(array('sts' => TRUE,'content' =>"$content"));
}
/**** GET GOAL INFORMATION IN DETAIL ****/
function get_goal_info_detail($goal_id,$returns){
$goal_query = $this->dbObj->runQuery("SELECT goal_id,lp_cust_goal.cust_id,lp_cust_goal.goal_family,goal_name,goal_date,goal_amount,inflation,inflation_amt,family_name,goal_for,goal_map FROM lp_cust_goal left join lp_cust_family on lp_cust_family.family_id = lp_cust_goal.goal_family where lp_cust_goal.status = '1' and lp_cust_goal.cust_id = '$this->cust_id' and goal_id = '$goal_id'");
$goal_info = $this->dbObj->result($goal_query);
$bank_scheme_info = array('1'=>"Bank Fixed Deposit",'2'=>"Company Deposit",'3'=>"Bank Recurring Deposit",'4'=>"Bonds",'5'=>"Other Deposits");
$goal_for_array = array("1"=>"Education","2"=>"Marriage","3"=>"Retirement","4"=>"Dream Home","5"=>"Dream Car");
$icon_array = array("1"=>"fa-graduation-cap","2"=>"fa-heartbeat","3"=>"fa-bed","4"=>"fa-home","5"=>"fa-car");
$tr_line = "";
foreach($goal_info as $goal){
$goal_id = $goal->goal_id;
$goal_name = $goal->goal_name;
$goal_date = new DateTime($goal->goal_date);
$goal_date = $goal_date->format("d M Y");
$goal_amount = $goal->goal_amount;
$inflation_amt = $goal->inflation_amt;
$family_name = $goal->family_name;
$goal_for = $goal->goal_for;
$goal_map = $goal->goal_map;
$goal_for_name = $goal_for_array[$goal_for];
$icon_name = $icon_array[$goal_for];
$goal_year = new DateTime($goal->goal_date);
$goal_year = $goal_year->format("Y");
$goal_map = explode(",",$goal_map);
$bank_amount = 0;
$ins_amount = 0;
$mf_amount = 0;
$gov_amount = 0;
$others_amount = 0;
$tot_goal_amount = 0;
foreach ($goal_map as $key => $value){
$goal_list = explode("_",$value);
$inv_mode = $goal_list[0];
$inv_rec_id = $goal_list[1];
if($inv_mode === "BK"){
$bank_list_info = $this->dbObj->runQuery("SELECT bank_id,lp_cust_bank.cust_id,bank_family,bank_scheme,bank_descript,bank_amt,bank_type,bank_startdate,bank_tenure,bank_tenure_type,bank_ror,bank_maturity,bank_maturity_amt,paying_type_name,family_name,bank_yearly FROM lp_cust_bank left join lp_cust_family on lp_cust_family.family_id = lp_cust_bank.bank_family left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_bank.bank_type where lp_cust_bank.status = '1' and lp_cust_bank.cust_id = '$this->cust_id' and bank_id = '$inv_rec_id'");
$bank_info = $this->dbObj->result($bank_list_info);
$bank_maturity = $bank_info[0]->bank_maturity;
$bank_maturity_amt = $bank_info[0]->bank_maturity_amt;
$bank_scheme = $bank_info[0]->bank_scheme;
$bank_scheme_name = $bank_scheme_info[$bank_scheme];
$maturity_date = new DateTime($bank_info[0]->bank_maturity);
$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($bank_info[0]->bank_maturity);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $bank_maturity_amt;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$bank_amount += round($inflation);
}else{
$bank_amount += $bank_maturity_amt;
}
$tot_goal_amount += $bank_amount;
$tr_line .= "<tr><td>Bank</td><td>$bank_scheme_name</td><td>$maturity_date</td><td>$bank_maturity_amt</td><td>$bank_amount</td></tr>";
}else
if($inv_mode === "INS"){
$ins_list_info = $this->dbObj->runQuery("SELECT insurance_id,lp_cust_insurance.cust_id,ins_type,ins_general_type,ins_proposer,ins_insured,ins_life_assured,ins_company,ins_plan,ins_sum_assured,ins_start_date,ins_issued_date,ins_term,ins_ppt,ins_premium,ins_due_date,insurance_type_name,insurance_company_name,insurance_plan_name,premium_yearly ,pensioner,vesting_date,pen_frq,pen_amt,pen_ror,vesting_corpus,one3rd_corpus,pen_payout,pen_ropen,pension_amount FROM lp_cust_insurance left join lp_insurance_type on lp_insurance_type.insurance_type_id = lp_cust_insurance.ins_type left join lp_insurance_company on lp_insurance_company.insurance_company_id = lp_cust_insurance.ins_company left join lp_insurance_plan on lp_insurance_plan.insurance_plan_id = lp_cust_insurance.ins_plan where lp_cust_insurance.status = '1' and lp_cust_insurance.cust_id = '$this->cust_id' and insurance_id = '$inv_rec_id'");
$ins_info = $this->dbObj->result($ins_list_info);
$ins_issued_date = $ins_info[0]->ins_issued_date;
$ins_term = $ins_info[0]->ins_term;
$ins_ppt = $ins_info[0]->ins_ppt;
$ins_premium = $ins_info[0]->ins_premium;
$premium_yearly = $ins_info[0]->premium_yearly;
$ins_sum_assured = $ins_info[0]->ins_sum_assured;
$insurance_type_name = $ins_info[0]->insurance_type_name;
$maturity_info = lp_calculation::maturity_date($ins_issued_date,$ins_term,3);
$maturity_info = json_decode($maturity_info);
$maturity_date = $maturity_info->maturity_date;
//$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($maturity_date);
$maturity_year = $maturity_year->format("Y");
$issued_year = new DateTime($ins_issued_date);
$issued_year = $issued_year->format("Y");
$ins_amount = 0;
$invest_amout = 0;
if((int)$goal_year > (int)$maturity_year){
$inflation = $premium_yearly;
for($i=1; $i<(int)$ins_ppt; $i++){
$interst= $inflation * 0.06;
$inflation=$inflation+$interst+$premium_yearly;
$invest_amout += $premium_yearly;
}
for($i=(int)$ins_ppt; $i<=(int)$ins_term; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
for($i=$maturity_year; $i<$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$ins_amount += round($inflation);
}else{
//$ins_amount += $ins_sum_assured;
}
$tot_goal_amount += $ins_amount;
$tr_line .= "<tr><td>Insurance</td><td>$insurance_type_name</td><td>$maturity_date</td><td>$invest_amout</td><td>$ins_amount</td></tr>";
}else
if($inv_mode === "MF"){
$mf_list_info = $this->dbObj->runQuery("SELECT mf_id,lp_cust_mf.cust_id,mf_investor,mf_amc,mf_scheme,mf_fund_class,mf_fund_type,mf_inv_type,mf_present_val,mf_live_sip,amc_name,fund_name,fund_class_name,family_name,mf_yearly,mf_end_date FROM lp_cust_mf left join lp_amc on lp_amc.amc_id = lp_cust_mf.mf_amc left join lp_fund_name on lp_fund_name.fund_name_id = lp_cust_mf.mf_scheme left join lp_fund_class on lp_fund_class.fund_class_id = lp_cust_mf.mf_fund_class left join lp_cust_family on lp_cust_family.family_id = lp_cust_mf.mf_investor where lp_cust_mf.status = '1' and lp_cust_mf.cust_id = '$this->cust_id' and mf_id = '$inv_rec_id'");
$mf_info = $this->dbObj->result($mf_list_info);
$mf_present_val = $mf_info[0]->mf_present_val;
$mf_live_sip = $mf_info[0]->mf_live_sip;
$mf_yearly = $mf_info[0]->mf_yearly;
$mf_end_date = $mf_info[0]->mf_end_date;
$amc_name = $mf_info[0]->amc_name;
$maturity_date = new DateTime($mf_info[0]->mf_end_date);
$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($mf_info[0]->mf_end_date);
$maturity_year = $maturity_year->format("Y");
$inflation = $mf_yearly;
/*
for($i=date("Y"); $i<=$goal_year; $i++){
$interst= $inflation * 0.06;
$inflation=$inflation+$interst+$mf_yearly;
}
*/
for($i=date("Y"); $i<$maturity_year; $i++){
$interst = $inflation * 0.12;
$inflation = $inflation+$interst+$mf_yearly;
}
for($i=$maturity_year; $i<=$goal_year; $i++){
$interst = $inflation * 0.12;
$inflation = $inflation+$interst;
}
$mf_amount += $mf_present_val + round($inflation);
$tot_goal_amount += $mf_amount;
$tr_line .= "<tr><td>Mutual Fund</td><td>$amc_name</td><td>$maturity_date</td><td>$mf_amount</td><td>$mf_amount</td></tr>";
}else
if($inv_mode === "GOV"){
$gov_list_info = $this->dbObj->runQuery("SELECT gov_id,lp_cust_gov.cust_id,gov_holder,gov_scheme,gov_type,gov_amount,gov_start_date,gov_maturity_date,gov_ror,gov_maturity_value,family_name,gov_scheme_name,paying_type_name,gov_yearly FROM lp_cust_gov left join lp_cust_family on lp_cust_family.family_id = lp_cust_gov.gov_holder left join lp_gov_scheme on lp_gov_scheme.gov_scheme_id = lp_cust_gov.gov_scheme left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_gov.gov_type where lp_cust_gov.status = '1' and lp_cust_gov.cust_id = '$this->cust_id' and gov_id = '$inv_rec_id'");
$gov_info = $this->dbObj->result($gov_list_info);
$gov_id = $gov_info[0]->gov_id;
$gov_maturity_date = $gov_info[0]->gov_maturity_date;
$gov_maturity_value = $gov_info[0]->gov_maturity_value;
$gov_scheme_name = $gov_info[0]->gov_scheme_name;
$maturity_date = new DateTime($gov_info[0]->gov_maturity_date);
$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($gov_info[0]->gov_maturity_date);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $bank_maturity_amt;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$gov_amount += round($inflation);
}else{
$gov_amount += $gov_maturity_value;
}
$tot_goal_amount += $gov_amount;
$tr_line .= "<tr><td>Government scheme</td><td>$gov_scheme_name</td><td>$maturity_date</td><td>$gov_maturity_value</td><td>$gov_amount</td></tr>";
}else
if($inv_mode === "OTH"){
$others_list_info = $this->dbObj->runQuery("SELECT others_id,lp_cust_others.cust_id,others_investor,others_descript,others_amt,others_type,others_startdate,others_tenure,others_tenure_type,others_expected_val,others_maturity_date,others_maturity_val,family_name,paying_type_name,other_yearly FROM lp_cust_others left join lp_cust_family on lp_cust_family.family_id = lp_cust_others.others_investor left join lp_paying_type on lp_paying_type.paying_type_id = lp_cust_others.others_type where lp_cust_others.status = '1' and lp_cust_others.cust_id = '$this->cust_id' and others_id = '$inv_rec_id'");
$others_info = $this->dbObj->result($others_list_info);
$others_maturity_date = $others_info[0]->others_maturity_date;
$others_maturity_val = $others_info[0]->others_maturity_val;
$others_descript = $others_info[0]->others_descript;
$maturity_date = new DateTime($others_info[0]->others_maturity_date);
$maturity_date = $maturity_date->format("d M Y");
$maturity_year = new DateTime($others_info[0]->others_maturity_date);
$maturity_year = $maturity_year->format("Y");
if((int)$goal_year > (int)$maturity_year){
$inflation = $others_maturity_val;
for($i=$maturity_year; $i<=$goal_year; $i++){
$inflation_info = lp_calculation::compound_interest($inflation,6,1);
$inflation_info = json_decode($inflation_info);
$inflation = $inflation_info->future_value;
}
$others_amount += round($inflation);
}else{
$others_amount += $others_maturity_val;
}
$tot_goal_amount += $others_amount;
$tr_line .= "<tr><td>Others</td><td>$others_descript</td><td>$maturity_date</td><td>$others_maturity_val</td><td>$others_amount</td></tr>";
}
}
$req_corp_info = "";
if((int)$goal_for === 3){
$req_corp = ($inflation_amt * 12) / 6 * 100;
$req_amount = $req_corp - $tot_goal_amount;
$percentage = round(($tot_goal_amount/$req_corp)*100,2);
$req_corp_info = "<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#ed780e;'>Required Corpus</td>
<td style='font-weight: bold;color:#ed780e;'>$req_corp</td>
</tr>";
}else{
$req_amount = $inflation_amt - $tot_goal_amount;
$percentage = round(($tot_goal_amount/$inflation_amt)*100,2);
}
//$req_amount = $inflation_amt - $tot_goal_amount;
//$percentage = round(($tot_goal_amount/$inflation_amt)*100,2);
if($percentage >= 100){
$req_amount = abs($req_amount);
$req_info = "<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#43d854;'>In Hand</td>
<td style='font-weight: bold;color:#43d854;'>$req_amount</td>
</tr>";
$percent_icon = "<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#43d854;'>Percentage</td>
<td style='font-weight: bold;color:#43d854;'>100%</td>
</tr>";
$suggetion = "<div class='col l6 s12'>
<div class='row mg0 goal_holder' style='text-align:center;color:#ed780e;padding:30px !important;'>
<i class='material-icons large'>directions_run</i>
<p style='text-align:center;color:#000000;font-size: 21px;'>
Great !!!<br/>
You can achieve your goal.
</p>
</div>
</div>";
}else{
$now = new DateTime();
$end = new DateTime($goal->goal_date);
$interval = $now->diff($end);
$years = $interval->format('%y years %m months and %d days');
$start_date = $now->format("Y-m-d");
$end_date = $end->format("Y-m-d");
$years_cal = lp_calculation::total_year($end_date ,$start_date);
$sip = lp_calculation::pmt($returns, $years_cal, $req_amount);
$total_month = lp_calculation::total_month($start_date, $end_date);
$lumpsum = lp_calculation::lumpsum($req_amount,$returns,$total_month);
$req_info = "<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#e31e2b;'>Deficit</td>
<td style='font-weight: bold;color:#e31e2b;'>$req_amount</td>
</tr>";
$percent_icon = "<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#e31e2b;'>Percentage</td>
<td style='font-weight: bold;color:#e31e2b;'>$percentage%</td>
</tr>";
$sug_list = "<option value='' disabled>-- Returns in% --</option>";
$sug_array = array(6, 8, 10, 12, 14, 16, 18);
foreach ($sug_array as $key=>$value) {
if((int)$returns === $value){
$sug_list .= "<option value='$value' selected>Returns in $value%</option>";
}else{
$sug_list .= "<option value='$value'>Returns in $value%</option>";
}
}
$suggetion = "<div class='col l6 s12'>
<div class='row mg0 goal_holder'>
<div class='col l12 s12 pd0'>
<div class='row mg0'>
<div class='col l9 s6 pd0'>
<h4 style='margin:13px 0px;'>Suggestion</h4>
</div>
<div class='col l3 s6 pd0'>
<input type='hidden' value='$goal_id' id='suggestion_id' name='suggestion_id'/>
<select id='suggestion_returs' name='suggestion_returs' onchange=suggestion_returs();>
$sug_list
</select>
</div>
</div>
</div>
<table>
<thead>
<tr>
<th>Years</th>
<th>Name</th>
<th>Interest</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>$years_cal</td>
<td>SIP</td>
<td>$returns</td>
<td>$sip</td>
</tr>
<tr>
<td>$years_cal</td>
<td>LUMPSUM</td>
<td>$returns</td>
<td>$lumpsum</td>
</tr>
</tbody>
</table>
</div>
</div>";
}
$content = "<div class='row mg0' style='padding:35px 15px;'>
<div class='col l6 s12'>
<div class='row mg0 goal_holder'>
<h4 style='text-align:center;'>Map goal in detail</h4>
<table>
<thead>
<tr>
<th>Category</th>
<th>Company</th>
<th>Maturity Date</th>
<th>Invested Amount</th>
<th>Final Amount</th>
</tr>
</thead>
<tbody>
$tr_line
<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#ed780e;'>Total Amount</td>
<td style='font-weight: bold;color:#ed780e;'>$tot_goal_amount</td>
</tr>
<tr>
<td colspan='4' style='text-align:center;font-weight: bold;color:#ed780e;'>Goal Amount</td>
<td style='font-weight: bold;color:#ed780e;'>$inflation_amt</td>
</tr>
$req_corp_info
$req_info
$percent_icon
</tbody>
</table>
</div>
</div>
$suggetion
</div>";
return json_encode(array('sts' => TRUE,'content' =>"$content"));
}
}
}
?>