Updated various files where the version number exists.
Continued work on templates.php.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
logentry.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -18,22 +18,20 @@ $isadmin=dblookup($db,"techs","techid","admin",$techid);
|
||||
$efftechid=$_REQUEST['efftechid'] ?? NULL;
|
||||
$noteid=$_REQUEST['noteid'] ?? NULL;
|
||||
$print=$_REQUEST['print'] ?? NULL;
|
||||
$refto=$_REQUEST['refto'] ?? NULL;
|
||||
$date=$_REQUEST['date'] ?? NULL;
|
||||
$time=$_REQUEST['time'] ?? NULL;
|
||||
$note=$_REQUEST['note'] ?? NULL;
|
||||
$shift=$_REQUEST['shift'] ?? NULL;
|
||||
$subject=$_REQUEST['subject'] ?? NULL;
|
||||
$refs=$_REQUEST['refs'] ?? NULL;
|
||||
$refstring=$_REQUEST['refstring'] ?? NULL;
|
||||
$refto=$_REQUEST['refto'] ?? NULL;
|
||||
$submit=$_REQUEST['submit'] ?? NULL;
|
||||
$add=$_REQUEST['add'] ?? NULL;
|
||||
$edit=$_REQUEST['edit'] ?? NULL;
|
||||
$delete=$_REQUEST['delete'] ?? NULL;
|
||||
$templateid=$_REQUEST['templateid'] ?? NULL;
|
||||
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
|
||||
$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL;
|
||||
$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL;
|
||||
$savetemplate=$_REQUEST['savetemplate'] ?? NULL;
|
||||
$copytemplate=$_REQUEST['copytemplate'] ?? NULL;
|
||||
$deltemplate=$_REQUEST['deltemplate'] ?? NULL;
|
||||
$templatename=$_REQUEST['templatename'] ?? NULL;
|
||||
$removepart=$_REQUEST['removepart'] ?? NULL;
|
||||
$syncflags=$_REQUEST['syncflags'] ?? NULL;
|
||||
@@ -63,20 +61,36 @@ if ($print=="Printer Friendly") {
|
||||
}
|
||||
if ($partview) $edit=1;
|
||||
if (!$add && !$edit && !$delete && !$submit) $add=1;
|
||||
|
||||
if ($isadmin) {
|
||||
$authorized=TRUE;
|
||||
} else {
|
||||
$authorized=FALSE;
|
||||
}
|
||||
|
||||
if ($add) {
|
||||
framework("begin","$logname","Note Entry",$print);
|
||||
$authorized=1;
|
||||
$authorized=TRUE;
|
||||
}
|
||||
if ($edit || $delete) {
|
||||
framework("begin","$logname","Note Edit",$print);
|
||||
$owner=dblookup($db,"lognotes","lognoteid","tech",$noteid);
|
||||
if (($techid==$owner) || $isadmin) $authorized=1;
|
||||
if ($techid==$owner) $authorized=TRUE;
|
||||
}
|
||||
|
||||
//var_dump($_REQUEST);
|
||||
// var_dump($_REQUEST);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
if ($usertemplateid) {
|
||||
$templateid=$usertemplateid;
|
||||
} else if ($globaltemplateid) {
|
||||
$templateid=$globaltemplateid;
|
||||
} else {
|
||||
$templateid=NULL;
|
||||
$loadtemplate=NULL;
|
||||
}
|
||||
|
||||
if ($add) {
|
||||
if ($submit) {
|
||||
// add the entry if submit is pressed
|
||||
@@ -100,9 +114,12 @@ if ($add) {
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
// remove cruft from references and sanitize
|
||||
$refs=preg_replace("#[a-zA-Z]{1,}#","",$refs);
|
||||
$refs=mysqli_real_escape_string($db,$refs);
|
||||
if (strlen($refstring)) {
|
||||
// remove everything except numbers and spaces from references and sanitize
|
||||
$refstring=preg_replace("#[^\d ]{1,}#"," ",$refstring);
|
||||
$refstring=mysqli_real_escape_string($db,$refstring);
|
||||
$refstring=trim($refstring);
|
||||
}
|
||||
|
||||
if ($doparts==1) {
|
||||
// inspect part data
|
||||
@@ -137,19 +154,29 @@ if ($add) {
|
||||
}
|
||||
if ($authorized) {
|
||||
// add the record to lognotes
|
||||
mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote,refs) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\",\"$refs\")");
|
||||
mysqli_query($db,"insert into lognotes(date,time,shift,tech,subject,lognote) values (\"$date\", \"$time\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")");
|
||||
$newnoteid=mysqli_insert_id($db);
|
||||
|
||||
// add this noteid to the appropriate flag_tables
|
||||
// add references to the reflinks table
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refarray=explode(" ",$refstring);
|
||||
foreach ($refarray as $target) {
|
||||
mysqli_query($db,"insert into reflinks(noteid,target) values($newnoteid,$target)");
|
||||
}
|
||||
}
|
||||
$chainmembers=generate_chain($newnoteid);
|
||||
foreach ($flags as $flagtblnum) {
|
||||
$flagtblname="flag_".$flagtblnum;
|
||||
|
||||
// update the flagmap table
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$newnoteid\")");
|
||||
mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$newnoteid\")");
|
||||
if ($syncflags) {
|
||||
//set flag for reference chain notes
|
||||
foreach ($chainmembers as $refdnote) {
|
||||
mysqli_query($db,"insert into $flagtblname(target,id) values(\"lognotes\",\"$refdnote\")");
|
||||
if ($refdnote != $newnoteid) {
|
||||
mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,98 +247,17 @@ if ($add) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($loadtemplate) {
|
||||
if ($templateid) {
|
||||
$templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""));
|
||||
$defaultshift=$templatevalues["shift"];
|
||||
$defaultsubject=$templatevalues["subject"];
|
||||
$note=$templatevalues["lognote"];
|
||||
$refto=$templatevalues["refs"];
|
||||
$techid=$templatevalues["tech"];
|
||||
} else {
|
||||
if ($loadtemplate) {
|
||||
$templatevalues=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""));
|
||||
$defaultshift=$templatevalues["shift"];
|
||||
$defaultsubject=$templatevalues["subject"];
|
||||
$note=$templatevalues["lognote"];
|
||||
$refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\"");
|
||||
while ($thistgt=mysqli_fetch_row($refstringqry)) {
|
||||
$refstring=$refstring." ".$thistgt[0];
|
||||
}
|
||||
} elseif ($savetemplate) {
|
||||
if ($note) {
|
||||
// remove cruft from note text
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
// remove cruft from references
|
||||
$refs=preg_replace("#[a-zA-Z]{1,}#","",$refs);
|
||||
if ($authorized) {
|
||||
if ($templateid) {
|
||||
// update the existing template
|
||||
mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where templateid=\"$templateid\"");
|
||||
|
||||
// update the flag_ tables
|
||||
$flagids=mysqli_query($db,"select flagid from flags");
|
||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
||||
$thisflag_tbl="flag_".$thisflagid[0];
|
||||
if ($flags[0]=="") $flags=[];
|
||||
if (in_array($thisflagid[0],$flags)) {
|
||||
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) {
|
||||
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"notetemplates\",\"$templateid\")");
|
||||
}
|
||||
} else {
|
||||
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\""))) {
|
||||
mysqli_query($db,"delete from $thisflag_tbl where target=\"notetemplates\" and id=\"$templateid\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// check if supplied name already exists
|
||||
if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) {
|
||||
// add the record to notetemplates
|
||||
mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")");
|
||||
$newtemplateid=mysqli_insert_id($db);
|
||||
|
||||
// add this templateid to the appropriate flag_tables
|
||||
foreach ($flags as $flagtblnum) {
|
||||
$flagtblname="flag_".$flagtblnum;
|
||||
mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")");
|
||||
}
|
||||
$templateid=$newtemplateid;
|
||||
} else {
|
||||
$save_nameexists=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($copytemplate) {
|
||||
if ($note) {
|
||||
// remove cruft from note text
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
// remove cruft from references
|
||||
$refs=preg_replace("#[a-zA-Z]{1,}#","",$refs);
|
||||
if ($authorized) {
|
||||
// check if supplied name already exists
|
||||
if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where templatename=\"$templatename\""))) {
|
||||
// add the record to notetemplates
|
||||
mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote,refs) values (\"$templatename\", \"$shift\",\"$techid\",\"$subject\",\"$note\",\"$refs\")");
|
||||
$newtemplateid=mysqli_insert_id($db);
|
||||
|
||||
// add this templateid to the appropriate flag_tables
|
||||
foreach ($flags as $flagtblnum) {
|
||||
$flagtblname="flag_".$flagtblnum;
|
||||
mysqli_query($db,"insert into $flagtblname(target,id) values(\"notetemplates\",\"$newtemplateid\")");
|
||||
}
|
||||
$templateid=$newtemplateid;
|
||||
} else {
|
||||
$copy_nameexists=TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($deltemplate) {
|
||||
// delete from notetemplates table
|
||||
mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\"");
|
||||
// delete occurances from the flag_ tables
|
||||
$flagids=mysqli_query($db,"select flagid from flags");
|
||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
||||
$delflag_tbl="flag_".$thisflagid[0];
|
||||
mysqli_query($db,"delete from $delflag_tbl where target=\"notetemplates\" and id=\"$templateid\"");
|
||||
}
|
||||
unset($templateid);
|
||||
}
|
||||
}
|
||||
if ($edit) {
|
||||
@@ -323,7 +269,10 @@ if ($edit) {
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
// remove cruft from references
|
||||
$refs=preg_replace("#[a-zA-Z]{1,}#","",$refs);
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refstring=preg_replace("#[a-zA-Z]{1,}#","",$refstring);
|
||||
}
|
||||
|
||||
if ($doparts==1) {
|
||||
// inspect part data
|
||||
@@ -359,31 +308,37 @@ if ($edit) {
|
||||
|
||||
if ($authorized) {
|
||||
// update lognotes table
|
||||
mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\", refs=\"$refs\" where lognoteid=\"$noteid\"");
|
||||
mysqli_query($db,"update lognotes set date=\"$date\", time=\"$time\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where lognoteid=\"$noteid\"");
|
||||
|
||||
// update the flag_tables
|
||||
$flagids=mysqli_query($db,"select flagid from flags");
|
||||
// update the reflinks table
|
||||
mysqli_query($db,"delete from reflinks where noteid=\"$noteid\"");
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refarray=explode(" ",$refstring);
|
||||
foreach($refarray as $thisref) {
|
||||
mysqli_query($db,"insert into reflinks(noteid,target) values(\"$noteid\",\"$thisref\")");
|
||||
}
|
||||
}
|
||||
$chainmembers=generate_chain($noteid);
|
||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
||||
$thisflag_tbl="flag_".$thisflagid[0];
|
||||
if ($flags[0]=="") $flags=[];
|
||||
if (in_array($thisflagid[0],$flags)) {
|
||||
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
|
||||
// set flag for this noteid
|
||||
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$noteid\")");
|
||||
// set flag for reference chain notes
|
||||
if ($syncflags) {
|
||||
foreach($chainmembers as $refdnote) {
|
||||
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$refdnote\""))) {
|
||||
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$refdnote\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\"");
|
||||
if ($syncflags) {
|
||||
foreach ($chainmembers as $refdnote) {
|
||||
if ($refdnote != $noteid) {
|
||||
mysqli_query($db,"delete from flagmap where lognoteid=\"$refdnote\"");
|
||||
}
|
||||
} else {
|
||||
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
|
||||
// clear flag for this note
|
||||
mysqli_query($db,"delete from $thisflag_tbl where target=\"lognotes\" and id=\"$noteid\"");
|
||||
}
|
||||
}
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$noteid\")");
|
||||
if ($syncflags) {
|
||||
//set flag for reference chain notes
|
||||
foreach ($chainmembers as $refdnote) {
|
||||
if ($refdnote != $noteid) {
|
||||
mysqli_query($db,"insert into flagmap(flagid,lognoteid) values(\"$thisflag\",\"$refdnote\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,25 +404,48 @@ if ($edit) {
|
||||
|
||||
} else {
|
||||
// no part info was entered
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// refresh the note in question from the database
|
||||
$getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\"");
|
||||
if ($loadtemplate) {
|
||||
// get the note in question from the selected template
|
||||
$getnote=mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\"");
|
||||
} else {
|
||||
// refresh the note in question from the database
|
||||
$getnote=mysqli_query($db,"select * from lognotes where lognoteid=\"$noteid\"");
|
||||
}
|
||||
$notetoedit=mysqli_fetch_assoc($getnote);
|
||||
}
|
||||
if ($delete) {
|
||||
// find notes having this note as a target
|
||||
$drefnoteqry=mysqli_query($db,"select noteid from reflinks where target=\"$noteid\"");
|
||||
while ($drefnoterow=mysqli_fetch_assoc($drefnoteqry)) {
|
||||
$drefnotes[]=$drefnoterow["noteid"];
|
||||
}
|
||||
// find targets for this note
|
||||
$dreftgtqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\"");
|
||||
while ($dreftgtrow=mysqli_fetch_assoc($dreftgtqry)) {
|
||||
$dreftgts[]=$dreftgtrow["target"];
|
||||
}
|
||||
// for every note having this one as a target, add this note's targets
|
||||
foreach ($drefnotes as $drefnote) {
|
||||
foreach ($dreftgts as $dreftgt) {
|
||||
mysqli_query($db,"insert into reflinks(noteid,target) values(\"$drefnote\",\"$dreftgt\")");
|
||||
}
|
||||
}
|
||||
// delete this note from reflinks
|
||||
mysqli_query($db,"delete from reflinks where noteid is not null and (noteid=\"$noteid\" or target=\"$noteid\")");
|
||||
|
||||
// delete from lognotes table
|
||||
mysqli_query($db,"delete from lognotes where lognoteid=\"$noteid\"");
|
||||
// delete occurances from the flag_ tables
|
||||
$flagids=mysqli_query($db,"select flagid from flags");
|
||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
||||
$delflag_tbl="flag_".$thisflagid[0];
|
||||
mysqli_query($db,"delete from $delflag_tbl where target=\"lognotes\" and id=\"$noteid\"");
|
||||
}
|
||||
|
||||
// delete occurances from the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where lognoteid=\"$noteid\"");
|
||||
|
||||
// delete occurances from the logparts table
|
||||
mysqli_query($db,"delete from logparts where lognoteid=\"$noteid\"");
|
||||
}
|
||||
@@ -488,17 +466,23 @@ if ($add) {
|
||||
$notetime=$now;
|
||||
}
|
||||
if ($edit || $delete) {
|
||||
$notedate=$notetoedit["date"];
|
||||
$notetime=$notetoedit["time"];
|
||||
$notedate=$notetoedit["date"] ?? $today;
|
||||
$notetime=$notetoedit["time"] ?? $now;
|
||||
$defaultshift=$notetoedit["shift"];
|
||||
$defaultsubject=$notetoedit["subject"];
|
||||
|
||||
$note=$notetoedit["lognote"];
|
||||
$refto=$notetoedit["refs"];
|
||||
// generate reference string for this note
|
||||
if ($submit) {
|
||||
$refstring=NULL;
|
||||
}
|
||||
$refstringqry=mysqli_query($db,"select target from reflinks where noteid=\"$noteid\"");
|
||||
while ($thistgt=mysqli_fetch_row($refstringqry)) {
|
||||
$refstring=$refstring." ".$thistgt[0];
|
||||
}
|
||||
$techid=$notetoedit["tech"];
|
||||
}
|
||||
$techname=dblookup($db,"techs","techid","techname",$techid);
|
||||
$copy_nameexists=$copy_nameexists ?? NULL;
|
||||
$save_nameexists=$save_nameexists ?? NULL;
|
||||
if ($submit) {
|
||||
if ($note) {
|
||||
if ($add) {
|
||||
@@ -514,54 +498,64 @@ if ($submit) {
|
||||
if ($delete) {
|
||||
format_message(0,"<strong>Note deleted.</strong> <a href=\"lognotes.php\">Return to main page.</a>");
|
||||
}
|
||||
if ($copy_nameexists) {
|
||||
format_message(1,"Template copy failed because the name you supplied already exists.");
|
||||
}
|
||||
if ($save_nameexists) {
|
||||
format_message(1,"Template save failed because the name you supplied already exists.");
|
||||
}
|
||||
echo "
|
||||
<form method=\"post\" action=\"logentry.php\">
|
||||
";
|
||||
if ($_SESSION['login']) {
|
||||
// generate template line
|
||||
echo "
|
||||
<table border=\"0\" cellpadding=\"10\"><tr><td>
|
||||
<select name=\"templateid\" title=\"Select the template you'd like to load and click the Load Template button.\">
|
||||
<table border=\"0\" cellpadding=\"10\"><tr>
|
||||
";
|
||||
if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$templateid);
|
||||
// list user templates
|
||||
echo "
|
||||
<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.\">
|
||||
";
|
||||
if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$usertemplateid);
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
|
||||
if ($loadtemplate) {
|
||||
printf("<option value=\"%s\">%s</option>","0","Select template");
|
||||
printf("<option value=\"%s\">%s</option>","0","Select user template");
|
||||
} else {
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select template");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
|
||||
}
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
if ($loadtemplate && ($templateitem["templateid"] == $templateid)) {
|
||||
if ($loadtemplate && ($templateitem["templateid"] == $usertemplateid)) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select> <input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
|
||||
</td><td>
|
||||
<input type=\"submit\" name=\"savetemplate\" value=\"Save As:\" title=\"Enter the name you'd like to use in the field to the right.\">
|
||||
<input type=\"text\" size=\"25\" name=\"templatename\" value=\"$templatename\" title=\"Name of the template you'd like to save or modify\">
|
||||
</td>
|
||||
</select> or
|
||||
";
|
||||
|
||||
if ($loadtemplate) {
|
||||
echo "
|
||||
<!-- <input type=\"hidden\" name=\"templateid\" value=\"$templateid\"> -->
|
||||
<td>
|
||||
<input type=\"submit\" name=\"deltemplate\" value=\"Delete\" title=\"Delete the template whose name is shown in the field to the left.\">
|
||||
<input type=\"submit\" name=\"copytemplate\" value=\"Copy\" title=\"Copy the template whose data is shown below to the new name in the field to the left.\">
|
||||
</td>
|
||||
";
|
||||
}
|
||||
|
||||
// list global templates
|
||||
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.\">
|
||||
";
|
||||
if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$globaltemplateid);
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
|
||||
if ($loadtemplate) {
|
||||
printf("<option value=\"%s\">%s</option>","0","Select global template");
|
||||
} else {
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
|
||||
}
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
if ($loadtemplate && ($templateitem["templateid"] == $globaltemplateid)) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
";
|
||||
// show load button
|
||||
echo "
|
||||
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
|
||||
</td>
|
||||
<td>
|
||||
<a href=\"templates.php\">Manage templates</a>
|
||||
</td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
";
|
||||
@@ -641,28 +635,32 @@ echo "
|
||||
</select></td>
|
||||
</tr></table>
|
||||
|
||||
<b>Note:</b> <img src=\"icons/question.png\" title=\"Enter note text below. To insert a link to a web page, enter it in the link field below the Note box and click Insert Link. \"><br>
|
||||
<b>Note:</b> <img src=\"icons/question.png\" title=\"Enter note text below. To insert a link to a web page, enter it's info in the link fields below the Note box and click Insert Link. You must provide the URL, but the link text is optional. \"><br>
|
||||
<textarea rows=\"10\" cols=\"60\" name=\"note\" id=\"notetextarea\" wrap=\"soft\">";
|
||||
if ($edit || $templateid || $schedmaintcomplete) echo "$note";
|
||||
if ($edit || $usertemplateid || $globaltemplateid || $schedmaintcomplete) echo "$note";
|
||||
echo "</textarea><br>
|
||||
<input type=\"text\" size=\"50\" id=\"linktextfield\" placeholder=\"Enter a URL to insert here\"> <a href=\"#\" onclick=\"insertUrlAtCaret('notetextarea','linktextfield');return false;\">Insert Link</a><br>
|
||||
<input type=\"text\" size=\"23\" id=\"linktextfield\" placeholder=\"Enter link text here\">
|
||||
<input type=\"text\" size=\"23\" id=\"linkurlfield\" placeholder=\"Enter URL here\">
|
||||
<a href=\"#\" onclick=\"insertUrlAtCaret('notetextarea','linktextfield','linkurlfield');return false;\">Insert Link</a><br>
|
||||
";
|
||||
// get an array of flagids set for this noteid
|
||||
|
||||
// create an array called theseflags of flagids set for this noteid
|
||||
$allflags=mysqli_query($db,"select flagid from flags");
|
||||
unset($theseflags);
|
||||
$theseflags=[];
|
||||
while ($thisflag=mysqli_fetch_row($allflags)) {
|
||||
$thisflagtbl="flag_".$thisflag[0];
|
||||
if ($templateid) {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"notetemplates\" and id=\"$templateid\""))) {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) {
|
||||
$theseflags[]=$thisflag[0];
|
||||
}
|
||||
} else {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"lognotes\" and id=\"$noteid\""))) {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and lognoteid=\"$noteid\""))) {
|
||||
$theseflags[]=$thisflag[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if adding a note/template, only show active flags, otherwise, show all flags
|
||||
if ($add) {
|
||||
$flagslist=mysqli_query($db,"select * from flags where status=1");
|
||||
} else {
|
||||
@@ -670,6 +668,8 @@ if ($add) {
|
||||
}
|
||||
$flagsperline=8;
|
||||
$flagcount=1;
|
||||
|
||||
// display checkboxes for all the flags, selecting the ones that are set for this note/template
|
||||
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
||||
|
||||
if (in_array($flagcheckbox["flagid"],$theseflags)) {
|
||||
@@ -692,8 +692,12 @@ while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
||||
}
|
||||
echo "
|
||||
<br><input type=\"checkbox\" name=\"syncflags\" value=\"1\"><font title=\"Set the selected flags on the other notes in the reference chain\">Set flags on reference chain</font>
|
||||
";
|
||||
|
||||
if ($add && $refto) $refstring=$refto;
|
||||
echo "
|
||||
<br><br><b>References: </b>
|
||||
<input type=\"text\" name=\"refs\" size=\"20\" value=\"$refto\" title=\"One or more Note ID numbers separated by commas\">
|
||||
<input type=\"text\" name=\"refstring\" size=\"20\" value=\"$refstring\" title=\"One or more Note ID numbers separated by spaces\">
|
||||
|
||||
";
|
||||
if ($add) {
|
||||
|
||||
Reference in New Issue
Block a user