Various reformats. Changed boolean variables from 1/0 to TRUE/FALSE in multiple files.

This commit is contained in:
2026-02-19 14:08:40 -05:00
parent 9122040863
commit 01fd47814b
22 changed files with 3502 additions and 3150 deletions

View File

@@ -8,27 +8,27 @@
*/
include("functions.php");
$version=OL_VERSION;
$version = OL_VERSION;
$print=$_REQUEST['print'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","About OpenLog","About OpenLog",$print);
framework("begin", "About OpenLog", "About OpenLog", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
echo "
<h3 align=\"center\">
OpenLog $version
@@ -87,10 +87,8 @@ border=0></a></td><td><b>Fugue<br>Icons</b></td><td>The icons used in OpenLog ar
</table>
</p>
";
pageblock("right","end");
";
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

File diff suppressed because it is too large Load Diff

View File

@@ -28,48 +28,50 @@ include("settings.php");
// build the basic color array
$basic_colors=array(
"White" => "#FFFFFF",
"Silver" => "#C0C0C0",
"Gray" => "#808080",
"Black" => "#000000",
"Red" => "#FF0000",
"Maroon" => "#800000",
"Orange" => "#FFA500",
"Yellow" => "#FFFF00",
"Olive" => "#808000",
"Lime" => "#00FF00",
"Green" => "#008000",
"Aqua" => "#00FFFF",
"Teal" => "#008080",
"Blue" => "#0000FF",
"Navy" => "#000080",
"Fuchsia" => "#FF00FF",
"Purple" => "#800080");
$basic_colors = array(
"White" => "#FFFFFF",
"Silver" => "#C0C0C0",
"Gray" => "#808080",
"Black" => "#000000",
"Red" => "#FF0000",
"Maroon" => "#800000",
"Orange" => "#FFA500",
"Yellow" => "#FFFF00",
"Olive" => "#808000",
"Lime" => "#00FF00",
"Green" => "#008000",
"Aqua" => "#00FFFF",
"Teal" => "#008080",
"Blue" => "#0000FF",
"Navy" => "#000080",
"Fuchsia" => "#FF00FF",
"Purple" => "#800080"
);
// Generic functions
function framework($option,$htmltitle,$pagetitle,$print) {
function framework($option, $htmltitle, $pagetitle, $print)
{
// generates html code for the beginning and end of all pages
if ($option=="begin") {
if ($option == "begin") {
// generates everything down to the first horiz rule inclusive
// htmltitle is the page title that appears in the window titlebar
// pagetitle is what will appear as the title of the page itself
// print is whether to format for printing or not
if ($print) {
$bgcolor=P_BACKGROUND_COLOR;
$textcolor=P_TEXT_COLOR;
$linkcolor=P_LINK_COLOR;
$vlinkcolor=P_VLINK_COLOR;
$hdgcolor=P_HEADING_COLOR;
$bgcolor = P_BACKGROUND_COLOR;
$textcolor = P_TEXT_COLOR;
$linkcolor = P_LINK_COLOR;
$vlinkcolor = P_VLINK_COLOR;
$hdgcolor = P_HEADING_COLOR;
} else {
$bgcolor=BACKGROUND_COLOR;
$textcolor=TEXT_COLOR;
$linkcolor=LINK_COLOR;
$vlinkcolor=VLINK_COLOR;
$hdgcolor=HEADING_COLOR;
$bgcolor = BACKGROUND_COLOR;
$textcolor = TEXT_COLOR;
$linkcolor = LINK_COLOR;
$vlinkcolor = VLINK_COLOR;
$hdgcolor = HEADING_COLOR;
}
echo "
<html>
<head>
@@ -91,13 +93,13 @@ function framework($option,$htmltitle,$pagetitle,$print) {
<font size=5 color=\"$hdgcolor\"><b> $htmltitle - $pagetitle</b></font><br>
";
}
} else if ($option=="end") {
} else if ($option == "end") {
// generates everything from the last horiz rule down to end of page
echo "
<hr><br><br>
";
if (defined("FOOTER_MESSAGE")) {
$footer_msg=FOOTER_MESSAGE;
$footer_msg = FOOTER_MESSAGE;
echo "
<center>$footer_msg</center><br>
";
@@ -221,14 +223,15 @@ function framework($option,$htmltitle,$pagetitle,$print) {
}
}
function pagetable($option) {
if ($option=="begin") {
function pagetable($option)
{
if ($option == "begin") {
echo "
<br>
<table border=\"0\" width=\"100%\" cellpadding=\"10\">
<tr>
";
} else if ($option=="end") {
} else if ($option == "end") {
echo "
</tr></table>
";
@@ -240,14 +243,15 @@ function pagetable($option) {
}
}
function pageblock($block,$option) {
function pageblock($block, $option)
{
global $sbcolor;
if ($block=="left") {
if ($option=="begin") {
if ($block == "left") {
if ($option == "begin") {
echo "
<td width=\"210\" bgcolor=\"$sbcolor\" valign=\"top\">
";
} else if ($option=="end") {
} else if ($option == "end") {
echo "
</td>
";
@@ -257,12 +261,12 @@ function pageblock($block,$option) {
";
exit(1);
}
} else if ($block=="right") {
if ($option=="begin") {
} else if ($block == "right") {
if ($option == "begin") {
echo "
<td valign=\"top\">
";
} else if ($option=="end") {
} else if ($option == "end") {
echo "
</td>
";
@@ -280,11 +284,12 @@ function pageblock($block,$option) {
}
}
function sidemenu($noprint=false) {
function sidemenu($noprint = false)
{
// Displays sidebar menu
global $db,$mbgcolor,$noprint;
$doparts=PARTS_FUNCTIONS;
$doschedmaint=SCHEDMAINT_FUNCTIONS;
global $db, $mbgcolor, $noprint;
$doparts = PARTS_FUNCTIONS;
$doschedmaint = SCHEDMAINT_FUNCTIONS;
echo "
<hr><br>
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
@@ -333,8 +338,8 @@ function sidemenu($noprint=false) {
</table>
";
} else {
$loginid=$_SESSION['login'];
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0];
$loginid = $_SESSION['login'];
$loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
echo "
<hr>
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
@@ -359,22 +364,23 @@ function sidemenu($noprint=false) {
";
}
function banner($print) {
function banner($print)
{
// displays a banner
global $db;
$bannerid=BANNER;
$bannerid = BANNER;
// get banner parameters from banner table
$banrow=mysqli_fetch_assoc(mysqli_query($db,"select * from banners where bannerid=\"$bannerid\""));
$banrow = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=\"$bannerid\""));
if (!$banrow) {
$bannerid=1;
$bannerid = 1;
} else {
$bannertext=$banrow["bannername"];
$bannertext = $banrow["bannername"];
if ($print) {
$bannercolor="#FFFFFF";
$bannertxtcolor="#000000";
$bannercolor = "#FFFFFF";
$bannertxtcolor = "#000000";
} else {
$bannercolor=$banrow["bannercolor"];
$bannertxtcolor=$banrow["textcolor"];
$bannercolor = $banrow["bannercolor"];
$bannertxtcolor = $banrow["textcolor"];
}
}
if ($bannerid != 1) {
@@ -385,47 +391,49 @@ function banner($print) {
}
}
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
function dblookup($dbhandle, $table, $in_field, $out_field, $in_data)
{
// look up a single field in a database given a value for a single field
$dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"");
$dbqry = mysqli_query($dbhandle, "select $out_field from $table where $in_field=\"$in_data\"");
if (mysqli_num_rows($dbqry)) {
$out_data=mysqli_fetch_row($dbqry)[0];
$out_data = mysqli_fetch_row($dbqry)[0];
} else {
$out_data=NULL;
$out_data = NULL;
}
return($out_data);
return ($out_data);
}
function calendar($year,$month,$day,$link_url) {
function calendar($year, $month, $day, $link_url)
{
// takes a numeric year, month, day, and the basic url for the day links as arguments
// Shows a calendar with clickable dates.
// Based on an embeddable calendar by Yves Glodt.
// See http://www.mind.lu/~yg/stuff/
$YearToShow = $year;
$MonthToShow = $month;
$DayToShow = $day;
$NumberOfDays = date(t,mktime(0,0,0,$MonthToShow+1,0,$YearToShow,-1));
if ($month==1) {
$mbackyear=$year-1;
$mbackmonth=12;
$NumberOfDays = date(t, mktime(0, 0, 0, $MonthToShow + 1, 0, $YearToShow, -1));
if ($month == 1) {
$mbackyear = $year - 1;
$mbackmonth = 12;
} else {
$mbackyear=$year;
$mbackmonth=$month-1;
$mbackyear = $year;
$mbackmonth = $month - 1;
}
if ($month==12) {
$mfwdyear=$year+1;
$mfwdmonth=1;
if ($month == 12) {
$mfwdyear = $year + 1;
$mfwdmonth = 1;
} else {
$mfwdyear=$year;
$mfwdmonth=$month+1;
$mfwdyear = $year;
$mfwdmonth = $month + 1;
}
$ybackyear=$year-1;
$ybackmonth=$month;
$yfwdyear=$year+1;
$yfwdmonth=$month;
$MonthNames = array(1=>'January','February','March','April','May','June','July','August','September','October','November','December');
$ybackyear = $year - 1;
$ybackmonth = $month;
$yfwdyear = $year + 1;
$yfwdmonth = $month;
$MonthNames = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
echo <<<EOT
<table border="1" cellpadding="1" cellspacing="0">
@@ -452,39 +460,39 @@ function calendar($year,$month,$day,$link_url) {
EOT;
$FirstDayOfWeek = date(l,mktime(0,0,0,$MonthToShow,1,$YearToShow));
$FirstDayOfWeek = date(l, mktime(0, 0, 0, $MonthToShow, 1, $YearToShow));
switch ($FirstDayOfWeek) {
case 'Monday':
$offset = 1;
break;
break;
case 'Tuesday':
$offset = 2;
break;
break;
case 'Wednesday':
$offset = 3;
break;
break;
case 'Thursday':
$offset = 4;
break;
break;
case 'Friday':
$offset = 5;
break;
break;
case 'Saturday':
$offset = 6;
break;
break;
default:
$offset = 0;
}
if ($offset > 0) {
print "<tr align=\"center\">\n";
echo str_repeat("<td class=\"n\">&nbsp;</td>\n",$offset);
echo str_repeat("<td class=\"n\">&nbsp;</td>\n", $offset);
}
for ($i=1; $i <= $NumberOfDays; $i++) {
$DayOfWeek = date(l,mktime(0,0,0,$MonthToShow,$i,$YearToShow));
if($DayOfWeek == 'Sunday') {
for ($i = 1; $i <= $NumberOfDays; $i++) {
$DayOfWeek = date(l, mktime(0, 0, 0, $MonthToShow, $i, $YearToShow));
if ($DayOfWeek == 'Sunday') {
print "<tr align=\"center\">\n";
}
if ($i != $DayToShow) {
@@ -492,27 +500,28 @@ EOT;
} else {
print "<td><a href=\"$link_url?y=$YearToShow&m=$MonthToShow&d=$i\"><b><font size=\"+1\" color=\"#FF0000\">$i</font></b></a></td>\n";
}
if($DayOfWeek == 'Saturday') {
if ($DayOfWeek == 'Saturday') {
print "</tr>\n";
}
}
if ( ( ($offset == 5) && ($NumberOfDays > 30) ) || ( ($offset == 6) && ($NumberOfDays > 29) ) ) {
if (42-$NumberOfDays-$offset > 0) {
echo str_repeat("<td class=\"n\">&nbsp;</td>\n",42-$NumberOfDays-$offset);
if ((($offset == 5) && ($NumberOfDays > 30)) || (($offset == 6) && ($NumberOfDays > 29))) {
if (42 - $NumberOfDays - $offset > 0) {
echo str_repeat("<td class=\"n\">&nbsp;</td>\n", 42 - $NumberOfDays - $offset);
}
print "</tr>\n";
} elseif ( ($NumberOfDays != 28) || ($offset > 0) ) {
if (35-$NumberOfDays-$offset > 0) {
echo str_repeat("<td class=\"n\">&nbsp;</td>\n",35-$NumberOfDays-$offset);
print "</tr>\n";
} elseif (($NumberOfDays != 28) || ($offset > 0)) {
if (35 - $NumberOfDays - $offset > 0) {
echo str_repeat("<td class=\"n\">&nbsp;</td>\n", 35 - $NumberOfDays - $offset);
print "</tr>\n";
}
}
}
print "</table>\n";
}
function colorpicker($baseurl) {
function colorpicker($baseurl)
{
// takes a standard url and tacks the color number on to the end of it
// giving a palette of links
echo "
@@ -595,54 +604,57 @@ function colorpicker($baseurl) {
// Project functions
function getsetting($setting_name,$tech_id) {
function getsetting($setting_name, $tech_id)
{
// get the value of a setting for a tech
global $db;
$confinfo=mysqli_fetch_assoc(mysqli_query($db,"select confid,confvalue from configs where confname=\"$setting_name\""));
$confid=$confinfo["confid"];
$confvalue=$confinfo["confvalue"];
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
$confid = $confinfo["confid"];
$confvalue = $confinfo["confvalue"];
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
if (mysqli_num_rows($custqry)) {
$custvalue=mysqli_fetch_row($custqry)[0];
$custvalue = mysqli_fetch_row($custqry)[0];
}
// if value in custom table, use it
if (mysqli_num_rows($custqry)) {
$retvalue=$custvalue;
$table="customs";
$retvalue = $custvalue;
$table = "customs";
} else {
$retvalue=$confvalue;
$table="configs";
$retvalue = $confvalue;
$table = "configs";
}
$result=array('value' => $retvalue,'table' => $table,'id' => $confid);
$result = array('value' => $retvalue, 'table' => $table, 'id' => $confid);
return $result;
}
function putsetting($setting_name,$setting_value,$tech_id) {
function putsetting($setting_name, $setting_value, $tech_id)
{
// set the value of a setting for a tech
global $db;
$confinfo=mysqli_fetch_assoc(mysqli_query($db,"select confid,confvalue from configs where confname=\"$setting_name\""));
$confid=$confinfo["confid"];
$confvalue=$confinfo["confvalue"];
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
$confid = $confinfo["confid"];
$confvalue = $confinfo["confvalue"];
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
if (mysqli_num_rows($custqry)) {
if ($setting_value == $confvalue) {
mysqli_query($db,"delete from customs where customtech=\"$tech_id\" and customconfnum=\"$confid\"");
mysqli_query($db, "delete from customs where customtech=\"$tech_id\" and customconfnum=\"$confid\"");
}
$custvalue=mysqli_fetch_row($custqry)[0];
$custvalue = mysqli_fetch_row($custqry)[0];
if ($custvalue != $setting_value) {
mysqli_query($db,"update customs set customconfvalue=\"$setting_value\" where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
mysqli_query($db, "update customs set customconfvalue=\"$setting_value\" where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
}
} else {
mysqli_query($db,"insert into customs(customtech,customconfnum,customconfvalue) values(\"$tech_id\",\"$confid\",\"$setting_value\")");
mysqli_query($db, "insert into customs(customtech,customconfnum,customconfvalue) values(\"$tech_id\",\"$confid\",\"$setting_value\")");
}
}
function islink($il_note) {
function islink($il_note)
{
// takes a noteid number as an argument
// determines if the argument is a link in a reference chain
// returns 1 if note is a link, 0 if not
global $db;
$refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
$refqry = mysqli_query($db, "select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
if (mysqli_num_rows($refqry)) {
return 1;
} else {
@@ -651,97 +663,101 @@ function islink($il_note) {
}
function generate_chain($chainlink) {
function generate_chain($chainlink)
{
// generate a reference chain
// takes a single parameter, a noteid
// finds all notes that are members of a chain containing the supplied noteid
// returns a sorted array (chainarray) of all notes in chain
global $db;
// create notes and refs arrays from the reflinks table
$notes=[];
$targets=[];
$linkqry=mysqli_query($db,"select noteid,target from reflinks where noteid is not null");
while ($link=mysqli_fetch_assoc($linkqry)) {
$notes[]=$link['noteid'];
$targets[]=$link['target'];
$notes = [];
$targets = [];
$linkqry = mysqli_query($db, "select noteid,target from reflinks where noteid is not null");
while ($link = mysqli_fetch_assoc($linkqry)) {
$notes[] = $link['noteid'];
$targets[] = $link['target'];
}
$chainarray=array(); // create the chainarray
$chainarray[]=$chainlink; // add the incoming noteid for which the chain should be generated
$captr=0; // chainarray pointer
while($captr<count($chainarray)) { // as long as the chainarray is growing
$nptr=0; // note pointer
$chainarray = array(); // create the chainarray
$chainarray[] = $chainlink; // add the incoming noteid for which the chain should be generated
$captr = 0; // chainarray pointer
while ($captr < count($chainarray)) { // as long as the chainarray is growing
$nptr = 0; // note pointer
// run through the notes array, adding all targets for this note to the chainarray
while($nptr<count($notes)) {
if(($notes[$nptr]==$chainarray[$captr]) && ( ! in_array($targets[$nptr],$chainarray))) {
$chainarray[]=$targets[$nptr];
while ($nptr < count($notes)) {
if (($notes[$nptr] == $chainarray[$captr]) && (! in_array($targets[$nptr], $chainarray))) {
$chainarray[] = $targets[$nptr];
}
$nptr=$nptr+1;
$nptr = $nptr + 1;
}
// run through the targets array, adding all notes for this target to the chainarray
$tptr=0; //target pointer
while($tptr<count($targets)) {
if(($targets[$tptr]==$chainarray[$captr]) && ( ! in_array($notes[$tptr],$chainarray))) {
$chainarray[]=$notes[$tptr];
$tptr = 0; //target pointer
while ($tptr < count($targets)) {
if (($targets[$tptr] == $chainarray[$captr]) && (! in_array($notes[$tptr], $chainarray))) {
$chainarray[] = $notes[$tptr];
}
$tptr=$tptr+1;
$tptr = $tptr + 1;
}
$captr=$captr+1;
$captr = $captr + 1;
}
// sort and return the output array
sort($chainarray);
return($chainarray);
return ($chainarray);
}
function convertweblinks($rawstring) {
function convertweblinks($rawstring)
{
// takes a string, finds urls, and returns the string with urls converted to clickable links
$urlchunksize=URL_CHUNK_SIZE;
$urlchunksize = URL_CHUNK_SIZE;
// define regex pattern for urls
$urlpatt="/<weblink\b[^>]*>(.*?)<\/weblink>/";
preg_match_all($urlpatt,$rawstring,$weblinks, PREG_SET_ORDER);
$urlpatt = "/<weblink\b[^>]*>(.*?)<\/weblink>/";
preg_match_all($urlpatt, $rawstring, $weblinks, PREG_SET_ORDER);
foreach ($weblinks as $urlblock) {
// split up really long url
$spliturl=str_split($urlblock[1],$urlchunksize);
$spliturl = str_split($urlblock[1], $urlchunksize);
unset($urlstack);
foreach ($spliturl as $urlchunk) {
$urlstack[]="<a href=\"$urlblock[1]\" target=\"_blank\">$urlchunk</a>";
$urlstack[] = "<a href=\"$urlblock[1]\" target=\"_blank\">$urlchunk</a>";
}
$hyperlink=implode("<br>",$urlstack);
$rawstring=str_replace($urlblock[0],$hyperlink,$rawstring);
$hyperlink = implode("<br>", $urlstack);
$rawstring = str_replace($urlblock[0], $hyperlink, $rawstring);
}
return $rawstring;
}
function showlinklist($print) {
function showlinklist($print)
{
global $db;
$linkresult=mysqli_query($db,"select linkid from links where status=\"1\"");
$linkresult = mysqli_query($db, "select linkid from links where status=\"1\"");
if (mysqli_num_rows($linkresult) && !$print) {
echo "
<b>Links</b><br>
";
$link=mysqli_query($db,"select displaytxt,urltxt from links where status=\"1\" order by linkpriority asc");
$link = mysqli_query($db, "select displaytxt,urltxt from links where status=\"1\" order by linkpriority asc");
while ($linkrow = mysqli_fetch_row($link)) {
printf("<a href=\"%s\">%s</a><br>",$linkrow[1],$linkrow[0]);
printf("<a href=\"%s\">%s</a><br>", $linkrow[1], $linkrow[0]);
}
}
}
function nag($tech_id) {
function nag($tech_id)
{
// nags the user if something is pending
global $db, $today;
// maintenance forms
$mfpending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
$mfpending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
if ($mfpending) {
echo "<font color=\"#FF0000\">NOTICE</font>: You have one or more maintenance forms to complete. <a href=\"maintform.php\">Click here to complete them</a>.<br><hr>";
}
// scheduled maintenance events
$ucevents=get_upcoming_events();
$due=false;
$overdue=false;
$ucevents = get_upcoming_events();
$due = false;
$overdue = false;
foreach ($ucevents as $event) {
if ($event['duedate'] == $today) $due=true;
if ($event['duedate'] < $today) $overdue=true;
if ($event['duedate'] == $today) $due = true;
if ($event['duedate'] < $today) $overdue = true;
}
if ($due) {
echo "<font color=\"#FF0000\">NOTICE</font>: One or more scheduled maintenance events are due today. <a href=\"schedmaint.php\">Click here to view them</a>.<br><hr>";
@@ -751,7 +767,8 @@ function nag($tech_id) {
}
}
function get_part_data($partinputdata) {
function get_part_data($partinputdata)
{
// given an associative array of partid, uid, partnum, sernum,
// return an associative array of
// partid, uid, partnum, sernum, partname, result
@@ -797,131 +814,133 @@ function get_part_data($partinputdata) {
// not enough input data supplied, so return result of 1
$result = 1;
}
if (! $result) {
if (! $result) {
if (mysqli_num_rows($partqry)) {
$partdata=mysqli_fetch_assoc($partqry);
$partdata = mysqli_fetch_assoc($partqry);
} else {
$result=1;
$result = 1;
}
}
// detect mismatched input data
if ($checkmm) {
if (mysqli_num_rows($mismatchqry)) {
$result=2;
$result = 2;
}
}
if ($result) {
$partdata=array();
$partdata['result']=$result;
$partdata = array();
$partdata['result'] = $result;
} else {
$partdata['result']=0;
$partdata['result'] = 0;
}
return $partdata;
}
function get_upcoming_events() {
function get_upcoming_events()
{
// build array of upcoming events
// takes no arguments
// returns an array containing arrays of upcoming event data
global $db, $today;
$uceventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
$ucevents=array();
while ($uceventrow=mysqli_fetch_assoc($uceventsqry)) {
$uceventsqry = mysqli_query($db, "select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
$ucevents = array();
while ($uceventrow = mysqli_fetch_assoc($uceventsqry)) {
// provide eventid,task,device,start_date,last_date,deferred_flag,deferred_date,active_flag
extract($uceventrow,EXTR_PREFIX_ALL,"eventdata");
extract($uceventrow, EXTR_PREFIX_ALL, "eventdata");
// provide deviceid,devicename,devicedesc,group_flag,active_flag
$devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$eventdata_device\""));
extract($devicedata,EXTR_PREFIX_ALL,"devicedata");
$devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$eventdata_device\""));
extract($devicedata, EXTR_PREFIX_ALL, "devicedata");
// provide taskid,taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag
$taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$eventdata_task\""));
extract($taskdata,EXTR_PREFIX_ALL,"taskdata");
if ( ! ($taskdata_period == "once" && $eventdata_last_date >= $eventdata_start_date)) { // ignore completed one-time events
$start=date_create($eventdata_start_date); // create start date object
if ($eventdata_last_date=="0000-00-00") { // event has never been done. last date object will be start date object
$lastdatestrg="never";
$last=$start;
$taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$eventdata_task\""));
extract($taskdata, EXTR_PREFIX_ALL, "taskdata");
if (! ($taskdata_period == "once" && $eventdata_last_date >= $eventdata_start_date)) { // ignore completed one-time events
$start = date_create($eventdata_start_date); // create start date object
if ($eventdata_last_date == "0000-00-00") { // event has never been done. last date object will be start date object
$lastdatestrg = "never";
$last = $start;
} else { // create last date object
$lastdatestrg="$eventdata_last_date";
$last=date_create($eventdata_last_date);
$lastdatestrg = "$eventdata_last_date";
$last = date_create($eventdata_last_date);
}
if ($taskdata_period=="once") { // nextdue object will be start date object
$nextdue=$start;
if ($taskdata_period == "once") { // nextdue object will be start date object
$nextdue = $start;
} else { // determine nextdue object from last date object (relative) or interval from start date object (absolute)
if ($lastdatestrg=="never") { // event has been scheduled to start today but has not been completed
$nextdue=$start;
} else if ($last==$start) { // event was completed for the first time on the start date
$nextdue=$start;
if ($lastdatestrg == "never") { // event has been scheduled to start today but has not been completed
$nextdue = $start;
} else if ($last == $start) { // event was completed for the first time on the start date
$nextdue = $start;
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
} else {
if ($taskdata_nextdue_relative) { // calculate from day of last done date
$nextdue=$last;
$nextdue = $last;
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
} else { // calculate from day of start date
$nextdue=$start;
$testdate=date_create("1970-01-01");
$nextdue = $start;
$testdate = date_create("1970-01-01");
while ($testdate <= $last) {
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
$testdate=$nextdue;
$testdate = $nextdue;
}
}
}
}
if ($taskdata_weekdays_only) { // move forward off the weekend if required
$nextduedow=date("w",date_timestamp_get($nextdue));
if ($nextduedow==0) { // due on a Sunday
$nextduedow = date("w", date_timestamp_get($nextdue));
if ($nextduedow == 0) { // due on a Sunday
date_add($nextdue, date_interval_create_from_date_string("1 days"));
}
if ($nextduedow==6) { // due on a Saturday
if ($nextduedow == 6) { // due on a Saturday
date_add($nextdue, date_interval_create_from_date_string("2 days"));
}
}
$duedate=date_format($nextdue, 'Y-m-d');
$daysaway=date_diff(date_create($today),$nextdue)->format('%a');
$direction=date_diff(date_create($today),$nextdue)->format('%R');
if ($direction=="+") {
$duedate = date_format($nextdue, 'Y-m-d');
$daysaway = date_diff(date_create($today), $nextdue)->format('%a');
$direction = date_diff(date_create($today), $nextdue)->format('%R');
if ($direction == "+") {
if ($daysaway == 0) {
$duedatestrg="<font color=\"#FF0000\"> $duedate </font>";
$duedatestrg = "<font color=\"#FF0000\"> $duedate </font>";
} else if ($daysaway < 4) {
$duedatestrg="<font color=\"#FFFF00\"> $duedate </font>";
$duedatestrg = "<font color=\"#FFFF00\"> $duedate </font>";
} else {
$duedatestrg="<font color=\"#00FF00\"> $duedate </font>";
$duedatestrg = "<font color=\"#00FF00\"> $duedate </font>";
}
} else {
$duedatestrg="<font size=\"+1\" color=\"#FF0000\"><b> $duedate </b></font><img src=\"icons/exclamation-red.png\" border=\"0\">";
$duedatestrg = "<font size=\"+1\" color=\"#FF0000\"><b> $duedate </b></font><img src=\"icons/exclamation-red.png\" border=\"0\">";
}
$uceventline=array(
'eventdata_eventid'=>$eventdata_eventid,
'duedate'=>$duedate,
'duedatestrg'=>$duedatestrg,
'devicedata_devicedesc'=>$devicedata_devicedesc,
'devicedata_devicename'=>$devicedata_devicename,
'taskdata_taskdesc'=>$taskdata_taskdesc,
'taskdata_taskname'=>$taskdata_taskname,
'lastdatestrg'=>$lastdatestrg
$uceventline = array(
'eventdata_eventid' => $eventdata_eventid,
'duedate' => $duedate,
'duedatestrg' => $duedatestrg,
'devicedata_devicedesc' => $devicedata_devicedesc,
'devicedata_devicename' => $devicedata_devicename,
'taskdata_taskdesc' => $taskdata_taskdesc,
'taskdata_taskname' => $taskdata_taskname,
'lastdatestrg' => $lastdatestrg
);
$ucevents[]=$uceventline;
$ucevents[] = $uceventline;
}
}
return $ucevents;
}
function format_message($msgtype,$msgtxt) {
function format_message($msgtype, $msgtxt)
{
// displays a formatted message
// $msgtype is 0 for success or anything else for failure
// $msgtxt is the string to display
if ($msgtype == 0) {
$state="ui-state-highlight";
$icon="ui-icon-info";
$state = "ui-state-highlight";
$icon = "ui-icon-info";
} else {
$state="ui-state-error";
$icon="ui-icon-alert";
$state = "ui-state-error";
$icon = "ui-icon-alert";
}
if ($msgtxt == "") $msgtxt="PROGRAM ERROR: No message text was supplied.";
if ($msgtxt == "") $msgtxt = "PROGRAM ERROR: No message text was supplied.";
echo "
<div class=\"$state ui-corner-all\" style=\"margin-top: 20px; padding: 0 .7em;\">
<p><span class=\"ui-icon $icon\" style=\"float: left; margin-right: .3em;\"></span>
@@ -930,7 +949,8 @@ function format_message($msgtype,$msgtxt) {
";
}
function templateselect($techid,$operation) {
function templateselect($techid, $operation)
{
// Displays a line enabling selection of a user or global template
// $techid is the id number of the current tech
// $operation is one of "add" "edit" "delete"
@@ -947,10 +967,10 @@ function templateselect($techid,$operation) {
<td>
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
$templaterow = mysqli_query($db, "select * from notetemplates where tech=\"$techid\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>", "0", "Select user template");
while ($templateitem = mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>", $templateitem["templateid"], $templateitem["templatename"]);
}
echo "
</select>&nbsp;or&nbsp;
@@ -959,10 +979,10 @@ function templateselect($techid,$operation) {
echo "
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
$templaterow = mysqli_query($db, "select * from notetemplates where tech=\"0\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>", "0", "Select global template");
while ($templateitem = mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>", $templateitem["templateid"], $templateitem["templatename"]);
}
echo "
</select>&nbsp;&nbsp;
@@ -980,4 +1000,3 @@ function templateselect($techid,$operation) {
</form>
";
}
?>

View File

@@ -10,25 +10,25 @@
include("functions.php");
$print=$_REQUEST['print'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","OpenLog License","OpenLog License",$print);
framework("begin", "OpenLog License", "OpenLog License", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
sidemenu();
pageblock("left","end");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
echo "
<pre>
GNU GENERAL PUBLIC LICENSE
@@ -375,10 +375,8 @@ Public License instead of this License.
</pre>
";
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

File diff suppressed because it is too large Load Diff

View File

@@ -9,56 +9,55 @@
include("functions.php");
$print=$_REQUEST['print'];
$tech=$_REQUEST['tech'];
$pass=$_REQUEST['pass'];
$login=$_REQUEST['login'];
$cancel=$_REQUEST['cancel'];
$print = $_REQUEST['print'];
$tech = $_REQUEST['tech'];
$pass = $_REQUEST['pass'];
$login = $_REQUEST['login'];
$cancel = $_REQUEST['cancel'];
if ($cancel) {
session_destroy();
}
$techalpha=TECH_ALPHA;
$logname=LOG_NAME;
$techalpha = TECH_ALPHA;
$logname = LOG_NAME;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Login Page",$print);
framework("begin", "$logname", "Login Page", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu("no print");
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
if ($login) {
// log me in
$pwhash=mysqli_fetch_row(mysqli_query($db,"select techpass from techs where techid=\"$tech\""))[0];
$pwhash = mysqli_fetch_row(mysqli_query($db, "select techpass from techs where techid=\"$tech\""))[0];
if (password_verify($pass, $pwhash)) {
$_SESSION['login']=$tech;
$techname=dblookup($db,"techs","techid","techname",$tech);
$_SESSION['login'] = $tech;
$techname = dblookup($db, "techs", "techid", "techname", $tech);
echo "
Welcome $techname. Please select a menu option at the left to continue.
";
} else {
$adminqry=mysqli_query($db,"select techname from techs where admin=1 and status=1");
$adminqry = mysqli_query($db, "select techname from techs where admin=1 and status=1");
echo "
Incorrect password. Please <a href=\"login.php\">try again</a>.<br><br>
Forgot your password? Contact an administrator:<br><br>
";
while ($admintech=mysqli_fetch_row($adminqry)[0]) {
while ($admintech = mysqli_fetch_row($adminqry)[0]) {
echo "$admintech <br>";
}
}
} else if ($cancel) {
echo "
@@ -72,11 +71,12 @@ if ($login) {
<b>Tech: </b>&nbsp;
<select name=\"tech\">
";
if ($techalpha) $torder="techname"; else $torder="techid";
$techrow=mysqli_query($db,"select * from techs order by $torder asc");
while ($techitem=mysqli_fetch_assoc($techrow)) {
if ($techitem["status"]==1) {
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]);
if ($techalpha) $torder = "techname";
else $torder = "techid";
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
while ($techitem = mysqli_fetch_assoc($techrow)) {
if ($techitem["status"] == 1) {
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
}
}
echo "</select><br><br>
@@ -87,16 +87,14 @@ if ($login) {
<br><hr>
";
} else {
$loginid=$_SESSION['login'];
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0];
$loginid = $_SESSION['login'];
$loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
echo "
You are already logged in as $loggedinas. Please select a menu option at the left to continue.<br><hr>
";
}
}
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -12,103 +12,107 @@ include("functions.php");
//$tgt_year=$_REQUEST['y'];
//$tgt_month=$_REQUEST['m'];
//$tgt_day=$_REQUEST['d'];
$tgt_date=$_REQUEST['tgt_date'] ?? "";
$print=$_REQUEST['print'] ?? "";
if (isset($_SESSION['login'])) $techid=$_SESSION['login'];
$tgt_date = $_REQUEST['tgt_date'] ?? "";
$print = $_REQUEST['print'] ?? "";
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
$logname=LOG_NAME;
$tablestyle=LOG_STYLE;
$logname = LOG_NAME;
$tablestyle = LOG_STYLE;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
// use default date values if not supplied
if ($tgt_date=="") $tgt_date=$today;
if ($tgt_date == "") $tgt_date = $today;
// define shifttable_classic function
function shifttable_classic($shift, $tgt_date, $db) {
function shifttable_classic($shift, $tgt_date, $db)
{
// convert the shift number to a name for display
$doparts=PARTS_FUNCTIONS;
$showtime=SHOW_TS;
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift);
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr=mysqli_fetch_row($dshdrdata);
$doparts = PARTS_FUNCTIONS;
$showtime = SHOW_TS;
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
$dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr = mysqli_fetch_row($dshdrdata);
if ($dshdr) {
// print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
$note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
echo "<br><table border=\"1\" width=\"100%\">\n";
echo "<tr><th width=\"70\">Note ID</th><th width=\"70\">Tech</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>\n";
while ($tablerow = mysqli_fetch_assoc($note)) {
$thisnote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
$thisnote = $tablerow["lognoteid"];
$refs = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($thisnote)) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
$refs = $refs . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
}
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
//convert subject number to name
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
// create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]);
$fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
$flagstring = "";
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
while ($flagid = mysqli_fetch_row($flagqry)) {
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
$flagcolor = $flagparams["flagcolor"];
$flagsym = $flagparams["flagsym"];
$flagname = $flagparams["flagname"];
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote=$fmtnote."<br>";
$fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote = $fmtnote . "<br>";
}
if ($doparts) {
// turn on the parts indicator if parts were entered with the note
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1&noteid=$thisnote\">PARTS</a>";
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote = $fmtnote . "<a href=\"logentry.php?partview=1&noteid=$thisnote\">PARTS</a>";
}
}
// now print the line in the table
if ($showtime) {
printf(
"<tr>
"<tr>
<td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\" title=\"Edit this note\">%s</a>&nbsp;&nbsp;%s</td>
<td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
</tr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"],
$tname,
$subjname,
$fmtnote,
$refs
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tablerow["time"],
$tname,
$subjname,
$fmtnote,
$refs
);
} else {
printf(
"<tr>
"<tr>
<td valign=\"top\"><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td>
<td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
</tr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"],
$tname,
$subjname,
$fmtnote,
$refs
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tname,
$subjname,
$fmtnote,
$refs
);
}
}
@@ -121,82 +125,85 @@ function shifttable_classic($shift, $tgt_date, $db) {
}
// define the shifttable_clean function
function shifttable_clean($shift, $tgt_date, $db) {
function shifttable_clean($shift, $tgt_date, $db)
{
// convert the shift number to a name for display
$doparts=PARTS_FUNCTIONS;
$showtime=SHOW_TS;
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift);
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr=mysqli_fetch_row($dshdrdata);
$doparts = PARTS_FUNCTIONS;
$showtime = SHOW_TS;
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
$dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
$dshdr = mysqli_fetch_row($dshdrdata);
if ($dshdr) {
// print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
$note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
echo "<br><br>";
echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
while ($tablerow = mysqli_fetch_assoc($note)) {
$thisnote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
$thisnote = $tablerow["lognoteid"];
$refs = "&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($tablerow["lognoteid"])) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
$refs = $refs . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
}
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
//convert subject number to name
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
// create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]);
$fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
$flagstring = "";
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
while ($flagid = mysqli_fetch_row($flagqry)) {
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
$flagcolor = $flagparams["flagcolor"];
$flagsym = $flagparams["flagsym"];
$flagname = $flagparams["flagname"];
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote=$fmtnote."<br>";
$fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote = $fmtnote . "<br>";
}
if ($doparts) {
// turn on the parts indicator if parts were entered with the note
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1&noteid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote = $fmtnote . "<a href=\"logentry.php?edit=1&noteid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
}
}
// now print the line in the table
if ($showtime) {
printf(
"<a href=\"logentry.php?edit=1&noteid=%s\" title=\"Note ID. Click to edit.\">%s</a>&nbsp;&nbsp;
"<a href=\"logentry.php?edit=1&noteid=%s\" title=\"Note ID. Click to edit.\">%s</a>&nbsp;&nbsp;
<b>%s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp;
%s</b>
<br>%s<br>
<hr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"],
$tablerow["time"],
$tname,
$subjname,
$refs,
$fmtnote
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tablerow["time"],
$tname,
$subjname,
$refs,
$fmtnote
);
} else {
printf(
"<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>&nbsp;&nbsp;
"<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>&nbsp;&nbsp;
<b>%s &nbsp;&nbsp;&nbsp;&nbsp;
%s &nbsp;&nbsp;&nbsp;&nbsp;
%s</b>
<br>%s<br>
<hr>\n",
$tablerow["lognoteid"],$tablerow["lognoteid"],
$tname,
$subjname,
$refs,
$fmtnote
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tname,
$subjname,
$refs,
$fmtnote
);
}
}
@@ -208,11 +215,11 @@ function shifttable_clean($shift, $tgt_date, $db) {
echo "<br><br>\n";
}
framework("begin","$logname","Online Logbook",$print);
framework("begin", "$logname", "Online Logbook", $print);
pagetable("begin");
if(!$print) {
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
//calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php");
echo "<div id=\"caldate\" style=\"display: none;\">";
echo htmlspecialchars($tgt_date);
@@ -225,29 +232,27 @@ if(!$print) {
sidemenu();
echo "<br><br>";
showlinklist($print);
pageblock("left","end");
pageblock("left", "end");
} else {
echo "
<center><b>$tgt_year-$tgt_month-$tgt_day</b></center><br>
";
}
pageblock("right","begin");
banner($print);
pageblock("right", "begin");
banner($print);
if (isset($techid)) nag($techid);
//$date=date("Y-m-d",mktime(0,0,0,$tgt_month,$tgt_day,$tgt_year));
$qry=mysqli_query($db,"select shiftid from shifts where status=1 order by shiftid asc");
while ($shnum=mysqli_fetch_row($qry)) {
if ($tablestyle==1) {
shifttable_classic($shnum[0],$tgt_date,$db);
} else if ($tablestyle==2) {
shifttable_clean($shnum[0],$tgt_date,$db);
$qry = mysqli_query($db, "select shiftid from shifts where status=1 order by shiftid asc");
while ($shnum = mysqli_fetch_row($qry)) {
if ($tablestyle == 1) {
shifttable_classic($shnum[0], $tgt_date, $db);
} else if ($tablestyle == 2) {
shifttable_clean($shnum[0], $tgt_date, $db);
}
}
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -9,39 +9,40 @@
include("functions.php");
if (isset($_SESSION['login'])) $techid=$_SESSION['login'];
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
$print=$_REQUEST['print'] ?? NULL;
$histdays=$_REQUEST['histdays'] ?? NULL;
$submit=$_REQUEST['submit'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$histdays = $_REQUEST['histdays'] ?? NULL;
$submit = $_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;
$logname = LOG_NAME;
$uidtext = UID_TEXT;
if ($histdays=="") $histdays=30;
if ($histdays == "") $histdays = 30;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
// define pendtable function
function pendtable($tech_id, $db) {
$uidtext=UID_TEXT;
function pendtable($tech_id, $db)
{
$uidtext = UID_TEXT;
// print section header
if ($tech_id) {
echo "
<b><font size=\"+1\">Your Pending Maintenance Forms</font></b><br>
";
$pmf=mysqli_query($db,"select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc");
$pmf = mysqli_query($db, "select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc");
} else {
echo "
<b><font size=\"+1\">All Pending Maintenance Forms</font></b><br>
";
$pmf=mysqli_query($db,"select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc");
$pmf = mysqli_query($db, "select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc");
}
echo "
<br><table border=\"1\" width=\"100%\">
@@ -60,26 +61,26 @@ function pendtable($tech_id, $db) {
";
while ($pendrow = mysqli_fetch_assoc($pmf)) {
// look up part data
$uid=dblookup($db,"parts","partid","uid",$pendrow["mfpart"]);
if ($uid=="") $uid="&nbsp;";
$partno=dblookup($db,"parts","partid","partnum",$pendrow["mfpart"]);
if ($partno=="") $partno="&nbsp;";
$serno=dblookup($db,"parts","partid","sernum",$pendrow["mfpart"]);
if ($serno=="") $serno="&nbsp;";
$partname=dblookup($db,"parts","partid","partname",$pendrow["mfpart"]);
if ($partname=="") $partname="&nbsp;";
$uid = dblookup($db, "parts", "partid", "uid", $pendrow["mfpart"]);
if ($uid == "") $uid = "&nbsp;";
$partno = dblookup($db, "parts", "partid", "partnum", $pendrow["mfpart"]);
if ($partno == "") $partno = "&nbsp;";
$serno = dblookup($db, "parts", "partid", "sernum", $pendrow["mfpart"]);
if ($serno == "") $serno = "&nbsp;";
$partname = dblookup($db, "parts", "partid", "partname", $pendrow["mfpart"]);
if ($partname == "") $partname = "&nbsp;";
// look up tech name
$tname=dblookup($db,"techs","techid","techname",$pendrow["mftech"]);
if ($pendrow["lognoteid"]==0) {
$noteidval="&nbsp;";
$notetag="%s%s";
$tname = dblookup($db, "techs", "techid", "techname", $pendrow["mftech"]);
if ($pendrow["lognoteid"] == 0) {
$noteidval = "&nbsp;";
$notetag = "%s%s";
} else {
$noteidval=$pendrow["lognoteid"];
$notetag="<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
$noteidval = $pendrow["lognoteid"];
$notetag = "<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
}
if (!$tech_id) {
printf(
"<tr>
"<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
@@ -89,18 +90,20 @@ function pendtable($tech_id, $db) {
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td>
</tr>",
$pendrow["maintformid"],$pendrow["maintformid"],
$pendrow["mfdate"],
$tname,
$uid,
$partno,
$serno,
$partname,
$noteidval,$noteidval
$pendrow["maintformid"],
$pendrow["maintformid"],
$pendrow["mfdate"],
$tname,
$uid,
$partno,
$serno,
$partname,
$noteidval,
$noteidval
);
} else {
printf(
"<tr>
"<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
@@ -109,13 +112,15 @@ function pendtable($tech_id, $db) {
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td>
</tr>",
$pendrow["maintformid"],$pendrow["maintformid"],
$pendrow["mfdate"],
$uid,
$partno,
$serno,
$partname,
$noteidval,$noteidval
$pendrow["maintformid"],
$pendrow["maintformid"],
$pendrow["mfdate"],
$uid,
$partno,
$serno,
$partname,
$noteidval,
$noteidval
);
}
}
@@ -125,9 +130,10 @@ function pendtable($tech_id, $db) {
}
// define histtable function
function histtable($hist_days,$db) {
$uidtext=UID_TEXT;
$dayopts=array(30,90,180,365);
function histtable($hist_days, $db)
{
$uidtext = UID_TEXT;
$dayopts = array(30, 90, 180, 365);
// print section header
echo "
<form method=\"post\" action=\"maintform.php\">
@@ -135,13 +141,13 @@ function histtable($hist_days,$db) {
<select name=\"histdays\">
";
foreach ($dayopts as $chunk) {
if ($chunk==$hist_days) {
if ($chunk == $hist_days) {
echo "<option value=\"$chunk\" selected>$chunk</option>";
} else {
echo "<option value=\"$chunk\">$chunk</option>";
}
}
$histqry=mysqli_query($db,"select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc");
$histqry = mysqli_query($db, "select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc");
echo "
</select>
<b><font size=\"+1\"> Days</font></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
@@ -160,24 +166,24 @@ function histtable($hist_days,$db) {
";
while ($histrow = mysqli_fetch_assoc($histqry)) {
// look up part data
$uid=dblookup($db,"parts","partid","uid",$histrow["mfpart"]);
$partno=dblookup($db,"parts","partid","partnum",$histrow["mfpart"]);
if ($partno=="") $partno="&nbsp;";
$serno=dblookup($db,"parts","partid","sernum",$histrow["mfpart"]);
if ($serno=="") $serno="&nbsp;";
$partname=dblookup($db,"parts","partid","partname",$histrow["mfpart"]);
if ($partname=="") $partname="&nbsp;";
$uid = dblookup($db, "parts", "partid", "uid", $histrow["mfpart"]);
$partno = dblookup($db, "parts", "partid", "partnum", $histrow["mfpart"]);
if ($partno == "") $partno = "&nbsp;";
$serno = dblookup($db, "parts", "partid", "sernum", $histrow["mfpart"]);
if ($serno == "") $serno = "&nbsp;";
$partname = dblookup($db, "parts", "partid", "partname", $histrow["mfpart"]);
if ($partname == "") $partname = "&nbsp;";
// look up tech name
$tname=dblookup($db,"techs","techid","techname",$histrow["mftech"]);
if ($histrow["lognoteid"]==0) {
$noteidval="&nbsp;";
$notetag="%s%s";
$tname = dblookup($db, "techs", "techid", "techname", $histrow["mftech"]);
if ($histrow["lognoteid"] == 0) {
$noteidval = "&nbsp;";
$notetag = "%s%s";
} else {
$noteidval=$histrow["lognoteid"];
$notetag="<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
$noteidval = $histrow["lognoteid"];
$notetag = "<a href=\"logentry.php?edit=1&noteid=%s\">%s</a>";
}
printf(
"<tr>
"<tr>
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
@@ -187,14 +193,16 @@ function histtable($hist_days,$db) {
<td valign=\"top\">%s</td>
<td align=\"center\" valign=\"top\">$notetag</td>
</tr>",
$histrow["maintformid"],$histrow["maintformid"],
$histrow["mfdate"],
$tname,
$uid,
$partno,
$serno,
$partname,
$noteidval,$noteidval
$histrow["maintformid"],
$histrow["maintformid"],
$histrow["mfdate"],
$tname,
$uid,
$partno,
$serno,
$partname,
$noteidval,
$noteidval
);
}
echo "
@@ -202,30 +210,28 @@ function histtable($hist_days,$db) {
";
}
framework("begin","$logname","Maintenance Forms",$print);
framework("begin", "$logname", "Maintenance Forms", $print);
pagetable("begin");
if(!$print) {
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
banner($print);
pageblock("right", "begin");
banner($print);
echo "<br>";
$haspending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\""));
$haspending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\""));
if ($haspending) {
pendtable($techid,$db);
pendtable($techid, $db);
echo "<br><hr><br>";
}
pendtable(0,$db);
pendtable(0, $db);
echo "<br><hr><br>";
histtable($histdays,$db);
histtable($histdays, $db);
echo "<br><br>";
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -11,121 +11,123 @@ include("functions.php");
if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
header ("Location: login.php");
header("Location: login.php");
}
$loggedinas=$_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
$loggedinas = $_SESSION['login'];
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
function getmfdata($maintformid) {
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\""));
$mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\""));
return $mfdata;
}
function getactiondata($maintactionid) {
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\""));
$actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\""));
return $actiondata;
}
$print=$_REQUEST['print'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$maintformid=$_REQUEST['maintformid'] ?? NULL;
$lognoteid=$_REQUEST['lognoteid'] ?? NULL;
$mfdate=$_REQUEST['date'] ?? NULL;
$mftime=$_REQUEST['time'] ?? NULL;
$mfsubmit=$_REQUEST['mfsubmit'] ?? NULL;
$mfadd=$_REQUEST['mfadd'] ?? NULL;
$mfedit=$_REQUEST['mfedit'] ?? NULL;
$mfdelete=$_REQUEST['mfdelete'] ?? NULL;
$mfpartloc=$_REQUEST['mfpartloc'] ?? NULL;
$mfmalfunction=$_REQUEST['mfmalfunction'] ?? NULL;
$nha=$_REQUEST['nha'] ?? NULL;
$repord=$_REQUEST['repord'] ?? NULL;
$mfpart=$_REQUEST['mfpart'] ?? NULL;
$uid=$_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname'] ?? NULL;
$actionadd=$_REQUEST['actionadd'] ?? NULL;
$actionedit=$_REQUEST['actionedit'] ?? NULL;
$actiondelete=$_REQUEST['actiondelete'] ?? NULL;
$maintactionid=$_REQUEST['maintactionid'] ?? NULL;
$actiondate=$_REQUEST['actiondate'] ?? NULL;
$actiontime=$_REQUEST['actiontime'] ?? NULL;
$actiontech=$_REQUEST['actiontech'] ?? NULL;
$action=$_REQUEST['action'] ?? NULL;
$actionaddsubmit=$_REQUEST['actionaddsubmit'] ?? NULL;
$actioneditsubmit=$_REQUEST['actioneditsubmit'] ?? NULL;
$printfmt=$_REQUEST['printfmt'] ?? NULL;
if ($printfmt) $print=TRUE;
$flags=$_POST['flags'] ?? [];
$maintformid = $_REQUEST['maintformid'] ?? NULL;
$lognoteid = $_REQUEST['lognoteid'] ?? NULL;
$mfdate = $_REQUEST['date'] ?? NULL;
$mftime = $_REQUEST['time'] ?? NULL;
$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL;
$mfadd = $_REQUEST['mfadd'] ?? NULL;
$mfedit = $_REQUEST['mfedit'] ?? NULL;
$mfdelete = $_REQUEST['mfdelete'] ?? NULL;
$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL;
$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL;
$nha = $_REQUEST['nha'] ?? NULL;
$repord = $_REQUEST['repord'] ?? NULL;
$mfpart = $_REQUEST['mfpart'] ?? NULL;
$uid = $_REQUEST['uid'] ?? NULL;
$partnum = $_REQUEST['partnum'] ?? NULL;
$sernum = $_REQUEST['sernum'] ?? NULL;
$partname = $_REQUEST['partname'] ?? NULL;
$actionadd = $_REQUEST['actionadd'] ?? NULL;
$actionedit = $_REQUEST['actionedit'] ?? NULL;
$actiondelete = $_REQUEST['actiondelete'] ?? NULL;
$maintactionid = $_REQUEST['maintactionid'] ?? NULL;
$actiondate = $_REQUEST['actiondate'] ?? NULL;
$actiontime = $_REQUEST['actiontime'] ?? NULL;
$actiontech = $_REQUEST['actiontech'] ?? NULL;
$action = $_REQUEST['action'] ?? NULL;
$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL;
$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL;
$printfmt = $_REQUEST['printfmt'] ?? NULL;
if ($printfmt) $print = TRUE;
$flags = $_POST['flags'] ?? [];
$logname=LOG_NAME;
$uidtext=UID_TEXT;
$logname = LOG_NAME;
$uidtext = UID_TEXT;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
if ($printfmt) {
framework("begin","","",$print);
framework("begin", "", "", $print);
} else if ($mfedit) {
framework("begin","$logname","Maintenance Form Edit",$print);
if ($loggedinas) $mfauthorized=TRUE;
framework("begin", "$logname", "Maintenance Form Edit", $print);
if ($loggedinas) $mfauthorized = TRUE;
} else if ($mfdelete) {
framework("begin","$logname","Maintenance Form Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE;
framework("begin", "$logname", "Maintenance Form Edit", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE;
} else if ($actionadd) {
framework("begin","$logname","Maintenance Action Entry",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
framework("begin", "$logname", "Maintenance Action Entry", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) {
$mfauthorized=TRUE;
$actionauthorized=TRUE;
$mfauthorized = TRUE;
$actionauthorized = TRUE;
}
} else if ($actionedit || $actiondelete) {
framework("begin","$logname","Maintenance Action Edit",$print);
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
if ($loggedinas) $mfauthorized=TRUE;
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid);
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE;
framework("begin", "$logname", "Maintenance Action Edit", $print);
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
if ($loggedinas) $mfauthorized = TRUE;
$actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE;
} else {
$mfadd=TRUE;
framework("begin","$logname","Maintenance Form Entry",$print);
$mftech=$loggedinas;
$mfauthorized=TRUE;
$mfadd = TRUE;
framework("begin", "$logname", "Maintenance Form Entry", $print);
$mftech = $loggedinas;
$mfauthorized = TRUE;
}
// ******** begin database manipulation ********
//var_dump($_REQUEST);
$pdatamismatch=NULL;
$pdatamismatch = NULL;
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
// pull mf data from database
$mftoedit=getmfdata($maintformid);
$partdatainput=[];
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=TRUE;
$mftoedit = getmfdata($maintformid);
$partdatainput = [];
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 = TRUE;
} else {
$pdatamismatch=FALSE;
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'];
$pdatamismatch = FALSE;
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'];
}
}
@@ -134,54 +136,54 @@ if ($mfadd) {
// 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)"));
$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 = "23:59:59:";
}
if ($datediff[0]>0) {
$mftime="00:00:01:";
if ($datediff[0] > 0) {
$mftime = "00:00:01:";
}
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
$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);
$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 ($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=TRUE;
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 = TRUE;
} else {
// if it is in parts table, get partid for this record
$pdatamismatch=FALSE;
$mfpart=$partinfo['partid'];
$pdatamismatch = FALSE;
$mfpart = $partinfo['partid'];
}
if ($uid =="" || $partnum == "" || $sernum == "") {
if ($uid == "" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
$pending = 1;
} else {
$pending=0;
$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)
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;
$newmaintformid = mysqli_insert_id($db);
$mfidtoprint = $newmaintformid;
// update the flagmap table
foreach ($flags as $thisflag) {
// set flag for this maintenance form
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")");
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")");
}
}
}
@@ -189,66 +191,66 @@ if ($mfadd) {
}
}
if ($mfedit) {
$mfidtoprint=$maintformid;
$mfidtoprint = $maintformid;
if ($mfsubmit && $mfauthorized) {
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
// remove cruft from malfunction text
$mfmalfunction=htmlentities($mfmalfunction);
$mfmalfunction=addslashes($mfmalfunction);
$mfmalfunction = htmlentities($mfmalfunction);
$mfmalfunction = addslashes($mfmalfunction);
// update parts table
if ($uid =="" || $partnum == "" || $sernum == "") {
if ($uid == "" || $partnum == "" || $sernum == "") {
// have the maintenance form stay pending due to incomplete part data
$pending=1;
$pending = 1;
} else {
$pending=0;
$pending = 0;
}
if (! $pdatamismatch) {
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
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\",
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 flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
foreach ($flags as $thisflag) {
// set flag for this maintenance form
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")");
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")");
}
}
}
}
// refresh the maintenance form in question from the database
$mftoedit=getmfdata($maintformid);
$mftoedit = getmfdata($maintformid);
}
if ($mfdelete && $mfauthorized) {
// delete from maintforms table
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\"");
// delete occurances from the flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
mysqli_query($db, "delete from flagmap where maintformid=\"$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)"));
$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 = "23:59:59:";
}
if ($datediff[0]>0) {
$actiontime="00:00:01:";
if ($datediff[0] > 0) {
$actiontime = "00:00:01:";
}
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
$action = htmlentities($action);
$action = addslashes($action);
// add to maintactions table
mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
mysqli_query($db, "insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")");
echo mysqli_error($db);
}
@@ -259,19 +261,19 @@ if ($actionedit) {
if ($actioneditsubmit && $actionauthorized) {
// update the action
// remove cruft from action text
$action=htmlentities($action);
$action=addslashes($action);
$action = htmlentities($action);
$action = addslashes($action);
// update maintactions table
mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
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);
$actiontoedit = getactiondata($maintactionid);
}
if ($actiondelete && $actionauthorized) {
// delete the action
mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\"");
mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\"");
}
@@ -279,66 +281,67 @@ if ($actiondelete && $actionauthorized) {
pagetable("begin");
if (!$print) {
pageblock("left","begin");
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
// display the form
if ($mfadd || $actionadd) {
$mfdate=$today;
$mftime=$now;
$actiondate=$today;
$actiontime=$now;
$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;
$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=TRUE; else $pdatamismatch=FALSE;
$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 = TRUE;
else $pdatamismatch = FALSE;
}
$techname=dblookup($db,"techs","techid","techname",$mftech);
$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>");
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>");
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.");
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.");
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>");
format_message(0, "Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
}
if ($pdatamismatch) {
$advtxt="
$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
@@ -346,7 +349,7 @@ if ($pdatamismatch) {
the <a href=\"parts.php\">Parts</a> page to correct the database.</b>
";
} else {
$advtxt="
$advtxt = "
<font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font>
";
}
@@ -374,34 +377,34 @@ if ($printfmt) {
<b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\">
";
// create an array called theseflags of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
$allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags);
$theseflags=[];
while ($thisflag=mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
$theseflags = [];
while ($thisflag = mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[] = $thisflag[0];
}
}
// display flag symbols for set flags
$flagslist=mysqli_query($db,"select * from flags");
while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
$flagslist = mysqli_query($db, "select * from flags");
while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0] == "") $theseflags = [];
if (!empty($theseflags) && 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"]);
$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>
@@ -463,39 +466,49 @@ if ($printfmt) {
<tr><td>
";
// create an array called theseflags of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
$allflags = mysqli_query($db, "select flagid from flags");
unset($theseflags);
$theseflags=[];
while ($thisflag=mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
$theseflags = [];
while ($thisflag = mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[] = $thisflag[0];
}
}
if ($mfadd) {
$flagslist=mysqli_query($db,"select * from flags where status=1");
$flagslist = mysqli_query($db, "select * from flags where status=1");
} else {
$flagslist=mysqli_query($db,"select * from flags");
$flagslist = mysqli_query($db, "select * from flags");
}
$flagsperline=8;
$flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
$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"]);
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"]);
$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) {
if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount=1;
$flagcount = 1;
}
}
echo "
@@ -542,7 +555,7 @@ if ($printfmt) {
</td></tr></table>
";
}
echo "
</form>
<hr>
@@ -550,16 +563,16 @@ if ($printfmt) {
if ($actionadd || $actionedit) {
// show the action form
if ($actionadd) {
$matime=$now;
$actiontext="";
$actiontech=$loggedinas;
$matime = $now;
$actiontext = "";
$actiontech = $loggedinas;
} else if ($actionedit) {
$actiontext=$actiontoedit['action'];
$actiontech=$actiontoedit['actiontech'];
$actiondate=$actiontoedit['actiondate'];
$actiontime=$actiontoedit['actiontime'];
$actiontext = $actiontoedit['action'];
$actiontech = $actiontoedit['actiontech'];
$actiondate = $actiontoedit['actiondate'];
$actiontime = $actiontoedit['actiontime'];
}
$tname=dblookup($db,"techs","techid","techname",$actiontech);
$tname = dblookup($db, "techs", "techid", "techname", $actiontech);
echo "<table width=\"70\" border=\"0\" cellpadding=\"5\">
<tr>
<td>Tech:&nbsp;&nbsp;$tname
@@ -597,25 +610,25 @@ if ($printfmt) {
<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"]);
$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) {
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>
@@ -638,16 +651,14 @@ if ($printfmt) {
</table><br>
";
}
echo "
</form>
";
}
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -11,39 +11,39 @@ include("functions.php");
if (!isset($_SESSION['login'])) {
header ("Location: login.php");
header("Location: login.php");
}
$loggedinas=$_SESSION['login'];
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
$loggedinas = $_SESSION['login'];
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
$print=$_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add'] ?? NULL;
$edit=$_REQUEST['edit'] ?? NULL;
$delete=$_REQUEST['delete'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$add = $_REQUEST['add'] ?? NULL;
$edit = $_REQUEST['edit'] ?? NULL;
$delete = $_REQUEST['delete'] ?? NULL;
$partid=$_REQUEST['partid'] ?? NULL;
$uid=$_REQUEST['uid'] ?? NULL;
$partnum=$_REQUEST['partnum'] ?? NULL;
$sernum=$_REQUEST['sernum'] ?? NULL;
$partname=$_REQUEST['partname'] ?? NULL;
$submit=$_REQUEST['submit'] ?? NULL;
$partid = $_REQUEST['partid'] ?? NULL;
$uid = $_REQUEST['uid'] ?? NULL;
$partnum = $_REQUEST['partnum'] ?? NULL;
$sernum = $_REQUEST['sernum'] ?? NULL;
$partname = $_REQUEST['partname'] ?? NULL;
$submit = $_REQUEST['submit'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;
$logname = LOG_NAME;
$uidtext = UID_TEXT;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
if ($edit || $delete) {
framework("begin","$logname","Part Edit",$print);
framework("begin", "$logname", "Part Edit", $print);
} else {
$add=1;
framework("begin","$logname","Part Entry",$print);
$add = 1;
framework("begin", "$logname", "Part Entry", $print);
}
// ******** begin database manipulation ********
@@ -53,11 +53,11 @@ if ($add) {
if ($submit) {
// add the entry if submit is pressed
if ($uid || ($partnum && $sernum)) {
$partexists=mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")"));
$partexists = mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")"));
if (! $partexists) {
// add to parts table
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$partid=mysqli_insert_id($db);
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
$partid = mysqli_insert_id($db);
}
}
}
@@ -66,18 +66,18 @@ if ($edit) {
if ($submit) {
if ($uid || ($partnum && $sernum)) {
// update parts table
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\"");
mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\"");
}
}
}
if ($delete) {
// check for occurrence in logparts table
$inlogparts=mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where partid=\"$partid\""));
$inlogparts = mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where partid=\"$partid\""));
// check for occurrence in maintforms table
$inmaintforms=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mfpart=\"$partid\""));
$inmaintforms = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mfpart=\"$partid\""));
// delete from parts table
if(!$inlogparts && !$inmaintforms) {
mysqli_query($db,"delete from parts where partid=\"$partid\"");
if (!$inlogparts && !$inmaintforms) {
mysqli_query($db, "delete from parts where partid=\"$partid\"");
}
}
@@ -85,24 +85,24 @@ if ($delete) {
pagetable("begin");
if (!$print) {
pageblock("left","begin");
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
// display the form
$partdatainput=array();
$partdatainput['partid']=$partid;
$partinfo=get_part_data($partdatainput);
if ($partinfo['result']==2) {
$pdatamismatch=TRUE;
$partdatainput = array();
$partdatainput['partid'] = $partid;
$partinfo = get_part_data($partdatainput);
if ($partinfo['result'] == 2) {
$pdatamismatch = TRUE;
} else {
$pdatamismatch=FALSE;
$uid = (array_key_exists('uid',$partinfo)) ? $partinfo['uid'] : NULL;
$partnum = (array_key_exists('partnum',$partinfo)) ? $partinfo['partnum'] : NULL;
$sernum = (array_key_exists('sernum',$partinfo)) ? $partinfo['sernum'] : NULL;
$partname = (array_key_exists('partname',$partinfo)) ? $partinfo['partname'] : NULL;
$pdatamismatch = FALSE;
$uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL;
$partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL;
$sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL;
$partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL;
}
if ($delete) {
if ($inmaintforms) {
@@ -168,9 +168,7 @@ echo "
</form>
";
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -10,50 +10,50 @@
include("functions.php");
if (isset($_SESSION['login'])) {
$loggedin=1;
$loggedin = TRUE;
} else {
unset($loggedin);
$loggedin = FALSE;
}
$print=$_REQUEST['print'] ?? NULL;
$add=$_REQUEST['add'] ?? NULL;
$sort=$_REQUEST['sort'] ?? NULL;
$order=$_REQUEST['order'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$add = $_REQUEST['add'] ?? NULL;
$sort = $_REQUEST['sort'] ?? NULL;
$order = $_REQUEST['order'] ?? NULL;
$logname=LOG_NAME;
$uidtext=UID_TEXT;
$logname = LOG_NAME;
$uidtext = UID_TEXT;
if ($add) {
header ("Location: partentry.php?add=1");
header("Location: partentry.php?add=1");
}
if (! $sort) $sort="uid";
if (! $sort) $sort = "uid";
if ($order == "asc") {
$order="desc";
$order = "desc";
} else if ($order == "desc") {
$order="asc";
$order = "asc";
} else {
$order="asc";
$order = "asc";
}
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Parts",$print);
framework("begin", "$logname", "Parts", $print);
pagetable("begin");
if(!$print) {
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
if ($loggedin) {
echo "
@@ -71,15 +71,16 @@ echo "
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
</tr>
";
$partqry=mysqli_query($db,"select * from parts order by $sort $order");
while ($partline=mysqli_fetch_assoc($partqry)) {
$partqry = mysqli_query($db, "select * from parts order by $sort $order");
while ($partline = mysqli_fetch_assoc($partqry)) {
if (!$partline['uid']) {
$pluidtxt="none";
$pluidtxt = "none";
} else {
$pluidtxt=$partline['uid'];
$pluidtxt = $partline['uid'];
}
if ($loggedin) {
printf("
printf(
"
<tr>
<td>
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
@@ -87,22 +88,24 @@ while ($partline=mysqli_fetch_assoc($partqry)) {
<td>%s</td>
<td>%s</td>
<td>%s</td>",
$partline['partid'],$pluidtxt,
$partline['partnum'],
$partline['sernum'],
$partline['partname']
$partline['partid'],
$pluidtxt,
$partline['partnum'],
$partline['sernum'],
$partline['partname']
);
} else {
printf("
printf(
"
<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>",
$pluidtxt,
$partline['partnum'],
$partline['sernum'],
$partline['partname']
$pluidtxt,
$partline['partnum'],
$partline['sernum'],
$partline['partname']
);
}
echo "
@@ -115,9 +118,7 @@ echo "
echo "<br><br>";
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -10,133 +10,136 @@
include("functions.php");
if (!isset($_SESSION['login'])) {
header ("Location: login.php");
header("Location: login.php");
}
$techid=$_SESSION['login'] ?? NULL;
$print=$_REQUEST['print'] ?? NULL;
$table=$_REQUEST['table'] ?? NULL;
$updateinfo=$_REQUEST['updateinfo'] ?? NULL;
$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL;
$setcolor=$_REQUEST['setcolor'] ?? NULL;
$name=$_REQUEST['name'] ?? NULL;
$pass=$_REQUEST['pass'] ?? NULL;
$passconf=$_REQUEST['passconf'] ?? NULL;
$shift=$_REQUEST['shift'] ?? NULL;
$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL;
$display_showts=$_REQUEST['display_showts'] ?? NULL;
$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL;
$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL;
$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL;
$modcolor=$_REQUEST['modcolor'] ?? NULL;
$hexcolor=$_REQUEST['hexcolor'] ?? NULL;
$resetcustom=$_REQUEST["resetcustom"] ?? NULL;
$techid = $_SESSION['login'] ?? NULL;
$print = $_REQUEST['print'] ?? NULL;
$table = $_REQUEST['table'] ?? NULL;
$updateinfo = $_REQUEST['updateinfo'] ?? NULL;
$updatedisplay = $_REQUEST['updatedisplay'] ?? NULL;
$setcolor = $_REQUEST['setcolor'] ?? NULL;
$name = $_REQUEST['name'] ?? NULL;
$pass = $_REQUEST['pass'] ?? NULL;
$passconf = $_REQUEST['passconf'] ?? NULL;
$shift = $_REQUEST['shift'] ?? NULL;
$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL;
$display_showts = $_REQUEST['display_showts'] ?? NULL;
$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL;
$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL;
$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL;
$modcolor = $_REQUEST['modcolor'] ?? NULL;
$hexcolor = $_REQUEST['hexcolor'] ?? NULL;
$resetcustom = $_REQUEST["resetcustom"] ?? NULL;
$logname=LOG_NAME;
$logname = LOG_NAME;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","My Profile",$print);
framework("begin", "$logname", "My Profile", $print);
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
// ******** begin database manipulation ********
if ($updateinfo) {
// name shift password settings
// do error checking
// test for name supplied
if (strlen(trim($name))) {
$namesuppld=1;
$namesuppld = TRUE;
} else {
$namesuppld=0;
$namesuppld = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name cannot be blank.<br>";
}
// test for name unique
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) {
$nameunique=0;
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
$nameunique = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;Tech name already exists.<br>";
} else {
$nameunique=1;
$nameunique = TRUE;
}
} else {
$nameunique=1;
$nameunique = TRUE;
}
// test for matching passwords
if ($pass!="password_is_unchanged") {
if ($pass==$passconf) {
$passmatch=1;
$passhash=password_hash($pass,PASSWORD_DEFAULT);
$namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
if ($pass != "password_is_unchanged") {
if ($pass == $passconf) {
$passmatch = TRUE;
$passhash = password_hash($pass, PASSWORD_DEFAULT);
$namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
} else {
$passmatch=0;
$passmatch = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;The passwords you supplied don't match.<br>";
}
} else {
$passmatch=1;
$namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\"";
$passmatch = TRUE;
$namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\"";
}
if ($namesuppld && $nameunique && $passmatch) {
mysqli_query($db,$namepassupdqry);
mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\"");
mysqli_query($db, $namepassupdqry);
mysqli_query($db, "update techs set shift=\"$shift\" where techid=\"$techid\"");
}
}
if ($updatedisplay) {
// display settings
if ($display_showts) $display_showts=1; else $display_showts=0;
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0;
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0;
if ($display_showts) $display_showts = 1;
else $display_showts = 0;
if ($display_techalpha == "a") $display_techalpha = 1;
else $display_techalpha = 0;
if ($display_subjalpha == "a") $display_subjalpha = 1;
else $display_subjalpha = 0;
// test for urlchunk supplied
if (strlen(trim($display_urlchunk))) {
$chunksuppld=1;
$chunksuppld = TRUE;
} else {
$chunksuppld=0;
$chunksuppld = FALSE;
echo "<img src=\"icons/exclamation-red.png\" border=\"0\">&nbsp;URL chunk size cannot be blank.<br>";
}
if ($chunksuppld) {
putsetting('url_chunk_size',$display_urlchunk,$techid);
putsetting('show_ts',$display_showts,$techid);
putsetting('tech_alpha',$display_techalpha,$techid);
putsetting('subj_alpha',$display_subjalpha,$techid);
putsetting('log_style',$display_logstyle,$techid);
putsetting('url_chunk_size', $display_urlchunk, $techid);
putsetting('show_ts', $display_showts, $techid);
putsetting('tech_alpha', $display_techalpha, $techid);
putsetting('subj_alpha', $display_subjalpha, $techid);
putsetting('log_style', $display_logstyle, $techid);
}
}
if ($setcolor) {
// color settings
$hexcolor="#".ltrim($hexcolor);
putsetting($modcolor,$hexcolor,$techid);
$hexcolor = "#" . ltrim($hexcolor);
putsetting($modcolor, $hexcolor, $techid);
}
if ($resetcustom) mysqli_query($db,"delete from customs where customtech=\"$techid\"");
if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\"");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
// pull my current data from tables
$curname=dblookup($db,"techs","techid","techname",$techid);
$curshift=dblookup($db,"techs","techid","shift",$techid);
$pass=$passconf="password_is_unchanged";
$curname = dblookup($db, "techs", "techid", "techname", $techid);
$curshift = dblookup($db, "techs", "techid", "shift", $techid);
$pass = $passconf = "password_is_unchanged";
// other values from customs
$curlchunk=getsetting('url_chunk_size',$techid)["value"];
$curts=getsetting('show_ts',$techid)["value"];
$curtdo=getsetting('tech_alpha',$techid)["value"];
$cursdo=getsetting('subj_alpha',$techid)["value"];
$curbgc=getsetting('background_color',$techid)["value"];
$cursbc=getsetting('sidebar_color',$techid)["value"];
$curmbgc=getsetting('menubg_color',$techid)["value"];
$curtc=getsetting('text_color',$techid)["value"];
$curlc=getsetting('link_color',$techid)["value"];
$curvlc=getsetting('vlink_color',$techid)["value"];
$curhc=getsetting('heading_color',$techid)["value"];
$curlogstyle=getsetting('log_style',$techid)["value"];
$curlchunk = getsetting('url_chunk_size', $techid)["value"];
$curts = getsetting('show_ts', $techid)["value"];
$curtdo = getsetting('tech_alpha', $techid)["value"];
$cursdo = getsetting('subj_alpha', $techid)["value"];
$curbgc = getsetting('background_color', $techid)["value"];
$cursbc = getsetting('sidebar_color', $techid)["value"];
$curmbgc = getsetting('menubg_color', $techid)["value"];
$curtc = getsetting('text_color', $techid)["value"];
$curlc = getsetting('link_color', $techid)["value"];
$curvlc = getsetting('vlink_color', $techid)["value"];
$curhc = getsetting('heading_color', $techid)["value"];
$curlogstyle = getsetting('log_style', $techid)["value"];
// show the form
echo "
@@ -149,19 +152,19 @@ Password: &nbsp;<input type=\"password\" name=\"pass\" size=\"40\" value=\"$pass
Repeat Password: &nbsp;<input type=\"password\" name=\"passconf\" size=\"40\" value=\"$passconf\"><br><br>
<font size=\"-1\">Need a random password? &nbsp;</font>
";
$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12);
$rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12);
echo "
&nbsp; $rpw<br><br>
<b>Shift: </b>&nbsp;
<select name=\"shift\">
";
$shiftrow=mysqli_query($db,"select * from shifts");
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
$shiftrow = mysqli_query($db, "select * from shifts");
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"]==$curshift) {
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
if ($shiftitem["shiftid"] == $curshift) {
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
} else {
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
}
}
}
@@ -176,12 +179,12 @@ echo "
<b>My Display Preferences</b><br><br>
Log style (the look of the log notes display): &nbsp;&nbsp;<select name=\"display_logstyle\">
";
$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\"");
while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) {
if ($logstylerow["styleid"]==$curlogstyle) {
printf("<option value=\"%s\" selected>%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
$logstyleqry = mysqli_query($db, "select styleid,stylename from styles where styletype=\"logdisplay\"");
while ($logstylerow = mysqli_fetch_assoc($logstyleqry)) {
if ($logstylerow["styleid"] == $curlogstyle) {
printf("<option value=\"%s\" selected>%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
} else {
printf("<option value=\"%s\">%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
printf("<option value=\"%s\">%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
}
}
echo "
@@ -236,7 +239,7 @@ echo "
<hr>
<b>My Color Preferences</b><br><br>
";
switch($modcolor) {
switch ($modcolor) {
case "background_color":
echo "<table border=\"0\"><tr><td>Page background color</td><td>";
colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor=");
@@ -290,9 +293,7 @@ echo "
</form>
";
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

View File

@@ -9,69 +9,70 @@
include("functions.php");
$print=$_REQUEST['print'] ?? "";
$chainnote=$_REQUEST['chainnote'];
$print = $_REQUEST['print'] ?? "";
$chainnote = $_REQUEST['chainnote'] ?? NULL;
$logname=LOG_NAME;
$logname = LOG_NAME;
if ($print) {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Reference Chain Display",$print);
framework("begin", "$logname", "Reference Chain Display", $print);
// ******** begin database manipulation ********
$master=generate_chain($chainnote);
$master = generate_chain($chainnote);
// ******** end database manipulation ********
pagetable("begin");
if(!$print){
pageblock("left","begin");
if (!$print) {
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
// display the chain
$mptr=0;
$mptr = 0;
echo "<br><br><table border=\"1\" width=\"100%\">";
echo "<tr><th>Note ID</th><th>Date &#47; Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>";
while($mptr<count($master)) {
if(mysqli_num_rows(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"))) {
$tablerow = mysqli_fetch_assoc(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"));
$noteid=$tablerow["lognoteid"];
$urldatestr="y=".date("Y",strtotime($tablerow["date"]))."&m=".date("m",strtotime($tablerow["date"]))."&d=".date("d",strtotime($tablerow["date"]));
$refs="&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>";
while ($mptr < count($master)) {
if (mysqli_num_rows(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"))) {
$tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"));
$noteid = $tablerow["lognoteid"];
$urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"]));
$refs = "&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>";
// convert the shift number to a name
$shname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
//convert subject number to name
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
// create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]);
$fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$flagmapqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$noteid");
$flagstring = "";
$flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid");
if (mysqli_num_rows($flagmapqry)) {
while ($flagids=mysqli_fetch_row($flagmapqry)) {
$flagid=$flagids[0];
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
while ($flagids = mysqli_fetch_row($flagmapqry)) {
$flagid = $flagids[0];
$flagparam = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid\""));
$flagcolor = $flagparam["flagcolor"];
$flagsym = $flagparam["flagsym"];
$flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
}
}
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
printf("
if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
printf(
"
<tr>
<td><a href=\"logentry.php?edit=1&noteid=%s\">%s</a></td>
<td>%s &#47; %s</td>
@@ -81,23 +82,24 @@ while($mptr<count($master)) {
<td>%s</td>
<td>%s</td>
</tr>",
$tablerow["lognoteid"],$tablerow["lognoteid"],
$tablerow["date"],$tablerow["time"],
$shname,
$tname,
$subjname,
$fmtnote,
$refs);
$tablerow["lognoteid"],
$tablerow["lognoteid"],
$tablerow["date"],
$tablerow["time"],
$shname,
$tname,
$subjname,
$fmtnote,
$refs
);
} else {
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n",$master[$mptr]);
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n", $master[$mptr]);
}
$mptr=$mptr+1;
$mptr = $mptr + 1;
}
echo "</table><br><br>";
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -11,55 +11,53 @@
$today = date("Y-m-d");
$now = date("H:i:s");
$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0];
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0];
$ostype = strtoupper(substr(php_uname('s'), 0, 3));
if ($ostype == 'WIN') {
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0];
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0];
} else {
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
}
$lifetime=60 * 60 * 24 * $sttl;
$lifetime = 60 * 60 * 24 * $sttl;
if (!is_dir($sdir)) mkdir($sdir, 0700, true);
ini_set('session.cookie_lifetime', $lifetime);
ini_set('session.gc_maxlifetime', $lifetime);
ini_set('session.save_path', $sdir);
$ss=session_status();
if ($ss==PHP_SESSION_NONE) session_start();
$ss = session_status();
if ($ss == PHP_SESSION_NONE) session_start();
// get config options from database and assign them to constants
unset($techid);
if (isset($_SESSION['login']) && $_SESSION['login'] != '') {
$techid=$_SESSION['login'];
$techid = $_SESSION['login'];
}
$configqry=mysqli_query($db,"select confname,confvalue,confid from configs");
$configqry = mysqli_query($db, "select confname,confvalue,confid from configs");
while ($configrow = mysqli_fetch_assoc($configqry)) {
$constname=strtoupper($configrow["confname"]);
$constname = strtoupper($configrow["confname"]);
if (isset($techid)) {
$confid=$configrow["confid"];
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
$confid = $configrow["confid"];
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
if (mysqli_num_rows($custqry)) {
$custrow=mysqli_fetch_row($custqry);
$custval=$custrow[0];
$custrow = mysqli_fetch_row($custqry);
$custval = $custrow[0];
} else {
unset($custval);
}
}
if (isset($custval)) {
$constvalue=$custval;
$constvalue = $custval;
} else {
$constvalue=$configrow["confvalue"];
$constvalue = $configrow["confvalue"];
}
define("$constname","$constvalue");
define("$constname", "$constvalue");
}
// error reporting
$logerrors=LOG_ERRORS;
if ($logerrors==1) {
$logerrors = LOG_ERRORS;
if ($logerrors == 1) {
error_reporting(E_ALL);
} else {
error_reporting(0);
}
?>

View File

@@ -10,72 +10,73 @@
include("functions.php");
if (!$_SESSION['login'] && !$_REQUEST['partview']) {
header ("Location: login.php");
header("Location: login.php");
}
$techid=$_SESSION['login'] ?? NULL;
$isadmin=dblookup($db,"techs","techid","admin",$techid);
$print=$_REQUEST['print'] ?? NULL;
$efftechid=$_REQUEST['efftechid'] ?? NULL;
$shift=$_REQUEST['shift'] ?? NULL;
$subject=$_REQUEST['subject'] ?? NULL;
$note=$_REQUEST['note'] ?? NULL;
$flags=$_POST['flags'] ?? [];
$refstring=$_REQUEST['refstring'] ?? NULL;
$submit=$_REQUEST['submit'] ?? NULL;
$operation=$_REQUEST['operation'] ?? NULL;
$templateid=$_REQUEST['templateid'] ?? NULL;
$templatename=$_REQUEST['templatename'] ?? NULL;
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL;
$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL;
$techid = $_SESSION['login'] ?? NULL;
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
$print = $_REQUEST['print'] ?? NULL;
$efftechid = $_REQUEST['efftechid'] ?? NULL;
$shift = $_REQUEST['shift'] ?? NULL;
$subject = $_REQUEST['subject'] ?? NULL;
$note = $_REQUEST['note'] ?? NULL;
$flags = $_POST['flags'] ?? [];
$refstring = $_REQUEST['refstring'] ?? NULL;
$submit = $_REQUEST['submit'] ?? NULL;
$operation = $_REQUEST['operation'] ?? NULL;
$templateid = $_REQUEST['templateid'] ?? NULL;
$templatename = $_REQUEST['templatename'] ?? NULL;
$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL;
$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL;
$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL;
$logname=LOG_NAME;
$techalpha=TECH_ALPHA;
$subjalpha=SUBJ_ALPHA;
$logname = LOG_NAME;
$techalpha = TECH_ALPHA;
$subjalpha = SUBJ_ALPHA;
$defaultshift=dblookup($db,"techs","techid","shift",$techid);
$defaultshift = dblookup($db, "techs", "techid", "shift", $techid);
if ($print=="Printer Friendly") {
$sbcolor=P_SIDEBAR_COLOR;
$mbgcolor=P_MENUBG_COLOR;
if ($print == "Printer Friendly") {
$sbcolor = P_SIDEBAR_COLOR;
$mbgcolor = P_MENUBG_COLOR;
} else {
$sbcolor=SIDEBAR_COLOR;
$mbgcolor=MENUBG_COLOR;
$sbcolor = SIDEBAR_COLOR;
$mbgcolor = MENUBG_COLOR;
}
framework("begin","$logname","Note Templates",$print);
framework("begin", "$logname", "Note Templates", $print);
// make basic determination about authorization
if ($isadmin) {
$authorized=TRUE;
} else if ($efftechid==$techid) {
$authorized=TRUE;
$authorized = TRUE;
} else if ($efftechid == $techid) {
$authorized = TRUE;
} else {
$authorized=FALSE;
$authorized = FALSE;
}
// var_dump($_REQUEST);
function templatetable($db,$techid,$user) {
function templatetable($db, $techid, $user)
{
// Show template table
$isadmin=dblookup($db,"techs","techid","admin",$techid);
$templatequery=mysqli_query($db,"select * from notetemplates where tech=\"$user\" order by templatename asc");
$tblusername=dblookup($db,"techs","techid","techname",$user);
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
$templatequery = mysqli_query($db, "select * from notetemplates where tech=\"$user\" order by templatename asc");
$tblusername = dblookup($db, "techs", "techid", "techname", $user);
if (mysqli_num_rows($templatequery)) {
$hastemplates=TRUE;
$hastemplates = TRUE;
} else {
$hastemplates=FALSE;
$hastemplates = FALSE;
}
echo "<b><font size=\"+1\">";
if ($hastemplates) {
// print the user header
if ($user=="0") {
if ($user == "0") {
echo "Global Templates</font></b>";
} else {
if ($user==$techid) {
if ($user == $techid) {
echo "My templates</font></b>";
} else {
echo "Templates for $tblusername</font></b>";
@@ -85,62 +86,62 @@ function templatetable($db,$techid,$user) {
echo "<br><table border=\"1\" width=\"100%\">";
echo "<tr><th width=\"70\">Template Name</th><th width=\"100\">Shift</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>";
while ($tablerow = mysqli_fetch_assoc($templatequery)) {
$templateid=$tablerow["templateid"];
$templatename=$tablerow["templatename"];
$templateid = $tablerow["templateid"];
$templatename = $tablerow["templatename"];
// convert shift number to name
$shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
$shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
// convert subject number to name
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
// create links of urls in note
$fmtnote=convertweblinks($tablerow["lognote"]);
$fmtnote = convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
$flagstring = "";
$flagqry = mysqli_query($db, "select flagid from flagmap where notetemplateid=$templateid");
while ($flagid = mysqli_fetch_row($flagqry)) {
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
$flagcolor = $flagparams["flagcolor"];
$flagsym = $flagparams["flagsym"];
$flagname = $flagparams["flagname"];
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote=$fmtnote."<br>";
$fmtnote = $fmtnote . "<br>" . $flagstring . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote = $fmtnote . "<br>";
}
// generate a reference string
$refstring=NULL;
$refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\"");
while ($tgt=mysqli_fetch_row($refstringqry)) {
$refstring=$refstring." ".$tgt[0];
$refstring = NULL;
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
while ($tgt = mysqli_fetch_row($refstringqry)) {
$refstring = $refstring . " " . $tgt[0];
}
// now print the line in the table
if (!$isadmin && $user=="0") {
$nameblock="$templatename</a>";
if (!$isadmin && $user == "0") {
$nameblock = "$templatename</a>";
} else {
$nameblock="<a href=\"templates.php?operation=edit&templateid=$templateid\">$templatename</a>";
$nameblock = "<a href=\"templates.php?operation=edit&templateid=$templateid\">$templatename</a>";
}
printf(
"<tr>
"<tr>
<td valign=\"top\">%s</td>
<td valign=\"top\"> %s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
<td valign=\"top\">%s</td>
</tr>\n",
$nameblock,
$shiftname,
$subjname,
$fmtnote,
$refstring
$nameblock,
$shiftname,
$subjname,
$fmtnote,
$refstring
);
};
echo "</table><br><hr><br>";
} else {
if ($user=="0") {
if ($user == "0") {
echo "There are no global templates</font></b>";
} else {
if ($user==$techid) {
if ($user == $techid) {
echo "You have no templates</font></b>";
} else {
echo "$tblusername has no templates</font></b>";
@@ -154,108 +155,108 @@ function templatetable($db,$techid,$user) {
// ******** begin database manipulation ********
if ($usertemplateid) {
$templateid=$usertemplateid;
$templateid = $usertemplateid;
} else if ($globaltemplateid) {
$templateid=$globaltemplateid;
$templateid = $globaltemplateid;
} else {
$loadtemplate=NULL;
$loadtemplate = NULL;
}
if ($operation=="add") {
if ($submit) {
if ($operation == "add") {
if ($submit) {
if ($note) {
// remove cruft from note text
$note=strip_tags($note,"<a>");
$note=mysqli_real_escape_string($db,$note);
$note = strip_tags($note, "<a>");
$note = mysqli_real_escape_string($db, $note);
if ($authorized) {
// check if name supplied
if ($templatename) {
$namesupplied=TRUE;
$namesupplied = TRUE;
// check if supplied name already exists
if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) {
if (! mysqli_num_rows(mysqli_query($db, "select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) {
// add the record to notetemplates
mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")");
$newtemplateid=mysqli_insert_id($db);
mysqli_query($db, "insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")");
$newtemplateid = mysqli_insert_id($db);
// update the flagmap table
foreach ($flags as $thisflag) {
// set flag for this note
mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")");
mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")");
}
// add references to the reflinks table
if (strlen($refstring)) {
$refstring=trim($refstring);
$refarray=explode(" ",$refstring);
$refstring = trim($refstring);
$refarray = explode(" ", $refstring);
foreach ($refarray as $target) {
mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)");
mysqli_query($db, "insert into reflinks(templateid,target) values($newtemplateid,$target)");
}
}
$templateid=$newtemplateid;
$templateid = $newtemplateid;
} else {
$nameexists=TRUE;
$nameexists = TRUE;
}
} else {
$namesupplied=FALSE;
$namesupplied = FALSE;
}
}
}
}
}
if ($operation=="edit" || $operation=="delete") {
if ($operation == "edit" || $operation == "delete") {
// test to see if this templateid is owned by techid to prevent hijacking
$owner=dblookup($db,"notetemplates","templateid","tech",$templateid);
if (!$isadmin && ($owner!=$techid)) $authorized=FALSE;
if ($submit) {
$owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid);
if (!$isadmin && ($owner != $techid)) $authorized = FALSE;
if ($submit) {
if ($note) {
// remove cruft from note text
$note=strip_tags($note,"<a>");
$note=mysqli_real_escape_string($db,$note);
$note = strip_tags($note, "<a>");
$note = mysqli_real_escape_string($db, $note);
if ($templatename) {
$namesupplied=TRUE;
$namesupplied = TRUE;
} else {
$namesupplied=FALSE;
$namesupplied = FALSE;
}
if ($authorized) {
// check if name was supplied
if ($templatename) {
// update notetemplates
mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\"");
mysqli_query($db, "update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\"");
// update the flagmap table
mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\"");
mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\"");
foreach ($flags as $thisflag) {
// set flag for this note
mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")");
mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")");
}
// update the reflinks table
mysqli_query($db,"delete from reflinks where templateid=\"$templateid\"");
mysqli_query($db, "delete from reflinks where templateid=\"$templateid\"");
if (strlen($refstring)) {
$refstring=trim($refstring);
$refarray=explode(" ",$refstring);
$refstring = trim($refstring);
$refarray = explode(" ", $refstring);
foreach ($refarray as $target) {
mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)");
mysqli_query($db, "insert into reflinks(templateid,target) values($templateid,$target)");
}
}
}
}
}
}
if ($operation=="delete") {
if ($operation == "delete") {
if ($authorized) {
// update notetemplates
mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\"");
mysqli_query($db, "delete from notetemplates where templateid=\"$templateid\"");
// update the flagmap table
mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\"");
mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\"");
// update the reflinks table
mysqli_query($db,"delete from reflinks where templateid=\"$templateid\"");
$templateid=NULL;
$note=NULL;
mysqli_query($db, "delete from reflinks where templateid=\"$templateid\"");
$templateid = NULL;
$note = NULL;
}
}
}
@@ -264,118 +265,118 @@ if ($operation=="edit" || $operation=="delete") {
pagetable("begin");
if (!$print) {
pageblock("left","begin");
pageblock("left", "begin");
sidemenu();
pageblock("left","end");
pageblock("left", "end");
}
pageblock("right","begin");
pageblock("right", "begin");
banner($print);
if ($submit || $operation=="delete") {
if ($submit || $operation == "delete") {
// show success/failure messages
$nameexists=$nameexists ?? NULL;
$namesupplied=$namesupplied ?? NULL;
if ($operation=="add") {
$addfail=FALSE;
$nameexists = $nameexists ?? NULL;
$namesupplied = $namesupplied ?? NULL;
if ($operation == "add") {
$addfail = FALSE;
if ($nameexists) {
format_message(1,"Template creation failed because the name you supplied already exists. Please try again.");
$addfail=TRUE;
format_message(1, "Template creation failed because the name you supplied already exists. Please try again.");
$addfail = TRUE;
}
if (!$namesupplied) {
format_message(1,"Template creation failed because you didn't supply a name. Please try again.");
$addfail=TRUE;
format_message(1, "Template creation failed because you didn't supply a name. Please try again.");
$addfail = TRUE;
}
if (!$note) {
format_message(1,"Template creation failed because you didn't enter any note text. Please try again.");
$addfail=TRUE;
format_message(1, "Template creation failed because you didn't enter any note text. Please try again.");
$addfail = TRUE;
}
if (!$authorized) {
format_message(1,"Template creation failed because you are not authorized to do so.");
$addfail=TRUE;
format_message(1, "Template creation failed because you are not authorized to do so.");
$addfail = TRUE;
}
if (!$addfail) format_message(0,"<strong>Template created.</strong>");
if (!$addfail) format_message(0, "<strong>Template created.</strong>");
}
if ($operation=="edit") {
$editfail=FALSE;
if ($operation == "edit") {
$editfail = FALSE;
if (!$namesupplied) {
format_message(1,"Template save failed because you didn't supply a name. Please try again.");
$editfail=TRUE;
format_message(1, "Template save failed because you didn't supply a name. Please try again.");
$editfail = TRUE;
}
if (!$note) {
format_message(1,"Template save failed because you didn't enter any note text. Please try again.");
$editfail=TRUE;
format_message(1, "Template save failed because you didn't enter any note text. Please try again.");
$editfail = TRUE;
}
if (!$authorized) {
format_message(1,"Template save failed because you are not authorized to do so.");
$editfail=TRUE;
format_message(1, "Template save failed because you are not authorized to do so.");
$editfail = TRUE;
}
if (!$editfail) format_message(0,"<strong>Template modified.</strong>");
if (!$editfail) format_message(0, "<strong>Template modified.</strong>");
}
if ($operation=="delete") {
$deletefail=FALSE;
if ($operation == "delete") {
$deletefail = FALSE;
if (!$authorized) {
format_message(1,"Template delete failed because you are not authorized to do so.");
$deletefail=TRUE;
format_message(1, "Template delete failed because you are not authorized to do so.");
$deletefail = TRUE;
}
if (!$deletefail) format_message(0,"<strong>Template deleted.</strong>");
if (!$deletefail) format_message(0, "<strong>Template deleted.</strong>");
}
}
if ($operation=="delete") {
if ($operation == "delete") {
// just show the link back to the templates page
echo "
<br><a href=\"templates.php\">Manage templates</a><br><br><br><br>
";
} else if ($operation=="add" || $operation=="edit") {
} else if ($operation == "add" || $operation == "edit") {
// Display the input form
if ($loadtemplate) {
// make templateid the selected template
if ($usertemplateid) {
$templateid=$usertemplateid;
$templateid = $usertemplateid;
} else if ($globaltemplateid) {
$templateid=$globaltemplateid;
$templateid = $globaltemplateid;
} else {
$templateid=NULL;
$templateid = NULL;
}
}
if ($operation=="edit" || $loadtemplate) {
if ($operation == "edit" || $loadtemplate) {
// use values from the templateid supplied with a defined tech id
$loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""));
$filltemplatename=$loadeddata["templatename"];
$loadeddata = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""));
$filltemplatename = $loadeddata["templatename"];
if ($efftechid) {
$filltech=$efftechid;
} else if ($isadmin && $loadeddata["tech"]=="0") {
$filltech="0";
$filltech = $efftechid;
} else if ($isadmin && $loadeddata["tech"] == "0") {
$filltech = "0";
} else {
$filltech=$techid;
$filltech = $techid;
}
$fillshift=$loadeddata["shift"];
$fillsubject=$loadeddata["subject"];
$fillnote=$loadeddata["lognote"];
$fillshift = $loadeddata["shift"];
$fillsubject = $loadeddata["subject"];
$fillnote = $loadeddata["lognote"];
} else {
// use empty values with a defined tech id
$filltemplatename=NULL;
$filltemplatename = NULL;
if ($efftechid) {
$filltech=$efftechid;
$filltech = $efftechid;
} else {
$filltech=$techid;
$filltech = $techid;
}
$fillshift=$defaultshift;
$fillsubject=NULL;
$fillnote=NULL;
$fillshift = $defaultshift;
$fillsubject = NULL;
$fillnote = NULL;
}
if ($operation=="add") $optext="Creating new";
if ($operation=="edit") $optext="Editing";
if ($operation == "add") $optext = "Creating new";
if ($operation == "edit") $optext = "Editing";
echo "
<br><b>$optext template</b><br><hr>
";
// show the template selection line
templateselect($techid,$operation);
templateselect($techid, $operation);
// start template entry section
echo "
<form method=\"post\" action=\"templates.php\">
@@ -388,25 +389,26 @@ if ($operation=="delete") {
<tr><td colspan=\"2\"><b>Tech: </b>&nbsp;
<select name=\"efftechid\">
";
if ($filltech=="0") {
if ($filltech == "0") {
echo "<option value=\"0\" selected>--Global Template--</option>";
} else {
echo "<option value=\"0\">--Global Template--</option>";
}
if ($techalpha) $torder="techname"; else $torder="techid";
$techrow=mysqli_query($db,"select * from techs order by $torder asc");
while ($techitem=mysqli_fetch_assoc($techrow)) {
if ($techitem["techid"]==$filltech) {
printf("<option value=\"%s\" selected>%s</option>",$techitem["techid"],$techitem["techname"]);
if ($techalpha) $torder = "techname";
else $torder = "techid";
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
while ($techitem = mysqli_fetch_assoc($techrow)) {
if ($techitem["techid"] == $filltech) {
printf("<option value=\"%s\" selected>%s</option>", $techitem["techid"], $techitem["techname"]);
} else {
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]);
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
}
}
echo "
</select></td></tr>
";
} else {
$authorized=TRUE;
$authorized = TRUE;
echo "
<input type=\"hidden\" name=\"efftechid\" value=\"$techid\">
";
@@ -416,13 +418,13 @@ if ($operation=="delete") {
<td><b>Shift: </b>&nbsp;
<select name=\"shift\">
";
$shiftrow=mysqli_query($db,"select * from shifts");
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
$shiftrow = mysqli_query($db, "select * from shifts");
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"]==$fillshift) {
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
if ($shiftitem["shiftid"] == $fillshift) {
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
} else {
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
}
}
}
@@ -431,18 +433,19 @@ if ($operation=="delete") {
<td><b>Subject: </b>&nbsp;
<select name=\"subject\">
";
if ($subjalpha) $sorder="subjectname"; else $sorder="subjectid";
$subjrow=mysqli_query($db,"select * from subjects order by $sorder asc");
while ($subjitem=mysqli_fetch_assoc($subjrow)) {
if ($subjitem["status"]==1) {
if ($subjitem["subjectid"]==$fillsubject) {
printf("<option value=\"%s\" selected>%s</option>",$subjitem["subjectid"],$subjitem["subjectname"]);
if ($subjalpha) $sorder = "subjectname";
else $sorder = "subjectid";
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
if ($subjitem["status"] == 1) {
if ($subjitem["subjectid"] == $fillsubject) {
printf("<option value=\"%s\" selected>%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
} else {
printf("<option value=\"%s\">%s</option>",$subjitem["subjectid"],$subjitem["subjectname"]);
printf("<option value=\"%s\">%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
}
}
}
echo "
</select></td>
</tr></table>
@@ -454,50 +457,60 @@ if ($operation=="delete") {
<input type=\"text\" size=\"23\" id=\"linkurlfield\" placeholder=\"Enter URL here\">&nbsp;
<a href=\"#\" onclick=\"insertUrlAtCaret('notetextarea','linktextfield','linkurlfield');return false;\">Insert Link</a><br>
";
// create an array called theseflags and optionally load it with flagids set for this template
unset($theseflags);
$theseflags=[];
$theseflags = [];
if ($templateid) {
$allflags=mysqli_query($db,"select flagid from flags");
while ($thisflag=mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) {
$theseflags[]=$thisflag[0];
$allflags = mysqli_query($db, "select flagid from flags");
while ($thisflag = mysqli_fetch_row($allflags)) {
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) {
$theseflags[] = $thisflag[0];
}
}
}
$flagslist=mysqli_query($db,"select * from flags where status=1");
$flagsperline=8;
$flagcount=1;
$flagslist = mysqli_query($db, "select * from flags where status=1");
$flagsperline = 8;
$flagcount = 1;
// display checkboxes for all the flags, selecting the ones that are set for this template
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if ($operation=="edit" && 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"]);
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
if ($operation == "edit" && 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"]);
$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) {
if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount=1;
$flagcount = 1;
}
}
if ($operation=="edit" || $loadtemplate) {
if ($operation == "edit" || $loadtemplate) {
// generate a reference string
$refstring=NULL;
$refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\"");
while ($tgt=mysqli_fetch_row($refstringqry)) {
$refstring=$refstring." ".$tgt[0];
$refstring = NULL;
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
while ($tgt = mysqli_fetch_row($refstringqry)) {
$refstring = $refstring . " " . $tgt[0];
}
}
echo "
@@ -505,14 +518,14 @@ if ($operation=="delete") {
<input type=\"text\" name=\"refstring\" size=\"20\" value=\"$refstring\" title=\"One or more Note ID numbers separated by spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
";
if ($operation=="add" && $authorized) {
if ($operation == "add" && $authorized) {
echo "
<input type=\"hidden\" name=\"operation\" value=\"add\">
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
";
}
if ($operation=="edit" && $authorized) {
if ($operation == "edit" && $authorized) {
echo "
<input type=\"hidden\" name=\"operation\" value=\"edit\">
<input type=\"hidden\" name=\"templateid\" value=\"$templateid\">
@@ -521,34 +534,32 @@ if ($operation=="delete") {
<button type=\"submit\" name=\"operation\" value=\"delete\">Delete this template</button><font color=\"#FF0000\"><b>Deleted templates are irretrievable!</b></font>
";
}
echo "
</form>
<br>
";
} else {
echo "<br><font size= \"+1\"><b><a href=\"templates.php?operation=add\">Create or copy a template</a></b></font><br><hr>";
// Show my user template table
templatetable($db,$techid,$techid);
templatetable($db, $techid, $techid);
// Show global template table
templatetable($db,$techid,"0");
templatetable($db, $techid, "0");
if ($isadmin) {
// Show template tables for other users
$techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0");
while ($techtblrow=(mysqli_fetch_row($techqry))) {
templatetable($db,$techid,$techtblrow[0]);
$techqry = mysqli_query($db, "select techid from techs where techid != $techid and techid != 0");
while ($techtblrow = (mysqli_fetch_row($techqry))) {
templatetable($db, $techid, $techtblrow[0]);
}
}
}
banner($print);
pageblock("right","end");
pageblock("right", "end");
pagetable("end");
framework("end","","",$print);
?>
framework("end", "", "", $print);