-
Notifications
You must be signed in to change notification settings - Fork 0
/
attendance_setup.php
executable file
·95 lines (82 loc) · 2.42 KB
/
attendance_setup.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
// --------------------------------------------------------------------
// attendance_setup.php -- The attendance setup page.
//
// Created: 1/20/15 DLB
// Updated: 1/16/15 DLB -- Reorganized...
// --------------------------------------------------------------------
require_once "libs/all.php";
session_start();
log_page();
CheckLogin();
CheckEditor();
$timer = new timer();
$loc = 'attendance_setup.php';
$error_msg = "";
$success_msg = "";
$param_list = array(
array("FieldName" => "LastDay", "FieldType" => "Text", "Caption" => "Last Date On Record"));
if( $_SERVER["REQUEST_METHOD"] == "GET")
{
$data = GetPrefsForUser(0);
PopulateParamList($param_list, $data);
goto GenerateHtml;
}
if( $_SERVER["REQUEST_METHOD"] == "POST")
{
$data = GetPrefsForUser(0);
PopulateParamList($param_list, $_POST);
// Check for illegal input...
if(!IsSqlTextOkay($_POST))
{
$error_msg = "Illegal characters in input... Do not use quotes and control chars.";
goto GenerateHtml;
}
$update = false;
// Check for changes.
foreach($param_list as $param_spec)
{
$k = $param_spec["FieldName"];
if(isset($param_spec["Value"]))
{
$curval = null;
if(isset($data[$k])) $curval = $data[$k];
if($curval != $param_spec["Value"]) { $update = true; break; }
}
}
if($update === false)
{
$success_msg = "No changes given.";
goto GenerateHtml;
}
// Looks like we are okay to update database!
$newdata = array();
foreach($param_list as $param_spec)
{
$n = $param_spec["FieldName"];
$v = $param_spec["Value"];
if($n == "LastDay")
{
$r = strtotime($v);
if($r === false)
{
$error_msg = "Undecodeable time value, try again.";
goto GenerateHtml;
}
$v = date("Y-m-d", $r);
}
$newdata[$n] = $v;
}
SavePrefsForUser(0, $newdata);
$data = GetPrefsForUser(0);
PopulateParamList($param_list, $data);
$success_msg = "Data Updated!";
goto GenerateHtml;
}
GenerateHtml:
include "forms/header.php";
include "forms/navform.php";
include "forms/attendance_menubar.php";
include "forms/attendance_setup_form.php";
include "forms/footer.php";
?>