Initial commit as release 1.1.0

This commit is contained in:
2026-02-14 11:07:25 -05:00
parent 6b49566e58
commit a6331f7fed
141 changed files with 50383 additions and 0 deletions

238
distfiles/create.php Normal file
View File

@@ -0,0 +1,238 @@
<?php
/*
create.php
OpenDRS Online Discrepancy Reporting System
Copyright (C) 2018 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("common.php");
// redirect to writeups.php on change cancel
if ($_REQUEST['cancel']) {
header("Cache-Control:no-cache, must-revalidate");
header("Pragma:no-cache");
header("Location:writeups.php");
exit();
}
// import session variables
if (isset($_SESSION['personid'])) $personid=$_SESSION['personid'];
// import incoming arrays
$print=$_REQUEST['print'];
if ($print) {
// if printer friendly was clicked, values will be passed in serialized
// form as "all_parameters" so we need to load those into $incoming[]
$incoming=unserialize($_REQUEST['all_parameters']);
} else {
// copy $_REQUEST[] to $incoming[]
$incoming=arrayCopy($_REQUEST);
}
// load variables from incoming array
$create=$incoming['create'];
$device=$incoming['device'];
$period=$incoming['period'];
$period_effective=$incoming['period_effective'];
$reported_by=$incoming['reported_by'];
$report_date=$incoming['report_date'];
$report_time=$incoming['report_time'];
$subsystem=$incoming['subsystem'];
$discrepancy_text=$incoming['discrepancy_text'];
$status=$incoming['status'];
// assign variables from constants
$appname=APP_NAME;
if ($print=="Printer Friendly") {
$mbgcolor=P_MENUBG_COLOR;
} else {
$mbgcolor=MENUBG_COLOR;
}
$role=dblookup($drs_db,"persons","id","role",$personid);
framework("begin","$appname","New Writeup",$print);
//var_dump($_REQUEST);
//var_dump($incoming);
// ******** begin database manipulation ********
// determine today's date and make it the default
$today=date("Y-m-d");
$now=date("H:i:s");
if (!$report_date || $report_date=="automatic") $report_date=$today;
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) {
// 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);
if (!$report_date) $report_date=$today;
if (!$report_time) $report_time=$now;
// remove html tags from discrepancy text and sanitize
$discrepancy_text=strip_tags($discrepancy_text);
$clean_discrepancy_text=mysqli_real_escape_string($drs_db,$discrepancy_text);
$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\")");
}
}
// ******** end database manipulation ********
pagetable("begin");
if (!$print) {
pageblock("left","begin");
sidemenu();
pageblock("left","end");
}
pageblock("right","begin");
banner($print);
echo "<br>";
// display the form
if ($create) {
if ($discrepancy_text && $reported_by) {
format_message(0,"<strong>Writeup created.</strong> You may create another writeup or <a href=\"writeups.php\">return to Open Writeups page.</a>");
$preserve=FALSE;
}
if (!$device) {
format_message(1,"You didn't select a device. 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.");
$preserve=TRUE;
}
if (!$discrepancy_text) {
format_message(1,"You didn't enter any discrepancy text. Please try again.");
$preserve=TRUE;
}
if (!$reported_by) {
format_message(1,"You didn't enter your name in the Reported by: block. Please try again.");
$preserve=TRUE;
}
} else {
$preserve=FALSE;
}
echo "
<form method=\"post\" action=\"create.php\">
";
// start writeup entry section
if ($status==1) $statusind="<b><font color=\"#FF0000\">OPEN</font></b>";
if ($status==2) $statusind="<b><font color=\"#008000\">CLSD</font></b>";
if ($status==3) $statusind="<b><font color=\"#FFFF00\">DFRD</font></b>";
echo "
<table border=\"0\" cellpadding=\"5\">
<tr>
<td align=\"left\">Device<br>
<select name=\"device\" id=\"device\">
<option value=\"\">Please select...</option>
";
$trow=mysqli_query($drs_db,"select * from devices where active is true order by id asc");
while ($titem=mysqli_fetch_assoc($trow)) {
if ($device==$titem["id"] && $preserve) {
printf("<option value=\"%s\" selected>%s</option>",$titem["id"],$titem["name"]);
} else {
printf("<option value=\"%s\">%s</option>",$titem["id"],$titem["name"]);
}
}
echo "
</select></td>
<td align=\"left\">Subsystem<br>
<select name=\"subsystem\" id=\"subsystem\">
<option value=\"\">Please select...</option>
";
$ssrow=mysqli_query($drs_db,"select * from subsystems where active is true order by id asc");
while ($ssitem=mysqli_fetch_assoc($ssrow)) {
if ($subsystem==$ssitem["id"] && $preserve) {
printf("<option value=\"%s\" title=\"%s\" selected>%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
} else {
printf("<option value=\"%s\" title=\"%s\">%s</option>",$ssitem["id"],$ssitem["description"],$ssitem["name"]);
}
}
echo "
</select></td><td></td>
</tr>
<tr>
<td align=\"left\">Period<br>
<select name=\"period\" id=\"period\">
<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"]);
} else {
printf("<option value=\"%s\" title=\"Period %s\">%s</option>",$pitem["id"],$pitem["id"],$pitem["times"]);
}
}
if (!$preserve) {
$report_date="automatic";
$report_time="automatic";
$discrepancy_text="";
$reported_by="";
}
$effstate=$nefstate="";
if ($preserve) {
if($period_effective==1) $effstate="checked";
if($period_effective==0) $nefstate="checked";
} else {
$effstate="checked";
}
echo "
</select></td>
<td align=\"left\" >Report Date<br>
<input type=\"text\" name=\"report_date\" size=\"10\" maxlength=\"10\" value=\"$report_date\" id=\"singledatepicker\" title=\"Format: YYYY-MM-DD\"></td>
<td align=\"left\">Report Time<br>
<input type=\"text\" name=\"report_time\" size=\"8\" maxlength=\"8\" value=\"$report_time\" title=\"Format: HH:MM:SS\"></td>
</tr>
<tr><td></td><td></td><td></td></tr>
<tr><td colspan=\"3\">
Discrepancy <font size=\"-2\">(required)</font><br>
<textarea rows=\"10\" cols=\"80\" name=\"discrepancy_text\" wrap=\"soft\">$discrepancy_text</textarea><br>
</tr>
<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>
<td align=\"right\" valign=\"bottom\"><input type=\"submit\" name=\"create\" value=\"Submit Writeup\" id=\"createbutton\"></td>
</tr>
<tr><td></td><td></td><td></td></tr>
<td></td><td></td><td align=\"right\" valign=\"bottom\">
<input type=\"submit\" name=\"cancel\" value=\"Cancel\" id=\"usercancelbutton\"></td>
</tr>
</table>
<input type=\"hidden\" name=\"status\" value=\"1\">
</form>
<br>
";
banner($print);
pageblock("right","end");
pagetable("end");
framework("end","","",$print);
?>