Repository navigation
Expand file tree
/
Copy pathfunc.php
More file actions
executable file
·191 lines (171 loc) · 6.1 KB
/
Copy pathfunc.php
File metadata and controls
executable file
·191 lines (171 loc) · 6.1 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
function myHeader(){
print("
<html>
<head>
<title>Belldandy - the Logos bell system!</title>
<link rel = \"stylesheet\" type=\"text/css\" href=\"css\styles.css\"/>
</head>
<body>");
}
function myFooter(){
print("</body>
</html>");
} //end footer()
function showBells(){
$schedules=simplexml_load_file('bells.xml');
$prepend = 0;
foreach($schedules as $schedule){
print("<h1 class=\"$schedule->active\">");
print($schedule->title);
print("<table>");
print("<tr class=\"h\"><td>Period</td><td>Start</td><td>End</td><td>DoW</td><td>Sound</td></tr>");
foreach($schedule->periods->period as $period){
print("<tr class=\"c$prepend\">");
print("<td>".$period->name."</td>");
print("<td>".$period->starttime."</td>");
print("<td>".$period->endtime."</td>");
print("<td>".$period->dow."</td>");
print("<td>".$period->sound."</td>");
print("</tr>");
$prepend++;
$prepend=$prepend%2;
}
print("</table>");
$prepend = 0;
}
}
function findSchedule($schedules,$key){
$selection = null;
foreach($schedules as $schedule){
if($schedule->sid==$key){
$selection = $schedule;
}
}
return $selection;
}
function findPeriod($schedule,$key){
$selection = null;
foreach($schedule as $periods){
foreach($periods as $period){
if($period->pid==$key){
$selection = $period;
}
}
}
return $selection;
}
function generateTimeSelect($name,$curtimeval){
print("<select name=\"".$name."hour\">");
$stime = explode(":",$curtimeval);
$shour = $stime[0];
$smin = $stime[1];
$selected="";
for($i=7;$i<24;$i++){
if($i<10)$i="0".$i;
if($i==$shour) $selected = "selected";
print("<option $selected>$i</option>");
$selected="";
}
for($i=0;$i<7;$i++) print("<option>0$i</option>");
print("</select>"); //end hour selection
print(":");
print("<select name=\"startmin\">");
for($i=0;$i<60;$i++){
if($i<10)$i="0".$i;
if($i==$smin) $selected = "selected";
print("<option $selected>$i</option>");
$selected="";
}
print("</select>"); //end min selection
}
function generateDOWSelect($name,$curdow,$id){
$possDOW=array("MON","TUE","WED","THU","FRI","SAT","SUN");
$curdow = explode(",",$curdow);
$checked="uncheck";
foreach($possDOW as $thisDOW){
foreach($curdow as $testdow){
if(strcmp($testdow,$thisDOW)==0) //$checked="green";
{
$checked="check";
}
}
print("<div style=\"float:left; padding:0px 5px 0px 5px;\" class=\"cbox ".$checked."\" id=\"$id.DOW.$thisDOW\">".$thisDOW." </div>");
$checked="uncheck";
}
}
// -----------------get periods from database--------------
function get_periods($id){
$db = new SQLite3('bell.db');
$data=null;
$results = $db->query('SELECT * FROM PERIODS where ID ='.$id);
while ($results = $results->fetchArray()) {
return $data=$results;
}
}
function get_all_periods($sid){
$db = new SQLite3('bell.db');
return $results = $db->query('SELECT * FROM PERIODS where SCHEDULE_ID='.$sid);
}
//-----------get only schedule that have ID = $sid---------------
function get_schedule($sid){
$db = new SQLite3('bell.db');
$data=null;
$results = $db->query('SELECT * FROM SCHEDULE where ID ='.$sid);
while ($results = $results->fetchArray()) {
return $data=$results;
}
}
// ------------------get all schedules---------------
function get_all_schedules(){
$db = new SQLite3('bell.db');
return $results = $db->query('SELECT * FROM SCHEDULE');
}
//------------update period except DOW----------------
function update_period($modifiedData,$value,$pid){
$db = new SQLite3('bell.db');
$results = $db->query('UPDATE PERIODS SET '.$modifiedData.'="'.$value.'" WHERE ID='.$pid);
}
//--------update period dow-----------
function update_dow($pid,$value){
$db = new SQLite3('bell.db');
$results = $db->query('UPDATE PERIODS SET DOW="'.$value.'" WHERE ID='.$pid);
}
//----------update scheule active---------
function update_active($sid,$value){
$db = new SQLite3('bell.db');
$results = $db->query('UPDATE SCHEDULE SET ACTIVE="'.$value.'" WHERE ID='.$sid);
}
//--------------update sound-------------
function update_sound($pid,$value){
$db = new SQLite3('bell.db');
$results = $db->query('UPDATE PERIODS SET SOUND="'.$value.'" WHERE ID='.$pid);
}
//------------delete periods--------------
function delete_period($pid){
$db = new SQLite3('bell.db');
$results = $db->query('DELETE FROM PERIODS WHERE ID='.$pid);
}
//-----------add period-----------------
function add_period($sid,$name){
$db = new SQLite3('bell.db');
$results = $db->query('INSERT INTO PERIODS (SCHEDULE_ID,NAME,START_DATE,END_DATE,DOW,SOUND) VALUES ('.$sid.',"'.$name.'","00:00","00:00","","bell.mp3")');
}
//--------------add schedule------------------
function add_schedule($name){
$db = new SQLite3('bell.db');
$db = new SQLite3('bell.db');
$results = $db->query('INSERT INTO SCHEDULE (NAME,ACTIVE) VALUES ("'.$name.'","false")');
}
//------------delete periods--------------
function delete_schedule($sid){
$db = new SQLite3('bell.db');
$results = $db->query('DELETE FROM SCHEDULE WHERE ID='.$sid);
$results = $db->query('DELETE FROM PERIODS WHERE SCHEDULE_ID='.$sid);
}
//--------------update schedule-------------
function update_schedule($sid,$name){
$db = new SQLite3('bell.db');
$results = $db->query('UPDATE SCHEDULE SET NAME="'.$name.'" WHERE ID='.$sid);
}
?>