Home

Adding Custom Editable Fields to OpenAudit

Print this articlePrint this article

Add Field

  1. Open the OpenAudit database
  2. Open the system_man table
  3. Add a new field in the form of system_man_* (ex. system_man_retired)
  4. Define the field (set type, default value, etc)

Display Field in Summary

  1. Backup system_viewdef_summary.php
  2. Open system_viewdef_summary.php
  3. Go to this section...
    ...
    "manual"=>array(
    "headline"=>__("Manual Data"),
    "sql"=>"SELECT * FROM system_man WHERE system_man_uuid = '" . $_GET["pc"] . "' ",
    "image"=>"images/notes_l.png",
    "edit"=>"y",
    "fields"=>array("10"=>array("name"=>"system_man_id", "show"=>"n",),
    "20"=>array("name"=>"system_man_location", "head"=>__("Location"), "edit"=>"y",),
    "30"=>array("name"=>"system_man_date_of_purchase", "head"=>__("Date of Purchase"), "edit"=>"y",),
    "40"=>array("name"=>"system_man_value", "head"=>__("Dollar Value"), "edit"=>"y",),
    "50"=>array("name"=>"system_man_serial_number", "head"=>__("Asset Tag"), "edit"=>"y",),
    "60"=>array("name"=>"system_man_description", "head"=>__("Description"), "edit"=>"y","edit_type"=>"textarea",),
    ),
    ),
    ...
  4. Add a line like this:
    "70"=>array("name"=>"system_man_retired", "head"=>__("Retired"), "edit"=>"y",),
    • name: The name of field in the system_man table.
    • head: The name displayed on system page.
    • edit: Editable Status.
    • edit_type: The type of the edit control.

Display Field in Report

  • Add a similar line to system_viewdef_report_full.php, as in system_viewdef_summary.php

Make Field Editable

  1. Open system_post.php
  2. Go to...
    ...
    //System-Manual-Data ------------------------------------------------------------------------
    }elseif($_REQUEST["view"]=="summary" AND $_REQUEST["category"]=="manual"){
    $sql = "UPDATE `system_man` SET ";
    $sql .= "`system_man_value` = '" . $_REQUEST['system_man_value'] . "', ";
    $sql .= "`system_man_description` = '" . $_REQUEST['system_man_description'] . "', ";
    $sql .= "`system_man_location` = '" . $_REQUEST['system_man_location'] . "', ";
    $sql .= "`system_man_serial_number` = '" . $_REQUEST['system_man_serial_number'] . "', ";
    $sql .= "`system_man_date_of_purchase` = '" . $_REQUEST['system_man_date_of_purchase'] . "'";
    $sql .= " WHERE `system_man_uuid` = '" . $_REQUEST['pc'] . "' ";
    ...
  3. Add a line like this: $sql .= "`system_man_retired` = '" . $_REQUEST['system_man_retired'] . "', ";