-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalc.php
48 lines (48 loc) · 1.34 KB
/
calc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
$date = "не определено";
$sum = "не определено";
$year = "не определено";
$replenishment = "не определено";
$sum_replenishment = "не определен";
if(isset($_POST["date"])){
$date = $_POST["date"];
}
if(isset($_POST["sum"])){
$sum = $_POST["sum"];
}
if(isset($_POST["year"])){
$year = $_POST["year"];
}
if(isset($_POST["replenishment"])){
$replenishment = $_POST["replenishment"];
}
if(isset($_POST["sum_replenishment"])){
$sum_replenishment = $_POST["sum_replenishment"];
}
$summn = $sum;
$lastDate = explode("/", $date);
$last = $year * 12;
$month = $lastDate[1];
$yearm = $lastDate[2];
$percent = 0.1;
for ($i = 0; $i < $last; $i++)
{
$daysn = date('t', mktime(0, 0, 0, $month, 1, $yearm));
$daysy = date('z', mktime(0, 0, 0, 12, 31, $yearm));
if ($replenishment === "yes")
{
$summn = $summn + ($summn + $sum_replenishment) * $daysn * ($percent/$daysy);
}
else
{
$summn = $summn + ($summn) * $daysn * ($percent/$daysy);
}
$month++;
if ($month == 13)
{
$month = 1;
$yearm + 1;
}
}
print_r((int)$summn);
?>