MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/lifemaze_in/lp_lib/lp_customer.php
<?php
/**********************************************************
	   Filename: lp_customer.php
	Description: Object for all customer related operation
		 Author: uday
	 Created on: AUG, 01 2018
	Approved on: 
	Reviewed on: 
	------------------------------------------------------------
	Modification Details
	Changed by:
	------------------------------------------------------------
**********************************************************/
class lp_customer{
	
	private $dbObj = null;		
	private $real_db = null;	
	private $created_date;
	private $valid_cust = false;
	
	public $cust_id;
	public $cust_name;
	public $cust_mobile;
	public $cust_email;
	public $cust_address;
	public $city;
	public $pin;
	public $country;
	
	function __construct() {
		$this->dbConnection();
		
		$this->cust_id      = '';
		$this->cust_name    = '';
		$this->cust_mobile  = '';
		$this->cust_email   = '';
		$this->cust_address = '';
		$this->city         = '';
		$this->state        = '';
		$this->pin          = '';
		$this->country      = '';
		$this->created_date = '';	
		$this->valid_cust   = false;
	}
	function __wakeup() {
		$this->dbConnection();
	}
	
	function __destruct() {
		unset($this->dbObj);		
		unset($this->real_db);
	}
	
	function dbConnection()	{
		$this->dbObj = lpObject::newObject('lp_db');
		$this->dbObj->open_db();
	}
	
	function getDBObject(){
		return $this->dbObj; 
	}
	
	function get_db(){
		$this->real_db = $this->dbObj->get_db();
		return $this->real_db;
	}
	
	function is_customer(){
		return $this->valid_cust;
	}	
	
	//LOGIN CUSTOMER INFORMATION
	function get_cust_info($cust_id) {	
		$cust_info  = $this->dbObj->query("customers","cust_id='$cust_id'");
		$cust_rows  = $this->dbObj->num_rows($cust_info);
		if((int)$cust_rows === 1){
			$cust_rslt  = $this->dbObj->result($cust_info);
			$this->valid_cust = true;
			
			$this->cust_id      = $cust_rslt[0]->cust_id;
			$this->cust_name    = $cust_rslt[0]->cust_name;
			$this->cust_mobile  = $cust_rslt[0]->cust_mobile;
			$this->cust_email   = $cust_rslt[0]->cust_email;
			$this->cust_address = $cust_rslt[0]->cust_address;
			$this->city         = $cust_rslt[0]->city;
			$this->state        = $cust_rslt[0]->state;
			$this->pin          = $cust_rslt[0]->pin;
			$this->country      = $cust_rslt[0]->country;
			$this->created_date = $cust_rslt[0]->created_date;
			return $cust_rslt;
		}else{
			return false;
		}
	}
	
	/**** DROP DOWN LIST INFORMATION - START ****/
	function get_common_drop(){
		$data = new stdClass;
		$data->relation           = $this->get_relation();
		$data->expense            = $this->get_expense();
		$data->expense_sub        = $this->get_expense_sub();
		$data->paying_type        = $this->get_paying_type();
		$data->loan_type          = $this->get_loan_type();
		$data->insurance_type     = $this->get_insurance_type();
		$data->insurance_company  = $this->get_insurance_company();
		$data->insurance_plan     = $this->get_insurance_plan();
		$data->amc  			  = $this->get_amc();
		$data->fund_name          = $this->get_fund_name();
		$data->fund_class         = $this->get_fund_class();
		$data->gov_scheme         = $this->get_gov_scheme();
		return $data;
	}
	
	function get_relation(){
		$relation_info = $this->dbObj->query('relation',"status='1'",'relation_id,relation_name');
		return $this->dbObj->result($relation_info);
	}
	
	function get_expense($exp_cat=false){
		$where = "status='1'";
		if($exp_cat){
			$where = "status='1' and expense_id='$exp_cat'";
		}
		$expense_info = $this->dbObj->query('expense',"$where",'expense_id,expense_name,expense_related');
		return $this->dbObj->result($expense_info);
	}
	
	function get_expense_sub($exp_cat=false){
		$where = "status='1'";
		if($exp_cat){
			$where = "status='1' and expense_id='$exp_cat'";
		}
		$expense_sub_info = $this->dbObj->query('expense_sub',"$where",'expense_sub_id,expense_id,expense_sub_name');
		return $this->dbObj->result($expense_sub_info);
	}
	
	function get_paying_type(){
		$paying_type_info = $this->dbObj->query('paying_type',"status='1'",'paying_type_id,paying_type_name');
		return $this->dbObj->result($paying_type_info);
	}
	
	function get_loan_type(){
		$loan_type_info = $this->dbObj->query('loan_type',"status='1'",'loan_type_id,loan_type_name');
		return $this->dbObj->result($loan_type_info);
	}
	
	function get_insurance_type(){
		$insurance_type_info = $this->dbObj->query('insurance_type',"status='1'",'insurance_type_id,insurance_type_name');
		return $this->dbObj->result($insurance_type_info);
	}
	
	function get_insurance_company(){
		$insurance_company_info = $this->dbObj->query('insurance_company',"status='1'",'insurance_company_id,insurance_type_id,insurance_company_name');
		return $this->dbObj->result($insurance_company_info);
	}
	
	function get_insurance_plan($ins_company=false){
		$where = "status='1'";
		if($ins_company){
			$where = "status='1' and insurance_company_id='$ins_company'";
		}
		$insurance_plan_info = $this->dbObj->query('insurance_plan',"$where",'insurance_plan_id,insurance_company_id,insurance_plan_name');
		return $this->dbObj->result($insurance_plan_info);
	}
	
	function get_amc(){
		$amc_info = $this->dbObj->query('amc',"status='1'",'amc_id,amc_name');
		return $this->dbObj->result($amc_info);
	}
	
	function get_fund_name($mf_amc=false){
		$where = "status='1'";
		if($mf_amc){
			$where = "status='1' and amc='$mf_amc'";
		}
		$fund_name_info = $this->dbObj->query('fund_name',"$where",'fund_name_id,amc,fund_name');
		return $this->dbObj->result($fund_name_info);
	}
	
	function get_fund_class(){
		$fund_class_info = $this->dbObj->query('fund_class',"status='1'",'fund_class_id,fund_class_name');
		return $this->dbObj->result($fund_class_info);
	}
	
	function get_gov_scheme(){
		$gov_scheme_info = $this->dbObj->query('gov_scheme',"status='1'",'gov_scheme_id,gov_scheme_name');
		return $this->dbObj->result($gov_scheme_info);
	}
	
	function get_salaried_list(){
		$salaried_info = $this->dbObj->query('cust_family',"(family_earning = '1' or family_earning = '2') and status='1' and cust_id = '$this->cust_id'",'family_id,family_name');
		return $this->dbObj->result($salaried_info);
	}
	
	function get_family_list(){
		$salaried_info = $this->dbObj->query('cust_family',"status='1' and cust_id = '$this->cust_id'",'family_id,family_name');
		return $this->dbObj->result($salaried_info);
	}
	/**** DROP DOWN LIST INFORMATION - END ****/
	
	/**** FAMILY - START ****/
	//PROVIDE FAMILY LIST
	function get_cust_family(){
		$query = "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";
		return $this->dbObj->runQuery($query);
	}
	function get_family_id($family_id){
		$query = "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' and lp_cust_family.family_id = '$family_id' order by lp_cust_family.family_id asc";
		$query_info = $this->dbObj->runQuery($query);
		return $this->dbObj->result($query_info);
	}
	function get_fam_list_content($msg=""){	
		$family_list   = "<h4 style='margin:8px 15px;'>Your Family List </h4>";
		$gender_array  = array("1"=>"Male","2"=>"Female","3"=>"Transgender");
		$earning_array = array("1"=>"Salaried","2"=>"Self Employed","3"=>"Not Working","4"=>"Nill");
		$icon_array    = array("0"=>"assignment_ind","1"=>"supervisor_account","2"=>"face","3"=>"face","4"=>"wc","5"=>"wc","6"=>"sentiment_very_satisfied","7"=>"sentiment_very_satisfied","8"=>"sentiment_very_satisfied","9"=>"sentiment_very_satisfied","10"=>"sentiment_very_satisfied","11"=>"sentiment_very_satisfied");
		
		$cust_family_info  = $this->get_cust_family();
		$cust_family_rows  = $this->dbObj->num_rows($cust_family_info);
		$mode = "Self";
		if((int)$cust_family_rows > 0){
			$mode = "Family";
			$cust_family = $this->dbObj->result($cust_family_info);
			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;
				
				$gender_name = "";
				if($gender){
					$gender_name  = $gender_array[$gender];
				}				
				$earning_name = "";
				if($earning){
					$earning_name  = $earning_array[$earning];
				}
				$icon_name  = $icon_array[$relation];
				
				if($relation === "0"){
					$relation_name = "Self";
					$family_list .= "<div class='col l6  s12 mgb4'>
										<div class='row pd4 list_card hoverable mg0'>
											<div class='col l1 s6 pd8 cl_gray'>
												<i class='material-icons small'>$icon_name</i>
											</div>
											<div class='col l3 s6 truncate'>
												$name
												<div class='list_name'>Name</div>
											</div>
											<div class='col l2 s6 truncate'>
												$dob
												<div class='list_name'>DOB</div>
											</div>
											<div class='col l2 s6 truncate'>
												$gender_name
												<div class='list_name'>Gender</div>
											</div>
											<div class='col l2 s6 truncate'>
												$earning_name
												<div class='list_name'>Earning</div>
											</div>
											<div class='col l1 s2 pl_btn pd8'>
												<span onclick=edit_data('family','$family_id') ><i class='material-icons small'>edit</i></span>
											</div>
											
										</div>
									</div>";
									/* UDY :: SELF CAN'T BE REMOVE
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('family','$family_id')><i class='material-icons small'>delete</i></span>
									</div>
									*/
				}else{
					$family_list .= "<div class='col l6  s12 mgb8'>
										<div class='row pd4 list_card hoverable mg0'>
											<div class='col l1 s6 pd8 cl_gray'>
												<i class='material-icons small'>$icon_name</i>
											</div>
											<div class='col l3 s6 truncate'>
												$name
												<div class='list_name'>Name</div>
											</div>
											<div class='col l2 s6 truncate'>
												$age
												<div class='list_name'>Age</div>
											</div>
											<div class='col l2 s6 truncate'>
												$relation_name
												<div class='list_name'>Relationship</div>
											</div>
											<div class='col l2 s6 truncate'>
												$earning_name
												<div class='list_name'>Earning</div>
											</div>
											<div class='col l1 s2 pl_btn pd8'>
												<span onclick=edit_data('family','$family_id')><i class='material-icons small'>edit</i></span>
											</div>
											<div class='col l1 s2 pl_btn pd8'>
												<span onclick=remove_data('family','$family_id')><i class='material-icons small'>delete</i></span>
											</div>
										</div>
									</div>";
				}
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$family_list", 'family_count' =>"$cust_family_rows", 'mode' =>"$mode"));
	}
	// PROVIDE FULL FAMILY CONTENT
	function get_family_content($msg=""){
		
		//DROP DOWN LIST - START
		$loda_data     = $this->get_common_drop();		
		$relation_list = "<option value='' disabled selected>-- Relationship --</option>";
		foreach($loda_data->relation as $relation){
			$relation_id   = $relation->relation_id;
			$relation_name = $relation->relation_name;
			$relation_list .=  "<option value='$relation_id'>$relation_name</option>";
		}
		//DROP DOWN LIST - END
		
		// LOAD FAMILY LIST
		$family_info = $this->get_fam_list_content($msg);
		$family_info = json_decode($family_info);
		$family_list  = $family_info->content;
		$family_count = $family_info->family_count;
		
		$self_from   = "style=display:initial";
		$family_from = "style=display:none;";
		$mode        = "Self";
		if((int)$family_count > 0){
			$mode = "Family";
			$self_from = "style=display:none";
			$family_from = "style=display:initial;";
		}
		
		$family_content = "<h1 class='inner_title'>FAMILY PROFILE</h1>
							<div class='col l12 s12 subtab_holder'>
								<div class='row mg0'>
									<div class='col l12  s12'>
										<div class='row input_holder'>
											<form id='save_family_form'>
												<input id='family_id' name='family_id' value='0' type='hidden'/>
												<input id='family_mode' name='family_mode' value='$mode' type='hidden'/>
												<div class='input-field col l2 s12'>
													<input id='family_name' name='family_name' type='text' value='' >
													<label for='family_name'>Name</label>
												</div>
												<div class='input-field col l2 s12' $self_from id='family_dob_div'>
													<input id='family_dob' name='family_dob' class='datepicker'>
													<label for='family_dob'>DOB</label>
												</div>
												<div class='input-field col l2 s12' $self_from id='family_gender_div'>
													<select id='family_gender' name='family_gender'>
													  <option value='' disabled selected>-- Gender --</option>
													  <option value='1'>Male</option>
													  <option value='2'>Female</option>
													  <option value='3'>Trans-gender</option>
													</select>
													<label>Gender</label>
												</div>
												<div class='input-field col l2 s12' $family_from id='family_age_div'>
													<input id='family_age' name='family_age' type='text' class='number'>
													<label for='family_age'>Age</label>
												</div>
												<div class='input-field col l2 s12' $family_from id='family_relation_div'>
													<select id='family_relation' name='family_relation'>
														$relation_list
													</select>
													<label>Relationship</label>
												</div>
												<div class='input-field col l2 s12'>
													<select id='family_earning' name='family_earning'>
													  <option value='' disabled selected>-- Earning --</option>
													  <option value='1'>Salaried</option>
													  <option value='2'>Business</option>
													  <option value='3'>Not Working</option>
													  <option value='4'>Nill</option>
													</select>
													<label>Earning</label>
												</div>
												<div class='input-field col l1 s12' style='margin-top:18px;'>
													<a class='waves-effect waves-light btn' id='save_family_btn'>Save</a>
												</div>
											</form>
										</div>
									</div>
								</div>
								<div class='col l12  s12 inv_split'></div>
								<div class='col l12  s12 save_content' style='padding:0px !important;' id='family_list'>									
									$family_list
								</div>
							</div>";
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'family_content' =>"$family_content", 'load_script' =>"", 'family_count' =>$family_count));
	}
	/**** FAMILY - END ****/
	
	/**** EXPENSE AND LOAN - START ****/	
	// PROVIDE EXPENSE LIST
	function get_expense_list(){
		$query = "SELECT lp_cust_expense.expense_id,lp_cust_expense.cust_id,exp_cat,exp_sub_cat,exp_frq,exp_amt,exp_yearly,expense_name,expense_sub_name,paying_type_name,family_name,expense_related 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' order by lp_cust_expense.expense_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE EXPENSE CONTENT
	function get_expense_content($msg=""){
		$expense_list_info  = $this->get_expense_list();
		$expense_list_rows  = $this->dbObj->num_rows($expense_list_info);
		
		$content = "<h4>Your Expense List </h4>";
		if((int)$expense_list_rows > 0){
			$expense_info = $this->dbObj->result($expense_list_info);
			foreach($expense_info as $expense){
				$expense_id      = $expense->expense_id;
				$cust_id         = $expense->cust_id;
				$exp_cat         = $expense->exp_cat;
				$exp_sub_cat     = $expense->exp_sub_cat;
				$exp_frq         = $expense->exp_frq;
				$exp_amt         = $expense->exp_amt;
				$exp_yearly      = $expense->exp_yearly;
				$expense_name    = $expense->expense_name;
				$expense_related = $expense->expense_related;				
				$frq_name        = $expense->paying_type_name;
				
				if((int)$expense_related === 1){
					$sub_name = $expense->expense_sub_name;
				}
				if((int)$expense_related === 2){
					$sub_name = $expense->family_name;
				}
				//echo "$expense_related :: $sub_name<br/>";
				$cat = $expense_name;
				if($sub_name){
					$cat = "$expense_name($sub_name)";
				}
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>									
									<div class='col l3 s6 truncate'>
										$cat
										<div class='list_name'>Category</div>
									</div>
									<div class='col l3 s6 truncate'>
										$frq_name
										<div class='list_name'>Frequency</div>
									</div>
									<div class='col l2 s6 truncate'>
										$exp_amt
										<div class='list_name'>Amount</div>
									</div> 
									<div class='col l2 s6 truncate'>
										$exp_yearly
										<div class='list_name'>Yearly</div>
									</div> 
									<div class='col l1 s2 pl_btn right-align pd8'>
										<span onclick=edit_data('expense','$expense_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('expense','$expense_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'exp_count' =>"$expense_list_rows"));
	}
	
	// PROVIDE LOAN LIST
	function get_loan_list(){				
		$query = "SELECT loan_id,cust_id,loan_name,loan_outstanding,loan_remaining,loan_emi,loan_interest,loan_type_name 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' order by lp_cust_loan.loan_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE LOAN CONTENT
	function get_loan_content($msg=""){
		$loan_list_info  = $this->get_loan_list();
		$loan_list_rows  = $this->dbObj->num_rows($loan_list_info);
		
		$content = "<h4>Your Loan List </h4>";
		if((int)$loan_list_rows > 0){
			$loan_info = $this->dbObj->result($loan_list_info);
			foreach($loan_info as $loan){
				$loan_id          = $loan->loan_id;
				$cust_id          = $loan->cust_id;
				$loan_name        = $loan->loan_name;
				$loan_outstanding = $loan->loan_outstanding;
				$loan_remaining   = $loan->loan_remaining;
				$loan_emi         = $loan->loan_emi;
				$loan_interest    = $loan->loan_interest;
				$loan_type_name   = $loan->loan_type_name;
				
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate pd8'>
										$loan_type_name
									</div>
									<div class='col l2 s6 truncate'>
										$loan_name
										<div class='list_name'>Name</div>
									</div>
									<div class='col l2 s6 truncate'>
										$loan_outstanding
										<div class='list_name'>Outstanding</div>
									</div> 									
									<div class='col l2 s6 truncate'>
										$loan_remaining
										<div class='list_name'>Term</div>
									</div>
									<div class='col l2 s6 truncate'>
										<div><span class='list_name'>EMI</span> $loan_emi</div>
										<div><span class='list_name'>Interest</span> $loan_interest%</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('loan','$loan_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('loan','$loan_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'loan_count' =>"$loan_list_rows"));
	}
	
	// PROVIDE FULL EXPENSE AND LOAN CONTENT
	function get_expense_loan_content($msg=""){
		
		//DROP DOWN LIST - START
		$loda_data         = $this->get_common_drop();		
		$expense_list = "<option value='' disabled selected>-- Expense --</option>";
		foreach($loda_data->expense as $expense){
			$expense_id    = $expense->expense_id;
			$expense_name  = $expense->expense_name;
			$expense_list .=  "<option value='$expense_id'>$expense_name</option>";
		}
		
		$expense_sub_list = "<option value='' disabled selected>-- Sub Category --</option>";
		foreach($loda_data->expense_sub as $expense_sub){
			$expense_sub_id    = $expense_sub->expense_sub_id;
			$expense_sub_name  = $expense_sub->expense_sub_name;
			$expense_sub_list .=  "<option value='$expense_sub_id'>$expense_sub_name</option>";
		}
		
		$paying_type_list = "<option value='' disabled selected>-- Frequency --</option>";
		foreach($loda_data->paying_type as $paying_type){
			$paying_type_id    = $paying_type->paying_type_id;
			$paying_type_name  = $paying_type->paying_type_name;
			$paying_type_list .=  "<option value='$paying_type_id'>$paying_type_name</option>";
		}
		
		$loan_type_list = "<option value='' disabled selected>-- Loan Type --</option>";
		foreach($loda_data->loan_type as $loan_type){
			$loan_type_id    = $loan_type->loan_type_id;
			$loan_type_name  = $loan_type->loan_type_name;
			$loan_type_list .=  "<option value='$loan_type_id'>$loan_type_name</option>";
		}
		//DROP DOWN LIST - END
		
		// LOAD expense LIST
		$expense_info = $this->get_expense_content($msg);
		$expense_info = json_decode($expense_info);
		$exp_content  = $expense_info->content;
		$exp_count    = $expense_info->exp_count;
		
		// LOAD LOAN LIST
		$loan_info    = $this->get_loan_content($msg);
		$loan_info    = json_decode($loan_info);
		$loan_content = $loan_info->content;
		$loan_count   = $loan_info->loan_count;
		
		$family_info = $this->get_family_list();
		$family_list = "<option value='' disabled selected>-- Family --</option>";
		$family_list .= "<option value='0'>All</option>";
		foreach($family_info as $family){
			$family_id    = $family->family_id;
			$family_name  = $family->family_name;
			$family_list .=  "<option value='$family_id'>$family_name</option>";
		}
		
		$tab_class = "";
		if(($exp_count === "0") && ($loan_count === "0")){
			$tab_class = "disabled";
		}
		
		$content = "<h1 class='inner_title'>YOUR EXPENSE & LOAN</h1>
					<div class='col l2 s12 pd0'>
						<ul class='tabs inv_subtab' >
							<li class='tab'>
								<a href='#expense_subtab' class='active'>expense</a>
							</li>
							<li class='tab'>
								<a href='#loan_subtab'>Loan</a>
							</li>
						</ul>
					</div>
					<div class='col l10 s12 subtab_holder'>
						<div id='expense_subtab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_expense_form'>
									<input id='expense_id' name='expense_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='exp_cat' name='exp_cat'>
										  $expense_list
										</select>
										<label>Category</label>
									</div>
									<div class='input-field col l2 s12' id='exp_family_div'>
										<select id='exp_family' name='exp_family'>
										  $family_list
										</select>
										<label>Family</label>
									</div>
									<div class='input-field col l2 s12' id='exp_sub_cat_div'>
										<select id='exp_sub_cat' name='exp_sub_cat'>
										  $expense_sub_list
										</select>
										<label>Sub Category</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='exp_frq' name='exp_frq'>
										  $paying_type_list
										</select>
										<label>Expense Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='exp_amt' name='exp_amt' type='text' class='inwords'>
										<label for='exp_amt'>Amount</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_expense_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='expense_list'>
								$exp_content
							</div>
						</div>
						<div id='loan_subtab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_loan_form'>
									<input id='loan_id' name='loan_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='loan_type' name='loan_type'>
										  $loan_type_list
										</select>
										<label>Loan Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='loan_name' name='loan_name' type='text'>
										<label for='loan_name'>Name</label>
									</div>									
									<div class='input-field col l2 s12'>
										<input id='loan_start' name='loan_start'  type='text' class='datepicker'>
										<label for='loan_start'>Start Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='loan_interest_type' name='loan_interest_type'>
										  <option value='' disabled selected>-- Interest Type --</option>
										  <option value='1'>Variable</option>
										  <option value='2'>Fixed</option>
										</select>
										<label>Interest Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='loan_outstanding' name='loan_outstanding'  type='text' class='inwords'>
										<label for='loan_outstanding'>Outstanding Amount</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='loan_frq' name='loan_frq'>
										  $paying_type_list
										</select>
										<label>Frequency</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='loan_remaining' name='loan_remaining' type='text' class='number'>
										<label for='loan_remaining'>Remaining Term</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='loan_emi' name='loan_emi' type='text' class='number'>
										<label for='loan_emi'>EMI</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='loan_interest' name='loan_interest' type='text' class='number'>
										<label for='loan_interest'>Interest Rate</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_loan_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='loan_list'>
								$loan_content
							</div>
						</div>
					</div>";
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'exp_loan_content' =>"$content", 'exp_loan_tab' =>"$tab_class"));
	}	
	/**** EXPENSE AND LOAN - END ****/
	
	/**** INCOME AND ASSET - START ****/
	// PROVIDE LOAN LIST
	function get_income_list(){
		$query = "SELECT income_id,lp_cust_income.cust_id,income_type,income_family,income_amt,income_pay_type,paying_type_name,family_name,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' order by lp_cust_income.income_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE LOAN CONTENT
	function get_income_content($msg=""){
		$income_list_info  = $this->get_income_list();
		$income_list_rows  = $this->dbObj->num_rows($income_list_info);
		
		$content = "<h4>Your Income List </h4>";
		if((int)$income_list_rows > 0){
			$income_info = $this->dbObj->result($income_list_info);
			foreach($income_info as $income){
				$income_id        = $income->income_id;
				$cust_id          = $income->cust_id;
				$income_type      = $income->income_type;
				$income_family    = $income->income_family;
				$income_amt       = $income->income_amt;
				$income_yearly    = $income->income_yearly;
				$income_pay_type  = $income->income_pay_type;
				$paying_type_name = $income->paying_type_name;
				$family_name      = $income->family_name;
				
				$income_name = "Others";
				if($income_type === "1"){
					$income_name = "Salaried";
				}
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$income_name
										<div class='list_name'>Income</div>
									</div>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Name</div>
									</div>
									<div class='col l2 s6 truncate'>
										$paying_type_name
										<div class='list_name'>Frequency</div>
									</div>
									<div class='col l2 s6 truncate'>
										$income_amt
										<div class='list_name'>Amount</div>
									</div>
									<div class='col l2 s6 truncate'>
										$income_yearly
										<div class='list_name'>Yearly</div>
									</div> 
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('income','$income_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('income','$income_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'income_count' =>"$income_list_rows"));
	}
	// PROVIDE ASSET LIST
	function get_asset_list(){
		$query = "SELECT asset_id,lp_cust_asset.cust_id,asset_family,asset_name,asset_current_value,family_name FROM lp_cust_asset left join lp_cust_family on lp_cust_family.family_id = lp_cust_asset.asset_family where lp_cust_asset.status = '1' and lp_cust_asset.cust_id = '$this->cust_id' order by lp_cust_asset.asset_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE ASSET CONTENT
	function get_asset_content($msg=""){
		$asset_list_info  = $this->get_asset_list();
		$asset_list_rows  = $this->dbObj->num_rows($asset_list_info);
		
		$content = "<h4>Your Asset List </h4>";
		if((int)$asset_list_rows > 0){
			$asset_info = $this->dbObj->result($asset_list_info);
			foreach($asset_info as $asset){
				$asset_id             = $asset->asset_id;
				$cust_id              = $asset->cust_id;
				$asset_family         = $asset->asset_family;
				$asset_name           = $asset->asset_name;
				$asset_current_value  = $asset->asset_current_value;
				$family_name          = $asset->family_name;
				
				
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Owner</div>
									</div>
									<div class='col l2 s6 truncate'>
										$asset_name
										<div class='list_name'>Type of asset name</div>
									</div>
									<div class='col l2 s6 truncate'>
										$asset_current_value
										<div class='list_name'>Current Value</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('asset','$asset_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('asset','$asset_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'asset_count' =>"$asset_list_rows"));
	}
	
	// PROVIDE FULL INCOME AND ASSE CONTENT
	function get_income_asset_content($msg=""){
		
		//DROP DOWN LIST - START
		$loda_data         = $this->get_common_drop();		
		$paying_type_list = "<option value='' disabled selected>-- Frequency --</option>";
		foreach($loda_data->paying_type as $paying_type){
			$paying_type_id    = $paying_type->paying_type_id;
			$paying_type_name  = $paying_type->paying_type_name;
			$paying_type_list .=  "<option value='$paying_type_id'>$paying_type_name</option>";
		}
		
		$salaried_info = $this->get_salaried_list();
		$salaried_list = "<option value='' disabled selected>-- Salaried --</option>";
		foreach($salaried_info as $salaried){
			$family_id    = $salaried->family_id;
			$family_name  = $salaried->family_name;
			$salaried_list .=  "<option value='$family_id'>$family_name</option>";
		}
		
		$family_info = $this->get_family_list();
		$family_list = "<option value='' disabled selected>-- Owner --</option>";
		foreach($family_info as $family){
			$family_id    = $family->family_id;
			$family_name  = $family->family_name;
			$family_list .=  "<option value='$family_id'>$family_name</option>";
		}
		//DROP DOWN LIST - END
		
		// LOAD INCOME LIST
		$income_info = $this->get_income_content($msg);
		$income_info = json_decode($income_info);
		$income_content  = $income_info->content;
		$income_count    = $income_info->income_count;
		
		// LOAD ASSET LIST
		$asset_info    = $this->get_asset_content($msg);
		$asset_info    = json_decode($asset_info);
		$asset_content = $asset_info->content;
		$asset_count   = $asset_info->asset_count;
		
		
		$tab_class = "";
		if(($income_count === "0") && ($asset_count === "0")){
			$tab_class = "disabled";
		}
		
		$content = "<h1 class='inner_title'>YOUR INCOME & ASSET</h1>
					<div class='col l2 s12 pd0'>
						<ul class='tabs inv_subtab' >
							<li class='tab'>
								<a href='#income_subtab' class='active'>Income</a>
							</li>
							<li class='tab'>
								<a href='#asset_subtab'>Asset</a>
							</li>
						</ul>
					</div>
					<div class='col l10 s12 subtab_holder'>
						<div id='income_subtab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_income_form'>
									<input id='income_id' name='income_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='income_type' name='income_type'>
										  <option value='' disabled selected>-- Income Type --</option>
										  <option value='1'>Salaried / Business</option>
										  <option value='2'>Other</option>
										</select>
										<label>Income Type</label>
									</div>
									<div class='input-field col l2 s12' id='income_family_div'>
										<select id='income_family' name='income_family'>
										  $salaried_list
										</select>
										<label>Select Family</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='income_amt' name='income_amt' type='text' class='inwords'>
										<label for='income_amt'>Amount</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='income_pay_type' name='income_pay_type'>
											$paying_type_list
										</select>
										<label>Type</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_income_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='income_list'>
								$income_content
							</div>
						</div>
						<div id='asset_subtab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_asset_form'>
									<input id='asset_id' name='asset_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='asset_family' name='asset_family'>
										  $family_list
										</select>
										<label>Owner</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='asset_name' name='asset_name' type='text' >
										<label for='asset_name'>Type of asset name</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='asset_current_value' name='asset_current_value' type='text' class='inwords'>
										<label for='asset_current_value'>Current Value</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_asset_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='asset_list'>
								$asset_content
							</div>
						</div>
					</div>";
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'income_asset_content' =>"$content", 'income_asset_tab' =>"$tab_class"));
	}
	/**** INCOME AND ASSET - END ****/
	
	/**** INVESTMENTS - START ****/	
	
	// PROVIDE BANK LIST
	function get_bank_list(){
		$query = "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' order by lp_cust_bank.bank_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE BANK CONTENT
	function get_bank_content($msg=""){
		$bank_list_info  = $this->get_bank_list();
		$bank_list_rows  = $this->dbObj->num_rows($bank_list_info);
		
		$content = "<h4>Your Bank Investments List </h4>";
		if((int)$bank_list_rows > 0){
			$bank_scheme_info = array('1'=>"Bank Fixed Deposit",'2'=>"Company Deposit",'3'=>"Bank Recurring Deposit",'4'=>"Bonds",'5'=>"Other Deposits");
			$tenure_type_info = array('1'=>"Days",'2'=>"Month",'3'=>"Year");
			
			$bank_info = $this->dbObj->result($bank_list_info);
			foreach($bank_info as $bank){
				$bank_id      		= $bank->bank_id;
				$cust_id      		= $bank->cust_id;
				$bank_family  		= $bank->bank_family;
				$bank_scheme  		= $bank->bank_scheme;
				$bank_descript      = $bank->bank_descript;
				$bank_amt           = $bank->bank_amt;
				$bank_type          = $bank->bank_type;
				$bank_startdate     = new DateTime($bank->bank_startdate);
				$bank_startdate     = $bank_startdate->format("d-M-Y");
				$bank_tenure        = $bank->bank_tenure;
				$bank_tenure_type   = $bank->bank_tenure_type;
				$bank_ror           = $bank->bank_ror;
				$bank_maturity      = new DateTime($bank->bank_maturity);
				$bank_maturity      = $bank_maturity->format("d-M-Y");
				$bank_maturity_amt  = $bank->bank_maturity_amt;
				$paying_type_name   = $bank->paying_type_name;
				$family_name        = $bank->family_name;
				$bank_scheme_name   = $bank_scheme_info[$bank_scheme];
				$tenure_name        = $tenure_type_info[$bank_tenure_type];
				$tenure             = $bank_tenure." / ". $tenure_name;
				
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Depositor</div>
									</div>
									<div class='col l2 s6 truncate'>
										$bank_scheme_name
										<div class='list_name'>Deposit Scheme</div>
									</div>
									<div class='col l1 s6 truncate'>
										$bank_amt
										<div class='list_name'>Amount</div>
									</div>
									<div class='col l1 s6 truncate'>
										$paying_type_name
										<div class='list_name'>Paying Type</div>
									</div>
									<div class='col l1 s6 truncate'>
										$bank_ror
										<div class='list_name'>Rate of Return</div>
									</div>
									<div class='col l1 s6 truncate'>
										$tenure
										<div class='list_name'>Tenure</div>
									</div>
									<div class='col l1 s6 truncate'>
										$bank_maturity
										<div class='list_name'>Maturity</div>
									</div>
									<div class='col l1 s6 truncate'>
										$bank_maturity_amt
										<div class='list_name'>Maturity Amount</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('bank','$bank_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('bank','$bank_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'bank_count' =>"$bank_list_rows"));
	}
	
	// PROVIDE INSURANCE LIST
	function get_insurance_list(){
		$query = "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' order by lp_cust_insurance.insurance_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE INSURANCE CONTENT
	function get_insurance_content($msg=""){
		$insurance_list_info  = $this->get_insurance_list();
		$insurance_list_rows  = $this->dbObj->num_rows($insurance_list_info);
		
		$content = "<h4>Your Insurance Investments List </h4>";
		if((int)$insurance_list_rows > 0){											
			$general_info = array('1'=>"Car",'2'=>"Bike",'3'=>"Van",'4'=>"Others");
			
			$insurance_info = $this->dbObj->result($insurance_list_info);
			foreach($insurance_info as $insurance){
				$insurance_id             = $insurance->insurance_id;
				$cust_id      		      = $insurance->cust_id;
				$ins_type      		      = $insurance->ins_type;
				$ins_general_type      	  = $insurance->ins_general_type;
				$ins_proposer      		  = $insurance->ins_proposer;
				$ins_insured      		  = $insurance->ins_insured;
				$ins_life_assured      	  = $insurance->ins_life_assured;
				$ins_company      		  = $insurance->ins_company;
				$ins_plan      		      = $insurance->ins_plan;
				$ins_sum_assured          = $insurance->ins_sum_assured;
				$ins_start_date           = new DateTime($insurance->ins_start_date);
				$ins_start_date           = $ins_start_date->format("d-M-Y");
				$ins_issued_date          = new DateTime($insurance->ins_issued_date);
				$ins_issued_date          = $ins_issued_date->format("d-M-Y");
				$ins_term      		      = $insurance->ins_term;
				$ins_ppt      		      = $insurance->ins_ppt;
				$ins_premium      		  = $insurance->ins_premium;
				$ins_due_date             = new DateTime($insurance->ins_due_date);
				$ins_due_date             = $ins_due_date->format("d-M-Y");
				$insurance_type_name      = $insurance->insurance_type_name;
				$insurance_company_name   = $insurance->insurance_company_name;
				$insurance_plan_name      = $insurance->insurance_plan_name;
				$pensioner                = $insurance->pensioner;		
				$vesting_date             = new DateTime($insurance->vesting_date);
				$vesting_date             = $vesting_date->format("d-M-Y");
				$pen_frq                  = $insurance->pen_frq;
				$pen_amt                  = $insurance->pen_amt;
				$pen_ror                  = $insurance->pen_ror;
				$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;

				$general_name = "";
				if($ins_general_type){
					$general_name = $general_info[$ins_general_type];
				}
				
				
				$plan_name = "-";
				if($insurance_plan_name){
					$plan_name = $insurance_plan_name;
				}
				if($ins_type === "6"){
					$plan = "$vesting_date <div class='list_name'>Vesting Date</div>";
					$assured = "$pen_amt <div class='list_name'>Amount</div>";
					$premium = "$pension_amount <div class='list_name'>Pension Amount</div>";
				}else{
					$plan = "$plan_name <div class='list_name'>Plan</div>";
					$assured = "$ins_sum_assured <div class='list_name'>Sum Assured</div>";
					$premium = "$ins_premium <div class='list_name'>Premium</div>";
				}
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$insurance_type_name
										<div class='list_name'>Type</div>
									</div>
									<div class='col l2 s6 truncate'>
										$insurance_company_name
										<div class='list_name'>Company</div>
									</div>
									<div class='col l2 s6 truncate'>
										$plan
									</div>
									<div class='col l2 s6 truncate'>
										$assured
									</div>
									<div class='col l2 s6 truncate'>
										$premium
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('insurance','$insurance_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('insurance','$insurance_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}			
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'insurance_count' =>"$insurance_list_rows"));
	}
	
	// PROVIDE MUTUAL FUND LIST
	function get_mf_list(){
		$query = "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 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' order by lp_cust_mf.mf_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE MUTUAL FUND CONTENT
	function get_mf_content($msg=""){
		$mf_list_info  = $this->get_mf_list();
		$mf_list_rows  = $this->dbObj->num_rows($mf_list_info);
		
		$content = "<h4>Your Mutual Fund Investments List </h4>";
		if((int)$mf_list_rows > 0){
			$fund_type_info = array('1'=>"Growth",'2'=>"Dividend",'3'=>"SWP");
			$inv_type_info = array('1'=>"SIP",'2'=>"LUMPSUM");
			$mf_info = $this->dbObj->result($mf_list_info);
			foreach($mf_info as $mf){
				$mf_id             = $mf->mf_id;
				$cust_id      	   = $mf->cust_id;
				$mf_investor       = $mf->mf_investor;
				$mf_amc      	   = $mf->mf_amc;
				$mf_scheme         = $mf->mf_scheme;
				$mf_fund_class     = $mf->mf_fund_class;
				$mf_fund_type      = $mf->mf_fund_type;
				$mf_inv_type       = $mf->mf_inv_type;
				$mf_present_val    = $mf->mf_present_val;
				$mf_live_sip       = $mf->mf_live_sip;
				$amc_name      	   = $mf->amc_name;
				$fund_name         = $mf->fund_name;
				$fund_class_name   = $mf->fund_class_name;
				$family_name       = $mf->family_name;
				$fund_type_name    = $fund_type_info[$mf_fund_type];
				$inv_type_name     = $inv_type_info[$mf_inv_type];
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Investor</div>
									</div>
									<div class='col l2 s6 truncate'>
										$amc_name
										<div class='list_name'>AMC</div>
									</div>
									<div class='col l2 s6 truncate'>
										$fund_class_name
										<div class='list_name'>Fund Class</div>
									</div>
									<div class='col l1 s6 truncate'>
										$fund_type_name
										<div class='list_name'>Fund Type</div>
									</div>
									<div class='col l1 s6 truncate'>
										$inv_type_name
										<div class='list_name'>Investment</div>
									</div>
									<div class='col l1 s6 truncate'>
										$mf_present_val
										<div class='list_name'>Present Value</div>
									</div>
									<div class='col l1 s6 truncate'>
										$mf_live_sip
										<div class='list_name'>Live SIP</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('mf','$mf_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('mf','$mf_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'mf_count' =>"$mf_list_rows"));
	}
	
	// PROVIDE GOVERNMENT SCHEME LIST
	function get_gov_list(){
		$query = "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' order by lp_cust_gov.gov_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE GOVERNMENT SCHEME CONTENT
	function get_gov_content($msg=""){
		$gov_list_info  = $this->get_gov_list();
		$gov_list_rows  = $this->dbObj->num_rows($gov_list_info);
		
		$content = "<h4>Your Government Scheme Investments List </h4>";
		if((int)$gov_list_rows > 0){
			$gov_info = $this->dbObj->result($gov_list_info);
			foreach($gov_info as $gov){
				$gov_id             = $gov->gov_id;
				$cust_id      	    = $gov->cust_id;
				$gov_holder         = $gov->gov_holder;
				$gov_scheme         = $gov->gov_scheme;
				$gov_type           = $gov->gov_type;
				$gov_amount         = $gov->gov_amount;
				$gov_start_date     = new DateTime($gov->gov_start_date);
				$gov_start_date     = $gov_start_date->format("d-M-Y");
				$gov_maturity_date  = new DateTime($gov->gov_maturity_date);
				$gov_maturity_date  = $gov_maturity_date->format("d-M-Y");
				$gov_ror            = $gov->gov_ror;
				$gov_maturity_value = $gov->gov_maturity_value;
				$family_name        = $gov->family_name;
				$gov_scheme_name    = $gov->gov_scheme_name;
				$paying_type_name   = $gov->paying_type_name;
				
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Holder</div>
									</div>
									<div class='col l2 s6 truncate'>
										$gov_scheme_name
										<div class='list_name'>Scheme</div>
									</div>
									<div class='col l1 s6 truncate'>
										$paying_type_name
										<div class='list_name'>Paying Type</div>
									</div>
									<div class='col l1 s6 truncate'>
										$gov_amount
										<div class='list_name'>Amount</div>
									</div>
									<div class='col l2 s6 truncate'>
										$gov_ror
										<div class='list_name'>Rate of Return</div>
									</div>
									<div class='col l2 s6 truncate'>
										$gov_maturity_value
										<div class='list_name'>Maturity Value</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('gov','$gov_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('gov','$gov_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}					
		
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'gov_count' =>"$gov_list_rows"));
	}
	
	// PROVIDE STOCK & BULLION LIST
	function get_stock_list(){
		$query = "SELECT stock_id,lp_cust_stock.cust_id,stock_type,stock_investor,bullion_type,stock_current_value,family_name,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' order by lp_cust_stock.stock_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE STOCK & BULLION CONTENT
	function get_stock_content($msg=""){
		$stock_list_info  = $this->get_stock_list();
		$stock_list_rows  = $this->dbObj->num_rows($stock_list_info);
		
		$content = "<h4>Your Stock & Bullion Investments List </h4>";
		if((int)$stock_list_rows > 0){
			$stock_info   = $this->dbObj->result($stock_list_info);
			$stockname_info   = array('1'=>"Stocks",'2'=>"Bullion");	
			$bullion_info = array('1'=>"Gold",'2'=>"Silver",'3'=>"Others");	
			
			foreach($stock_info as $stock){
				$stock_id             = $stock->stock_id;
				$cust_id      	      = $stock->cust_id;
				$stock_type           = $stock->stock_type;
				$stock_investor       = $stock->stock_investor;
				$bullion_type         = $stock->bullion_type;
				$stock_current_value  = $stock->stock_current_value;
				$family_name          = $stock->family_name;
				$stock_name           = $stockname_info[$stock_type];
				$bullion_name = "-";
				if($bullion_type){					
					$bullion_name = $bullion_info[$bullion_type];
				}
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$stock_name
										<div class='list_name'>Type</div>
									</div>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Investor</div>
									</div>
									<div class='col l2 s6 truncate'>
										$bullion_name
										<div class='list_name'>Bullion Type</div>
									</div>
									<div class='col l2 s6 truncate'>
										$stock_current_value
										<div class='list_name'>Current Value</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('stock','$stock_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('stock','$stock_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'stock_count' =>"$stock_list_rows"));
	}
	
	// PROVIDE OTHERS LIST
	function get_others_list(){
		$query = "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' order by lp_cust_others.others_id DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE OTHERS CONTENT
	function get_others_content($msg=""){
		$others_list_info  = $this->get_others_list();
		$others_list_rows  = $this->dbObj->num_rows($others_list_info);
		
		$content = "<h4>Your others Investments List </h4>";
		if((int)$others_list_rows > 0){
			$others_info   = $this->dbObj->result($others_list_info);
			$tenure_type_info = array('1'=>"Days",'2'=>"Month",'3'=>"Year");
			
			foreach($others_info as $others){
				$others_id             = $others->others_id;
				$cust_id      	       = $others->cust_id;
				$others_investor       = $others->others_investor;
				$others_descript       = $others->others_descript;
				$others_amt      	   = $others->others_amt;
				$others_type      	   = $others->others_type;
				$others_startdate      = $others->others_startdate;
				$others_tenure         = $others->others_tenure;
				$others_tenure_type    = $others->others_tenure_type;
				$others_expected_val   = $others->others_expected_val;
				$others_maturity_date  = $others->others_maturity_date;
				$others_maturity_val   = $others->others_maturity_val;
				$family_name      	   = $others->family_name;
				$paying_type_name      = $others->paying_type_name;
				$tenure_name           = $tenure_type_info[$others_tenure_type];
				
				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Investor</div>
									</div>
									<div class='col l1 s6 truncate'>
										$others_amt
										<div class='list_name'>Amount</div>
									</div>
									<div class='col l1 s6 truncate'>
										$paying_type_name
										<div class='list_name'>Paying Type</div>
									</div>
									<div class='col l2 s6 truncate'>
										$others_tenure ($tenure_name)
										<div class='list_name'>Tenure</div>
									</div>
									<div class='col l2 s6 truncate'>
										$others_expected_val
										<div class='list_name'>Expected Returns</div>
									</div>
									<div class='col l2 s6 truncate'>
										$others_maturity_val
										<div class='list_name'>Maturity value</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('others','$others_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('others','$others_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'others_count' =>"$others_list_rows"));
	}
	
	// PROVIDE FULL INVESTMENTS CONTENT
	function get_investments_content($msg=""){
		
		//DROP DOWN LIST - START
		$loda_data         = $this->get_common_drop();		
		$paying_type_list = "<option value='' disabled selected>-- Frequency --</option>";
		foreach($loda_data->paying_type as $paying_type){
			$paying_type_id    = $paying_type->paying_type_id;
			$paying_type_name  = $paying_type->paying_type_name;
			$paying_type_list .=  "<option value='$paying_type_id'>$paying_type_name</option>";
		}
		
		$insurance_type_list = "<option value='' disabled selected>-- Type --</option>";
		foreach($loda_data->insurance_type as $insurance_type){
			$insurance_type_id    = $insurance_type->insurance_type_id;
			$insurance_type_name  = $insurance_type->insurance_type_name;
			$insurance_type_list .=  "<option value='$insurance_type_id'>$insurance_type_name</option>";
		}
		
		$insurance_company_list = "<option value='' disabled selected>-- Company --</option>";
		foreach($loda_data->insurance_company as $insurance_company){
			$insurance_company_id    = $insurance_company->insurance_company_id;
			$insurance_company_name  = $insurance_company->insurance_company_name;
			$insurance_company_list .=  "<option value='$insurance_company_id'>$insurance_company_name</option>";
		}
		
		$insurance_plan_list = "<option value='' disabled selected>-- Plan --</option>";
		foreach($loda_data->insurance_plan as $insurance_plan){
			$insurance_plan_id    = $insurance_plan->insurance_plan_id;
			$insurance_plan_name  = $insurance_plan->insurance_plan_name;
			$insurance_plan_list .=  "<option value='$insurance_plan_id'>$insurance_plan_name</option>";
		}
		
		$amc_list = "<option value='' disabled selected>-- AMC --</option>";
		foreach($loda_data->amc as $amc){
			$amc_id    = $amc->amc_id;
			$amc_name  = $amc->amc_name;
			$amc_list .=  "<option value='$amc_id'>$amc_name</option>";
		}
		
		$fund_name_list = "<option value='' disabled selected>-- Fund Name --</option>";
		foreach($loda_data->fund_name as $fund_name){
			$fund_name_id    = $fund_name->fund_name_id;
			$fund_name       = $fund_name->fund_name;
			$fund_name_list .=  "<option value='$fund_name_id'>$fund_name</option>";
		}
		
		$fund_class_list = "<option value='' disabled selected>-- Fund Class --</option>";
		foreach($loda_data->fund_class as $fund_class){
			$fund_class_id    = $fund_class->fund_class_id;
			$fund_class_name  = $fund_class->fund_class_name;
			$fund_class_list .=  "<option value='$fund_class_id'>$fund_class_name</option>";
		}
		
		$gov_scheme_list = "<option value='' disabled selected>-- Scheme --</option>";
		foreach($loda_data->gov_scheme as $gov_scheme){
			$gov_scheme_id    = $gov_scheme->gov_scheme_id;
			$gov_scheme_name  = $gov_scheme->gov_scheme_name;
			$gov_scheme_list .=  "<option value='$gov_scheme_id'>$gov_scheme_name</option>";
		}
		
		$family_info       = $this->get_family_list();
		$family_list       = "<option value='' disabled selected>-- Depositor --</option>";
		$proposer_list     = "<option value='' disabled selected>-- Proposer --</option>";
		$life_assured_list = "<option value='' disabled selected>-- Life Assured --</option>";
		$insured_list      = "<option value='' disabled>-- Insured --</option>";
		$investor_list     = "<option value='' disabled selected>-- Investor --</option>";
		$holder_list       = "<option value='' disabled selected>-- Holder --</option>";
		$pensioner_list       = "<option value='' disabled selected>-- Pensioner --</option>";
		foreach($family_info as $family){
			$family_id    = $family->family_id;
			$family_name  = $family->family_name;
			$family_list       .=  "<option value='$family_id'>$family_name</option>";
			$proposer_list     .=  "<option value='$family_id'>$family_name</option>";
			$life_assured_list .=  "<option value='$family_id'>$family_name</option>";
			$insured_list      .=  "<option value='$family_id'>$family_name</option>";
			$investor_list     .=  "<option value='$family_id'>$family_name</option>";
			$holder_list       .=  "<option value='$family_id'>$family_name</option>";
			$pensioner_list    .=  "<option value='$family_id'>$family_name</option>";
		}
		
		//DROP DOWN LIST - END
		
		// LOAD BANK LIST
		$bank_info     = $this->get_bank_content($msg);
		$bank_info     = json_decode($bank_info);
		$bank_content  = $bank_info->content;
		$bank_count    = $bank_info->bank_count;
		
		// LOAD INSURANCE LIST
		$insurance_info     = $this->get_insurance_content($msg);
		$insurance_info     = json_decode($insurance_info);
		$insurance_content  = $insurance_info->content;
		$insurance_count    = $insurance_info->insurance_count;
		
		// LOAD MUTUAL FUND LIST
		$mf_info     = $this->get_mf_content($msg);
		$mf_info     = json_decode($mf_info);
		$mf_content  = $mf_info->content;
		$mf_count    = $mf_info->mf_count;
		
		// LOAD GOVERNMENT SCHEME LIST
		$gov_info     = $this->get_gov_content($msg);
		$gov_info     = json_decode($gov_info);
		$gov_content  = $gov_info->content;
		$gov_count    = $gov_info->gov_count;
		
		//LOAD STOCK & BULLION LIST
		$stock_info     = $this->get_stock_content($msg);
		$stock_info     = json_decode($stock_info);
		$stock_content  = $stock_info->content;
		$stock_count    = $stock_info->stock_count;
		
		//LOAD OTHERS LIST
		$others_info     = $this->get_others_content($msg);
		$others_info     = json_decode($others_info);
		$others_content  = $others_info->content;
		$others_count    = $others_info->others_count;
		
		$tab_class = "";
		if(($bank_count === "0") && ($insurance_count === "0") && ($mf_count === "0") && ($gov_count === "0") && ($stock_count === "0") && ($others_count === "0")){
			$tab_class = "disabled";
		}
		
		$content = "<h1 class='inner_title'>YOUR INVESTMENTS</h1>
					<div class='col l2 s12 pd0'>
						<ul class='tabs inv_subtab' >
							<li class='tab'>
								<a href='#bank_tab' class='active'>Bank</a>
							</li>
							<li class='tab'>
								<a href='#insurance_tab'>Insurance</a>
							</li>
							<li class='tab'>
								<a href='#mf_tab'>Mutual Fund</a>
							</li>
							<li class='tab'>
								<a href='#gov_tab'>Government Scheme</a>
							</li>
							<li class='tab'>
								<a href='#stock_tab'>Stock & Bullion</a>
							</li>
							<li class='tab'>
								<a href='#others_tab'>Others</a>
							</li>
						</ul>
					</div>
					<div class='col l10 s12 subtab_holder'>
						<div id='bank_tab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_bank_form'>
									<input id='bank_id' name='bank_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='bank_family' name='bank_family'>
											$family_list
										</select>
										<label>Depositor</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='bank_scheme' name='bank_scheme'>
											<option value='' disabled selected>-- Deposit Scheme --</option>
											<option value='1'>Bank Fixed Deposit</option>
											<option value='2'>Company Deposit</option>
											<option value='3'>Bank Recurring Deposit</option>
											<option value='4'>Bonds</option>
											<option value='5'>Other Deposits</option>
										</select>
										<label>Deposit Scheme</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_descript' name='bank_descript' type='text'>
										<label for='bank_descript'>Description</label>
									</div>									
									<div class='input-field col l2 s12'>
										<select id='bank_type' name='bank_type'>
											$paying_type_list
										</select>
										<label>Compounding</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_amt' name='bank_amt' type='text' class='inwords'>
										<label for='bank_amt'>Amount</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_startdate'  name='bank_startdate' type='text' class='datepicker'>
										<label for='bank_startdate'>Start Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<div class='row mg0' style='margin-bottom:0px;'>
											<div class='input-field col l6 s6 pd0'>
												<input id='bank_tenure' name='bank_tenure' type='text'>
												<label for='bank_tenure'>Value</label>
											</div>
											<div class='input-field col l6 s6 pd0'>
												<select id='bank_tenure_type' name='bank_tenure_type'>
													<option value=' ' disabled selected>-- Tenure --</option>
													<option value='1'>Days</option>
													<option value='2'>Month</option>
													<option value='3'>Year</option>
												</select>
											</div>
										</div>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_ror' name='bank_ror' type='text'>
										<label for='bank_ror'>Rate of Return</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_maturity' name='bank_maturity' type='text'  class='datepicker'>
										<label for='bank_maturity'>Maturity Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='bank_maturity_amt' name='bank_maturity_amt' type='text' class='inwords'>
										<label for='bank_maturity_amt'>Maturity Amount</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_bank_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='bank_list'>
								$bank_content
							</div>
						</div>
						<div id='insurance_tab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_insurance_form'>
									<input id='insurance_id' name='insurance_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='ins_type' name='ins_type'>
											$insurance_type_list
										</select>
										<label>Type</label>
									</div>
									<div class='input-field col l2 s12' id='ins_general_type_div'>
										<select id='ins_general_type' name='ins_general_type'>
											<option value='' disabled selected>-- General Type --</option>
											<option value='1'>Car</option>
											<option value='2'>Bike</option>
											<option value='3'>Van</option>
											<option value='4'>others</option>
										</select>
										<label>Type</label>
									</div>
									<div class='input-field col l2 s12' id='ins_proposer_div'>
										<select id='ins_proposer' name='ins_proposer'>
											$proposer_list											 
										</select>
										<label>Proposer</label>
									</div>
									<div class='input-field col l2 s12' id='ins_insured_div'>
										<select id='ins_insured' name='ins_insured' multiple>
											$insured_list
										</select>
										<label>Insured</label>
									</div>
									<div class='input-field col l2 s12' id='ins_life_assured_div'>
										<select id='ins_life_assured' name='ins_life_assured'>
											$life_assured_list
										</select>
										<label>Life Assured</label>
									</div>
									<div class='input-field col l2 s12' id='pensioner_div'>
										<select id='pensioner' name='pensioner'>
											$pensioner_list
										</select>
										<label>Pensioner</label>
									</div>
									<div class='input-field col l2 s12' id='ins_company_div'>
										<select id='ins_company' name='ins_company'>
											$insurance_company_list
										</select>
										<label>Company</label>
									</div>
									<div class='input-field col l2 s12' id='ins_plan_div'>
										<select id='ins_plan' name='ins_plan'>
										  $insurance_plan_list
										</select>
										<label>Plan</label>
									</div>
									<div class='input-field col l2 s12' id='ins_sum_assured_div'>
										<input id='ins_sum_assured' name='ins_sum_assured' type='text' class='inwords'>
										<label for='ins_sum_assured'>Sum Assured</label>
									</div>
									<div class='input-field col l2 s12' id='ins_start_date_div'>
										<input id='ins_start_date' name='ins_start_date' type='text' class='datepicker'>
										<label for='ins_start_date'>Start Date</label>
									</div>
									<div class='input-field col l2 s12' id='ins_issued_date_div'>
										<input id='ins_issued_date' name='ins_issued_date' type='text' class='datepicker'>
										<label for='ins_issued_date'>Issued Date</label>
									</div>
									<div class='input-field col l2 s12' id='ins_term_div'>
										<input id='ins_term' name='ins_term' type='text' class='number'>
										<label for='ins_term'>Term </label>
									</div>
									<div class='input-field col l2 s12' id='ins_ppt_div'>
										<input id='ins_ppt' name='ins_ppt' type='text' class='number'>
										<label for='ins_ppt'>PPT </label>
									</div>
									<div class='input-field col l2 s12' id='ins_premium_div'>
										<input id='ins_premium' name='ins_premium' type='text' class='inwords'>
										<label for='ins_premium'>Premium</label>
									</div>
									<div class='input-field col l2 s12' id='ins_frq_div'>
										<select id='ins_frq' name='ins_frq'>
											$paying_type_list
										</select>
										<label>Paying Type</label>
									</div>
									<div class='input-field col l2 s12' id='ins_due_date_div'>
										<input id='ins_due_date' name='ins_due_date' type='text' class='datepicker'>
										<label for='ins_due_date'>Due Date</label>
									</div>
									<div class='input-field col l2 s12' id='ins_rider_div'>
										<select id='ins_rider' name='ins_rider'>
											<option value='' disabled selected>-- Rider --</option>
											<option value='1'>Yes</option>
											<option value='2'>No</option>
										</select>
										<label>Rider</label>
									</div>
									<div class='input-field col l2 s12' id='ins_rider_amt_div'>
										<input id='ins_rider_amt' name='ins_rider_amt' type='text' class='inwords'>
										<label for='ins_rider_amt'>Rider Amount</label>
									</div>
									<div class='input-field col l2 s12' id='vesting_date_div'>
										<input id='vesting_date' name='vesting_date' type='text' class='datepicker'>
										<label for='vesting_date'>Vesting Date</label>
									</div>
									<div class='input-field col l2 s12' id='pen_frq_div'>
										<select id='pen_frq' name='pen_frq'>
											$paying_type_list
										</select>
										<label>Frequency</label>
									</div>
									<div class='input-field col l2 s12' id='pen_amt_div'>
										<input id='pen_amt' name='pen_amt' type='text' class='inwords'>
										<label for='pen_amt'>Amount</label>
									</div>
									<div class='input-field col l2 s12' id='pen_ror_div'>
										<input id='pen_ror' name='pen_ror' type='text'>
										<label for='pen_ror'>Rate of Return</label>
									</div>
									<div class='input-field col l2 s12' id='vesting_corpus_div'>
										<input id='vesting_corpus' name='vesting_corpus' type='text' class='inwords'>
										<label for='vesting_corpus'>Vesting Corpus</label>
									</div>
									<div class='input-field col l2 s12' id='one3rd_corpus_div'>
										<input id='one3rd_corpus' name='one3rd_corpus' type='text' class='inwords'>
										<label for='one3rd_corpus'>one 3rd of corpus</label>
									</div>
									<div class='input-field col l2 s12' id='pen_payout_div'>
										<select id='pen_payout' name='pen_payout'>
											$paying_type_list
										</select>
										<label>Payout option</label>
									</div>
									<div class='input-field col l2 s12' id='pen_ropen_div'>
										<input id='pen_ropen' name='pen_ropen' type='text'>
										<label for='pen_ropen'>Rate of Pension</label>
									</div>
									<div class='input-field col l2 s12' id='pension_amount_div'>
										<input id='pension_amount' name='pension_amount' type='text'>
										<label for='pension_amount'>Pension Amount</label>
									</div>									
									<div class='input-field col l1 s12' style='margin-top:18px;' id='save_insurance_btn_div'>
										<a class='waves-effect waves-light btn' id='save_insurance_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='insurance_list'>
								$insurance_content
							</div>
						</div>
						<div id='mf_tab' class='col l12  s12'>
							<form id='save_mf_form'>
								<input id='mf_id' name='mf_id' value='0' type='hidden'/>
								<div class='row input_holder'>
									<div class='input-field col l2 s12'>
										<select id='mf_investor' name='mf_investor'>
											$investor_list
										</select>
										<label>Investor</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='mf_amc' name='mf_amc'>
										  $amc_list
										</select>
										<label>AMC</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='mf_scheme' name='mf_scheme'>
										  $fund_name_list
										</select>
										<label>Scheme</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='mf_fund_class' name='mf_fund_class'>
										  $fund_class_list
										</select>
										<label>Fund Class</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='mf_fund_type' name='mf_fund_type'>
										  <option value='' disabled selected>-- Fund Type --</option>
										  <option value='1'>Growth</option>
										  <option value='2'>Dividend</option>
										  <option value='3'>SWP</option>
										</select>
										<label>Fund Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='mf_inv_type' name='mf_inv_type'>
										  <option value='' disabled selected>-- Investment Type --</option>
										  <option value='1'>SIP</option>
										  <option value='2'>LUMPSUM</option>
										</select>
										<label>Investment Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='mf_present_val' name='mf_present_val' type='text' class='inwords'>
										<label for='mf_present_val'>Present Value</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='mf_live_sip' name='mf_live_sip' type='text' class='inwords'>
										<label for='mf_live_sip'>Live SIP</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='mf_end_date' name='mf_end_date' type='text' class='datepicker'>
										<label for='mf_end_date'>Expected End Date</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_mf_btn'>Save</a>
									</div>
								</div>
								<div class='row inv_split'></div>
								<div class='row save_content' id='mf_list'>
									$mf_content
								</div>
							</form>
						</div>
						<div id='gov_tab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_gov_form'>
									<input id='gov_id' name='gov_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='gov_holder' name='gov_holder'>
											$holder_list
										</select>
										<label>Holder</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='gov_scheme' name='gov_scheme'>
											$gov_scheme_list
										</select>
										<label>Scheme</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='gov_type' name='gov_type'>
											$paying_type_list 
										</select>
										<label>Paying Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='gov_amount' name='gov_amount' type='text' class='inwords'>
										<label for='gov_amount'>Amount</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='gov_start_date' name='gov_start_date' type='text' class='datepicker'>
										<label for='gov_start_date'>Start Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='gov_maturity_date' name='gov_maturity_date' type='text' class='datepicker'>
										<label for='gov_maturity_date'>Maturity Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='gov_ror' name='gov_ror' type='text' class='number'>
										<label for='gov_ror'>Rate of Return</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='gov_maturity_value' name='gov_maturity_value' type='text' class='inwords'>
										<label for='gov_maturity_value'>Maturity Value</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_gov_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='gov_list'>
								$gov_content
							</div>
						</div>
						<div id='stock_tab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_stock_form'>
									<input id='stock_id' name='stock_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='stock_type' name='stock_type'>
											<option value='' disabled selected>-- Type --</option>
											<option value='1'>Stocks</option>
											<option value='2'>Bullion</option>
										</select>
										<label>Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='stock_investor' name='stock_investor'>
											$investor_list
										</select>
										<label>Investor</label>
									</div>
									<div class='input-field col l2 s12' id='bullion_type_div'>
										<select id='bullion_type' name='bullion_type'>
											<option value='' disabled selected>-- Bullion Type --</option>
											<option value='1'>Gold</option>
											<option value='2'>Silver</option>
											<option value='3'>Others</option>
										</select>
										<label>Bullion Type</label>
									</div>
									<div class='input-field col l2 s12' id='stock_inflow_value_div'>
										<input id='stock_inflow_value' name='stock_inflow_value' type='text' class='inwords'>
										<label for='stock_inflow_value'>Inflow Value</label>
									</div>
									<div class='input-field col l2 s12' id='stock_current_value_div'>
										<input id='stock_current_value' name='stock_current_value' type='text' class='inwords'>
										<label for='stock_current_value'>Current Value</label>
									</div>
									<div class='input-field col l2 s12' id='stock_expected_value_div'>
										<input id='stock_expected_value' name='stock_expected_value' type='text' class='inwords'>
										<label for='stock_expected_value'>Expected Returns</label>
									</div>
									<div class='input-field col l2 s12' id='stock_paytype_div'>
										<select id='stock_paytype' name='stock_paytype'>
											$paying_type_list 
										</select>
										<label>Paying Type</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_stock_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='stock_list'>
								$stock_content
							</div>
						</div>
						<div id='others_tab' class='col l12  s12'>
							<div class='row input_holder'>
								<form id='save_others_form'>
									<input id='others_id' name='others_id' value='0' type='hidden'/>
									<div class='input-field col l2 s12'>
										<select id='others_investor' name='others_investor'>
											$investor_list
										</select>
										<label>Investor</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='others_descript' name='others_descript' type='text'>
										<label for='others_descript'>Description</label>
									</div>
									<div class='input-field col l2 s12'>
										<select id='others_type' name='others_type'>
											$paying_type_list 
										</select>
										<label>Paying Type</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='others_amt' name='others_amt' type='text' class='inwords'>
										<label for='others_amt'>Amount</label>
									</div>									
									<div class='input-field col l2 s12'>
										<input id='others_startdate' name='others_startdate' type='text' class='datepicker'>
										<label for='others_startdate'>Start Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<div class='row mg0' style='margin-bottom:0px;'>
											<div class='input-field col l6 s6 pd0'>
												<input id='others_tenure'  name='others_tenure' type='text'>
												<label for='others_tenure'>Value</label>
											</div>
											<div class='input-field col l6 s6 pd0'>
												<select id='others_tenure_type' name='others_tenure_type'>
													<option value='' disabled selected>-- Tenure --</option>
													<option value='1'>Days</option>
													<option value='2'>Month</option>
													<option value='3'>Year</option>
												</select>
											</div>
										</div>
									</div>
									<div class='input-field col l2 s12'>
										<input id='others_expected_val' name='others_expected_val' type='text' class='number'>
										<label for='others_expected_val'>Expected Returns</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='others_maturity_date' name='others_maturity_date' type='text' class='datepicker'>
										<label for='others_maturity_date'>Maturity Date</label>
									</div>
									<div class='input-field col l2 s12'>
										<input id='others_maturity_val' name='others_maturity_val' type='text' class='inwords'>
										<label for='others_maturity_val'>Maturity value</label>
									</div>
									<div class='input-field col l1 s12' style='margin-top:18px;'>
										<a class='waves-effect waves-light btn' id='save_others_btn'>Save</a>
									</div>
								</form>
							</div>
							<div class='row inv_split'></div>
							<div class='row save_content' id='others_list'>
								$others_content
							</div>
						</div>
					</div>";
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'investments_content' =>"$content", 'investments_tab' =>"$tab_class"));
	}	
	/**** INVESTMENTS - END ****/
	
	/**** LONG TERM GOAL - START ****/
	function goal_get_expense(){
		$expense_info = $this->dbObj->query('cust_expense',"status='1' and cust_id = '$this->cust_id'","IFNULL(sum(exp_amt),0) as exp_amt");
		return $this->dbObj->result($expense_info);
	}
	
	// PROVIDE GOAL LIST
	function get_goal_inner_list(){
		$query = "SELECT goal_id,lp_cust_goal.cust_id,lp_cust_goal.goal_family,goal_name,goal_date,goal_amount,inflation,inflation_amt,family_name 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 DESC";
		return $this->dbObj->runQuery($query);
	}
	
	// PROVIDE GOAL CONTENT
	function get_goal_inner_content($msg){
		$goal_list_info  = $this->get_goal_inner_list();
		$goal_list_rows  = $this->dbObj->num_rows($goal_list_info);
		
		$content = "<h4>Your Goal List</h4>";
		if((int)$goal_list_rows > 0){
			$goal_info   = $this->dbObj->result($goal_list_info);
			$tenure_type_info = array('1'=>"Days",'2'=>"Month",'3'=>"Year");
			
			foreach($goal_info as $goal){
				$goal_id        = $goal->goal_id;
				$cust_id        = $goal->cust_id;
				$goal_family    = $goal->goal_family;
				$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      = $goal->inflation;
				$inflation_amt  = $goal->inflation_amt;
				$family_name    = $goal->family_name;
				
				$now = new DateTime();
				$end = new DateTime($goal->goal_date);
				$interval = $now->diff($end);
				$years =  $interval->format('%y years %m months and %d days');				

				$content .= "<div class='col l12  s12 list_card hoverable'>
								<div class='row pd4 mg0'>
									<div class='col l2 s6 truncate'>
										$family_name
										<div class='list_name'>Family</div>
									</div>
									<div class='col l2 s6 truncate'>
										$goal_name
										<div class='list_name'>Goal Name</div>
									</div>
									<div class='col l1 s6 truncate'>
										$goal_date
										<div class='list_name'>Goal Date</div>
									</div>
									<div class='col l1 s6 truncate'>
										$years
										<div class='list_name'>Years to go</div>
									</div>
									<div class='col l1 s6 truncate'>
										$goal_amount
										<div class='list_name'>Current Expence</div>
									</div>
									<div class='col l1 s6 truncate'>
										$inflation
										<div class='list_name'>Inflation</div>
									</div>
									<div class='col l2 s6 truncate'>
										$inflation_amt
										<div class='list_name'>Inflation Amount</div>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=edit_data('goal','$goal_id')><i class='material-icons small'>edit</i></span>
									</div>
									<div class='col l1 s2 pl_btn pd8'>
										<span onclick=remove_data('goal','$goal_id')><i class='material-icons small'>delete</i></span>
									</div>
								</div>
							</div>";
			}
		}
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'content' =>"$content", 'goal_count' =>"$goal_list_rows"));
	}
	// PROVIDE FULL LONG TERM GOALS CONTENT
	function get_goal_content($msg=""){
		$family_info       = $this->get_family_list();
		$family_list       = "<option value='' disabled selected>-- Family --</option>";
		foreach($family_info as $family){
			$family_id    = $family->family_id;
			$family_name  = $family->family_name;
			$family_list .=  "<option value='$family_id'>$family_name</option>";
		}
		
		$bank_scheme_info     = array('1'=>"Bank Fixed Deposit",'2'=>"Company Deposit",'3'=>"Bank Recurring Deposit",'4'=>"Bonds",'5'=>"Other Deposits");
		$bank_list_info       = $this->get_bank_list();
		$bank_info            = $this->dbObj->result($bank_list_info);
		
		$insurance_list_info  = $this->get_insurance_list();
		$insurance_info       = $this->dbObj->result($insurance_list_info);
		
		$mf_list_info         = $this->get_mf_list();
		$mf_info              = $this->dbObj->result($mf_list_info);
		
		$gov_list_info        = $this->get_gov_list();
		$gov_info             = $this->dbObj->result($gov_list_info);
		
		$others_list_info     = $this->get_others_list();
		$others_info          = $this->dbObj->result($others_list_info);
		
		$goal_map_list = "<option value='' disabled>-- Map Investments --</option>";
		
		foreach($bank_info as $bank){
			$bank_id          = $bank->bank_id;
			$bank_scheme      = $bank->bank_scheme;
			$bank_descript    = $bank->bank_descript;
			$bank_amt         = $bank->bank_amt;
			$bank_scheme_name = $bank_scheme_info[$bank_scheme];
			$list_id = "BK_$bank_id";
			$goal_map_list .=  "<option value='$list_id'>$bank_scheme_name - $bank_amt </option>";
		}
		
		foreach($insurance_info as $insurance){				
			$insurance_id          = $insurance->insurance_id;
			$ins_type              = $insurance->ins_type;
			$insurance_type_name   = $insurance->insurance_type_name;
			$ins_sum_assured       = $insurance->ins_sum_assured;
			$list_id = "INS_$insurance_id";
			if(($ins_type === "2") || ($ins_type === "3")){
				$goal_map_list .=  "<option value='$list_id'>$insurance_type_name - $ins_sum_assured</option>";
			}
		}

		foreach($mf_info as $mf){				
			$mf_id       = $mf->mf_id;
			$amc_name    = $mf->amc_name;
			$mf_live_sip = $mf->mf_live_sip;
			$list_id = "MF_$mf_id";
			$goal_map_list .=  "<option value='$list_id'>$amc_name - $mf_live_sip</option>";
		}
		
		foreach($gov_info as $gov){
			$gov_id          = $gov->gov_id;
			$gov_scheme_name = $gov->gov_scheme_name;
			$gov_amount      = $gov->gov_amount;
			$list_id = "GOV_$gov_id";
			$goal_map_list .=  "<option value='$list_id'>$gov_scheme_name - $gov_amount</option>";
		}
		foreach($others_info as $others){
			$others_id        = $others->others_id;
			$others_descript  = $others->others_descript;
			$others_amt       = $others->others_amt;
			$list_id = "OTH_$others_id";
			$goal_map_list .=  "<option value='$list_id'>$others_descript - $others_amt</option>";
		}		
		//LOAD GOAL LIST
		$goal_info    = $this->get_goal_inner_content($msg);
		$goal_info    = json_decode($goal_info);
		$goal_content = $goal_info->content;
		$goal_count   = $goal_info->goal_count;
		
		$tab_class = "disabled";
		$content   = "<h1 class='inner_title'>YOUR LONG TERM GOALS</h1>
						<div class='col l12 s12 subtab_holder'>
							<div class='row mg0'>
								<div class='col l12  s12'>
									<div class='row input_holder'>
										<form id='save_goal_form'>
											<input id='goal_id' name='goal_id' type='hidden' value='0'/>
											<div class='input-field col l2 s12'>
												<select id='goal_family' name='goal_family'>
												  $family_list
												</select>
												<label>Family</label>
											</div>
											<div class='input-field col l2 s12'>
												<select id='goal_for' name='goal_for'>
												  <option value='' disabled selected>-- Goal For --</option>
												  <option value='1'>Education</option>
												  <option value='2'>Marriage</option>
												  <option value='3'>Retirement</option>
												  <option value='4'>Dream Home</option>
												  <option value='5'>Dream Car</option>
												</select>
												<label>Goal For</label>
											</div>
											<div class='input-field col l2 s12'>
												<input id='goal_name' name='goal_name' type='text'>
												<label for='goal_name'>Goal Name</label>
											</div>
											<div class='input-field col l2 s12'>
												<input id='goal_date' name='goal_date' type='text' class='datepicker'>
												<label for='goal_date'>Goal Time</label>
											</div>
											<div class='input-field col l2 s12'>
												<input id='goal_amount' name='goal_amount' type='text' class='inwords'>
												<label for='goal_amount'>Current Expence</label>
											</div>
											<div class='input-field col l2 s12'>
												<select id='goal_map' name='goal_map' multiple>												  
												  $goal_map_list
												</select>
												<label>Map Investments</label>
											</div>
											<div class='input-field col l1 s12' style='margin-top:18px;'>
												<a class='waves-effect waves-light btn' id='save_goal_btn'>Save</a>
											</div>
											<div class='input-field col l5 s6' id='retirement_info'></div>
										</form>
									</div>
								</div>
							</div>
							<div class='col l12  s12 inv_split'></div>
							<div class='col l12  s12 save_content' id='goal_list'>
								$goal_content
							</div>
						</div>";
		return json_encode(array('sts' => TRUE, 'info' =>"$msg", 'goal_content' =>"$content", 'goal_tab' =>"$tab_class"));
	}
	/**** LONG TERM GOAL - END ****/
	
	/**** INVESTMENTS CHART - START ****/
	function investments_chart_info(){
		$bank_tr_line = "";
		$bank_total = 0;
		$bank_list_info  = $this->get_bank_list();
		$bank_list_rows  = $this->dbObj->num_rows($bank_list_info);
		if((int)$bank_list_rows > 0){
			$bank_scheme_info = array('1'=>"Bank Fixed Deposit",'2'=>"Company Deposit",'3'=>"Bank Recurring Deposit",'4'=>"Bonds",'5'=>"Other Deposits");
			$tenure_type_info = array('1'=>"Days",'2'=>"Month",'3'=>"Year");
			
			$bank_info  = $this->dbObj->result($bank_list_info);
			
			foreach($bank_info as $bank){
				$family_name        = $bank->family_name;
				$bank_scheme  		= $bank->bank_scheme;
				$bank_amt           = $bank->bank_amt;
				$paying_type_name   = $bank->paying_type_name;
				$bank_ror           = $bank->bank_ror;
				$bank_tenure        = $bank->bank_tenure;
				$bank_tenure_type   = $bank->bank_tenure_type;
				$bank_yearly        = $bank->bank_yearly;
				$bank_maturity      = new DateTime($bank->bank_maturity);
				$bank_maturity      = $bank_maturity->format("d-M-Y");
				$bank_maturity_amt  = $bank->bank_maturity_amt;
				$bank_scheme_name   = $bank_scheme_info[$bank_scheme];
				$tenure_name        = $tenure_type_info[$bank_tenure_type];
				$tenure             = $bank_tenure." / ". $tenure_name;
				$bank_total        += $bank_yearly;
				$bank_tr_line .= "<tr>
								<td>$family_name</td>
								<td>$bank_scheme_name</td>
								<td>$bank_amt</td>
								<td>$paying_type_name</td>
								<td>$bank_ror%</td>
								<td>$tenure</td>
								<td>$bank_maturity</td>
								<td>$bank_maturity_amt</td>
							</tr>";
			}			
		}
		$bank_table = "<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_bank'>
					<thead>
						<tr>
							<th>Depositor</th>
							<th>Scheme</th>
							<th>Amount</th>
							<th>Paying</th>
							<th>Return</th>
							<th>Tenure</th>
							<th>Date</th>
							<th>Maturity</th>
						</tr>
					</thead>
					<tbody>
						$bank_tr_line
					</tbody>
					</table>";
					
		$portfolio_tr_line = "";
		$ulip_tr_line      = "";
		$health_tr_line    = "";
		$general_tr_line   = "";
		$annuity_tr_line   = "";
		$insurance_total = 0;
		$insurance_list_info  = $this->get_insurance_list();
		$insurance_list_rows  = $this->dbObj->num_rows($insurance_list_info);		
		if((int)$insurance_list_rows > 0){											
			$general_info = array('1'=>"Car",'2'=>"Bike",'3'=>"Van",'4'=>"Others");			
			$insurance_info = $this->dbObj->result($insurance_list_info);
			foreach($insurance_info as $insurance){				
				$ins_type                 = $insurance->ins_type;
				$insurance_type_name      = $insurance->insurance_type_name;
				$insurance_company_name   = $insurance->insurance_company_name;
				$insurance_plan_name      = $insurance->insurance_plan_name;
				$ins_sum_assured          = $insurance->ins_sum_assured;
				$ins_premium      		  = $insurance->ins_premium;
				$ins_general_type      	  = $insurance->ins_general_type;
				$premium_yearly      	  = $insurance->premium_yearly;
				
				$pen_amt                  = $insurance->pen_amt;
				$pen_ror                  = $insurance->pen_ror;
				$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;
				
				$general_name = "";
				if($ins_general_type){
					$general_name = $general_info[$ins_general_type];
				}				
				
				$plan_name = "-";
				if($insurance_plan_name){
					$plan_name = $insurance_plan_name;
				}
				$insurance_total += $premium_yearly;
				if(($ins_type === "1") || ($ins_type === "2")){
					$portfolio_tr_line .= "<tr>
								<td>$insurance_type_name</td>
								<td>$insurance_company_name</td>
								<td>$plan_name</td>
								<td>$ins_sum_assured</td>
								<td>$ins_premium</td>
							</tr>";
				}else
				if($ins_type === "3"){
					$ulip_tr_line .= "<tr>
								<td>$insurance_type_name</td>
								<td>$insurance_company_name</td>
								<td>$plan_name</td>
								<td>$ins_sum_assured</td>
								<td>$ins_premium</td>
							</tr>";
				}else
				if($ins_type === "4"){
					$health_tr_line .= "<tr>
								<td>$insurance_type_name</td>
								<td>$insurance_company_name</td>
								<td>$plan_name</td>
								<td>$ins_sum_assured</td>
								<td>$ins_premium</td>
							</tr>";
				}else
				if($ins_type === "5"){
					$general_tr_line .= "<tr>
								<td>$insurance_type_name</td>
								<td>$insurance_company_name</td>
								<td>$plan_name</td>
								<td>$ins_sum_assured</td>
								<td>$ins_premium</td>
							</tr>";
				}else
				if($ins_type === "6"){
					$annuity_tr_line .= "<tr>
								<td>$insurance_company_name</td>
								<td>$pen_amt</td>
								<td>$vesting_corpus</td>
								<td>$one3rd_corpus</td>
								<td>$pension_amount</td>
							</tr>";
				}
				
			}			
		}
		$ins_table = "<div class='row mg0'>
					<ul class='tabs'>
						<li class='tab' style='line-height:25px !important;'>
							<a href='#chart_portfolio_tab' class='active'>Portfolio</a>
						</li>
						<li class='tab' style='line-height:25px !important;'>
							<a href='#chart_ulip_tab'>ULIP</a>
						</li>
						<li class='tab' style='line-height:25px !important;'>
							<a href='#chart_health_tab'>Health</a>
						</li>
						<li class='tab' style='line-height:25px !important;'>
							<a href='#chart_general_tab'>General</a>
						</li>
						<li class='tab' style='line-height:25px !important;'>
							<a href='#chart_annuity_tab'>Annuity</a>
						</li>
					</ul> 
					<div class='col l12 s12' id='chart_portfolio_tab' style='height:270px;padding:0px;'>
						<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_pro'>
							<thead>
								<tr>
									<th>Type</th>
									<th>Company</th>
									<th>Plan</th>
									<th>Sum Assured</th>
									<th>Premium</th>
								</tr>
							</thead>
							<tbody>
								$portfolio_tr_line
							</tbody>
						</table>
					</div>
					<div class='col l12 s12' id='chart_ulip_tab' style='height:270px;padding:0px;'>
						<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_ulip'>
							<thead>
								<tr>
									<th>Type</th>
									<th>Company</th>
									<th>Plan</th>
									<th>Sum Assured</th>
									<th>Premium</th>
								</tr>
							</thead>
							<tbody>
								$ulip_tr_line
							</tbody>
						</table>
					</div>
					<div class='col l12 s12' id='chart_health_tab' style='height:270px;padding:0px;'>
						<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_health'>
							<thead>
								<tr>
									<th>Type</th>
									<th>Company</th>
									<th>Plan</th>
									<th>Sum Assured</th>
									<th>Premium</th>
								</tr>
							</thead>
							<tbody>
								$health_tr_line
							</tbody>
						</table>
					</div>
					<div class='col l12 s12' id='chart_general_tab' style='height:270px;padding:0px;'>
						<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_general'>
							<thead>
								<tr>
									<th>Type</th>
									<th>Company</th>
									<th>Plan</th>
									<th>Sum Assured</th>
									<th>Premium</th>
								</tr>
							</thead>
							<tbody>
								$general_tr_line
							</tbody>
						</table>
					</div>
					<div class='col l12 s12' id='chart_annuity_tab' style='height:270px;padding:0px;'>
						<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_annuity'>
							<thead>
								<tr>
									<th>Company</th>
									<th>Amount</th>
									<th>Vesting Corpus</th>
									<th>one3rd Corpus</th>
									<th>Pension Amount</th>
								</tr>
							</thead>
							<tbody>
								$annuity_tr_line
							</tbody>
						</table>
					</div>
				</div>";
		
		$mf_tr_line = "";
		$mf_total = 0;
		$mf_list_info  = $this->get_mf_list();
		$mf_list_rows  = $this->dbObj->num_rows($mf_list_info);		
		if((int)$mf_list_rows > 0){
			$fund_type_info = array('1'=>"Growth",'2'=>"Dividend",'3'=>"SWP");
			$inv_type_info = array('1'=>"SIP",'2'=>"LUMPSUM");
			$mf_info = $this->dbObj->result($mf_list_info);
			foreach($mf_info as $mf){
				$family_name       = $mf->family_name;
				$amc_name      	   = $mf->amc_name;
				$fund_class_name   = $mf->fund_class_name;
				$mf_fund_type      = $mf->mf_fund_type;
				$mf_inv_type       = $mf->mf_inv_type;
				$mf_present_val    = $mf->mf_present_val;
				$mf_live_sip       = $mf->mf_live_sip;
				$mf_yearly         = $mf->mf_yearly;
				$fund_type_name    = $fund_type_info[$mf_fund_type];
				$inv_type_name     = $inv_type_info[$mf_inv_type];
				$mf_total += $mf_yearly;
				$mf_tr_line .= "<tr>
								<td>$family_name</td>
								<td>$amc_name</td>
								<td>$fund_class_name</td>
								<td>$fund_type_name</td>
								<td>$inv_type_name</td>
								<td>$mf_present_val</td>
								<td>$mf_live_sip</td>
							</tr>";
			}
		}
		$mf_table = "<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_mf'>
						<thead>
							<tr>
								<th>Investor</th>
								<th>AMC</th>
								<th>Class</th>
								<th>Type</th>
								<th>Investment</th>
								<th>Present Value</th>
								<th>Live SIP</th>
							</tr>
						</thead>
						<tbody>
							$mf_tr_line
						</tbody>
						</table>";
		$gov_tr_line = "";
		$gov_total   = 0;
		$gov_list_info  = $this->get_gov_list();
		$gov_list_rows  = $this->dbObj->num_rows($gov_list_info);		
		if((int)$gov_list_rows > 0){
			$gov_info = $this->dbObj->result($gov_list_info);
			foreach($gov_info as $gov){
				$family_name        = $gov->family_name;
				$gov_scheme_name    = $gov->gov_scheme_name;
				$paying_type_name   = $gov->paying_type_name;
				$gov_amount         = $gov->gov_amount;
				$gov_ror            = $gov->gov_ror;
				$gov_maturity_value = $gov->gov_maturity_value;
				$gov_yearly         = $gov->gov_yearly;
				$gov_total   += $gov_yearly;
				$gov_tr_line .= "<tr>
								<td>$family_name</td>
								<td>$gov_scheme_name</td>
								<td>$paying_type_name</td>
								<td>$gov_amount</td>
								<td>$gov_ror%</td>
								<td>$gov_maturity_value</td>
							</tr>";
			}
		}
		$gov_table = "<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_gov'>
						<thead>
							<tr>
								<th>Holder</th>
								<th>Scheme</th>
								<th>Paying</th>
								<th>Amount</th>
								<th>Return</th>
								<th>Maturity</th>
							</tr>
						</thead>
						<tbody>
							$gov_tr_line
						</tbody>
						</table>";
						
		$stock_tr_line = "";
		$stock_total   = 0;
		$stock_list_info  = $this->get_stock_list();
		$stock_list_rows  = $this->dbObj->num_rows($stock_list_info);		
		if((int)$stock_list_rows > 0){
			$stock_info   = $this->dbObj->result($stock_list_info);
			$stockname_info   = array('1'=>"Stocks",'2'=>"Bullion");	
			$bullion_info = array('1'=>"Gold",'2'=>"Silver",'3'=>"Others");			
			foreach($stock_info as $stock){
				$family_name          = $stock->family_name;
				$bullion_type         = $stock->bullion_type;
				$stock_current_value  = $stock->stock_current_value;
				$stock_yearly         = $stock->stock_yearly;
				$stock_type           = $stock->stock_type ;
				$stock_name           = $stockname_info[$stock_type];
				$stock_total += $stock_yearly;
				$bullion_name = "-";
				if($bullion_type){					
					$bullion_name = $bullion_info[$bullion_type];
				}
				$stock_tr_line .= "<tr>
								<td>$stock_name</td>
								<td>$family_name</td>
								<td>$bullion_name</td>
								<td>$stock_current_value</td>
							</tr>";
			}
		}
		$stock_table = "<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_stock'>
					<thead>
						<tr>
							<th>Type</th>
							<th>Investor</th>
							<th>Bullion Type</th>
							<th>Current Value</th>
						</tr>
					</thead>
					<tbody>
						$stock_tr_line
					</tbody>
					</table>";
					
		$others_tr_line = "";
		$others_total   = 0;
		$others_list_info  = $this->get_others_list();
		$others_list_rows  = $this->dbObj->num_rows($others_list_info);		
		if((int)$others_list_rows > 0){
			$others_info   = $this->dbObj->result($others_list_info);
			$tenure_type_info = array('1'=>"Days",'2'=>"Month",'3'=>"Year");
			
			foreach($others_info as $others){
				$family_name      	   = $others->family_name;
				$others_amt      	   = $others->others_amt;
				$paying_type_name      = $others->paying_type_name;
				$others_tenure         = $others->others_tenure;
				$others_tenure_type    = $others->others_tenure_type;
				$others_expected_val   = $others->others_expected_val;
				$others_maturity_val   = $others->others_maturity_val;
				$other_yearly          = $others->other_yearly;
				$tenure_name           = $tenure_type_info[$others_tenure_type];				
				$others_total += $other_yearly;
				$others_tr_line .= "<tr>
										<td>$family_name</td>
										<td>$others_amt</td>
										<td>$paying_type_name</td>
										<td>$others_tenure ($tenure_name)</td>
										<td>$others_expected_val</td>
										<td>$others_maturity_val</td>
									</tr>";
			}
		}
		$other_table = "<table class='striped responsive-table' style='background-color:#FFFFFF !important;' id='inv_chart_info_others'>
					<thead>
						<tr>
							<th>Investor</th>
							<th>Amount</th>
							<th>Paying</th>
							<th>Tenure</th>
							<th>Expected</th>
							<th>Maturity</th>
						</tr>
					</thead>
					<tbody>
						$others_tr_line
					</tbody>
					</table>";
		$content = "<ul class='collapsible' style='margin:0px;'>
						<li class='active'>
							<div class='collapsible-header col_pd'>Bank <span class='badge lp_badge'>$bank_total</span> <div class='pl_btn' id='inv_detail_crop' style='text-align: right;'><i class='material-icons' style='margin:0px;'>crop_free</i></div></div>
							<div class='collapsible-body col_body' id='bank_table'>
								$bank_table
							</div>
						</li>
						<li>
							<div class='collapsible-header col_pd'>Insurance <span class='badge lp_badge'>$insurance_total</span></div>
							<div class='collapsible-body col_body' id='insurance_table' style='padding:0px !important;'>
								$ins_table
							</div>
						</li>
						<li>
							<div class='collapsible-header col_pd'>Mutual Fund <span class='badge lp_badge'>$mf_total</span></div> 
							<div class='collapsible-body col_body' id='mf_table'>
								$mf_table
							</div>
						</li>
						<li>
							<div class='collapsible-header col_pd'>Government scheme <span class='badge lp_badge'>$gov_total</span></div>
							<div class='collapsible-body col_body' id='gov_table'>
								$gov_table
							</div>
						</li>
						<li>
							<div class='collapsible-header col_pd'>Stock & bullion <span class='badge lp_badge'>$stock_total</span></div>
							<div class='collapsible-body col_body' id='stock_table'>
								$stock_table
							</div>
						</li>
						<li>
							<div class='collapsible-header col_pd'>Others <span class='badge lp_badge'>$others_total</span></div>
							<div class='collapsible-body col_body' id='others_table'>
								$other_table
							</div>
						</li>
					</ul>";
		return json_encode(array('sts' => TRUE,'content' =>"$content"));
	}
	/**** INVESTMENTS CHART - END ****/
	
	//FEEDBACK INSERT
	function feedback_save($query){
		$feedback_info  = $this->dbObj->runQuery($query);
		if($feedback_info){
			return json_encode(array('sts' => TRUE,'info'=>'Feedback Added Successfully'));
		}else{
			return json_encode(array('sts' => FALSE,'info'=>'Invalid login'));
		}		
	}
}