PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/Scheduling/MassSchedule.php

https://gitlab.com/gregtyka/opensis
PHP | 205 lines | 173 code | 4 blank | 28 comment | 10 complexity | 7b1d139f02dea2062cc556ff76c6f26e MD5 | raw file
  1. <?php
  2. #**************************************************************************
  3. # openSIS is a free student information system for public and non-public
  4. # schools from Open Solutions for Education, Inc. It is web-based,
  5. # open source, and comes packed with features that include student
  6. # demographic info, scheduling, grade book, attendance,
  7. # report cards, eligibility, transcripts, parent portal,
  8. # student portal and more.
  9. #
  10. # Visit the openSIS web site at http://www.opensis.com to learn more.
  11. # If you have question regarding this system or the license, please send
  12. # an email to info@os4ed.com.
  13. #
  14. # Copyright (C) 2007-2008, Open Solutions for Education, Inc.
  15. #
  16. #*************************************************************************
  17. # This program is free software: you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation, version 2 of the License. See license.txt.
  20. #
  21. # This program is distributed in the hope that it will be useful,
  22. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. # GNU General Public License for more details.
  25. #
  26. # You should have received a copy of the GNU General Public License
  27. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  28. #**************************************************************************
  29. if(!$_REQUEST['modfunc'] && $_REQUEST['search_modfunc']!='list')
  30. unset($_SESSION['MassSchedule.php']);
  31. if($_REQUEST['modfunc']=='save')
  32. {
  33. if($_SESSION['MassSchedule.php'])
  34. {
  35. $start_date = $_REQUEST['day'].'-'.$_REQUEST['month'].'-'.$_REQUEST['year'];
  36. if(!VerifyDate($start_date))
  37. BackPrompt('The date you entered is not valid');
  38. $course_mp = DBGet(DBQuery("SELECT MARKING_PERIOD_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."'"));
  39. $course_mp = $course_mp[1]['MARKING_PERIOD_ID'];
  40. $course_mp_table = GetMPTable(GetMP($course_mp,'TABLE'));
  41. if($course_mp_table!='FY' && $course_mp!=$_REQUEST['marking_period_id'] && strpos(GetChildrenMP($course_mp_table,$course_mp),"'".$_REQUEST['marking_period_id']."'")===false)
  42. {
  43. // BackPrompt("You cannot schedule a student into that course during the marking period that you chose. This course meets on ".GetMP($course_mp).'.');
  44. ShowErr("You cannot schedule a student into that course during the marking period that you chose. This course meets on ".GetMP($course_mp).'.');
  45. for_error();
  46. }
  47. $mp_table = GetMPTable(GetMP($_REQUEST['marking_period_id'],'TABLE'));
  48. $current_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."' AND SYEAR='".UserSyear()."' AND (('".$start_date."' BETWEEN START_DATE AND END_DATE OR END_DATE IS NULL) AND '".$start_date."'>=START_DATE)"),array(),array('STUDENT_ID'));
  49. $request_RET = DBGet(DBQuery("SELECT STUDENT_ID FROM SCHEDULE_REQUESTS WHERE WITH_PERIOD_ID=(SELECT PERIOD_ID FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."') AND SYEAR='".UserSyear()."' AND COURSE_ID='".$_SESSION['MassSchedule.php']['course_id']."'"),array(),array('STUDENT_ID'));
  50. $check_seats = DBGet(DBQuery("SELECT (TOTAL_SEATS - FILLED_SEATS) AS AVAILABLE_SEATS FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."'"));
  51. $check_seats = $check_seats[1]['AVAILABLE_SEATS'];
  52. $no_seat = 'There is no available seats in this period.<br>Please increase the "Total Seats" from Scheduling>>Setup>Courses';
  53. foreach($_REQUEST['student'] as $student_id=>$yes)
  54. {
  55. if(!$current_RET[$student_id])
  56. {
  57. if(!$request_RET[$student_id])
  58. {
  59. $sql = "INSERT INTO SCHEDULE (SYEAR,SCHOOL_ID,STUDENT_ID,COURSE_ID,COURSE_PERIOD_ID,MP,MARKING_PERIOD_ID,START_DATE)
  60. values('".UserSyear()."','".UserSchool()."','".$student_id."','".$_SESSION['MassSchedule.php']['course_id']."','".$_SESSION['MassSchedule.php']['course_period_id']."','".$mp_table."','".$_REQUEST['marking_period_id']."','".$start_date."')";
  61. DBQuery($sql);
  62. DBQuery("UPDATE COURSE_PERIODS SET FILLED_SEATS=FILLED_SEATS+1 WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."'");
  63. $request_exists = false;
  64. $note = "That course has been added to the selected students' schedules.";
  65. }
  66. else
  67. {
  68. $select_stu = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME FROM STUDENTS WHERE STUDENT_ID='".$student_id."'"));
  69. $select_stu = $select_stu[1]['FIRST_NAME']."&nbsp;".$select_stu[1]['LAST_NAME'];
  70. $request_clash .= $select_stu."<br>";
  71. $request_exists = true;
  72. }
  73. }
  74. else
  75. {
  76. $select_stu = DBGet(DBQuery("SELECT FIRST_NAME,LAST_NAME FROM STUDENTS WHERE STUDENT_ID='".$student_id."'"));
  77. $select_stu = $select_stu[1]['FIRST_NAME']."&nbsp;".$select_stu[1]['LAST_NAME'];
  78. $clash .= $select_stu."<br>";
  79. }
  80. }
  81. unset($_REQUEST['modfunc']);
  82. unset($_SESSION['MassSchedule.php']);
  83. }
  84. else
  85. {
  86. //BackPrompt('You must choose a Course');
  87. ShowErr('You must choose a Course');
  88. for_error();
  89. }
  90. }
  91. if($_REQUEST['modfunc']!='choose_course')
  92. {
  93. DrawBC("Scheduling > ".ProgramTitle());
  94. if($_REQUEST['search_modfunc']=='list')
  95. {
  96. echo "<FORM name=sav id=sav action=Modules.php?modname=$_REQUEST[modname]&modfunc=save method=POST>";
  97. #DrawHeader('',SubmitButton('Add Course to Selected Students'));
  98. PopTable_wo_header ('header');
  99. echo '<TABLE><TR><TD>Course to Add</TD><TD><DIV id=course_div>';
  100. if($_SESSION['MassSchedule.php'])
  101. {
  102. $course_title = DBGet(DBQuery("SELECT TITLE FROM COURSES WHERE COURSE_ID='".$_SESSION['MassSchedule.php']['course_id']."'"));
  103. $course_title = $course_title[1]['TITLE'];
  104. $period_title = DBGet(DBQuery("SELECT TITLE FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."'"));
  105. $period_title = $period_title[1]['TITLE'];
  106. echo "$course_title - $_REQUEST[course_weight]<BR>$period_title";
  107. }
  108. echo '</DIV>'."<A HREF=# onclick='window.open(\"for_window.php?modname=$_REQUEST[modname]&modfunc=choose_course\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'>Choose a Course</A></TD></TR>";
  109. echo '<TR><TD>Start Date</TD><TD>'.PrepareDate(DBDate(),'').'</TD></TR>';
  110. echo '<TR><TD>Marking Period</TD><TD>';
  111. //echo '<SELECT name=marking_period_id><OPTION value=0>Full Year</OPTION>';
  112. $years_RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,TITLE,NULL AS SEMESTER_ID FROM SCHOOL_YEARS WHERE SYEAR='".UserSyear()."' AND SCHOOL_ID='".UserSchool()."'"));
  113. $semesters_RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,TITLE,NULL AS SEMESTER_ID FROM SCHOOL_SEMESTERS WHERE SYEAR='".UserSyear()."' AND SCHOOL_ID='".UserSchool()."' ORDER BY SORT_ORDER"));
  114. $quarters_RET = DBGet(DBQuery("SELECT MARKING_PERIOD_ID,TITLE,SEMESTER_ID FROM SCHOOL_QUARTERS WHERE SYEAR='".UserSyear()."' AND SCHOOL_ID='".UserSchool()."' ORDER BY SORT_ORDER"));
  115. echo '<SELECT name=marking_period_id><OPTION value='.$years_RET[1]['MARKING_PERIOD_ID'].'>'.$years_RET[1]['TITLE'].'</OPTION>';
  116. foreach($semesters_RET as $mp)
  117. echo "<OPTION value=$mp[MARKING_PERIOD_ID]>".$mp['TITLE'].'</OPTION>';
  118. foreach($quarters_RET as $mp)
  119. echo "<OPTION value=$mp[MARKING_PERIOD_ID]>".$mp['TITLE'].'</OPTION>';
  120. echo '</SELECT>';
  121. echo '</TD></TR>';
  122. echo '</TABLE>';
  123. PopTable ('footer');
  124. }
  125. if($note)
  126. DrawHeader('<IMG SRC=assets/check.gif>'.$note);
  127. if($check_seats<=0 && $no_seat)
  128. DrawHeaderHome('<IMG SRC=assets/warning_button.gif>'.$no_seat);
  129. if($clash)
  130. DrawHeaderHome('<IMG SRC=assets/warning_button.gif>'.$clash." is already in the schedule");
  131. if($request_exists)
  132. DrawHeaderHome('<IMG SRC=assets/warning_button.gif>'.$request_clash.' already have unscheduled requests');
  133. }
  134. if(!$_REQUEST['modfunc'])
  135. {
  136. if($_REQUEST['search_modfunc']!='list')
  137. unset($_SESSION['MassSchedule.php']);
  138. $extra['link'] = array('FULL_NAME'=>false);
  139. $extra['SELECT'] = ",CAST(NULL AS CHAR(1)) AS CHECKBOX";
  140. $extra['functions'] = array('CHECKBOX'=>'_makeChooseCheckbox');
  141. $extra['columns_before'] = array('CHECKBOX'=>'</A><INPUT type=checkbox value=Y name=controller onclick="checkAll(this.form,this.form.controller.checked,\'student\');"><A>');
  142. $extra['new'] = true;
  143. Widgets('course');
  144. Widgets('request');
  145. Widgets('activity');
  146. Search('student_id',$extra);
  147. if($_REQUEST['search_modfunc']=='list')
  148. {
  149. echo '<BR><CENTER>'.SubmitButton('Add Course to Selected Students','','class=btn_xlarge onclick=\'formload_ajax("sav");\'').'</CENTER>';
  150. echo "</FORM>";
  151. }
  152. }
  153. if($_REQUEST['modfunc']=='choose_course')
  154. {
  155. // if($_REQUEST['course_id'])
  156. // {
  157. // $weights_RET = DBGet(DBQuery("SELECT COURSE_WEIGHT,GPA_MULTIPLIER FROM COURSE_WEIGHTS WHERE COURSE_ID='$_REQUEST[course_id]'"));
  158. // if(count($weights_RET)==1)
  159. // $_REQUEST['course_weight'] = $weights_RET[1]['COURSE_WEIGHT'];
  160. // }
  161. if(!$_REQUEST['course_period_id'])
  162. include 'modules/Scheduling/CoursesforWindow.php';
  163. else
  164. {
  165. $_SESSION['MassSchedule.php']['subject_id'] = $_REQUEST['subject_id'];
  166. $_SESSION['MassSchedule.php']['course_id'] = $_REQUEST['course_id'];
  167. //$_SESSION['MassSchedule.php']['course_weight'] = $_REQUEST['course_weight'];
  168. $_SESSION['MassSchedule.php']['course_period_id'] = $_REQUEST['course_period_id'];
  169. $course_title = DBGet(DBQuery("SELECT TITLE FROM COURSES WHERE COURSE_ID='".$_SESSION['MassSchedule.php']['course_id']."'"));
  170. $course_title = $course_title[1]['TITLE'];
  171. $period_title = DBGet(DBQuery("SELECT TITLE FROM COURSE_PERIODS WHERE COURSE_PERIOD_ID='".$_SESSION['MassSchedule.php']['course_period_id']."'"));
  172. $period_title = $period_title[1]['TITLE'];
  173. echo "<script language=javascript>opener.document.getElementById(\"course_div\").innerHTML = \"$course_title<BR>$period_title\"; window.close();</script>";
  174. }
  175. }
  176. function _makeChooseCheckbox($value,$title)
  177. { global $THIS_RET;
  178. return "<INPUT type=checkbox name=student[".$THIS_RET['STUDENT_ID']."] value=Y>";
  179. }
  180. ?>