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)
 
(12 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 field label, and one for the input of the value for evaluator_name.
 
 
<pre>
 
<tr>
 
  <td align="right"><label for="evaluator_name"><strong>Evaluator Name</strong></label></td>
 
  <td>
 
      <input type="text" name="evaluator_name" />
 
  </td>
 
</tr>
 
</pre>
 
 
4.  If the field requires validation, then the validateForm javascript function should be modified to perform validation.  For example, to make the evaluator_name field required, add:
 
 
<pre>
 
if(theForm.evaluator_name.value == "") {
 
  alert('Please enter a value for the "Evaluator Name" field.');
 
  theForm.evaluator_name.focus();
 
  return (false);
 
}
 
</pre>
 
 
5.  In edit.php, the same changes made to add.php must be made.  In addition, a variable must be created called $evaluator_name that reads the $row[‘evaluator_name’] returned in $results and this variable should be displayed as the value for the HTML input field for evaluator_name.
 
 
<pre>
 
<?php
 
if (isset($i)) {
 
  $result = mysql_query("SELECT * FROM disabilities WHERE uid = '$i'");
 
  $row = mysql_fetch_array($result);
 
  $sid = $row['sid'];
 
  $disability = $row['disability'];
 
  $specification = $row['specification'];
 
  $type = $row['type'];
 
  $evaluator_name = $row['evaluator_name'];
 
  ...
 
?>
 
...
 
<tr>
 
  <td align="right"><label for="evaluator_name"><strong>Evaluator Name</strong></label></td>
 
  <td>
 
      <input type="text" name="evaluator_name" value="<?php echo $evaluator_name; ?>" />
 
  </td>
 
</tr>
 
</pre>
 

Latest revision as of 10:50, 19 May 2015