";
echo '
Missing Values
';
foreach ($validate_data as $key => $value) {
echo ":: Value
$key is missing.
";
}
echo "
";
return false;
}
}
private function calculate()
{
$power = pow((1 + $this->interest),$this->period);
if($power > 0){
$d= 1/$power;
$interest=0;
$deno = 1 - $d;
if($deno > 0){
$this->term_pay = ($this->loan_amount * $this->interest) / $deno;
$interest = $this->loan_amount * $this->interest;
$this->principal = $this->term_pay - $interest;
$this->balance = $this->loan_amount - $this->principal;
return array(
'payment' => $this->term_pay,
'interest' => $interest,
'principal' => $this->principal,
'balance' => $this->balance
);
}else{
return array(
'payment' => $this->term_pay,
'interest' => $interest,
'principal' => $this->principal,
'balance' => $this->balance
);
}
}else{
return array();
}
}
public function getSummary()
{
$this->calculate();
$total_pay = $this->term_pay * $this->period;
$total_interest = $total_pay - $this->loan_amount;
return array (
'total_pay' => $total_pay,
'total_interest' => $total_interest,
);
}
public function getSchedule($data)
{
$schedule = array();
$limit = $data['terms']*$data['term_years'];
$i=0;
while ($i < $limit) {
$i++;
array_push($schedule, $this->calculate());
$this->loan_amount = $this->balance;
$this->period--;
}
return $schedule;
}
private function getJSON($data)
{
header('Content-Type: application/json');
$this->results = $data;
return $this->results;
}
private function getResults($data)
{
//header('Content-Type: application/json');
$this->results = $data;
return $this->results;
}
}
?>