forked from mehulsbhatt/opensis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSide.php
More file actions
335 lines (300 loc) · 15.7 KB
/
Side.php
File metadata and controls
335 lines (300 loc) · 15.7 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<?php
#**************************************************************************
# openSIS is a free student information system for public and non-public
# schools from Open Solutions for Education, Inc. It is web-based,
# open source, and comes packed with features that include student
# demographic info, scheduling, grade book, attendance,
# report cards, eligibility, transcripts, parent portal,
# student portal and more.
#
# Visit the openSIS web site at http://www.opensis.com to learn more.
# If you have question regarding this system or the license, please send
# an email to info@os4ed.com.
#
# Copyright (C) 2007-2008, Open Solutions for Education, Inc.
#
#*************************************************************************
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License. See license.txt.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#**************************************************************************
error_reporting(1);
include "./Warehouse.php";
$tmp_REQUEST = $_REQUEST;
$_SESSION['Side_PHP_SELF'] = "Side.php";
$old_school = UserSchool();
$old_syear = UserSyear();
$old_period = UserCoursePeriod();
$btnn = $_REQUEST['btnn'];
$nsc = $_REQUEST['nsc'];
if(($_REQUEST['school'] && $_REQUEST['school']!=$old_school) || ($_REQUEST['period'] && $_REQUEST['period']!=$old_period))
{
unset($_SESSION['student_id']);
$_SESSION['unset_student'] = true;
unset($_SESSION['staff_id']);
unset($_SESSION['UserMP']);
unset($_REQUEST['mp']);
}
if($_REQUEST['modfunc']=='update' && $_POST)
{
if(User('PROFILE')=='admin' && ($_REQUEST['school']!=$old_school || $nsc=='NT'))
{
$_SESSION['UserSchool'] = $_REQUEST['school'];
DBQuery("UPDATE STAFF SET CURRENT_SCHOOL_ID='".UserSchool()."' WHERE STAFF_ID='".User('STAFF_ID')."'");
}
if(User('PROFILE')=='admin' && $nsc=='TT')
{
// --------------------------------------------------------------- School Session Assign ------------------------------------------------------------------ //
$QI = DBQuery("SELECT ID,TITLE FROM SCHOOLS ORDER BY ID DESC");
$RET = DBGet($QI);
//print_r($RET);
//echo $RET[1]['ID'];
//echo "<br>";
//echo $RET[1]['TITLE'];
// --------------------------------------------------------------- School Session Assign ------------------------------------------------------------------ //
//$_SESSION['UserSchool'] = $_REQUEST['school'];
$_SESSION['UserSchool'] = $RET[1]['ID'];
DBQuery("UPDATE STAFF SET CURRENT_SCHOOL_ID='".UserSchool()."' WHERE STAFF_ID='".User('STAFF_ID')."'");
}
$_SESSION['UserSyear'] = $_REQUEST['syear'];
$_SESSION['UserCoursePeriod'] = $_REQUEST['period'];
$_SESSION['UserMP'] = $_REQUEST['mp'];
if(User('PROFILE')=='parent')
{
if($_SESSION['student_id']!=$_REQUEST['student_id'])
unset($_SESSION['UserMP']);
$_SESSION['student_id'] = $_REQUEST['student_id'];
}
echo "<script language=javascript>parent.body.location='".str_replace('&','&',PreparePHP_SELF($_SESSION['_REQUEST_vars']))."';</script>";
}
if(!$_SESSION['UserSyear'])
$_SESSION['UserSyear'] = $DefaultSyear;
if(!$_SESSION['student_id'] && User('PROFILE')=='student')
$_SESSION['student_id'] = $_SESSION['STUDENT_ID'];
if(!$_SESSION['UserSchool'])
{
if(User('PROFILE')=='admin' && (!User('SCHOOLS') || strpos(User('SCHOOLS'),','.User('CURRENT_SCHOOL_ID').',')!==false))
$_SESSION['UserSchool'] = User('CURRENT_SCHOOL_ID');
elseif(User('PROFILE')=='student')
$_SESSION['UserSchool'] = trim(User('SCHOOLS'),',');
elseif(User('PROFILE')=='teacher')
{
$QI = DBQuery("SELECT cp.SCHOOL_ID FROM COURSE_PERIODS cp, SCHOOL_PERIODS sp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.PERIOD_ID=sp.PERIOD_ID AND cp.SYEAR='".UserSyear()."' AND cp.TEACHER_ID='".User('STAFF_ID')."'".(UserMP()?' AND cp.MARKING_PERIOD_ID IN ('.GetAllMP('QTR',UserMP()).')':'')." ORDER BY sp.SORT_ORDER LIMIT 1");
$RET = DBGet($QI);
$_SESSION['UserSchool'] = $RET[1]['SCHOOL_ID'];
}
}
if((!$_SESSION['UserMP'] || ($_REQUEST['school'] && $_REQUEST['school'] != $old_school) || ($_REQUEST['syear'] && $_REQUEST['syear'] != $old_syear) || ($_REQUEST['period'] && $_REQUEST['period'] != $old_period)) && User('PROFILE')!='parent')
$_SESSION['UserMP'] = GetCurrentMP('QTR',DBDate());
if(($_REQUEST['school'] && $_REQUEST['school'] != $old_school) || ($_REQUEST['syear'] && $_REQUEST['syear'] != $old_syear))
{
unset($_SESSION['UserPeriod']);
unset($_SESSION['UserCoursePeriod']);
}
if($_REQUEST['student_id']=='new')
{
unset($_SESSION['student_id']);
unset($_SESSION['_REQUEST_vars']['student_id']);
unset($_SESSION['_REQUEST_vars']['search_modfunc']);
echo "<script language=javascript>parent.body.location='".str_replace('&','&',PreparePHP_SELF($_SESSION['_REQUEST_vars']))."';</script>";
}
if($_REQUEST['school_id']=='new')
{
unset($_SESSION['UserSchool']);
echo "<script language=javascript>parent.body.location='".str_replace('&','&',PreparePHP_SELF($_SESSION['_REQUEST_vars']))."';</script>";
/*
unset($_SESSION['student_id']);
unset($_SESSION['_REQUEST_vars']['student_id']);
unset($_SESSION['_REQUEST_vars']['search_modfunc']);
*/
}
if($_REQUEST['staff_id']=='new')
{
unset($_SESSION['staff_id']);
unset($_SESSION['_REQUEST_vars']['staff_id']);
unset($_SESSION['_REQUEST_vars']['search_modfunc']);
echo "<script language=javascript>parent.body.location='".str_replace('&','&',PreparePHP_SELF($_SESSION['_REQUEST_vars']))."';</script>";
}
unset($_REQUEST['modfunc']);
echo "
<HTML>
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />
<link rel=stylesheet type=\"text/css\" href=\"assets/stylesheet.css\">
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
var old_modcat = false;
function openMenu(modcat)
{
document.getElementById(\"menu_visible\"+modcat).innerHTML = document.getElementById(\"menu_hidden\"+modcat).innerHTML;
if(old_modcat!=false)
document.getElementById(\"menu_visible\"+old_modcat).innerHTML = \"\";
document.getElementById(\"modcat_input\").value=modcat;
if(old_modcat==modcat)
old_modcat = false;
else
old_modcat = modcat;
}
-->
</script>
<title>".Config('TITLE')."</title>
</head>
<BODY background=assets/themes/".Preferences('THEME')."/bg.jpg leftmargin=6 marginwidth=4 topmargin=0 ".($_REQUEST['modcat']?"onload=openMenu('".$_REQUEST['modcat']."');":'').">";
// User Information
echo "<TABLE border=0 cellpadding=0 cellspacing=0 width=100%><TR><TD height=30>";
echo '<A HREF=index.php target=_top>'.DrawPNG('themes/'.Preferences('THEME').'/logo.png','border=0 width=160').'</A>';
echo "</TD></TR><TR>";
echo "<TD class=BoxContents style='border: inset #C9C9C9 2px; background-image:url(\"assets/bg.gif\")' width=100% valign=top>
<FORM action=Side.php?modfunc=update method=POST>
<INPUT type=hidden name=modcat value='' id=modcat_input>
<b>".User('NAME')."</b>
<BR>".date('l F j, Y')."
<BR>";
if(User('PROFILE')=='admin')
{
$schools = substr(str_replace(",","','",User('SCHOOLS')),2,-2);
$QI = DBQuery("SELECT ID,TITLE FROM SCHOOLS".($schools?" WHERE ID IN ($schools)":''));
$RET = DBGet($QI);
if(!UserSchool())
{
$_SESSION['UserSchool'] = $RET[1]['ID'];
DBQuery("UPDATE STAFF SET CURRENT_SCHOOL_ID='".UserSchool()."' WHERE STAFF_ID='".User('STAFF_ID')."'");
}
echo "<SELECT name=school onChange='document.forms[0].submit();' style='width:150;'>";
foreach($RET as $school)
echo "<OPTION value=$school[ID]".((UserSchool()==$school['ID'])?' SELECTED':'').">".$school['TITLE']."</OPTION>";
echo "</SELECT><BR>";
}
if(1)
{
if(User('PROFILE')!='student')
$sql = "SELECT DISTINCT sy.SYEAR FROM SCHOOL_YEARS sy,STAFF s WHERE s.SYEAR=sy.SYEAR AND s.USERNAME=(SELECT USERNAME FROM STAFF WHERE SYEAR='$DefaultSyear' AND STAFF_ID='$_SESSION[STAFF_ID]')";
else
$sql = "SELECT DISTINCT sy.SYEAR FROM SCHOOL_YEARS sy,STUDENT_ENROLLMENT se WHERE se.SYEAR=sy.SYEAR AND se.STUDENT_ID='$_SESSION[STUDENT_ID]'";
$years_RET = DBGet(DBQuery($sql));
}
else
$years_RET = array(1=>array('SYEAR'=>"$DefaultSyear"));
echo "<SELECT name=syear onChange='document.forms[0].submit();'>";
foreach($years_RET as $year)
echo "<OPTION value=$year[SYEAR]".((UserSyear()==$year['SYEAR'])?' SELECTED':'').">$year[SYEAR]-".($year['SYEAR']+1)."</OPTION>";
echo '</SELECT><BR>';
if(User('PROFILE')=='parent')
{
$RET = DBGet(DBQuery("SELECT sju.STUDENT_ID,s.LAST_NAME||', '||s.FIRST_NAME AS FULL_NAME,se.SCHOOL_ID FROM STUDENTS s,STUDENTS_JOIN_USERS sju, STUDENT_ENROLLMENT se WHERE s.STUDENT_ID=sju.STUDENT_ID AND sju.STAFF_ID='".User('STAFF_ID')."' AND se.SYEAR=".UserSyear()." AND se.STUDENT_ID=sju.STUDENT_ID AND (('".DBDate()."' BETWEEN se.START_DATE AND se.END_DATE OR se.END_DATE IS NULL) AND '".DBDate()."'>=se.START_DATE)"));
if(!UserStudentID())
$_SESSION['student_id'] = $RET[1]['STUDENT_ID'];
echo "<SELECT name=student_id onChange='document.forms[0].submit();'>";
if(count($RET))
{
foreach($RET as $student)
{
echo "<OPTION value=$student[STUDENT_ID]".((UserStudentID()==$student['STUDENT_ID'])?' SELECTED':'').">".$student['FULL_NAME']."</OPTION>";
if(UserStudentID()==$student['STUDENT_ID'])
$_SESSION['UserSchool'] = $student['SCHOOL_ID'];
}
}
echo "</SELECT><BR>";
if(!UserMP())
$_SESSION['UserMP'] = GetCurrentMP('QTR',DBDate());
}
if(User('PROFILE')=='teacher')
{
//if(UserMP())
// $QI = DBQuery("SELECT DISTINCT cp.PERIOD_ID,cp.COURSE_PERIOD_ID,sp.TITLE,sp.SHORT_NAME,cp.MARKING_PERIOD_ID,cp.DAYS,cp.SCHOOL_ID,sp.SORT_ORDER,c.TITLE AS COURSE_TITLE FROM COURSE_PERIODS cp, SCHOOL_PERIODS sp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.PERIOD_ID=sp.PERIOD_ID AND cp.SYEAR='".UserSyear()."' AND cp.TEACHER_ID='".User('STAFF_ID')."' AND cp.MARKING_PERIOD_ID IN (".GetAllMP('QTR',UserMP()).") ORDER BY sp.SORT_ORDER ");
//else
$QI = DBQuery("SELECT DISTINCT cp.PERIOD_ID,cp.COURSE_PERIOD_ID,sp.TITLE,sp.SHORT_NAME,cp.MARKING_PERIOD_ID,cp.DAYS,cp.SCHOOL_ID,sp.SORT_ORDER,c.TITLE AS COURSE_TITLE FROM COURSE_PERIODS cp, SCHOOL_PERIODS sp,COURSES c WHERE c.COURSE_ID=cp.COURSE_ID AND cp.PERIOD_ID=sp.PERIOD_ID AND cp.SYEAR='".UserSyear()."' AND cp.TEACHER_ID='".User('STAFF_ID')."' ORDER BY sp.SORT_ORDER");
$RET = DBGet($QI);
// get the fy marking period id's, there should be exactly one fy marking period per school
$fy_RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,SCHOOL_ID FROM SCHOOL_YEARS WHERE SYEAR='".UserSyear()."'"),array(),array('SCHOOL_ID'));
// only need quarters and semesters since years are suppressed and progress_periods aren't used
$mp_RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,TITLE,SHORT_NAME FROM SCHOOL_QUARTERS WHERE SYEAR='".UserSyear()."'
UNION SELECT MARKING_PERIOD_ID,TITLE,SHORT_NAME FROM SCHOOL_SEMESTERS WHERE SYEAR='".UserSyear()."'"),array(),array('MARKING_PERIOD_ID'));
if(!UserPeriod())
$_SESSION['UserPeriod'] = $RET[1]['PERIOD_ID'];
if(!UserCoursePeriod())
$_SESSION['UserCoursePeriod'] = $RET[1]['COURSE_PERIOD_ID'];
echo "<SELECT name=period onChange='document.forms[0].submit();' style='width:150;'>";
foreach($RET as $period)
{
echo "<OPTION value=$period[COURSE_PERIOD_ID]".((UserCoursePeriod()==$period['COURSE_PERIOD_ID'])?' SELECTED':'').">".$period['SHORT_NAME'].($period['MARKING_PERIOD_ID']!=$fy_RET[$period['SCHOOL_ID']][1]['MARKING_PERIOD_ID']?' '.$mp_RET[$period['MARKING_PERIOD_ID']][1]['SHORT_NAME']:'').(strlen($period['DAYS'])<5?' '.$period['DAYS']:'').' - '.$period['COURSE_TITLE']."</OPTION>";
if(UserCoursePeriod()==$period['COURSE_PERIOD_ID'])
{
if($period['SCHOOL_ID']!=UserSchool())
unset($_SESSION['UserMP']);
$_SESSION['UserSchool'] = $period['SCHOOL_ID'];
$_SESSION['UserPeriod'] = $period['PERIOD_ID'];
}
}
echo "</SELECT><BR>";
}
$RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,TITLE FROM SCHOOL_QUARTERS WHERE SCHOOL_ID='".UserSchool()."' AND SYEAR='".UserSyear()."' ORDER BY SORT_ORDER"));
echo "<SELECT name=mp onChange='document.forms[0].submit();'>";
if(count($RET))
{
if(!UserMP())
$_SESSION['UserMP'] = $RET[1]['MARKING_PERIOD_ID'];
foreach($RET as $quarter)
echo "<OPTION value=$quarter[MARKING_PERIOD_ID]".(UserMP()==$quarter['MARKING_PERIOD_ID']?' SELECTED':'').">".$quarter['TITLE']."</OPTION>";
}
echo "</SELECT>";
echo '</FORM>';
if(UserStudentID() && User('PROFILE')!='parent' && User('PROFILE')!='student')
{
$RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME,MIDDLE_NAME,NAME_SUFFIX FROM STUDENTS WHERE STUDENT_ID='".UserStudentID()."'"));
echo '<TABLE border=0 cellpadding=0 cellspacing=0 width=100%><TR><TD width=19 valign=middle><A HREF=Side.php?student_id=new&modcat='.$_REQUEST['modcat'].'><IMG SRC=assets/x.gif height=17 border=0></A></TD><TD ><B><A HREF=Modules.php?modname=Students/Student.php&student_id='.UserStudentID().' target=body><font color=#FFFFFF size=-2>'.$RET[1]['FIRST_NAME'].' '.($RET[1]['MIDDLE_NAME']?$RET[1]['MIDDLE_NAME'].' ':'').$RET[1]['LAST_NAME'].' '.$RET[1]['NAME_SUFFIX'].'</font></A></B></TD></TR></TABLE>';
}
if(UserStaffID() && User('PROFILE')=='admin')
{
if(UserStudentID())
echo '<IMG SRC=assets/pixel_trans.gif height=2>';
$RET = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME FROM STAFF WHERE STAFF_ID='".UserStaffID()."'"));
echo '<TABLE border=0 cellpadding=0 cellspacing=0 width=100%><TR><TD bgcolor=#336633 width=19 valign=middle><A HREF=Side.php?staff_id=new&modcat='.$_REQUEST['modcat'].'><IMG SRC=assets/x.gif height=17 border=0></A></TD><TD bgcolor=#336633><B><A HREF=Modules.php?modname=Users/User.php&staff_id='.UserStaffID().' target=body><font color=#FFFFFF size=-2>'.$RET[1]['FIRST_NAME'].' '.$RET[1]['LAST_NAME'].'</font></A></B></TD></TR></TABLE>';
}
echo '<BR>';
// Program Information
require('Menu.php');
foreach($_CENTRE['Menu'] as $modcat=>$programs)
{
if(count($_CENTRE['Menu'][$modcat]))
{
$keys = array_keys($_CENTRE['Menu'][$modcat]);
$menu = false;
foreach($keys as $key_index=>$file)
{
if(!is_numeric($file))
$menu = true;
}
if(!$menu)
continue;
echo "<A style='cursor: pointer; cursor:hand;' onclick='openMenu(\"".$modcat."\");parent.body.location=\"Modules.php?modname=$modcat/Search.php\";'><IMG SRC=assets/icons/$modcat.gif height=20 border=0 align=absmiddle><font color=blue face='Verdana, Arial, sans-serif'><B>".str_replace('_',' ',$modcat)."</B></font></A><BR><DIV id=menu_visible".$modcat."></DIV>";
echo "<DIV id=menu_hidden".$modcat." style=\"visibility:hidden;position:absolute;\"><TABLE width=100%>";
//foreach($_CENTRE['Menu'][$modcat] as $file=>$title)
foreach($keys as $key_index=>$file)
{
$title = $_CENTRE['Menu'][$modcat][$file];
if(substr($file,0,7)=='http://')
echo "<TR><TD width=20></TD><TD class=BoxContents><b>›</b> <A HREF=$file target=body onclick='javascript:parent.help.location=\"Bottom.php?modname=$file\"'><font color=blue>$title</font></A></TD></TR>";
elseif(substr($file,0,7)=='HTTP://')
echo "<TR><TD width=20></TD><TD class=BoxContents><b>›</b> <A HREF=$file target=_blank><font color=blue>$title</font></A></TD></TR>";
elseif(!is_numeric($file))
echo "<TR><TD width=20></TD><TD class=BoxContents><b>›</b> <A HREF=Modules.php?modname=$file target=body onclick='javascript:parent.help.location=\"Bottom.php?modname=$file\"'><font color=blue>$title</font></A></TD></TR>";
elseif($keys[$key_index+1] && !is_numeric($keys[$key_index+1]))
echo '<TR><TD colspan=2 height=3></TD></TR><TR><TD colspan=2 class=BoxContents> <b>'.$title.'</b></TD></TR>';
}
echo "</TABLE></DIV>";
}
}
echo '</TD></TR></TABLE>';
echo '</BODY>';
echo '</HTML>';
?>