Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($_POST['calc']) {
- $data = $_POST['calc'];
- $percent = 10;
- $start_summ = (int)str_replace(" ","",$data['contribution']);
- if ($data['radio'] == 'yes') {
- $summ_add = (int)str_replace(" ","",$data['adjunction']);
- } else {
- $summ_add = 0;
- }
- $date = new DateTime($data['date']);
- $day = (int)$date->format('d');
- $month = (int)$date->format('m');
- $year = (int)$date->format('Y');
- $summ = 0;
- for ($i = 1; $i <= ((int)($data['years']))*12; $i++) {
- if ($i == 1) {
- $days_in_month = (int)$date->format('t')-$day;
- $summ_add = 0;
- } else {
- $date->modify('+ 1 month');
- $day = (int)$date->format('d');
- $month = (int)$date->format('m');
- $year = (int)$date->format('Y');
- $days_in_month = (int)$date->format('t');
- }
- if (($year % 4) == 0) {
- $days = 366;
- } else {
- $days = 365;
- }
- var_dump($days_in_month);
- $summ += ($start_summ + ($start_summ + $summ_add))*($days_in_month*($percent/$days));
- }
- echo $summ;
- //echo number_format($summ, 2, ',', ' ');
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement