Difference between revisions of "SAM V2:customization"

From AMACWiki
Jump to: navigation, search
(How to Add a Field to a Table and Form)
(Blanked the page)
 
(18 intermediate revisions by one other user not shown)
Line 1: Line 1:
Since SAM V2 is open-source software, it is easily customized with a working knowledge of HTML, PHP, MySQL, and the SAM source code/database structure.
 
  
==Tables Names and Directory Structure==
 
 
<table border="1">
 
<tr>
 
<th>&nbsp;</th>
 
<th>Table Name</th>
 
<th>Subdirectory Name</th>
 
</tr>
 
<tr>
 
<td>Student</td>
 
<td>students</td>
 
<td>student</td>
 
</tr>
 
<tr>
 
<td>Disabilities</td>
 
<td>disabilities</td>
 
<td>disability</td>
 
</tr>
 
<tr>
 
<td>Accommodations</td>
 
<td>accommodations</td>
 
<td>accommodation</td>
 
</tr>
 
<tr>
 
<td>Consents</td>
 
<td>consent_types</td>
 
<td>consent</td>
 
</tr>
 
<tr>
 
<td>Referrals</td>
 
<td>referrals</td>
 
<td>referral</td>
 
</tr>
 
<tr>
 
<td>Case Notes</td>
 
<td>case_notes</td>
 
<td>case</td>
 
</tr>
 
<tr>
 
<td>Tasks</td>
 
<td>tasks</td>
 
<td>task</td>
 
</tr>
 
<tr>
 
<td>Documentation</td>
 
<td>documentation</td>
 
<td>doc</td>
 
</tr>
 
<tr>
 
<td>Tests</td>
 
<td>tests</td>
 
<td>test</td>
 
</tr>
 
<tr>
 
<td>Class Schedules</td>
 
<td>class_schedules</td>
 
<td>schedule</td>
 
</tr>
 
<tr>
 
<td>Orders</td>
 
<td>orders</td>
 
<td>order</td>
 
</tr>
 
</table>
 
 
==How to Add a Field to a Table and Form==
 
 
1. Add the field to the underlying table in MySQL.  For example, to add a field called Evaluator Name to the disabilities table, you would execute a SQL statement similar to:
 
 
<pre>alter table disabilities add column evaluator_name varchar(50) … </pre>
 
 
Or you could use the MySQL workbench to alter the table.
 
 
2. In the disability subdirectory, you will need to modify the programs add.php, edit.php, and view.php to handle the new evaluator_name field.
 
 
3. In add.php, you would add a table row for the new field with 2 table columns, one for the label, and one for the input of the value for evaluator_name.
 
 
<pre>
 
<h2>Add a New Disability</h2>
 
<?php if(lookupPermission("disabilities","add","yes")=="0") return; ?>
 
<?php
 
  if (isset($i)) {
 
      $result = mysql_query("SELECT * FROM students WHERE sid = '$i'");
 
      $row = mysql_fetch_array($result);
 
      $id = $row['id'];
 
      $first_name = $row['first_name'];
 
      $middle_name = $row['middle_name'];
 
      $last_name = $row['last_name'];
 
  }
 
  if (isset($m)) {
 
      echo '<p><font color="red">'.stripslashes($m).'</font></p>';
 
  }
 
?>
 
<div class="box">
 
<form method="post" onsubmit="return validateForm(this)" enctype="multipart/form-data" action="dbaction.php">
 
<table class="size8">
 
<tr>
 
  <td align="right"><strong>Student</strong></td>
 
  <td><?php echo trim(trim($id . ' ' . $first_name . ' ' . $middle_name) . ' ' . $last_name); ?></td>
 
</tr>
 
<tr>
 
  <td align="right"><font color="red">* </font><label for="disability"><strong>Disability</strong></label></td>
 
  <td>
 
      <select name="disability" id="disability">
 
        <option value=""></option>
 
        <?php selectList("disabilities","disability",null); ?>
 
      </select>
 
  </td>
 
</tr>
 
<tr>
 
  <td align="right"><label for="specification"><strong>Specification</strong></label></td>
 
  <td>
 
      <select name="specification">
 
        <option value=""></option>
 
        <?php selectList("disabilities","specification",null); ?>
 
      </select>
 
  </td>
 
</tr>
 
<tr>
 
  <td align="right"><font color="red">* </font><label for="type"><strong>Type</strong></label></td>
 
  <td>
 
      <select name="type">
 
        <option value=""></option>
 
        <?php selectList("disabilities","type",null); ?>
 
      </select>
 
  </td>
 
</tr>
 
<tr>
 
  <td align="right"><label for="expiration"><strong>Expiration Date</strong></label></td>
 
  <td><input type="text" name="expiration" size="20" maxlength="10" value="<?php echo $expiration; ?>" />&nbsp;
 
            <a href="javascript:NewCal('expiration','MMddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a Date" /></a>
 
  </td>
 
</tr>
 
<tr>
 
  <td align="right"><label for="expiration"><strong>Expiration Date</strong></label></td>
 
  <td><input type="text" name="expiration" size="20" maxlength="10" value="<?php echo $expiration; ?>" />&nbsp;
 
            <a href="javascript:NewCal('expiration','MMddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a Date" /></a>
 
  </td>
 
</tr>
 
'''<tr>'''
 
  <td align="right"><label for="evaluator_name"><strong>Evaluator Name</strong></label></td>
 
  <td>
 
      <input type=”text” name=”evaluator_name” />
 
  </td>
 
</tr>
 
<tr>
 
  <td align="right"><label for="notes"><strong>Notes</strong></label></td>
 
  <td><textarea name="notes" cols="50" rows="5"><?php echo $notes; ?></textarea></td>
 
</tr>
 
<tr>
 
  <td colspan="2"><br /><font color="red">* required fields</font></td>
 
</tr>
 
</table>
 
<input type="submit" name="submit" value="Add" />
 
<input type="reset" name="reset" value="Reset" />
 
<input type="button" name="back" value="Back" onclick="history.go(-1);" />
 
<input type="hidden" name="t" value="disabilities" />
 
<input type="hidden" name="i" value="<?php echo $i; ?>" />
 
</form>
 
</div>
 
<script type="text/javascript" language="javascript">
 
function validateForm(theForm) {
 
  if(theForm.disability.selectedIndex == 0) {
 
      alert('Please select a value for the "Disability" field.');
 
      theForm.disability.focus();
 
      return (false);
 
  }
 
  if(theForm.type.selectedIndex == 0) {
 
      alert('Please select a value for the "Type" field.');
 
      theForm.type.focus();
 
      return (false);
 
  }
 
  if(theForm.expiration.value != "") {
 
      if(!theForm.expiration.value.match(/^\d{1,2}\-\d{1,2}\-\d{4}$/)) {
 
        alert('Please enter the "Expiration Date" in the format MM-DD-YYYY.');
 
        theForm.expiration.focus();
 
        return (false);
 
      }
 
  }
 
}
 
</script>
 
<script type="text/javascript" language="javascript">
 
document.getElementById('disability').focus();
 
</script>
 
</pre>
 

Latest revision as of 10:50, 19 May 2015