PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/admin_manage_attendance_3.php

http://swifttide.googlecode.com/
PHP | 241 lines | 194 code | 23 blank | 24 comment | 15 complexity | b801d7dfa53264b22b12d720d4bdfc16 MD5 | raw file
  1. <?php
  2. //*
  3. // admin_manage_attendance_3.php
  4. // Admin Section
  5. // Edit attendance record for student
  6. //v1.5 12-4-05 Fixed "note added by" to display username
  7. //*
  8. //Check if admin is logged in
  9. session_start();
  10. if(!session_is_registered('UserId') || $_SESSION['UserType'] != "A")
  11. {
  12. header ("Location: index.php?action=notauth");
  13. exit;
  14. }
  15. //Include global functions
  16. include_once "common.php";
  17. //Initiate database functions
  18. include_once "ez_sql.php";
  19. // config
  20. include_once "configuration.php";
  21. $menustudent=1;
  22. $attendance = "";
  23. $custom_attendance_fields = "";
  24. $web_user=$_SESSION['UserId'];
  25. $current_year=$_SESSION['CurrentYear'];
  26. //Get student id
  27. $studentid=get_param("studentid");
  28. //Get action
  29. $action=get_param("action");
  30. if ($action=="edit"){
  31. //Get attendace id
  32. $attid=get_param("attid");
  33. //Gather info from db
  34. $sSQL="SELECT studentbio.studentbio_fname, studentbio.studentbio_lname,
  35. school_names.school_names_desc, school_years.school_years_desc,
  36. attendance_history.attendance_history_date AS attdate, attendance_codes.attendance_codes_desc,
  37. attendance_history.attendance_history_notes, web_users.web_users_flname, attendance_codes.attendance_codes_id
  38. FROM ((((attendance_history INNER JOIN studentbio ON attendance_history.attendance_history_student = studentbio.studentbio_id)
  39. INNER JOIN school_years ON attendance_history.attendance_history_year = school_years.school_years_id)
  40. INNER JOIN school_names ON attendance_history.attendance_history_school = school_names.school_names_id)
  41. INNER JOIN attendance_codes ON attendance_history.attendance_history_code = attendance_codes.attendance_codes_id)
  42. INNER JOIN web_users ON attendance_history.attendance_history_user = web_users.web_users_id
  43. WHERE attendance_history.attendance_history_id=$attid";
  44. $attendance=$db->get_row($sSQL);
  45. $slname=$attendance->studentbio_lname;
  46. $sfname=$attendance->studentbio_fname;
  47. $user=$attendance->web_users_flname;
  48. $cyear=$attendance->school_years_desc;
  49. $sschool=$attendance->school_names_desc;
  50. //get the custom fields associated with this attendance event added by Joshua
  51. $custom_attendance_sql = "SELECT * from custom_attendance_history, custom_fields
  52. WHERE (custom_attendance_history.custom_field_id = custom_fields.custom_field_id)
  53. AND (attendance_history_id = '$attid')";
  54. $custom_attendance_fields = $db->get_results($custom_attendance_sql);
  55. }else{
  56. //Get student names
  57. $sSQL="SELECT studentbio_fname, studentbio_lname, studentbio_school FROM studentbio WHERE studentbio_id=$studentid";
  58. $student=$db->get_row($sSQL);
  59. $slname=$student->studentbio_lname;
  60. $sfname=$student->studentbio_fname;
  61. $sschoolid=$student->studentbio_school;;
  62. //Get user name
  63. $sSQL="SELECT web_users_flname FROM web_users WHERE web_users_id=$web_user";
  64. $user=$db->get_var($sSQL);
  65. //Get Year
  66. $sSQL="SELECT school_years_desc FROM school_years WHERE school_years_id=$current_year";
  67. $cyear=$db->get_var($sSQL);
  68. //Get School
  69. $sSQL="SELECT school_names_desc FROM school_names WHERE school_names_id=$sschoolid";
  70. $sschool=$db->get_var($sSQL);
  71. $attendance = "";
  72. $custom_attendance_fields = "";
  73. };
  74. //Get list of attendance codes
  75. $attendancecodes=$db->get_results("SELECT * FROM attendance_codes ORDER BY attendance_codes_desc");
  76. ?>
  77. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  78. <html xmlns="http://www.w3.org/1999/xhtml">
  79. <head>
  80. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
  81. <title><?php echo _BROWSER_TITLE?></title>
  82. <style type="text/css" media="all">@import "student-admin.css";</style>
  83. <script language="JavaScript" src="datepicker.js"></script>
  84. <SCRIPT language="JavaScript">
  85. /* Javascript function to submit form and check if fields are empty */
  86. function submitform(fldName1, fldName2)
  87. {
  88. var f = document.forms[0];
  89. var t = f.elements[fldName1];
  90. var y = f.elements[fldName2];
  91. if(t.value=="<?php echo _ADMIN_MANAGE_ATTENDANCE_3_FORM_ERROR?>" || y.selectedIndex==0){
  92. alert('Code and Date should be entered');
  93. return false;
  94. }
  95. else{
  96. return true;
  97. };
  98. };
  99. </SCRIPT>
  100. <link rel="icon" href="favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
  101. <script type="text/javascript" language="JavaScript" src="sms.js"></script>
  102. </head>
  103. <body><img src="images/<?php echo _LOGO?>" border="0">
  104. <div id="Header">
  105. <table width="100%">
  106. <tr>
  107. <td width="50%" align="left"><font size="2">&nbsp;&nbsp;<?php echo date(_DATE_FORMAT); ?></font></td>
  108. <td width="50%"><?php echo _ADMIN_MANAGE_ATTENDANCE_3_UPPER?></td>
  109. </tr>
  110. </table>
  111. </div>
  112. <div id="Content">
  113. <h1><?php echo _ADMIN_MANAGE_ATTENDANCE_3_TITLE?></h1>
  114. <br>
  115. <h2><?php echo $sfname. " " .$slname ; ?></h2>
  116. <br>
  117. <h2><?php echo _ADMIN_MANAGE_ATTENDANCE_3_INSERTED?><?php echo $user; ?></h2>
  118. <table border="1" cellpadding="0" cellspacing="0" width="100%">
  119. <form name="attendance" method="POST" action="admin_manage_attendance_4.php" onsubmit="return submitform('attdate','attcode');">
  120. <tr class="trform">
  121. <td width="50%">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_SCHOOL?></td>
  122. <td width="50%">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_YEAR?></td>
  123. </tr>
  124. <tr class="tblcont">
  125. <td width="50%">&nbsp;<?php echo $sschool ; ?></td>
  126. <td width="50%">&nbsp;<?php echo $cyear ; ?></td>
  127. </tr>
  128. <tr class="trform">
  129. <td width="50%">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_CODE?></td>
  130. <td width="50%">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_DATE?></td>
  131. </tr>
  132. <tr class="tblcont">
  133. <td width="50%" class="tdinput">
  134. <select name="attcode">
  135. <option><?php echo _ADMIN_MANAGE_ATTENDANCE_3_SELECT?></option>
  136. <?php
  137. //Display attendance codes from table
  138. foreach($attendancecodes as $attendancecode){
  139. ?>
  140. <option value="<?php echo $attendancecode->attendance_codes_id; ?>" <?php if ($attendancecode->attendance_codes_id==$attendance->attendance_codes_id){echo "selected=selected";};?>><?php echo $attendancecode->attendance_codes_desc; ?></option>
  141. <?php
  142. };
  143. ?>
  144. </select>
  145. </td>
  146. <td width="50%" class="tdinput"><input type="text" onChange="capitalizeMe(this)" name="attdate" size="10" value="<?php if($action=="edit"){echo $attendance->attdate;};?>" READONLY onclick="javascript:show_calendar('attendance.attdate');"><a href="javascript:show_calendar('attendance.attdate');"><img src="images/cal.gif" border="0" class="imma"></a>
  147. </td>
  148. </tr>
  149. <tr class="trform">
  150. <td width="100%" colspan="2">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_NOTES?></td>
  151. </tr>
  152. <tr class="tdinput">
  153. <td width="100%" colspan="2">&nbsp;<textarea name="attnotes" cols="40" rows="5"><?php if($action=="edit"){echo strip($attendance->attendance_history_notes);};?></textarea></td>
  154. </tr>
  155. <?php
  156. if($action=="new"){
  157. ?>
  158. <tr>
  159. <td width="100%" colspan="2" class="tdinput">&nbsp;<?php echo _ADMIN_MANAGE_ATTENDANCE_3_NOTIFY?>:<input type="checkbox" name="notify" value="1" checked=checked></td>
  160. <input type="hidden" name="sschool" value="<?php echo $sschoolid; ?>">
  161. </tr>
  162. <?php
  163. };
  164. ?>
  165. <?php //custom fields added by Joshua
  166. //get all the custom field names for the select loops
  167. $cfSQL = "SELECT * FROM custom_fields";
  168. $custom_fields = $db->get_results($cfSQL);
  169. ?> <tr class="trform"><td colspan=2><?php echo _ADMIN_MANAGE_ATTENDANCE_3_CUSTOM_FIELDS?></td></tr>
  170. <tr><td colspan=2><table width="100%"> <?php
  171. if($custom_attendance_fields) {
  172. foreach($custom_attendance_fields as $custom_attendance_field) {
  173. ?> <tr><td><select name="custom_fields[<?php
  174. echo($custom_attendance_field->custom_attendance_history_id);
  175. ?>]"><option value="0"><?php echo _ADMIN_MANAGE_ATTENDANCE_3_DELETE?>...</option><?php
  176. foreach($custom_fields as $custom_field) {
  177. ?><option value="<?php echo($custom_field->custom_field_id);
  178. ?>" <?php
  179. if($custom_field->custom_field_id == $custom_attendance_field->custom_field_id) {
  180. echo" selected";
  181. }
  182. ?>><?php
  183. echo($custom_field->name);
  184. ?></option><?php
  185. }
  186. ?></select></td><td><input type="text" name="custom_attendance_fields[<?php
  187. echo($custom_attendance_field->custom_attendance_history_id);
  188. ?>]" value="<?php echo($custom_attendance_field->data);
  189. ?>" size=70></td></tr> <?php
  190. }
  191. }
  192. ?><tr><td><select name="new_custom_field_id">
  193. <option value="0" selected><?php echo _ADMIN_MANAGE_ATTENDANCE_3_ADD_NEW?>...</option><?php
  194. foreach($custom_fields as $custom_field) {
  195. ?><option value="<?echo($custom_field->custom_field_id);
  196. ?>"><?php echo($custom_field->name);
  197. ?></option><?php
  198. }
  199. ?></td><td><input type="text" name="new_custom_field_data" size=70>
  200. </td></tr></table></td></tr><?php
  201. //end custom fields
  202. ?>
  203. </table>
  204. <br>
  205. <table border="0" cellpadding="0" cellspacing="0" width="100%">
  206. <tr>
  207. <td width="50%"><a href="admin_edit_student_1.php?studentid=<?php echo $studentid; ?>" class="aform"><?php echo _ADMIN_MANAGE_ATTENDANCE_3_BACK?></a></td>
  208. <td width="50%" align="right"><input type="submit" name="submit" value="<?php if($action=="edit"){echo _ADMIN_MANAGE_ATTENDANCE_3_UPDATE;}else{echo _ADMIN_MANAGE_ATTENDANCE_3_ADD;};?>" class="frmbut"></td>
  209. </tr>
  210. <input type="hidden" name="attid" value="<?php echo $attid; ?>">
  211. <input type="hidden" name="studentid" value="<?php echo $studentid; ?>">
  212. <input type="hidden" name="action" value="<?php if($action=="edit"){echo "update";}else{echo "new";};?>">
  213. </table>
  214. </form>
  215. </div>
  216. <?php include "admin_menu.inc.php"; ?>
  217. </body>
  218. </html>