-
Notifications
You must be signed in to change notification settings - Fork 0
/
late.php
110 lines (101 loc) · 5.5 KB
/
late.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
session_start();
if(!isset($_SESSION['id'])) {
header("Location: index.php");
exit;
} else {
include 'template/template.php';
include 'includes/dbConnections.php';
// preparing SQL statement
$query = $db->prepare("SELECT id,fName,lName FROM TeamMemberInfo ORDER BY lName ASC");
// executes the query
$query->execute();
// fetch the results from the query that was executed
$sideBar = "<h3>Team Members</h3>";
while($row = $query->fetch(PDO::FETCH_ASSOC)) {
$sideBar .= '<button type="button" class="lateName" name="id" value="' . $row['id'] . '">' . $row['fName'] . " " . $row['lName'] . '</button><br />';
}
// call displayPage() (in template.php)
displayPage($sideBar,'<div id="box1">
<h2 id="sName">Late Log - Select a name</h2>
<div id="grid" style="display: none;">
<script>
$(document).ready(function() {
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "",
dataType: "json"
},
update: {
url: "",
dataType: "json"
},
destroy: {
url: "",
dataType: "json"
},
create: {
url: "",
dataType: "json"
},
parameterMap: function(options, operation) {
if (operation !== "read" && options.models) {
return {models: kendo.stringify(options.models)};
}
}
},
batch: true,
pageSize: 10,
schema: {
model: {
id: "uniqueID",
fields: {
uniqueID: { editable: false, nullable: true },
memID: { editable: false, nullable: true },
name: { editable: true, validation: { required: true } },
date: { editable: true, type: "date" },
timeArrived: { editable: true, validation: { required: true } },
schedTime: { editable: true, validation: { required: true } },
managerName: { editable: true },
comments: { editable: true, validation: { required: true } }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
sortable: true,
pageable: true,
height: 500,
toolbar: ["create"],
columns: [
{ field: "name", title: "Employee Name", width: "120px" },
{ field: "date", title: "Date", format: "{0:MM/dd/yyyy}", width: "90px" },
{ field: "timeArrived", title: "Time Arrived", width: "100px" },
{ field: "schedTime", title: "Sched. Arrival", width: "110px" },
{ field: "managerName", title: "Manager Name", width: "115px" },
{ field: "comments", title: "Comments", width: "140px",editor: textareaEditor },
{ command: ["edit", "destroy"], title: " "}],
editable: "popup"
});
$(".lateName").click(function () {
$("#sName").html("Late Log - " + $(this).html());
$("#grid").show();
var grid = $("#grid").data("kendoGrid");
grid.dataSource.transport.options.read.url = "/modules/getLate.php?id=" + $(this).attr("value") + "&q=1";
grid.dataSource.transport.options.update.url = "/modules/getLate.php?id=" + $(this).attr("value") + "&q=2";
grid.dataSource.transport.options.destroy.url = "/modules/getLate.php?id=" + $(this).attr("value") + "&q=3";
grid.dataSource.transport.options.create.url = "/modules/getLate.php?id=" + $(this).attr("value") + "&q=4";
dataSource.read();
});
function textareaEditor(container, options) {
$("<textarea data-bind=\"value: " + options.field + "\" cols=\"19\" rows=\"4\"></textarea>")
.appendTo(container);
}
});
</script>
</div>
</div>');
}
?>