PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/School_Setup/Schools.php

https://gitlab.com/gregtyka/opensis
PHP | 183 lines | 116 code | 20 blank | 47 comment | 24 complexity | 777fb77b7e38e893ef2a9085a385bcc4 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. unset($_SESSION['_REQUEST_vars']['values']);unset($_SESSION['_REQUEST_vars']['modfunc']);
  30. DrawBC("School Setup > ".ProgramTitle());
  31. // --------------------------------------------------------------- Test SQL ------------------------------------------------------------------ //
  32. /*
  33. $QI = DBQuery("SELECT ID,TITLE FROM SCHOOLS ORDER BY ID DESC");
  34. $RET = DBGet($QI);
  35. //print_r($RET);
  36. echo $RET[1]['ID'];
  37. echo "<br>";
  38. echo $RET[1]['TITLE'];
  39. */
  40. // --------------------------------------------------------------- Tset SQL ------------------------------------------------------------------ //
  41. if($_REQUEST['modfunc']=='update' && ($_REQUEST['button']=='Save' || $_REQUEST['button']=='Update' || $_REQUEST['button']==''))
  42. {
  43. if($_REQUEST['values'] && $_POST['values'] && User('PROFILE')=='admin')
  44. {
  45. if($_REQUEST['new_school']!='true')
  46. {
  47. $sql = "UPDATE SCHOOLS SET ";
  48. foreach($_REQUEST['values'] as $column=>$value)
  49. {
  50. $sql .= $column."='".str_replace("\'","''",$value)."',";
  51. }
  52. $sql = substr($sql,0,-1) . " WHERE ID='".UserSchool()."'";
  53. DBQuery($sql);
  54. echo '<script language=JavaScript>parent.side.location="'.$_SESSION['Side_PHP_SELF'].'?modcat="+parent.side.document.forms[0].modcat.value;</script>';
  55. $note[] = 'This school has been modified.';
  56. }
  57. else
  58. {
  59. $fields = $values = '';
  60. foreach($_REQUEST['values'] as $column=>$value)
  61. if($column!='ID' && $value)
  62. {
  63. $fields .= ','.$column;
  64. $values .= ",'".str_replace("\'","''",$value)."'";
  65. }
  66. if($fields && $values)
  67. {
  68. $id = DBGet(DBQuery("SELECT ".db_seq_nextval('SCHOOLS_SEQ')." AS ID".FROM_DUAL));
  69. $id = $id[1]['ID'];
  70. $sql = "INSERT INTO SCHOOLS (SYEAR,ID$fields) values(".UserSyear().", $id$values)";
  71. DBQuery($sql);
  72. DBQuery("UPDATE STAFF SET SCHOOLS=CONCAT(CONCAT(SCHOOLS,','),'$id') WHERE STAFF_ID='".User('STAFF_ID')."' AND SCHOOLS IS NOT NULL");
  73. $_SESSION['UserSchool'] = $id;
  74. echo '<script language=JavaScript>parent.side.location="'.$_SESSION['Side_PHP_SELF'].'?modcat="+parent.side.document.forms[0].modcat.value;</script>';
  75. unset($_REQUEST['new_school']);
  76. }
  77. }
  78. }
  79. $_REQUEST['modfunc'] = '';
  80. unset($_SESSION['_REQUEST_vars']['values']);
  81. unset($_SESSION['_REQUEST_vars']['modfunc']);
  82. echo '<script language=JavaScript> document.forms[0].submit(); </script>';
  83. }
  84. if($_REQUEST['modfunc']=='update' && $_REQUEST['button']=='Delete' && User('PROFILE')=='admin')
  85. {
  86. if(DeletePrompt('school'))
  87. {
  88. if(BlockDelete('school'))
  89. {
  90. DBQuery("DELETE FROM SCHOOLS WHERE ID='".UserSchool()."'");
  91. DBQuery("DELETE FROM SCHOOL_GRADELEVELS WHERE SCHOOL_ID='".UserSchool()."'");
  92. DBQuery("DELETE FROM ATTENDANCE_CALENDAR WHERE SCHOOL_ID='".UserSchool()."'");
  93. DBQuery("DELETE FROM SCHOOL_PERIODS WHERE SCHOOL_ID='".UserSchool()."'");
  94. DBQuery("DELETE FROM SCHOOL_YEARS WHERE SCHOOL_ID='".UserSchool()."'");
  95. DBQuery("DELETE FROM SCHOOL_SEMESTERS WHERE SCHOOL_ID='".UserSchool()."'");
  96. DBQuery("DELETE FROM SCHOOL_QUARTERS WHERE SCHOOL_ID='".UserSchool()."'");
  97. DBQuery("DELETE FROM SCHOOL_PROGRESS_PERIODS WHERE SCHOOL_ID='".UserSchool()."'");
  98. DBQuery("UPDATE STAFF SET CURRENT_SCHOOL_ID=NULL WHERE CURRENT_SCHOOL_ID='".UserSchool()."'");
  99. DBQuery("UPDATE STAFF SET SCHOOLS=replace(SCHOOLS,',".UserSchool().",',',')");
  100. unset($_SESSION['UserSchool']);
  101. echo '<script language=JavaScript>parent.side.location="'.$_SESSION['Side_PHP_SELF'].'?modcat="+parent.side.document.forms[0].modcat.value;</script>';
  102. unset($_REQUEST);
  103. $_REQUEST['modname'] = "School_Setup/Schools.php?new_school=true";
  104. $_REQUEST['new_school'] = true;
  105. unset($_REQUEST['modfunc']);
  106. echo '
  107. <SCRIPT language="JavaScript">
  108. window.location="Side.php?school_id=new&modcat='.$_REQUEST['modcat'].'";
  109. </SCRIPT>
  110. ';
  111. }/*echo '<script language=JavaScript> document.head_frm.submit(); </script>'; */
  112. }
  113. }
  114. if(!$_REQUEST['modfunc'])
  115. {
  116. if(!$_REQUEST['new_school'])
  117. {
  118. $schooldata = DBGet(DBQuery("SELECT ID,TITLE,ADDRESS,CITY,STATE,ZIPCODE,PHONE,PRINCIPAL,WWW_ADDRESS,REPORTING_GP_SCALE,E_MAIL,CEEB FROM SCHOOLS WHERE ID='".UserSchool()."'"));
  119. $schooldata = $schooldata[1];
  120. $school_name = GetSchool(UserSchool());
  121. }
  122. else
  123. $school_name = 'Add a School';
  124. echo "<FORM name=school id=school METHOD='POST' ACTION='Modules.php?modname=".$_REQUEST['modname']."&modfunc=update&btn=".$_REQUEST['button']."&new_school=$_REQUEST[new_school]'>";
  125. # DrawHeader('',"<INPUT TYPE=SUBMIT name=button VALUE='Save'>".(($_REQUEST['new_school']!='true')?"<INPUT type=submit name=button value=Delete>":''));
  126. # echo '<BR>';
  127. # PopTable('header',$school_name);
  128. PopTable_wo_header('header');
  129. # echo "<FIELDSET><TABLE>";
  130. echo "<table border=0 align=center><tr><td><TABLE align=center>";
  131. echo "<TR><TD class='label'><b>School Name:</b></td><td>".TextInput($schooldata['TITLE'],'values[TITLE]', '','class=cell_floating size=24')."</td></TR>";
  132. echo "<TR ALIGN=LEFT><TD class='label'><b>Address:</b></TD><td>".TextInput($schooldata['ADDRESS'],'values[ADDRESS]','','class=cell_floating maxlength=100 size=24')."</td></TR>";
  133. echo "<TR ALIGN=LEFT><TD class='label'><b>City:</b></TD><td>".TextInput($schooldata['CITY'],'values[CITY]','','maxlength=100, class=cell_floating size=24')."</td></TR>";
  134. echo "<TR ALIGN=LEFT><TD class='label'><b>State:</b></TD><td>".TextInput($schooldata['STATE'],'values[STATE]','','maxlength=10 class=cell_floating size=24')."</td></TR>";
  135. echo "<TR ALIGN=LEFT><TD class='label'><b>Zip:</b></TD><td>".TextInput($schooldata['ZIPCODE'],'values[ZIPCODE]','','maxlength=10 class=cell_floating size=24')."</td></TR>";
  136. echo "<TR ALIGN=LEFT><TD class='label'><b>Telephone:</b></td><td>".TextInput($schooldata['PHONE'],'values[PHONE]','','class=cell_floating size=24')."</TD></TR>";
  137. echo "<TR ALIGN=LEFT><TD class='label'><b>Principal:</b></td><td>".TextInput($schooldata['PRINCIPAL'],'values[PRINCIPAL]','','class=cell_floating size=24')."</TD></TR>";
  138. echo "<TR ALIGN=LEFT><TD class='label'><b>Base Grading Scale:</b></td><td>".TextInput($schooldata['REPORTING_GP_SCALE'],'values[REPORTING_GP_SCALE]','','class=cell_floating maxlength=10 size=24')."</TD></TR>";
  139. echo "<TR ALIGN=LEFT><TD class='label'><b>E-Mail:</b></td><td>".TextInput($schooldata['E_MAIL'],'values[E_MAIL]','','class=cell_floating maxlength=100 size=24')."</TD></TR>";
  140. echo "<TR ALIGN=LEFT><TD class='label'><b>CEEB:</b></td><td>".TextInput($schooldata['CEEB'],'values[CEEB]','','class=cell_floating maxlength=100 size=24')."</TD></TR>";
  141. if(AllowEdit() || !$schooldata['WWW_ADDRESS'])
  142. echo "<TR ALIGN=LEFT><TD class='label'><b>Website:</b></td><td>".TextInput($schooldata['WWW_ADDRESS'],'values[WWW_ADDRESS]','','class=cell_floating size=24')."</TD></TR>";
  143. else
  144. //echo "<TR ALIGN=LEFT><TD colspan=3><A HREF=http://$schooldata[WWW_ADDRESS] target=_blank>$schooldata[WWW_ADDRESS]</A><BR><small><FONT color=".Preferences('TITLES').">Website</FONT></small></TD></TR>";
  145. echo "<TR ALIGN=LEFT><TD class='label'><b>Website:</b></td><td><A HREF=http://$schooldata[WWW_ADDRESS] target=_blank>$schooldata[WWW_ADDRESS]</A></TD></TR>";
  146. # echo "</TABLE></FIELDSET>";
  147. echo "</TABLE>";
  148. if(User('PROFILE')=='admin' && AllowEdit())
  149. {
  150. if($_REQUEST['new_school'])
  151. DrawHeader('','',"<INPUT TYPE=BUTTON name=button id=button class=btn_medium VALUE='Save' onclick='formcheck_school_setup_school();'></CENTER>");
  152. # DrawHeader('','',"<INPUT TYPE=SUBMIT name=button id=button class=btn_medium VALUE='Save' onclick='formcheck_school_setup_school();'></CENTER>");
  153. else
  154. DrawHeader('','',"<INPUT TYPE=BUTTON name=button id=button class=btn_medium VALUE='Update' onclick='formcheck_school_setup_school();'>&nbsp;<INPUT TYPE=SUBMIT name=button id=button class=btn_medium VALUE='Delete'></CENTER>");
  155. # DrawHeader('','',"<INPUT TYPE=SUBMIT name=button id=button class=btn_medium VALUE='Save' onclick='formcheck_school_setup_school();'>&nbsp;<INPUT TYPE=SUBMIT name=button id=button class=btn_medium VALUE='Delete'></CENTER>");
  156. }
  157. echo "</td></tr></table>";
  158. PopTable('footer');
  159. /* if(User('PROFILE')=='admin' && AllowEdit())
  160. echo "<CENTER><INPUT TYPE=SUBMIT name=button VALUE='Save'></CENTER>"; */
  161. echo "</FORM>";
  162. }
  163. ?>