Files
OpenLog/distfiles/maintformentry.php
2026-02-10 22:18:42 -05:00

663 lines
26 KiB
PHP

<?php
/*
maintformentry.php
OpenLog Online Logbook
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
header ("Location: login.php");
}
$loggedinas=$_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
function getmfdata($maintformid) {
// pull maintenance form data from maintforms table
global $db;
$mfdata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintforms where maintformid=\"$maintformid\""));
return $mfdata;
}
function getactiondata($maintactionid) {
// pull maintenance action data from maintactions table
global $db;
$actiondata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintactions where maintactionid=\"$maintactionid\""));
return $actiondata;
}
$print=$_REQUEST['print'];
$maintformid=$_REQUEST['maintformid'];
$lognoteid=$_REQUEST['lognoteid'];
$mfdate=$_REQUEST['date'];
$mftime=$_REQUEST['time'];
$mfsubmit=$_REQUEST['mfsubmit'];
$mfadd=$_REQUEST['mfadd'];
$mfedit=$_REQUEST['mfedit'];
$mfdelete=$_REQUEST['mfdelete'];
$mfpartloc=$_REQUEST['mfpartloc'];
$mfmalfunction=$_REQUEST['mfmalfunction'];
$nha=$_REQUEST['nha'];
$repord=$_REQUEST['repord'];
$mfpart=$_REQUEST['mfpart'];
$uid=$_REQUEST['uid'];
$partnum=$_REQUEST['partnum'];
$sernum=$_REQUEST['sernum'];
$partname=$_REQUEST['partname'];
$actionadd=$_REQUEST['actionadd'];
$actionedit=$_REQUEST['actionedit'];
$actiondelete=$_REQUEST['actiondelete'];
$maintactionid=$_REQUEST['maintactionid'];
$actiondate=$_REQUEST['actiondate'];
$actiontime=$_REQUEST['actiontime'];
$actiontech=$_REQUEST['actiontech'];
$action=$_REQUEST['action'];
$actionaddsubmit=$_REQUEST['actionaddsubmit'];
$actioneditsubmit=$_REQUEST['actioneditsubmit'];
$printfmt=$_REQUEST['printfmt'];
if ($printfmt) $print=1;
$flags=$_POST['flags'];
$logname=LOG_NAME;
$uidtext=UID_TEXT;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
}
if ($printfmt) {
framework("begin","","",$print);
} else if ($mfedit) {
framework("begin","$logname","Maintenance Form Edit",$print);
if ($loggedinas) $mfauthorized=1;
} else if ($mfdelete) {
framework("begin","$logname","Maintenance Form Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=1;
} else if ($actionadd) {
framework("begin","$logname","Maintenance Action Entry",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if ($loggedinas) {
$mfauthorized=1;
$actionauthorized=1;
}
} else if ($actionedit || $actiondelete) {
framework("begin","$logname","Maintenance Action Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if ($loggedinas) $mfauthorized=1;
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid);
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1;
} else {
$mfadd=1;
framework("begin","$logname","Maintenance Form Entry",$print);
$mftech=$loggedinas;
$mfauthorized=1;
}
// ******** begin database manipulation ********
//var_dump($_REQUEST);
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
// pull mf data from database
$mftoedit=getmfdata($maintformid);
$partdatainput=array();
if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart'];
if ($uid) $partdatainput['uid']=$uid;
if ($partnum) $partdatainput['partnum']=$partnum;
if ($sernum) $partdatainput['sernum']=$sernum;
$partinfo=get_part_data($partdatainput);
if ($partinfo['result']==2) {
$pdatamismatch=1;
} else {
unset($pdatamismatch);
if ($partinfo['partid']) $mfpart=$partinfo['partid'];
if ($partinfo['uid']) $uid=$partinfo['uid'];
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
if ($partinfo['sernum']) $sernum=$partinfo['sernum'];
if ($partinfo['partname']) $partname=$partinfo['partname'];
}
}
if ($mfadd) {
if ($mfsubmit) {
// add the entry if submit is pressed
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// determine whether supplied date is future or past
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$mfdate\",CURRENT_DATE)"));
// if future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) {
$mftime="23:59:59:";
}
if ($datediff[0]>0) {
$mftime="00:00:01:";
}
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
if ($mfauthorized) {
$partdatainput=array();
if ($uid) $partdatainput['uid']=$uid;
if ($partnum) $partdatainput['partnum']=$partnum;
if ($sernum) $partdatainput['sernum']=$sernum;
$partinfo=get_part_data($partdatainput);
// add to parts table
if ($partinfo['result']==1) {
// if this part has not been seen before, add it to the parts table and get partid
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$mfpart=mysqli_insert_id($db);
} else if ($partinfo['result']==2) {
$pdatamismatch=1;
} else {
// if it is in parts table, get partid for this record
$mfpart=$partinfo['partid'];
}
if ($uid =="" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
} else {
$pending=0;
}
// add the record to maintforms
if (! $pdatamismatch) {
mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
$newmaintformid=mysqli_insert_id($db);
$mfidtoprint=$newmaintformid;
// add this maintformid to the appropriate flag_tables
foreach ($flags as $flagtblnum) {
$flagtblname="flag_".$flagtblnum;
mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$newmaintformid\")");
}
}
}
}
}
}
if ($mfedit) {
$mfidtoprint=$maintformid;
if ($mfsubmit && $mfauthorized) {
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
// update parts table
if ($uid =="" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
} else {
$pending=0;
}
if (! $pdatamismatch) {
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
}
// update the record in maintforms
if (! $pdatamismatch) {
mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\"");
// update the appropriate flag_tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[0],$flags)) {
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")");
}
} else {
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"delete from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
}
}
}
}
}
// refresh the maintenance form in question from the database
$mftoedit=getmfdata($maintformid);
}
if ($mfdelete && $mfauthorized) {
// delete from maintforms table
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
// delete occurances from the flag_ tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$delflag_tbl="flag_".$thisflagid[0];
mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
}
if ($actionadd) {
if ($actionaddsubmit) {
if ($action) {
// determine whether supplied date is future or past
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$actiondate\",CURRENT_DATE)"));
// if future, set time to 00:00:01, if past, set to 23:59:59
if ($datediff[0]<0) {
$actiontime="23:59:59:";
}
if ($datediff[0]>0) {
$actiontime="00:00:01:";
}
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
// add to maintactions table
mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")");
echo mysqli_error($db);
}
}
}
if ($actionedit) {
if ($actioneditsubmit && $actionauthorized) {
// update the action
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
// update maintactions table
mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
}
// refresh the action in question from the database
$actiontoedit=getactiondata($maintactionid);
}
if ($actiondelete && $actionauthorized) {
// delete the action
mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\"");
}
// ******** end database manipulation ********
pagetable("begin");
if (!$print) {
pageblock("left","begin");
sidemenu();
pageblock("left","end");
}
pageblock("right","begin");
banner($print);
// display the form
if ($mfadd || $actionadd) {
$mfdate=$today;
$mftime=$now;
$actiondate=$today;
$actiontime=$now;
}
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) {
$mfdate=$mftoedit["mfdate"];
$mftime=$mftoedit["mftime"];
$mfpart=$mftoedit["mfpart"];
$mfpartloc=$mftoedit["mfpartloc"];
$mfmalfunction=$mftoedit["mfmalfunction"];
$nha=$mftoedit["nha"];
$repord=$mftoedit["repord"];
$lognoteid=$mftoedit["lognoteid"];
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"];
if (! $mftime) $mftime=$now;
}
if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) {
$partinfo=array();
$partinfoinput['partid']=$mfpart;
$partinfo=get_part_data($partinfoinput);
$mfpart=$partinfo['partid'];
$uid=$partinfo['uid'];
$partnum=$partinfo['partnum'];
$sernum=$partinfo['sernum'];
$partname=$partinfo['partname'];
$pluresult=$partinfo['result'];
if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch);
}
$techname=dblookup($db,"techs","techid","techname",$mftech);
if ($mfsubmit) {
if ($mfmalfunction) {
if (($uid || ($partnum && $sernum)) || $mfpart) {
if ($mfadd) {
format_message(0,"Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
}
if ($mfedit) {
format_message(0,"Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
}
} else {
format_message(1,"You didn't enter any part information. Please try again.");
}
} else {
format_message(1,"You didn't enter any malfunction description. Please try again.");
}
}
if ($mfdelete) {
format_message(0,"Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
}
if ($pdatamismatch) {
$advtxt="
<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;
<b>Warning:</b> The $uidtext doesn't match the Part Number/Serial Number associated
with it in our database. Please ensure the part information
you entered is correct and try again. If you know it to be correct, please use
the <a href=\"parts.php\">Parts</a> page to correct the database.</b>
";
} else {
$advtxt="
<font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font>
";
}
if ($printfmt) {
// show entire maint form
echo "
<hr>
<table width=\"100%\" border=\"0\">
<tr><td align=\"center\"><font size=\"+1\"><b>Maintenance Form</b></font></td></tr>
</table>
<hr>
<table width=\"100%\" border=\"0\">
<tr><td><b>Form ID:</b><br> $maintformid </td><td><b>Date:</b><br> $mfdate </td><td><b>Time:</b><br> $mftime </td><td><b> Tech:</b><br> $techname </td><td><b>Log Note ID:</b><br> $lognoteid </td><td><b>Repair Order:</b><br> $repord </td></tr>
</table><hr>
<table width=\"100%\" border=\"0\">
<tr><td colspan=\"4\"><b><u>Part Data</u></b><br><br></td></tr>
<tr><td><b>$uidtext:</b><br> $uid </td><td><b>Part Number:</b><br> $partnum </td><td><b>Serial Number:</b><br> $sernum </td><td><b>Part Name:</b><br> $partname </td></tr>
<tr><td><b>Part Location:</b><br> $mfpartloc </td><td><b>Next Higher Assembly:</b><br> $nha </td></tr>
</table><hr>
<b><u>Malfuction Description</u></b><br>
<table width=\"100%\" border=\"0\">
<tr><td>$mfmalfunction</td></tr>
</table><br>
<b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\">
";
// get an array of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
unset($theseflags);
while ($thisflag=mysqli_fetch_row($allflags)) {
$thisflagtbl="flag_".$thisflag[0];
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
}
}
$flagslist=mysqli_query($db,"select * from flags");
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
}
}
echo "
</table><hr>
<b><u>Maintenance Actions</u></b><br>
";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
$actiondate=$actiontable["actiondate"];
$actiontime=$actiontable["actiontime"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]);
// print the actions
echo "<table border=\"0\" cellpadding=\"5\">
<tr>
<td><b>Tech:</b>&nbsp;&nbsp;$tname</td>
<td><b>Date:</b>&nbsp;&nbsp;$actiondate</td>
<td><b>Time:</b>&nbsp;&nbsp;$actiontime</td>
</tr></table>
<table width=\"100%\" border=\"0\" cellpadding=\"5\">
<tr>
<td colspan=\"4\">$actiontext</td>
</tr>
</table>
<hr>
";
}
} else {
echo "
<form method=\"post\" action=\"maintformentry.php\">
<table class=\"mfentry\" border=\"0\" cellpadding=\"8\">
<tr>
<td valign=\"bottom\"><b>Date <br><font size=\"-1\">(YYYY-MM-DD):</font></b><br>
<input type=\"text\" name=\"date\" size=\"10\" maxlength=\"10\" id=\"singledatepicker\" value=\"$mfdate\"></td>
<td valign=\"bottom\"><b>Time:</b><br>
<input type=\"text\" name=\"time\" size=\"8\" maxlength=\"8\" value=\"$mftime\"></td>
<td valign=\"bottom\"><b>Tech:</b><br>
$techname</td>
<td valign=\"bottom\"><b>Log Note ID:</b><br>
<input type=\"text\" name=\"lognoteid\" size=\"8\" value=\"$lognoteid\"></td>
</tr>
</table>
<table class=\"mfentry\" border=\"0\" cellpadding=\"8\">
<tr>
<td class=\"forcewrap\" colspan=\"3\"><font size=\"-1\">$advtxt</td>
</tr>
<input type=\"hidden\" name=\"mfpart\" value=\"$mfpart\">
<tr>
<td valign=\"bottom\"><b>$uidtext:</b><br>
<input type=\"text\" name=\"uid\" size=\"8\" value=\"$uid\"></td>
<td valign=\"bottom\"><b>Part Number:</b><br>
<input type=\"text\" name=\"partnum\" size=\"20\" value=\"$partnum\"></td>
<td valign=\"bottom\"><b>Serial Number:</b><br>
<input type=\"text\" name=\"sernum\" size=\"20\" value=\"$sernum\"></td>
</tr><tr>
<td colspan=\"3\" valign=\"bottom\"><b>Part Name:</b><br>
<input type=\"text\" name=\"partname\" size=\"80\" value=\"$partname\"></td>
</tr><tr>
<td valign=\"bottom\"><b>Part Location:</b><br>
<input type=\"text\" name=\"mfpartloc\" size=\"20\" value=\"$mfpartloc\"></td>
<td valign=\"bottom\"><b>Next Higher Assembly:</b><br>
<input type=\"text\" name=\"nha\" size=\"20\" value=\"$nha\"></td>
<td valign=\"bottom\"><b>Repair Order:</b><br>
<input type=\"text\" name=\"repord\" size=\"12\" value=\"$repord\"></td>
</tr></table>
<hr>
<table border=\"0\" cellpadding=\"8\">
<tr><td><b>Malfunction Description:</b></td></tr>
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
<tr><td>
";
// get an array of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
unset($theseflags);
$theseflags=[];
while ($thisflag=mysqli_fetch_row($allflags)) {
$thisflagtbl="flag_".$thisflag[0];
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
}
}
if ($mfadd) {
$flagslist=mysqli_query($db,"select * from flags where status=1");
} else {
$flagslist=mysqli_query($db,"select * from flags");
}
$flagsperline=8;
$flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (in_array($flagcheckbox["flagid"],$theseflags)) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
} else {
$flagid=$flagcheckbox["flagid"];
if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) {
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
}
}
if ($flagcount<$flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount=1;
}
}
echo "
</td></tr>
<tr><td>
";
if ($mfadd) {
if ($mfauthorized) {
echo "
<input type=\"hidden\" name=\"mfadd\" value=\"1\">
<input type=\"submit\" name=\"mfsubmit\" value=\"Submit Maintenance Form\">
</td></tr>
";
}
if ($mfsubmit) {
echo "
<tr><td><a href=\"maintformentry.php?printfmt=1&maintformid=$mfidtoprint\" target=\"_blank\">Print This Maintenance Form</a></td></tr>
";
}
echo "</table><br>";
} else {
if ($mfauthorized) {
echo "
<table border=\"0\">
<tr>
<td valign=\"top\">
<input type=\"hidden\" name=\"mfedit\" value=\"1\">
<input type=\"hidden\" name=\"maintformid\" value=\"$maintformid\">
<input type=\"submit\" name=\"mfsubmit\" value=\"Change This Maintenance Form\">
</td><td valign=\"top\">
<input type=\"submit\" name=\"mfdelete\" value=\"Delete This Maintenance Form\"><font color=\"#FF0000\"><br><b>Deleted maintenance forms are irretrievable!</b></font>
</td></tr>
<tr><td><a href=\"maintformentry.php?printfmt=1&maintformid=$mfidtoprint\" target=\"_blank\">Print This Maintenance Form</a></td></tr>
</table>
";
} else {
echo "
<br>Only the owner of a maintenance form or an administrator can delete it.<br><br>
<input type=\"hidden\" name=\"maintformid\" value=\"$maintformid\">
<a href=\"maintformentry.php?printfmt=1&maintformid=$mfidtoprint\" target=\"_blank\">Print This Maintenance Form</a>
";
}
echo "
</td></tr></table>
";
}
echo "
</form>
<hr>
<form method=\"post\" action=\"maintformentry.php?maintformid=$maintformid\">";
if ($actionadd || $actionedit) {
// show the action form
if ($actionadd) {
$matime=$now;
$actiontext="";
$actiontech=$loggedinas;
} else if ($actionedit) {
$actiontext=$actiontoedit['action'];
$actiontech=$actiontoedit['actiontech'];
$actiondate=$actiontoedit['actiondate'];
$actiontime=$actiontoedit['actiontime'];
}
$tname=dblookup($db,"techs","techid","techname",$actiontech);
echo "<table width=\"70\" border=\"0\" cellpadding=\"5\">
<tr>
<td>Tech:&nbsp;&nbsp;$tname
<input type=\"hidden\" name=\"actiontech\" value=\"$actiontech\">
</td>
<td><Date <font size=\"-1\">(YYYY-MM-DD):</font> &nbsp;
<input type=\"text\" name=\"actiondate\" size=\"10\" maxlength=\"10\" value=\"$actiondate\">
</td>
<td>Time: &nbsp;
<input type=\"text\" name=\"actiontime\" size=\"8\" maxlength=\"8\" value=\"$actiontime\">
</td>
</tr>
<tr>
<td colspan=\"3\">Action Taken:<br>
<textarea rows=\"4\" cols=\"65\" name=\"action\" wrap=\"soft\">$actiontext</textarea>
</td>
</tr>
</table><br>
";
if ($actionadd) {
echo "
<input type=\"hidden\" name=\"actionadd\" value=\"1\">
<input type=\"submit\" name=\"actionaddsubmit\" value=\"Add This Action\">
<hr>
";
} else if ($actionedit) {
echo "
<input type=\"hidden\" name=\"maintformid\" value=\"$maintformid\">
<input type=\"hidden\" name=\"maintactionid\" value=\"$maintactionid\">
<input type=\"hidden\" name=\"actionedit\" value=\"1\">
<input type=\"submit\" name=\"actioneditsubmit\" value=\"Change This Action\">
";
}
echo "
<br><br>
";
}
echo "<b>Maintenance Actions</b>&nbsp;&nbsp;&nbsp;&nbsp;";
if ($_SESSION['login'] && $maintformid) echo "<input type=\"submit\" name=\"actionadd\" value=\"Add New Action\">";
echo "<br><br>";
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
$maintactionid=$actiontable["maintactionid"];
$actiondate=$actiontable["actiondate"];
$actiontime=$actiontable["actiontime"];
$maintformnum=$actiontable["maintformnum"];
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
$actiontext=convertweblinks($actiontable["action"]);
// print the table
echo "<table width=\"100%\" border=\"1\" cellpadding=\"5\">
<tr><td>
";
if (($loggedinas==$actiontable["actiontech"]) || $isadmin) {
echo "
<a href=\"maintformentry.php?maintformid=$maintformid&actionedit=1&maintactionid=$maintactionid\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this action\" alt=\"Edit this action\"></a>&nbsp;&nbsp;
<a href=\"maintformentry.php?maintformid=$maintformid&actiondelete=1&maintactionid=$maintactionid\"><img src=\"icons/minus-button.png\" border=\"0\" title=\"Delete this action\" alt=\"Delete this action\"></a>
";
} else {
echo "
<img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Only the owner or an admin can edit an action\" alt=\"Only the owner or an admin can edit an action\">
<img src=\"icons/minus-button.png\" border=\"0\" title=\"Only the owner or an admin can delete an action\" alt=\"Only the owner or an admin can delete an action\">
";
}
echo "
</td>
<td>Tech:&nbsp;&nbsp;$tname</td>
<td>Date:&nbsp;&nbsp;$actiondate</td>
<td>Time:&nbsp;&nbsp;$actiontime</td>
</tr>
<tr>
<td colspan=\"4\">$actiontext</td>
</tr>
</table><br>
";
}
echo "
</form>
";
}
banner($print);
pageblock("right","end");
pagetable("end");
framework("end","","",$print);
?>