Incorporate changes for 1.2.0

This commit is contained in:
2026-02-24 19:48:08 -05:00
parent 39931c0ca5
commit 3667c4358f
24 changed files with 1833 additions and 1061 deletions

View File

@@ -1,5 +1,5 @@
OpenDRS - Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,3 +70,8 @@ Changelog
ownership of the installed server directory tree if the http
user and group names were left at the default.
- Updated and tested to support Raspberry Pi 4B hardware.
1.2.0 - 2021-05-05
- Added ability to customize the terminology used for Device,
Period, and Effective/Non-effective to make OpenDRS usable in
a wider range of applications.

View File

@@ -2,7 +2,7 @@
/*
about.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -53,7 +53,9 @@ $role=dblookup($mts_db,"users","id","role",$userid);
framework("begin","$appname","About OpenDRS",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********

View File

@@ -2,7 +2,7 @@
/*
common.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -26,7 +26,19 @@ if (!file_exists("db.php")) {
include("db.php");
include("settings.php");
// define some constants
// assign variables from constants
$device_term=DEVICE_TERM;
$discovered_term=DISCOVERED_TERM;
$discovered_term_short=DISCOVERED_TERM_SHORT;
$functional_term=FUNCTIONAL_TERM;
$functional_term_short=FUNCTIONAL_TERM_SHORT;
$disc_drop_data=DISC_DROP_DATA;
$functional_yes=FUNCTIONAL_YES;
$functional_no=FUNCTIONAL_NO;
$functional_yes_short=FUNCTIONAL_YES_SHORT;
$functional_no_short=FUNCTIONAL_NO_SHORT;
// define some other constants
define("STAT_OPEN",1);
define("STAT_CLOSED",2);
define("STAT_DEFERRED",3);
@@ -260,9 +272,9 @@ function framework($option,$htmltitle,$pagetitle,$print) {
$( \"#logoutall\" ).checkboxradio({
icon: false
});
$( \"#device, #subsystem, #period, #period_effective, [id|='sel']\" ).selectmenu();
$( \"#device, #subsystem, #discoveredselect, #functional, [id|='sel']\" ).selectmenu();
$( \"#status, #user, #reason\" ).selectmenu();
$( \"#subsystem, #period, #searchstatus, #pass, #passconf\").tooltip();
$( \"#subsystem, #discovered, #searchstatus, #pass, #passconf\").tooltip();
$( \"[id|='ms']\").multiselect();
$( \"#configtabs, #dbadmintabs, #profiletabs\" ).tabs();
</script>
@@ -276,7 +288,6 @@ function framework($option,$htmltitle,$pagetitle,$print) {
exit(1);
}
}
function pagetable($option) {
if ($option=="begin") {
echo "
@@ -532,17 +543,24 @@ function validate_password($pass,$passconf) {
}
function displaywriteup($id) {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
global $drs_db;
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id=\"$id\""));
// determine status indicator
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
// determine effective icon
if($writeupdata["period_effective"]==1) {
$effind="<font color=\"#00FF00\" title=\"Period Effective\">EFF</font>";
// determine functional indicator
if($writeupdata["functional"]==1) {
$funcind="<font color=\"#00FF00\" title=\"$functional_yes\">$functional_yes_short</font>";
} else {
$effind="<font color=\"#FF0000\" title=\"Period Non-effective\">NEF</font>";
$funcind="<font color=\"#FF0000\" title=\"$functional_no\">$functional_no_short</font>";
}
// look up text data
$devicename=dblookup($drs_db,"devices","id","name",$writeupdata["device"]);
@@ -552,8 +570,8 @@ function displaywriteup($id) {
$rdate=$writeupdata["report_date"];
$rtime=$writeupdata["report_time"];
$repby=$writeupdata["reported_by"];
$period=$writeupdata["period"];
$periodtimes=dblookup($drs_db,"periods","id","times",$period);
$whendiscoveredname=dblookup($drs_db,"discovered","id","whendiscoveredname",$writeupdata["discovered"]);
$whendiscovereddesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$writeupdata["discovered"]);
$techfname=dblookup($drs_db,"users","id","firstname",$writeupdata["action_by"]);
$techlname=dblookup($drs_db,"users","id","lastname",$writeupdata["action_by"]);
$reasonname=dblookup($drs_db,"reasons","id","text",$writeupdata["action_reason"]);
@@ -585,10 +603,10 @@ function displaywriteup($id) {
<table border=\"0\">
<tr><td><b>ID:</b> <a href=\"writeupdetail.php?id=$id\" title=\"View or change details of this writeup\">$id</a></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$statusind</b></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Device:</b> $devicename</td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$device_term:</b> $devicename</td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Subsystem:</b> <font title=\"$subsystemdesc\">$subsystemname</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>Period:</b> <font title=\"$periodtimes\">$period</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$effind</b></td>
<td><b>$discovered_term:</b> <font title=\"$whendiscovereddesc\">$whendiscoveredname</font></td><td>&nbsp;&nbsp;&nbsp;</td>
<td><b>$funcind</b></td>
</tr>
</table>
<table border=\"0\">
@@ -676,7 +694,14 @@ function putsetting($setting_name,$setting_value,$user_id) {
function group_table($groupid,$role=false,$mode="view",$selection="none",$expanded=false) {
// display a table for a single group
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
global $drs_db;
// print group id and name
if ($selection == "all") {
$sel_flag="checked";
@@ -706,12 +731,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
} else {
@@ -721,12 +746,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
}
@@ -744,13 +769,14 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
if ($writeupdata['status']==1) $statusind="<font color=\"#FF0000\"><div title=\"Open\">OPEN</div></font>";
if ($writeupdata['status']==2) $statusind="<font color=\"#00FF00\"><div title=\"Closed\">CLSD</div></font>";
if ($writeupdata['status']==3) $statusind="<font color=\"#FFFF00\"><div title=\"Deferred\">DFRD</div></font>";
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$writeupdata['period']}\""))[0];
// determine effective icon
if($writeupdata["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine whendiscovered text for discovered id
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$writeupdata['discovered']}\""))[0];
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$writeupdata['discovered']}\""))[0];
// determine functional icon
if($writeupdata["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// print table row
if ($role && $mode=="select") {
@@ -771,12 +797,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
$writeupdata["id"],$writeupdata["id"],
$statusind,
$writeupdata["report_date"],
$ptimes, $writeupdata["period"],
$whendiscdesc, $whendiscname,
$tname,
$ssname,
$writeupdata["reported_by"],
$writeupdata["discrepancy_text"],
$eff_icon
$func_icon
);
} else {
printf(
@@ -794,12 +820,12 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
$writeupdata["id"],$writeupdata["id"],
$statusind,
$writeupdata["report_date"],
$ptimes, $writeupdata["period"],
$whendiscdesc, $whendiscname,
$tname,
$ssname,
$writeupdata["reported_by"],
$writeupdata["discrepancy_text"],
$eff_icon
$func_icon
);
}
}
@@ -807,4 +833,5 @@ function group_table($groupid,$role=false,$mode="view",$selection="none",$expand
}
?>

View File

@@ -2,7 +2,7 @@
/*
config.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -45,7 +45,17 @@ $update_display=$incoming['update_display'];
$display_appname=$incoming['display_appname'];
$display_banner=$incoming['display_banner'];
$display_footer=$incoming['display_footer'];
$display_pereffhlp=$incoming['display_pereffhlp'];
$display_funchelp=$incoming['display_funchelp'];
$display_device_term=$incoming['display_device_term'];
$display_discovered_term=$incoming['display_discovered_term'];
$display_discovered_term_short=$incoming['display_discovered_term_short'];
$display_disc_drop_data=$incoming['display_disc_drop_data'];
$display_functional_term=$incoming['display_functional_term'];
$display_functional_term_short=$incoming['display_functional_term_short'];
$display_functional_yes=$incoming['display_functional_yes'];
$display_functional_no=$incoming['display_functional_no'];
$display_functional_yes_short=$incoming['display_functional_yes_short'];
$display_functional_no_short=$incoming['display_functional_no_short'];
$update_colors=$incoming['update_colors'];
$reset_colors=$incoming['reset_colors'];
@@ -81,7 +91,9 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","Configuration",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -92,14 +104,52 @@ if ($update_display) {
// remove html tags from app name and sanitize
$display_appname=strip_tags($display_appname);
$clean_display_appname=mysqli_real_escape_string($drs_db,$display_appname);
// remove html tags from period effective help text and sanitize
$display_pereffhlp=strip_tags($display_pereffhlp);
$clean_display_pereffhlp=mysqli_real_escape_string($drs_db,$display_pereffhlp);
// remove html tags from functional help text and sanitize
$display_funchelp=strip_tags($display_funchelp);
$clean_display_funchelp=mysqli_real_escape_string($drs_db,$display_funchelp);
// remove html tags from device term and sanitize
$display_device_term=strip_tags($display_device_term);
$clean_display_device_term=mysqli_real_escape_string($drs_db,$display_device_term);
// remove html tags from discovered term and sanitize
$display_discovered_term=strip_tags($display_discovered_term);
$clean_display_discovered_term=mysqli_real_escape_string($drs_db,$display_discovered_term);
// remove html tags from short discovered term and sanitize
$display_discovered_term_short=strip_tags($display_discovered_term_short);
$clean_display_discovered_term_short=mysqli_real_escape_string($drs_db,$display_discovered_term_short);
// remove html tags from functional term and sanitize
$display_functional_term=strip_tags($display_functional_term);
$clean_display_functional_term=mysqli_real_escape_string($drs_db,$display_functional_term);
// remove html tags from short functional term and sanitize
$display_functional_term_short=strip_tags($display_functional_term_short);
$clean_display_functional_term_short=mysqli_real_escape_string($drs_db,$display_functional_term_short);
// remove html tags from functional yes and sanitize
$display_functional_yes=strip_tags($display_functional_yes);
$clean_display_functional_yes=mysqli_real_escape_string($drs_db,$display_functional_yes);
// remove html tags from functional no and sanitize
$display_functional_no=strip_tags($display_functional_no);
$clean_display_functional_no=mysqli_real_escape_string($drs_db,$display_functional_no);
// remove html tags from short functional yes and sanitize
$display_functional_yes_short=strip_tags($display_functional_yes_short);
$clean_display_functional_yes_short=mysqli_real_escape_string($drs_db,$display_functional_yes_short);
// remove html tags from short functional no and sanitize
$display_functional_no_short=strip_tags($display_functional_no_short);
$clean_display_functional_no_short=mysqli_real_escape_string($drs_db,$display_functional_no_short);
mysqli_query($drs_db,"update config set value=\"$clean_display_appname\" where name=\"app_name\"");
mysqli_query($drs_db,"update config set value=\"$display_banner\" where name=\"banner\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_footer\" where name=\"footer_message\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_pereffhlp\" where name=\"period_eff_help_txt\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_funchelp\" where name=\"functional_help_txt\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_device_term\" where name=\"device_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_discovered_term\" where name=\"discovered_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_discovered_term_short\" where name=\"discovered_term_short\"");
mysqli_query($drs_db,"update config set value=\"$display_disc_drop_data\" where name=\"disc_drop_data\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_term\" where name=\"functional_term\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_term_short\" where name=\"functional_term_short\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_yes\" where name=\"functional_yes\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_no\" where name=\"functional_no\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_yes_short\" where name=\"functional_yes_short\"");
mysqli_query($drs_db,"update config set value=\"$clean_display_functional_no_short\" where name=\"functional_no_short\"");
echo "<meta http-equiv='refresh' content='0'>";
}
@@ -239,7 +289,18 @@ echo "
$curapn=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"app_name\""))[0];
$curbnr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"banner\""))[0];
$curftr=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"footer_message\""))[0];
$curpereffhlp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"period_eff_help_txt\""))[0];
$curfunchelp=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_help_txt\""))[0];
$curdscterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"discovered_term\""))[0];
$curdscterms=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"discovered_term_short\""))[0];
$curdiscdropdata=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"disc_drop_data\""))[0];
$curfuncterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_term\""))[0];
$curfuncterms=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_term_short\""))[0];
$curfuncyes=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_yes\""))[0];
$curfuncno=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_no\""))[0];
$curfuncyess=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_yes_short\""))[0];
$curfuncnos=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"functional_no_short\""))[0];
$curdevterm=mysqli_fetch_row(mysqli_query($drs_db,"select value from config where name=\"device_term\""))[0];
echo "
<font size=\"+1\"><b>Display Configuration Parameters</b></font><br><br><br><br>
";
@@ -259,12 +320,37 @@ while ($bannerrow=mysqli_fetch_assoc($bannerqry)) {
printf("<option value=\"%s\">%s</option>",$bannerrow["bannerid"],$bannerrow["bannername"]);
}
}
$dropnamestate=$dropdescstate="";
if($curdiscdropdata=="Name") $dropnamestate="checked";
if($curdiscdropdata=="Desc") $dropdescstate="checked";
echo "
</select><br><br><br>
Footer Message (will appear at the bottom of pages):<br>
<input type=\"text\" name=\"display_footer\" size=\"80\" value=\"$curftr\"><br><br><br>
Period Effective Help Text :<br>
<textarea rows=\"4\" cols=\"80\" name=\"display_pereffhlp\" wrap=\"soft\">$curpereffhlp</textarea><br><br><br><br>
Device Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_device_term\" size=\"10\" value=\"$curdevterm\"><br><br><br>
When Discovered Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_discovered_term\" size=\"20\" value=\"$curdscterm\"><br><br><br>
Short When Discovered Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_discovered_term_short\" size=\"9\" value=\"$curdscterms\"><br><br><br>
When Discovered data to show in dropdowns:&nbsp;&nbsp;&nbsp;<input type=\"radio\" name=\"display_disc_drop_data\" value=\"Name\" $dropnamestate> Name &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"display_disc_drop_data\" value=\"Desc\" $dropdescstate> Description<br><br><br>
Functional Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_term\" size=\"20\" value=\"$curfuncterm\"><br><br><br>
Short Functional Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_term_short\" size=\"4\" value=\"$curfuncterms\"><br><br><br>
Functional Yes Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_yes\" size=\"20\" value=\"$curfuncyes\"><br><br><br>
Functional No Terminology :&nbsp;&nbsp;&nbsp;
<input type=\"text\" name=\"display_functional_no\" size=\"20\" value=\"$curfuncno\"><br><br><br>
Short Functional Yes Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_yes_short\" size=\"4\" value=\"$curfuncyess\"><br><br><br>
Short Functional No Terminology (shown where space is limited, like table headers) :<br>
<input type=\"text\" name=\"display_functional_no_short\" size=\"4\" value=\"$curfuncnos\"><br><br><br>
Functional Help Text :<br>
<textarea rows=\"4\" cols=\"80\" name=\"display_funchelp\" wrap=\"soft\">$curfunchelp</textarea><br><br><br><br>
<input type=\"submit\" name=\"update_display\" value=\"Update Options\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br><br><br>
</form>

View File

@@ -2,7 +2,7 @@
/*
create.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -34,8 +34,8 @@ if ($print) {
// load variables from incoming array
$create=$incoming['create'];
$device=$incoming['device'];
$period=$incoming['period'];
$period_effective=$incoming['period_effective'];
$discovered=$incoming['discovered'];
$functional=$incoming['functional'];
$reported_by=$incoming['reported_by'];
$report_date=$incoming['report_date'];
$report_time=$incoming['report_time'];
@@ -56,7 +56,9 @@ $role=dblookup($drs_db,"persons","id","role",$personid);
framework("begin","$appname","New Writeup",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -69,7 +71,7 @@ if (!$report_time || $report_time=="automatic") $report_time=$now;
if ($create) {
// add the entry if create is pressed
if ($discrepancy_text && $reported_by && $device && $subsystem && $period) {
if ($discrepancy_text && $reported_by && $device && $subsystem && $discovered) {
// sanitize and fix blank date and time
$report_date=mysqli_real_escape_string($drs_db,$report_date);
$report_time=mysqli_real_escape_string($drs_db,$report_time);
@@ -82,8 +84,8 @@ if ($create) {
$clean_reported_by=mysqli_real_escape_string($drs_db,$reported_by);
// add the record to writeups
mysqli_query($drs_db,"insert into writeups(device,period,period_effective,reported_by,report_date,report_time,subsystem,discrepancy_text,status)
values (\"$device\",\"$period\",\"$period_effective\",\"$clean_reported_by\",\"$report_date\",\"$report_time\",\"$subsystem\",\"$clean_discrepancy_text\",\"$status\")");
mysqli_query($drs_db,"insert into writeups(device,discovered,functional,reported_by,report_date,report_time,subsystem,discrepancy_text,status)
values (\"$device\",\"$discovered\",\"$functional\",\"$clean_reported_by\",\"$report_date\",\"$report_time\",\"$subsystem\",\"$clean_discrepancy_text\",\"$status\")");
}
}
@@ -105,15 +107,15 @@ if ($create) {
$preserve=FALSE;
}
if (!$device) {
format_message(1,"You didn't select a device. Please try again.");
format_message(1,"You didn't select a $device_term. Please try again.");
$preserve=TRUE;
}
if (!$subsystem) {
format_message(1,"You didn't select a subsystem. Please try again.");
$preserve=TRUE;
}
if (!$period) {
format_message(1,"You didn't select a period. Please try again.");
if (!$discovered) {
format_message(1,"You didn't select a $discovered_term. Please try again.");
$preserve=TRUE;
}
if (!$discrepancy_text) {
@@ -140,7 +142,7 @@ if ($status==3) $statusind="<b><font color=\"#FFFF00\">DFRD</font></b>";
echo "
<table border=\"0\" cellpadding=\"5\">
<tr>
<td align=\"left\">Device<br>
<td align=\"left\">$device_term<br>
<select name=\"device\" id=\"device\">
<option value=\"\">Please select...</option>
";
@@ -170,16 +172,23 @@ echo "
</select></td><td></td>
</tr>
<tr>
<td align=\"left\">Period<br>
<select name=\"period\" id=\"period\">
<td align=\"left\">$discovered_term<br>
<select name=\"discovered\" id=\"discoveredselect\">
<option value=\"\">Please select...</option>
";
$prow=mysqli_query($drs_db,"select * from periods where active is true order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if ($period==$pitem["id"] && $preserve) {
printf("<option value=\"%s\" title=\"Period %s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$drow=mysqli_query($drs_db,"select * from discovered where active is true order by whendiscoveredname asc");
while ($ditem=mysqli_fetch_assoc($drow)) {
if ($discoverd==$ditem["id"] && $preserve) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$ditem["id"],$ditem["$discddtitle"],$ditem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$ditem["id"],$ditem["$discddtitle"],$ditem["$discddtext"]);
}
}
@@ -190,12 +199,12 @@ if (!$preserve) {
$reported_by="";
}
$effstate=$nefstate="";
$funcyesstate=$funcnostate="";
if ($preserve) {
if($period_effective==1) $effstate="checked";
if($period_effective==0) $nefstate="checked";
if($functional==1) $funcyesstate="checked";
if($functional==0) $funcnostate="checked";
} else {
$effstate="checked";
$funcyesstate="checked";
}
echo "
@@ -213,9 +222,9 @@ Discrepancy <font size=\"-2\">(required)</font><br>
<tr>
<td>Reported by <font size=\"-2\">(required)</font><br>
<input type=\"text\" name=\"reported_by\" size=\"30\" value=\"$reported_by\" title=\"Who to contact with questions about this writeup\"></td>
<td>Period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
<input type=\"radio\" name=\"period_effective\" value=\"1\" $effstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"period_effective\" value=\"0\" $nefstate> No
<td>$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
<input type=\"radio\" name=\"functional\" value=\"1\" $funcyesstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"functional\" value=\"0\" $funcnostate> No
</td>
<td align=\"right\" valign=\"bottom\"><input type=\"submit\" name=\"create\" value=\"Submit Writeup\" id=\"createbutton\"></td>
</tr>

View File

@@ -2,7 +2,7 @@
/*
dbadmin.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -79,13 +79,14 @@ $reason_id=$incoming['reason_id'];
$reason_text=$incoming['reason_text'];
$reason_active=$incoming['reason_active'];
$edit_period=$incoming['edit_period'];
$add_period=$incoming['add_period'];
$update_period=$incoming['update_period'];
$delete_period=$incoming['delete_period'];
$period_id=$incoming['period_id'];
$period_times=$incoming['period_times'];
$period_active=$incoming['period_active'];
$edit_discovered=$incoming['edit_discovered'];
$add_discovered=$incoming['add_discovered'];
$update_discovered=$incoming['update_discovered'];
$delete_discovered=$incoming['delete_discovered'];
$discovered_id=$incoming['discovered_id'];
$discovered_name=$incoming['discovered_name'];
$discovered_desc=$incoming['discovered_desc'];
$discovered_active=$incoming['discovered_active'];
// define local functions
@@ -101,7 +102,9 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","Database Administration",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -526,102 +529,118 @@ if ($edit_reason) {
}
}
// periods-----------------------------------
if ($add_period) {
// when discovered-----------------------------------
if ($add_discovered) {
// do error checking
// remove html tags from id and times
$period_id=strip_tags($period_id);
$period_times=strip_tags($period_times);
// test for id supplied
if (strlen(trim($period_id))) {
$peridsuppld=true;
// remove html tags from name and description
$discovered_name=strip_tags($discovered_name);
$discovered_desc=strip_tags($discovered_desc);
// test for name supplied
if (strlen(trim($discovered_name))) {
$discnamesuppld=true;
} else {
$peridsuppld=false;
$peridsuppld_err=true;
$discnamesuppld=false;
$discnamesuppld_err=true;
}
// test for id is integer
if (preg_match('/^[0-9]+$/',$period_id)) {
$peridisint=true;
// test for name unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\""))) {
$discnameunique=false;
$discnameunique_err=true;
} else {
$peridisint=false;
$peridisint_err=true;
$discnameunique=true;
}
// test for id unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where id=\"$period_id\""))) {
$peridunique=false;
$peridunique_err=true;
// test for description supplied
if (strlen(trim($discovered_desc))) {
$discdescsuppld=true;
} else {
$peridunique=true;
$discdescsuppld=false;
$discdescsuppld_err=true;
}
// test for times supplied
if (strlen(trim($period_times))) {
$pertimessuppld=true;
// test for description unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from description where whendiscovereddesc =\"$discovered_desc\""))) {
$discdescunique=false;
$discdescunique_err=true;
} else {
$pertimessuppld=false;
$pertimessuppld_err=true;
}
// test for times unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\""))) {
$pertimesunique=false;
$pertimesunique_err=true;
} else {
$pertimesunique=true;
$discdescunique=true;
}
// set active status
if (!$period_active) $period_active=0;
if (!$discovered_active) $discovered_active=0;
if ($pertimessuppld && $pertimesunique && $peridsuppld && $peridunique && $peridisint) {
// sanitize times
$clean_pertimes=mysqli_real_escape_string($drs_db,$period_times);
if ($discnamesuppld && $discnameunique && $discdescsuppld) {
// sanitize name
$clean_discovered_name=mysqli_real_escape_string($drs_db,$discovered_name);
// sanitize description
$clean_discovered_desc=mysqli_real_escape_string($drs_db,$discovered_desc);
// modify the table
mysqli_query($drs_db,"insert into periods(id,times,active) values(\"$period_id\",\"$clean_pertimes\",\"$period_active\")");
mysqli_query($drs_db,"insert into discovered(whendiscoveredname,whendiscovereddesc,active) values(\"$clean_discovered_name\",\"$clean_discovered_desc\",\"$discovered_active\")");
} else {
$period_add_fail=true;
$discovered_add_fail=true;
}
}
if ($edit_period) {
if ($delete_period) {
// check for writeups with this period
if (mysqli_num_rows(mysqli_query($drs_db,"select id from writeups where period=\"$period_id\""))) {
$perhaswriteups=true;
$perhaswriteups_err=true;
if ($edit_discovered) {
if ($delete_discovered) {
// check for writeups with this when discovered
if (mysqli_num_rows(mysqli_query($drs_db,"select id from writeups where discovered=\"$discovered_id\""))) {
$dischaswriteups=true;
$dischaswriteups_err=true;
} else {
$perhaswriteups=false;
$dischaswriteups=false;
}
// if none, then remove from db
if (!$perhaswriteups) mysqli_query($drs_db,"delete from periods where id=\"$period_id\"");
if (!$dischaswriteups) mysqli_query($drs_db,"delete from discovered where id=\"$discovered_id\"");
}
if ($update_period) {
if ($update_discovered) {
// do error checking
// remove html tags from times
$period_times=strip_tags($period_times);
// test for times supplied
if (strlen(trim($period_times))) {
$pertimessuppld=true;
} else {
$pertimessuppld=false;
$pertimessuppld_err=true;
}
// test for period times unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\" and id!=\"$period_id\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select id from periods where times=\"$period_times\""))) {
$pertimesunique=false;
$pertimesunique_err=true;
} else {
$pertimesunique=true;
}
} else {
$pertimesunique=true;
}
// remove html tags from name and description
$discovered_name=strip_tags($discovered_name);
$discovered_desc=strip_tags($discovered_desc);
// test for name supplied
if (strlen(trim($discovered_name))) {
$discnamesuppld=true;
} else {
$discnamesuppld=false;
$discnamesuppld_err=true;
}
// test for name unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\" and id!=\"$discovered_id\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscoveredname=\"$discovered_name\""))) {
$discnameunique=false;
$discnameunique_err=true;
} else {
$discnameunique=true;
}
} else {
$discnameunique=true;
}
// test for description supplied
if (strlen(trim($discovered_desc))) {
$discdescsuppld=true;
} else {
$discdescsuppld=false;
$discdescsuppld_err=true;
}
// test for description unique
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscovereddesc=\"$discovered_text\" and id!=\"$discovered_id\""))) {
if (mysqli_num_rows(mysqli_query($drs_db,"select id from discovered where whendiscovereddesc =\"$discovered_desc\""))) {
$discdescunique=false;
$discdescunique_err=true;
} else {
$discdescunique=true;
}
} else {
$discdescunique=true;
}
// set active status
if (!$period_active) $period_active=0;
if (!$discovered_active) $discovered_active=0;
// sanitize times
$clean_pertimes=mysqli_real_escape_string($drs_db,$period_times);
$updqry="update periods set times=\"$clean_pertimes\",active=\"$period_active\" where id=\"$period_id\"";
if ($pertimessuppld && $pertimesunique) {
// sanitize name
$clean_discovered_name=mysqli_real_escape_string($drs_db,$discovered_name);
// sanitize description
$clean_discovered_desc=mysqli_real_escape_string($drs_db,$discovered_desc);
$updqry="update discovered set whendiscoveredname=\"$clean_discovered_name\",whendiscovereddesc=\"$clean_discovered_desc\",active=\"$discovered_active\" where id=\"$discovered_id\"";
if ($discnamesuppld && $discnameunique && $discdescsuppld && $discdescunique) {
// modify the table
mysqli_query($drs_db,$updqry);
}
@@ -646,7 +665,7 @@ echo "
<li><a href=\"#devices\">Device Management</a></li>
<li><a href=\"#subsystems\">Subsystem Management</a></li>
<li><a href=\"#reasons\">Action Reasons Management</a></li>
<li><a href=\"#periods\">Period Management</a></li>
<li><a href=\"#discovered\">When Discovered Management</a></li>
</ul>
<div id=\"users\">
@@ -1001,53 +1020,49 @@ echo "</table>";
echo "
</div>
<div id=\"periods\">
<div id=\"discovered\">
";
if ($peridisint_err) format_message(1,"Period number must be an integer.");
if ($peridsuppld_err) format_message(1,"Period number cannot be blank.");
if ($peridunique_err) format_message(1,"Period number already exists.");
if ($pertimesunique_err) format_message(1,"Period already exists.");
if ($pertimessuppld_err) format_message(1,"Period times cannot be blank.");
if ($perhaswriteups_err) format_message(1,"Period has writeups in the database and cannot be deleted.");
if ($discnamesuppld_err) format_message(1,"When Discovered name cannot be blank.");
if ($discnameunique_err) format_message(1,"When Discovered name already exists.");
if ($dischaswriteups_err) format_message(1,"When Discovered has writeups in the database and cannot be deleted.");
if ($edit_period && !$delete_period) {
if ($edit_discovered && !$delete_discovered) {
// set form options for editing
$sectiontitle="<b><font size=\"+1\">Modify Period</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"dbadmin.php#periods\">Click here to add a new period</a><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php?edit_period=1#periods\">";
$sectiontitle="<b><font size=\"+1\">Modify When Discovered</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"dbadmin.php#discovered\">Click here to add a new when discovered</a><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php?edit_discovered=1#discovered\">";
$buttontags="
<input type=\"hidden\" name=\"period_id\" value=\"$period_id\">
<input type=\"submit\" name=\"update_period\" value=\"Update Period\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"delete_period\" value=\"Delete Period\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"hidden\" name=\"discovered_id\" value=\"$discovered_id\">
<input type=\"submit\" name=\"update_discovered\" value=\"Update When Discovered\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"delete_discovered\" value=\"Delete When Discovered\">&nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"submit\" name=\"reset\" value=\"Reset\"><br>
";
// pull current values from database
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from periods where id=$period_id"));
$period_times=$currentvalues["times"];
$currentvalues=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from discovered where id=$discovered_id"));
$discovered_name=$currentvalues["whendiscoveredname"];
$discovered_desc=$currentvalues["whendiscovereddesc"];
if ($currentvalues["active"]==1) {
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\" checked>";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\" checked>";
} else {
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\">";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\">";
}
$idtag="$period_id";
} else {
// set form options for add
if (!$period_add_fail) unset($period_id,$period_times,$period_active);
$sectiontitle="<b><font size=\"+1\">Add New Period</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#periods\">";
if (!$discovered_add_fail) unset($discovered_id,$discovered_name,$discovered_desc,$discovered_active);
$sectiontitle="<b><font size=\"+1\">Add New When Discovered</font></b><br><br>";
$formtag="<form method=\"post\" action=\"dbadmin.php#discovered\">";
$buttontags="
<input type=\"submit\" name=\"add_period\" value=\"Add Period\">
<input type=\"submit\" name=\"add_discovered\" value=\"Add When Discovered\">
";
$idtag="<input type=\"text\" name=\"period_id\" size=\"3\" value=\"$period_id\">";
// set default values
$activetag="<input type=\"checkbox\" name=\"period_active\" value=\"1\" checked>";
$activetag="<input type=\"checkbox\" name=\"discovered_active\" value=\"1\" checked>";
}
echo "
$sectiontitle
$formtag
<table border=\"0\">
<tr><td>
Period Number: &nbsp;$idtag<br><br>
Period Times: &nbsp;<input type=\"text\" name=\"period_times\" size=\"40\" value=\"$period_times\"><br><br>
When Discovered Name: &nbsp;<input type=\"text\" name=\"discovered_name\" size=\"8\" value=\"$discovered_name\"><br><br>
When Discovered Description: &nbsp;<input type=\"text\" name=\"discovered_desc\" size=\"60\" value=\"$discovered_desc\"><br><br>
Active: &nbsp; $activetag <br><br>
</td></tr>
</table>
@@ -1057,11 +1072,11 @@ $buttontags
";
// show the table of entities
$existingdata=mysqli_query($drs_db,"select * from periods order by id asc");
$existingdata=mysqli_query($drs_db,"select * from discovered order by id asc");
echo "
<b>Existing Periods</b>&nbsp;&nbsp;&nbsp;<font size=\"-1\">Click on the Period ID to edit.</font><br><br>
<b>Existing When Discovereds</b>&nbsp;&nbsp;&nbsp;<font size=\"-1\">Click on the When Disc ID to edit.</font><br><br>
<table border=\"1\">
<tr><th>Period ID</th><th>Period Times</th><th>Active</th></tr>
<tr><th>When Disc ID</th><th>Name</th><th>Description</th><th>Active</th></tr>
";
while ($tablerow=mysqli_fetch_assoc($existingdata)) {
if ($tablerow["active"]) {
@@ -1071,12 +1086,14 @@ while ($tablerow=mysqli_fetch_assoc($existingdata)) {
}
printf("
<tr>
<td><a href=\"dbadmin.php?edit_period=1&period_id=%s#periods\">%s</a></td>
<td><a href=\"dbadmin.php?edit_discovered=1&discovered_id=%s#discovered\">%s</a></td>
<td>%s</td>
<td>%s</td>
<td align=\"center\">%s</td>
</tr>",
$tablerow["id"],$tablerow["id"],
$tablerow["times"],
$tablerow["whendiscoveredname"],
$tablerow["whendiscovereddesc"],
$activedef);
}
echo "</table>";

View File

@@ -2,7 +2,7 @@
/*
gpl.php
OpenMTS Online Maintenance Tracking System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -52,7 +52,9 @@ $role=dblookup($mts_db,"users","id","role",$userid);
framework("begin","$appname","GNU General Public License",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********

View File

@@ -2,7 +2,7 @@
/*
groups.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -44,14 +44,14 @@ $search=$incoming['search'];
$s_status=$incoming['s_status'];
$s_device=$incoming['s_device'];
$s_subsystem=$incoming['s_subsystem'];
$s_period=$incoming['s_period'];
$s_discovered=$incoming['s_discovered'];
$s_report_date_start=$incoming['s_report_date_start'];
$s_report_date_end=$incoming['s_report_date_end'];
$s_report_time_start=$incoming['s_report_time_start'];
$s_report_time_end=$incoming['s_report_time_end'];
$s_discrepancy_text=$incoming['s_discrepancy_text'];
$s_reported_by=$incoming['s_reported_by'];
$s_period_effective=$incoming['s_period_effective'];
$s_functional=$incoming['s_functional'];
$edit_status=$incoming['edit_status'];
$edit_action_by=$incoming['edit_action_by'];
@@ -78,7 +78,9 @@ $role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","Writeup Groups",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -205,33 +207,33 @@ if ($search) {
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period
if ($s_period) {
// discovered
if ($s_discovered) {
$query_string="{$query_string}(";
$period_param="Periods:";
foreach ($s_period as $per_val) {
$query_string="{$query_string}period=\"{$per_val}\" or ";
$period_dsp=$per_val;
$period_param="{$period_param} {$period_dsp}, ";
$discovered_param="{$discovered_term_short}s:";
foreach ($s_discovered as $disc_val) {
$query_string="{$query_string}discovered=\"{$disc_val}\" or ";
$disc_dsp=$disc_val;
$discovered_param="{$discovered_param} {$disc_dsp}, ";
}
$period_param=rtrim($period_param,", ");
$num_periods=mysqli_num_rows(mysqli_query($drs_db,"select id from periods"));
if (count($s_period)==$num_periods) $period_param="Periods: any";
$discovered_param=rtrim($discovered_param,", ");
$num_discovereds=mysqli_num_rows(mysqli_query($drs_db,"select id from discovered"));
if (count($s_discovered)==$num_discovereds) $discovered_param="{$discovered_term_short}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period_effective
if ($s_period_effective) {
// functional
if ($s_functional) {
$query_string="{$query_string}(";
$eff_param="Period effective:";
foreach ($s_period_effective as $eff_val) {
$query_string="{$query_string}period_effective=\"{$eff_val}\" or ";
if ($eff_val=="0") $eff_dsp="<font color=\"#FF0000\">NEF</font>";
if ($eff_val=="1") $eff_dsp="<font color=\"#00FF00\">EFF</font>";
$eff_param="{$eff_param} {$eff_dsp}, ";
$func_param="$functional_term:";
foreach ($s_functional as $func_val) {
$query_string="{$query_string}functional=\"{$func_val}\" or ";
if ($func_val=="0") $func_dsp="<font color=\"#FF0000\">$functional_no_short</font>";
if ($func_val=="1") $func_dsp="<font color=\"#00FF00\">$functional_yes_short</font>";
$func_param="{$func_param} {$func_dsp}, ";
}
$eff_param=rtrim($eff_param,", ");
$func_param=rtrim($func_param,", ");
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
@@ -416,17 +418,17 @@ if ($action=="add") {
<tr>
<td align=\"left\">
";
// Period cell **********************
// Discovered cell **********************
echo "
Period<br>
<select name=\"s_period[]\" id=\"ms-period\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
$discovered_term<br>
<select name=\"s_discovered[]\" id=\"ms-discovered\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$prow=mysqli_query($drs_db,"select * from periods order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if (!$search || in_array($pitem["id"],$s_period,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
$discrow=mysqli_query($drs_db,"select * from discovered order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if (!$search || in_array($discitem["id"],$s_discovered,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["whendiscovereddesc"],$discitem["whendiscoveredname"]);
} else {
printf("<option value=\"%s\" title=\"%s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["whendiscovereddesc"],$discitem["whendiscoveredname"]);
}
}
echo "
@@ -488,21 +490,21 @@ if ($action=="add") {
</td>
<td align=\"left\">
";
// Period effective cell ************
// functional cell ************
echo "
Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($search) {
$effstate=$nefstate="";
if (in_array("1",$s_period_effective,true)) $effstate="selected";
if (in_array("0",$s_period_effective,true)) $nefstate="selected";
$funcyesstate=$funcnostate="";
if (in_array("1",$s_functional,true)) $funcyesstate="selected";
if (in_array("0",$s_functional,true)) $funcnostate="selected";
} else {
$effstate=$nefstate="selected";
$funcyesstate=$funcnostate="selected";
}
echo "
<select name=\"s_period_effective[]\" id=\"ms-period_effective\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $effstate title=\"Training objectives were achieved\">Effective</option>
<option value=\"0\" $nefstate title=\"Training objectives were not achieved\">Non-effective</option>
<select name=\"s_functional[]\" id=\"ms-functional\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $funcyesstate>$functional_yes</option>
<option value=\"0\" $funcnostate>$functional_no</option>
</select>
</td>
";
@@ -530,15 +532,15 @@ if ($action=="add") {
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup_qry)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine functional icon
if($tablerow["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no\">";
}
// determine status indicator
@@ -586,7 +588,7 @@ if ($action=="add") {
$dname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$func_icon
);
}
echo "

View File

@@ -2,7 +2,7 @@
/*
login.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -31,7 +31,10 @@ if ($print) {
framework("begin","$appname","Login Page",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
pagetable("begin");
if(!$print){

View File

@@ -2,7 +2,7 @@
/*
profile.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -74,7 +74,9 @@ if ($print=="Printer Friendly") {
framework("begin","$appname","User Profile",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********

View File

@@ -46,8 +46,8 @@ if ($print || $exportcsv) {
$search=$incoming['search'];
$viewtype=$incoming['viewtype'];
$s_device=$incoming['s_device'];
$s_period=$incoming['s_period'];
$s_period_effective=$incoming['s_period_effective'];
$s_discovered=$incoming['s_discovered'];
$s_functional=$incoming['s_functional'];
$s_reported_by=$incoming['s_reported_by'];
$s_report_date_start=$incoming['s_report_date_start'];
$s_report_date_end=$incoming['s_report_date_end'];
@@ -110,7 +110,7 @@ if ($search) {
// device
if ($s_device) {
$query_string="{$query_string}(";
$device_param="Devices:";
$device_param="{$device_term}s:";
foreach ($s_device as $dev_val) {
$query_string="{$query_string}device=\"{$dev_val}\" or ";
$device_dsp=dblookup($drs_db,"devices","id","name",$dev_val);
@@ -118,7 +118,7 @@ if ($search) {
}
$device_param=rtrim($device_param,", ");
$num_devices=mysqli_num_rows(mysqli_query($drs_db,"select id from devices"));
if (count($s_device)==$num_devices) $device_param="Devices: any";
if (count($s_device)==$num_devices) $device_param="{$device_term}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
@@ -149,33 +149,33 @@ if ($search) {
} else {
$id_param="ID: any";
}
// period
if ($s_period) {
// discovered
if ($s_discovered) {
$query_string="{$query_string}(";
$period_param="Periods:";
foreach ($s_period as $per_val) {
$query_string="{$query_string}period=\"{$per_val}\" or ";
$period_dsp=$per_val;
$period_param="{$period_param} {$period_dsp}, ";
$discovered_param="{$discovered_term_short}:";
foreach ($s_discovered as $disc_val) {
$query_string="{$query_string}discovered=\"{$disc_val}\" or ";
$disc_dsp=$disc_val;
$discovered_param="{$discovered_param} {$disc_dsp}, ";
}
$period_param=rtrim($period_param,", ");
$num_periods=mysqli_num_rows(mysqli_query($drs_db,"select id from periods"));
if (count($s_period)==$num_periods) $period_param="Periods: any";
$discovered_param=rtrim($discovered_param,", ");
$num_discovereds=mysqli_num_rows(mysqli_query($drs_db,"select id from discovered"));
if (count($s_discovered)==$num_discovereds) $discovered_param="{$discovered_term_short}s: any";
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
}
// period_effective
if ($s_period_effective) {
// functional
if ($s_functional) {
$query_string="{$query_string}(";
$eff_param="Period effective:";
foreach ($s_period_effective as $eff_val) {
$query_string="{$query_string}period_effective=\"{$eff_val}\" or ";
if ($eff_val=="0") $eff_dsp="<font color=\"#FF0000\">NEF</font>";
if ($eff_val=="1") $eff_dsp="<font color=\"#00FF00\">EFF</font>";
$eff_param="{$eff_param} {$eff_dsp}, ";
$func_param="$functional_term:";
foreach ($s_functional as $func_val) {
$query_string="{$query_string}functional=\"{$func_val}\" or ";
if ($func_val=="0") $func_dsp="<font color=\"#FF0000\">$functional_no_short</font>";
if ($func_val=="1") $func_dsp="<font color=\"#00FF00\">$functional_yes_short</font>";
$func_param="{$func_param} {$func_dsp}, ";
}
$eff_param=rtrim($eff_param,", ");
$func_param=rtrim($func_param,", ");
$query_string=rtrim($query_string," or ");
$query_string="{$query_string})";
$query_string="{$query_string} and ";
@@ -348,7 +348,7 @@ if (! $exportcsv) {
";
// Device cell *********************
echo "
Device<br>
$device_term<br>
<select name=\"s_device[]\" id=\"ms-device\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$drow=mysqli_query($drs_db,"select * from devices order by id asc");
@@ -392,17 +392,24 @@ if (! $exportcsv) {
<tr>
<td align=\"left\">
";
// Period cell **********************
// Discovered cell **********************
echo "
Period<br>
<select name=\"s_period[]\" id=\"ms-period\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
$discovered_term<br>
<select name=\"s_discovered[]\" id=\"ms-discovered\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
";
$prow=mysqli_query($drs_db,"select * from periods order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if (!$search || in_array($pitem["id"],$s_period,true)) {
printf("<option value=\"%s\" title=\"Period %s\" selected>%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$discrow=mysqli_query($drs_db,"select * from discovered order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if (!$search || in_array($discitem["id"],$s_discovered,true)) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
}
}
echo "
@@ -464,21 +471,21 @@ if (! $exportcsv) {
</td>
<td align=\"left\">
";
// Period effective cell ************
// functional cell ************
echo "
Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($search) {
$effstate=$nefstate="";
if (in_array("1",$s_period_effective,true)) $effstate="selected";
if (in_array("0",$s_period_effective,true)) $nefstate="selected";
$funcyesstate=$funcnostate="";
if (in_array("1",$s_functional,true)) $funcyesstate="selected";
if (in_array("0",$s_functional,true)) $funcnostate="selected";
} else {
$effstate=$nefstate="selected";
$funcyesstate=$funcnostate="selected";
}
echo "
<select name=\"s_period_effective[]\" id=\"ms-period_effective\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $effstate>Effective</option>
<option value=\"0\" $nefstate>Non-effective</option>
<select name=\"s_functional[]\" id=\"ms-functional\" multiple title=\"If you uncheck all, then this field will not be included in the search.\">
<option value=\"1\" $funcyesstate>$functional_yes</option>
<option value=\"0\" $funcnostate>$functional_no</option>
</select>
";
// **********************************
@@ -611,7 +618,7 @@ if (! $exportcsv) {
} else {
$summarystat="checked";
}
$idsort=$statussort=$datesort=$periodsort=$devicesort=$subsyssort=$repbysort=$discrepsort=$effsort="";
$idsort=$statussort=$datesort=$discsort=$devicesort=$subsyssort=$repbysort=$discrepsort=$funcsort="";
switch ($sort) {
case "id":
$idsort="checked";
@@ -622,8 +629,8 @@ if (! $exportcsv) {
case "report_date":
$datesort="checked";
break;
case "period":
$periodsort="checked";
case "discovered":
$discsort="checked";
break;
case "device":
$devicesort="checked";
@@ -637,8 +644,8 @@ if (! $exportcsv) {
case "discrepancy_text":
$discrepsort="checked";
break;
case "period_effective":
$effsort="checked";
case "functional":
$funcsort="checked";
break;
default:
$datesort="checked";
@@ -660,12 +667,12 @@ if (! $exportcsv) {
<input type=\"radio\" $idsort name=\"sort\" value=\"id\" id=\"idview\" ><label for=\"idview\" title=\"Sort by ID.\">ID</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $statussort name=\"sort\" value=\"status\" id=\"statusview\" ><label for=\"statusview\" title=\"Sort by Status.\">Status</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $datesort name=\"sort\" value=\"report_date\" id=\"dateview\" ><label for=\"dateview\" title=\"Sort by Report Date.\">Date</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $periodsort name=\"sort\" value=\"period\" id=\"periodview\" ><label for=\"periodview\" title=\"Sort by Period.\">Period</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $devicesort name=\"sort\" value=\"device\" id=\"deviceview\" ><label for=\"deviceview\" title=\"Sort by Device.\">Device</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $discsort name=\"sort\" value=\"discovered\" id=\"discoveredview\" ><label for=\"discoveredview\" title=\"Sort by $discovered_term.\">$discovered_term_short</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $devicesort name=\"sort\" value=\"device\" id=\"deviceview\" ><label for=\"deviceview\" title=\"Sort by $device_term.\">$device_term</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $subsyssort name=\"sort\" value=\"subsystem\" id=\"subsysview\" ><label for=\"subsysview\" title=\"Sort by Subsystem.\">Subsystem</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $repbysort name=\"sort\" value=\"reported_by\" id=\"repbyview\" ><label for=\"repbyview\" title=\"Sort by Reported by.\">Reported by</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $discrepsort name=\"sort\" value=\"discrepancy_text\" id=\"discrepview\" ><label for=\"discrepview\" title=\"Sort by Discrepancy.\">Discrepancy</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $effsort name=\"sort\" value=\"period_effective\" id=\"effview\" ><label for=\"effview\" title=\"Sort by Mission Effective.\">Msn Eff</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $funcsort name=\"sort\" value=\"functional\" id=\"funcview\" ><label for=\"funcview\" title=\"Sort by $functional_term.\">$functional_term_short</label>&nbsp;&nbsp;&nbsp;
<br>Sort Order:<br>
<input type=\"radio\" $ascsort name=\"order\" value=\"asc\" id=\"ascview\" ><label for=\"ascview\" title=\"Sort results in ascending order.\">Ascending</label>&nbsp;&nbsp;&nbsp;
<input type=\"radio\" $descsort name=\"order\" value=\"desc\" id=\"descview\" ><label for=\"descview\" title=\"Sort results in descending order.\">Descending</label>&nbsp;&nbsp;&nbsp;
@@ -704,7 +711,7 @@ if ($search) {
</table>
<table border=\"0\">
<tr>
<td>$period_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$discovered_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$reportdate_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$reporttime_param</td><td>&nbsp;&nbsp;&nbsp;</td>
</tr>
@@ -717,7 +724,7 @@ if ($search) {
<table border=\"0\">
<tr>
<td>$repby_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$eff_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$func_param</td><td>&nbsp;&nbsp;&nbsp;</td>
<td>$group_param</td><td>&nbsp;&nbsp;&nbsp;</td>
</tr>
</table>
@@ -780,7 +787,7 @@ if ($search) {
// generate csv file
// create an array of lines of the csv data
$csv_data=array();
$csv_data[]=['WriteupID','Status','Device','Subsystem','Period','Effective','Discrepancy','Group','Report date','Report time','Reported by','Action taken by','Status Change Reason','Action taken','Action date','Action time'];
$csv_data[]=['WriteupID','Status',$device_term,'Subsystem',$discovered_term_short,$functional_term,'Discrepancy','Group','Report date','Report time','Reported by','Action taken by','Status Change Reason','Action taken','Action date','Action time'];
$csv_fp=fopen('php://temp', 'w+');
while ($tablerow = mysqli_fetch_assoc($writeup)) {
@@ -799,14 +806,14 @@ if ($search) {
// convert subsystem number to name for csv
$csv_ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// period number for csv
$csv_period="{$tablerow["period"]}";
// discovered name for csv
$csv_discovered=dblookup($drs_db,"discovered","id","whendiscoveredname",$tablerow["discovered"]);
// determine effective text for csv
if($tablerow["period_effective"]==1) {
$csv_eff_text="EFF";
// determine functional text for csv
if($tablerow["functional"]==1) {
$csv_func_text="$functional_yes_short";
} else {
$csv_eff_text="NEF";
$csv_func_text="$functional_no_short";
}
// discrepancy text for csv
@@ -866,7 +873,7 @@ if ($search) {
if (($show_groupmems == $show_nongroupmems) || ($is_member && $show_groupmems) || (!$is_member && $show_nongroupmems)) {
// add line of results to csv array
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_period, $csv_eff_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
$csv_data[]=[$csv_id, $csv_status_text, $csv_dname, $csv_ssname, $csv_discovered, $csv_func_text, $csv_disc_txt, $csv_member_group_name, $csv_report_date, $csv_report_time, $csv_reported_by_text, $csv_action_by, $csv_reasonname, $csv_action_text, $csv_action_date, $csv_action_time];
}
}
@@ -891,12 +898,12 @@ if ($search) {
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
@@ -904,11 +911,11 @@ if ($search) {
$member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\"");
$is_member=mysqli_num_rows($member_qry);
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
// determine functional icon
if($tablerow["functional"]==1) {
$func_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$func_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// determine status indicator
@@ -918,8 +925,10 @@ if ($search) {
// convert device number to name
$dname=dblookup($drs_db,"devices","id","name",$tablerow["device"]);
// convert period number to times
$ptimes=dblookup($drs_db,"periods","id","times",$tablerow["period"]);
// convert discovered number to description
$discname=dblookup($drs_db,"discovered","id","whendiscoveredname",$tablerow["discovered"]);
// convert discovered number to description
$discdesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$tablerow["discovered"]);
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
$disc_txt="{$tablerow["discrepancy_text"]}";
@@ -958,12 +967,12 @@ if ($search) {
$tablerow["id"],$tablerow["id"],
$statusind,
$tablerow["report_date"],
$ptimes,$tablerow["period"],
$discdesc,$discname,
$dname,
$ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$func_icon
);
}
}

View File

@@ -2,7 +2,7 @@
/*
settings.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -2,7 +2,7 @@
/*
writeupdetail.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -39,8 +39,8 @@ $useredit=$incoming['useredit'];
$techedit=$incoming['techedit'];
$id=$incoming['id'];
$device=$incoming['device'];
$period=$incoming['period'];
$period_effective=$incoming['period_effective'];
$discovered=$incoming['discovered'];
$functional=$incoming['functional'];
$reported_by=$incoming['reported_by'];
$report_date=$incoming['report_date'];
$report_time=$incoming['report_time'];
@@ -66,6 +66,9 @@ $role=dblookup($drs_db,"users","id","role",$userid);
framework("begin","$appname","Writeup Detail",$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);
// ******** begin database manipulation ********
@@ -89,7 +92,7 @@ if ($usersave) {
$clean_reported_by=mysqli_real_escape_string($drs_db,$reported_by);
// update the record in writeups
mysqli_query($drs_db,"update writeups set device=\"$device\",period=\"$period\",period_effective=\"$period_effective\",reported_by=\"$clean_reported_by\",report_date=\"$report_date\",report_time=\"$report_time\",subsystem=\"$subsystem\",discrepancy_text=\"$clean_discrepancy_text\" where id=\"$id\"");
mysqli_query($drs_db,"update writeups set device=\"$device\",discovered=\"$discovered\",functional=\"$functional\",reported_by=\"$clean_reported_by\",report_date=\"$report_date\",report_time=\"$report_time\",subsystem=\"$subsystem\",discrepancy_text=\"$clean_discrepancy_text\" where id=\"$id\"");
}
}
elseif ($techsave) {
@@ -115,8 +118,8 @@ elseif ($techsave) {
// get current writeup data from database to populate fields
$writeupdata=mysqli_fetch_assoc(mysqli_query($drs_db,"select * from writeups where id=\"$id\""));
$device=$writeupdata['device'];
$period=$writeupdata['period'];
$period_effective=$writeupdata['period_effective'];
$discovered=$writeupdata['discovered'];
$functional=$writeupdata['functional'];
$reported_by=$writeupdata['reported_by'];
$report_date=$writeupdata['report_date'];
$report_time=$writeupdata['report_time'];
@@ -195,7 +198,7 @@ echo "
<td align=\"left\">Writeup ID<br>
<table border=\"1\" width=\"100%\"><tr><td><center>$id</center></td></tr></table>
</td>
<td align=\"left\">Device<br>
<td align=\"left\">$device_term<br>
";
if ($useredit) {
echo "
@@ -248,41 +251,49 @@ echo "
</td>
</tr>
<tr>
<td align=\"left\">Period<br>
<td align=\"left\">$discovered_term<br>
";
if ($useredit) {
echo "
<select name=\"period\" id=\"period\">
<select name=\"discovered\" id=\"discoveredselect\">
";
$prow=mysqli_query($drs_db,"select * from periods where active is true order by times asc");
while ($pitem=mysqli_fetch_assoc($prow)) {
if ($period==$pitem["id"]) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$pitem["id"],$pitem["times"],$pitem["id"]);
if ($disc_drop_data=="Name") {
$discddtitle="whendiscovereddesc";
$discddtext="whendiscoveredname";
} else if ($disc_drop_data=="Desc") {
$discddtitle="whendiscoveredname";
$discddtext="whendiscovereddesc";
}
$discrow=mysqli_query($drs_db,"select * from discovered where active is true order by whendiscoveredname asc");
while ($discitem=mysqli_fetch_assoc($discrow)) {
if ($discovered==$discitem["id"]) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
} else {
printf("<option value=\"%s\" title=\"%s\">%s</option>",$pitem["id"],$pitem["times"],$pitem["id"]);
printf("<option value=\"%s\" title=\"%s\">%s</option>",$discitem["id"],$discitem["$discddtitle"],$discitem["$discddtext"]);
}
}
echo "
</select>
";
} else {
$pertimes=dblookup($drs_db,"periods","id","times",$period);
$discname=dblookup($drs_db,"discovered","id","whendiscoveredname",$discovered);
$discdesc=dblookup($drs_db,"discovered","id","whendiscovereddesc",$discovered);
echo "
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$pertimes\">$period</font></td></tr></table>
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$discdesc\">$discname</font></td></tr></table>
";
}
echo "
</td>
";
$effstate=$nefstate="";
if($period_effective==1) {
$effstate="checked";
$eff_ind="Effective";
$funcyesstate=$funcnostate="";
if($functional==1) {
$funcyesstate="checked";
$func_ind="$functional_yes";
}
if($period_effective==0) {
$nefstate="checked";
$eff_ind="Non-Effective";
if($functional==0) {
$funcnostate="checked";
$func_ind="$functional_no";
}
$openstate=$closedstate=$deferredstate="";
@@ -340,16 +351,16 @@ if ($useredit) {
";
}
echo "
<td align=\"left\">Sim period effective? &nbsp; <img src=\"icons/question.png\" title=\"" . PERIOD_EFF_HELP_TXT . "\"><br>
<td align=\"left\">$functional_term? &nbsp; <img src=\"icons/question.png\" title=\"" . FUNCTIONAL_HELP_TXT . "\"><br>
";
if ($useredit) {
echo "
<input type=\"radio\" name=\"period_effective\" value=\"1\" $effstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"period_effective\" value=\"0\" $nefstate> No
<input type=\"radio\" name=\"functional\" value=\"1\" $funcyesstate> Yes &nbsp;&nbsp;&nbsp;&nbsp;
<input type=\"radio\" name=\"functional\" value=\"0\" $funcnostate> No
";
} else {
echo "
<table border=\"1\" width=\"100%\"><tr><td><font title=\"$eff_title\">$eff_ind</font></td></tr></table>
<table border=\"1\" width=\"100%\"><tr><td><font title=\"" . FUNCTIONAL_HELP_TXT . "\">$func_ind</font></td></tr></table>
";
}
echo "

View File

@@ -2,7 +2,7 @@
/*
writeups.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2020 Rod Wright
Copyright (C) 2021 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -52,6 +52,13 @@ $role=dblookup($drs_db,"users","id","role",$userid);
// define local functions
function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
// show date range selector
echo "
<form method=post action=\"writeups.php\">
@@ -71,7 +78,7 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
echo "
</form>
";
$writeup=mysqli_query($drs_db,"select * from writeups where status=".STAT_OPEN." and report_date between \"$start_date\" and \"$end_date\" order by report_date desc,period desc,report_time desc");
$writeup=mysqli_query($drs_db,"select * from writeups where status=".STAT_OPEN." and report_date between \"$start_date\" and \"$end_date\" order by report_date desc,report_time desc");
if (mysqli_num_rows($writeup)) {
$now=date("H:i l");
echo "
@@ -80,20 +87,20 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
<tr>
<th style=\"width:1%;\">ID</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
if($tablerow["functional"]==1) {
$funcind="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$funcind="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// convert device number to name
@@ -102,8 +109,12 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$tablerow['period']}\""))[0];
// convert subsystem number to description
$ssdesc=dblookup($drs_db,"subsystems","id","description",$tablerow["subsystem"]);
// determine values for when discovered
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$tablerow['discovered']}\""))[0];
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$tablerow['discovered']}\""))[0];
$disc_txt="{$tablerow['discrepancy_text']}";
@@ -133,19 +144,19 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
<td valign=\"top\">%s</td>
<td valign=\"top\"><font title=\"%s\">%s</font></td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\"><font title=\"%s\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">%s</td>
</tr>\n",
$tablerow["id"],$tablerow["id"],
$tablerow["report_date"],
$ptimes, $tablerow["period"],
$whendiscdesc, $whendiscname,
$dname,
$ssname,
$ssdesc, $ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$funcind
);
}
echo "</table>\n";
@@ -164,6 +175,13 @@ function opentable($start_date,$end_date,$print,$drs_db,$viewtype="summary") {
}
function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$role) {
// grab some important global variables
global $device_term;
global $discovered_term, $discovered_term_short, $disc_drop_data;
global $functional_term, $functional_term_short;
global $functional_yes, $functional_no;
global $functional_yes_short, $functional_no_short;
// show date range selector
$summarystat=$detailstat="";
if ($viewtype=="detail") {
@@ -196,7 +214,7 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
<br><br>
";
}
$writeup=mysqli_query($drs_db,"select * from writeups where report_date between \"$start_date\" and \"$end_date\" order by report_date desc,period desc,report_time desc");
$writeup=mysqli_query($drs_db,"select * from writeups where report_date between \"$start_date\" and \"$end_date\" order by report_date desc,report_time desc");
if (mysqli_num_rows($writeup)) {
$now=date("H:i l");
if ($viewtype == "summary") {
@@ -213,20 +231,20 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
<th style=\"width:1%;\">ID</th>
<th style=\"width:1%;\">Status</th>
<th style=\"width:100px;\">Date</th>
<th style=\"width:1%;\">Period</th>
<th style=\"width:1%;\">Device</th>
<th style=\"width:1%;\">$discovered_term_short</th>
<th style=\"width:1%;\">$device_term</th>
<th style=\"width:1%;\">Subsystem</th>
<th style=\"width:1%;\">Reported by</th>
<th>Discrepancy</th>
<th style=\"width:1%;\">Msn Eff</th>
<th style=\"width:1%;\">$functional_term_short</th>
</tr>
";
while ($tablerow = mysqli_fetch_assoc($writeup)) {
// determine effective icon
if($tablerow["period_effective"]==1) {
$eff_icon="<img src=\"icons/tick.png\" border=\"0\" title=\"Period Effective\" alt=\"Period Effective\">";
if($tablerow["functional"]==1) {
$funcind="<img src=\"icons/tick.png\" border=\"0\" title=\"$functional_yes\" alt=\"$functional_yes_short\">";
} else {
$eff_icon="<img src=\"icons/cross.png\" border=\"0\" title=\"Period Non-effective\" alt=\"Period Non-effective\">";
$funcind="<img src=\"icons/cross.png\" border=\"0\" title=\"$functional_no\" alt=\"$functional_no_short\">";
}
// determine status indicator
@@ -240,9 +258,11 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
// convert subsystem number to name
$ssname=dblookup($drs_db,"subsystems","id","name",$tablerow["subsystem"]);
// determine times for period
$ptimes=mysqli_fetch_row(mysqli_query($drs_db,"select times from periods where id=\"{$tablerow['period']}\""))[0];
$disc_txt="{$tablerow['discrepancy_text']}";
// determine values for when discovered
$whendiscdesc=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscovereddesc from discovered where id=\"{$tablerow['discovered']}\""))[0];
$whendiscname=mysqli_fetch_row(mysqli_query($drs_db,"select whendiscoveredname from discovered where id=\"{$tablerow['discovered']}\""))[0];
$disc_txt="{$tablerow['discrepancy_text']}";
// determine if this is a member of a group
$member_qry=mysqli_query($drs_db,"select linkgroup from links where writeupid=\"{$tablerow['id']}\"");
@@ -286,12 +306,12 @@ function viewtable($start_date,$end_date,$print,$drs_db,$viewtype="summary",$rol
$tablerow["id"],$tablerow["id"],
$statusind,
$tablerow["report_date"],
$ptimes, $tablerow["period"],
$whendiscdesc, $whendiscname,
$dname,
$ssname,
$tablerow["reported_by"],
$disc_txt,
$eff_icon
$funcind
);
}
echo "</table>\n";
@@ -360,7 +380,9 @@ if ($view) {
}
framework("begin","$appname",$pgtitle,$print);
//echo "_REQUEST array <br>";
//var_dump($_REQUEST);
//echo "<br><hr> incoming array <br>";
//var_dump($incoming);