Adding Custom Editable Fields to OpenAudit
Print this articleAdd Field
- Open the OpenAudit database
- Open the system_man table
- Add a new field in the form of system_man_* (ex. system_man_retired)
- Define the field (set type, default value, etc)
Display Field in Summary
- Backup system_viewdef_summary.php
- Open system_viewdef_summary.php
- 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",),
),
),
... - 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
- Open system_post.php
- 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'] . "' ";
... - Add a line like this: $sql .= "`system_man_retired` = '" . $_REQUEST['system_man_retired'] . "', ";