Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. if($_POST['calc']) {
  2.  
  3. $data = $_POST['calc'];
  4.  
  5. $percent = 10;
  6. $start_summ = (int)str_replace(" ","",$data['contribution']);
  7.  
  8. if ($data['radio'] == 'yes') {
  9. $summ_add = (int)str_replace(" ","",$data['adjunction']);
  10. } else {
  11. $summ_add = 0;
  12. }
  13.  
  14. $date = new DateTime($data['date']);
  15. $day = (int)$date->format('d');
  16. $month = (int)$date->format('m');
  17. $year = (int)$date->format('Y');
  18.  
  19. $summ = 0;
  20.  
  21. for ($i = 1; $i <= ((int)($data['years']))*12; $i++) {
  22.  
  23. if ($i == 1) {
  24. $days_in_month = (int)$date->format('t')-$day;
  25. $summ_add = 0;
  26. } else {
  27. $date->modify('+ 1 month');
  28. $day = (int)$date->format('d');
  29. $month = (int)$date->format('m');
  30. $year = (int)$date->format('Y');
  31. $days_in_month = (int)$date->format('t');
  32. }
  33.  
  34. if (($year % 4) == 0) {
  35. $days = 366;
  36. } else {
  37. $days = 365;
  38. }
  39. var_dump($days_in_month);
  40.  
  41. $summ += ($start_summ + ($start_summ + $summ_add))*($days_in_month*($percent/$days));
  42.  
  43. }
  44.  
  45.  
  46.  
  47. echo $summ;
  48.  
  49. //echo number_format($summ, 2, ',', ' ');
  50.  
  51. exit;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement