SAM V2:customization

From AMACWiki
Revision as of 12:59, 17 May 2011 by Srunkle3X (Talk | contribs) (How to Add a Field to a Table and Form)

Jump to: navigation, search

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 Name Subdirectory Name
Student students student
Disabilities disabilities disability
Accommodations accommodations accommodation
Consents consent_types consent
Referrals referrals referral
Case Notes case_notes case
Tasks tasks task
Documentation documentation doc
Tests tests test
Class Schedules class_schedules schedule
Orders orders order

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:

alter table disabilities add column evaluator_name varchar(50) …

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. The code addition is highlighted in green below:

Add a New Disability

<?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 '

'.stripslashes($m).'

';
  }

?>

<form method="post" onsubmit="return validateForm(this)" enctype="multipart/form-data" action="dbaction.php">

Student <?php echo trim(trim($id . ' ' . $first_name . ' ' . $middle_name) . ' ' . $last_name); ?>
* <label for="disability">Disability</label>
     <select name="disability" id="disability">
        <option value=""></option>
        <?php selectList("disabilities","disability",null); ?>
     </select>
<label for="specification">Specification</label>
     <select name="specification">
        <option value=""></option>
        <?php selectList("disabilities","specification",null); ?>
     </select>
* <label for="type">Type</label>
     <select name="type">
        <option value=""></option>
        <?php selectList("disabilities","type",null); ?>
     </select>
<label for="expiration">Expiration Date</label> <input type="text" name="expiration" size="20" maxlength="10" value="<?php echo $expiration; ?>" /> 
           <a href="javascript:NewCal('expiration','MMddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a Date" /></a>
<label for="expiration">Expiration Date</label> <input type="text" name="expiration" size="20" maxlength="10" value="<?php echo $expiration; ?>" /> 
           <a href="javascript:NewCal('expiration','MMddyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a Date" /></a>
<label for="evaluator_name">Evaluator Name</label>
     <input type=”text” name=”evaluator_name” />
<label for="notes">Notes</label> <textarea name="notes" cols="50" rows="5"><?php echo $notes; ?></textarea>

* required fields

<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>

<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>