-
Notifications
You must be signed in to change notification settings - Fork 0
/
save.php
70 lines (51 loc) · 1.94 KB
/
save.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
include("payroll.inc");
// if the "Week Complete" checkbox was checked, set to true. else set false.
if (isset($_POST['complete']))
$isComplete = 1;
else
$isComplete = 0;
$weekbegins = $_POST["startdate"];
$startdatetext = strtotime($weekbegins . " 00:00:00");
$year = date("Y", $startdatetext);
$day = date("d", $startdatetext);
$month = date("m", $startdatetext);
$startdate = date("mdY", mktime(12,30,0,$month,$day,$year));
$grandtotalhours = 0;
for ($i=0; $i<14; $i++) {
$date = date("D m/d/y", mktime(12,30,0,$month,$day+$i,$year)) ;
$date_SQL = date("Y-m-d", mktime(12,30,0,$month,$day+$i,$year)) ;
//$starttimeval = $_POST["start" . date("mdY", mktime(12,30,0,$month,$day+$i,$year)) ];
$starttimeval = $_POST["start" . $i ];
if ($starttimeval == 0) {
$starttime = "00:00:00";
$starttime_SQL = "00:00:00";
} else {
$starttime = date("h:i a", $starttimeval);
$starttime_SQL = date("H:i:s", $starttimeval);
}
//$endtimeval = $_POST["end" . date("mdY", mktime(12,30,0,$month,$day+$i,$year)) ];
$endtimeval = $_POST["end" . $i ];
if ($endtimeval == 0) {
$endtime = "00:00:00";
$endtime_SQL = "00:00:00";
} else {
$endtime = date("h:i a", $endtimeval);
$endtime_SQL = date("H:i:s", $endtimeval);
}
$querytext="DELETE FROM `payrollinfo` WHERE `username`='" . $username . "' AND `date`='" . $date_SQL . "'";
$result = mysql_query($querytext,$db);
if ( mysql_errno() != 0 ) {
echo "ERROR:" . mysql_errno() . ": " . mysql_error(). "\n";
exit(1);
}
$querytext="INSERT INTO `payrollinfo` ( `username` , `date` , `starttime` , `endtime`, `iscomplete`, `currentPayrate`) VALUES ('". $username . "', '" . $date_SQL . "', '" . $starttime_SQL . "', '" . $endtime_SQL ."', '".$isComplete. "', '".$_POST['payrate']."')";
//echo $querytext . "<br>";
$result = mysql_query($querytext,$db);
if ( mysql_errno() != 0 ) {
echo "ERROR:" .mysql_errno() . ": " . mysql_error(). "\n";
exit(1);
}
}
header ('location: view.php?saveok=1&startdate=' . $weekbegins);
?>