Updated various files where the version number exists.
Continued work on templates.php.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
CHANGELOG
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
@@ -240,7 +240,3 @@
|
||||
treating the $today variable as global.
|
||||
- In install.php, if a previous installation was found, make upgrade
|
||||
the default choice.
|
||||
|
||||
5.2.5 - 2026-02-10
|
||||
This is just a version number bump to get on a major-minor-patch
|
||||
scheme. There are no code changes for this release.
|
||||
|
||||
2
INSTALL
2
INSTALL
@@ -1,6 +1,6 @@
|
||||
INSTALL
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
5.2.5
|
||||
5.3.0
|
||||
|
||||
@@ -69,7 +69,7 @@ CREATE TABLE `configs` (
|
||||
LOCK TABLES `configs` WRITE;
|
||||
/*!40000 ALTER TABLE `configs` DISABLE KEYS */;
|
||||
INSERT INTO `configs` VALUES
|
||||
(1,'ol_version','5.2.5'),
|
||||
(1,'ol_version','5.2.4'),
|
||||
(2,'log_name','OpenLog'),
|
||||
(3,'banner','1'),
|
||||
(4,'background_color','#003333'),
|
||||
@@ -232,6 +232,32 @@ LOCK TABLES `flags` WRITE;
|
||||
/*!40000 ALTER TABLE `flags` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `flagmap`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `flagmap`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `flagmap` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`flagid` int(11) NOT NULL,
|
||||
`lognoteid` int(11) DEFAULT NULL,
|
||||
`maintformid` int(11) DEFAULT NULL,
|
||||
`notetemplateid` int(11) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `flagmap`
|
||||
--
|
||||
|
||||
LOCK TABLES `flagmap` WRITE;
|
||||
/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `links`
|
||||
--
|
||||
@@ -273,7 +299,6 @@ CREATE TABLE `lognotes` (
|
||||
`tech` int(11) NOT NULL,
|
||||
`subject` int(11) NOT NULL,
|
||||
`lognote` text DEFAULT NULL,
|
||||
`refs` tinytext DEFAULT NULL,
|
||||
PRIMARY KEY (`lognoteid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
@@ -287,6 +312,31 @@ LOCK TABLES `lognotes` WRITE;
|
||||
/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `reflinks`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `reflinks`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `reflinks` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`noteid` int(11) DEFAULT NULL,
|
||||
`templateid` int(11) DEFAULT NULL,
|
||||
`target` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Dumping data for table `reflinks`
|
||||
--
|
||||
|
||||
LOCK TABLES `reflinks` WRITE;
|
||||
/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `logpartactions`
|
||||
--
|
||||
|
||||
@@ -37,3 +37,7 @@ margs="--defaults-extra-file=$mysql_opt_file"
|
||||
# ---------- version 5.2.5 ------------
|
||||
# Nothing to do
|
||||
# -------------------------------------
|
||||
|
||||
# ---------- version 5.3.0 ------------
|
||||
# Nothing to do
|
||||
# -------------------------------------
|
||||
|
||||
@@ -55,3 +55,8 @@ UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version";
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.3.0 -------------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/*
|
||||
db.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
CHANGELOG
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
@@ -240,8 +240,3 @@
|
||||
treating the $today variable as global.
|
||||
- In install.php, if a previous installation was found, make upgrade
|
||||
the default choice.
|
||||
|
||||
5.2.5 - 2026-02-10
|
||||
This is just a version number bump to get on a major-minor-patch
|
||||
scheme. There are no code changes for this release.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
INSTALL
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
about.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
admin.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
functions.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -181,17 +181,28 @@ function framework($option,$htmltitle,$pagetitle,$print) {
|
||||
}
|
||||
}).datepicker(\"setDate\", defdate);
|
||||
|
||||
function insertUrlAtCaret(outputAreaId, inputAreaId) {
|
||||
var rawlinktext=document.getElementById(inputAreaId).value;
|
||||
var url='<a href=\"' + rawlinktext.replace(/ /g,'\%20') + '\">' + rawlinktext + '</a>';
|
||||
function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) {
|
||||
var linktext=document.getElementById(inputTextAreaId).value;
|
||||
var rawurltext=document.getElementById(inputUrlAreaId).value;
|
||||
if (rawurltext=='') return;
|
||||
var lastslashindex=rawurltext.lastIndexOf('/');
|
||||
if (lastslashindex==rawurltext.length-1) {
|
||||
rawurltext=rawurltext.slice(0, -1);
|
||||
}
|
||||
if (linktext=='' && rawurltext!= '') {
|
||||
lastslashindex=rawurltext.lastIndexOf('/');
|
||||
var lastpartofurl=rawurltext.substring(lastslashindex+1);
|
||||
linktext=lastpartofurl;
|
||||
}
|
||||
var link='<a href=\"' + rawurltext.replace(/ /g,'\%20') + '\" target=\"_blank\">' + linktext + '</a>';
|
||||
var txtarea = document.getElementById(outputAreaId);
|
||||
var scrollPos = txtarea.scrollTop;
|
||||
var caretPos = txtarea.selectionStart;
|
||||
|
||||
var front = (txtarea.value).substring(0, caretPos);
|
||||
var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
|
||||
txtarea.value = front + url + back;
|
||||
caretPos = caretPos + url.length;
|
||||
txtarea.value = front + link + back;
|
||||
caretPos = caretPos + link.length;
|
||||
txtarea.selectionStart = caretPos;
|
||||
txtarea.selectionEnd = caretPos;
|
||||
txtarea.focus();
|
||||
@@ -311,6 +322,7 @@ function sidemenu($noprint=false) {
|
||||
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
|
||||
<tr><td align=\"center\"><a href=\"admin.php\" title=\"Control global settings. Must be an administrator.\"><b>Administration</b></a></td></tr>
|
||||
<tr><td align=\"center\"><a href=\"profile.php\">My Profile</a></td></tr>
|
||||
<tr><td align=\"center\"><a href=\"templates.php\">Manage Templates</a></td></tr>
|
||||
</table>
|
||||
";
|
||||
if (!isset($_SESSION['login'])) {
|
||||
@@ -375,8 +387,13 @@ function banner($print) {
|
||||
|
||||
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
|
||||
$out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""));
|
||||
return($out_data[0]);
|
||||
$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];
|
||||
} else {
|
||||
$out_data=NULL;
|
||||
}
|
||||
return($out_data);
|
||||
}
|
||||
|
||||
function calendar($year,$month,$day,$link_url) {
|
||||
@@ -625,63 +642,53 @@ function islink($il_note) {
|
||||
// determines if the argument is a link in a reference chain
|
||||
// returns 1 if note is a link, 0 if not
|
||||
global $db;
|
||||
$il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\""));
|
||||
if ($il_pq[0]=="") {
|
||||
$il_hasprev=0;
|
||||
} else {
|
||||
$il_hasprev=1;
|
||||
}
|
||||
$il_sq=mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where refs like \"%$il_note%\""));
|
||||
if ($il_sq) {
|
||||
$il_hassubs=1;
|
||||
} else {
|
||||
$il_hassubs=0;
|
||||
}
|
||||
if($il_hassubs || $il_hasprev) {
|
||||
$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 {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 of all notes in chain
|
||||
// returns a sorted array (chainarray) of all notes in chain
|
||||
global $db;
|
||||
$refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\"");
|
||||
$nanote=array();
|
||||
$narefs=array();
|
||||
while ($allrefs=mysqli_fetch_row($refsqry)) {
|
||||
$spltrefs=explode(",",$allrefs[1]);
|
||||
$iptr=0;
|
||||
while ($iptr<count($spltrefs)) {
|
||||
array_push($nanote,$allrefs[0]);
|
||||
array_push($narefs,$spltrefs[$iptr]);
|
||||
$iptr=$iptr+1;
|
||||
}
|
||||
// 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'];
|
||||
}
|
||||
$chainarray=array($chainlink);
|
||||
$results=array();
|
||||
$mptr=0;
|
||||
while($mptr<count($chainarray)) {
|
||||
$nptr=0;
|
||||
while($nptr<count($nanote)) {
|
||||
if(($nanote[$nptr]==$chainarray[$mptr]) && ( ! in_array($narefs[$nptr],$chainarray))) {
|
||||
array_push($chainarray,$narefs[$nptr]);
|
||||
|
||||
$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];
|
||||
}
|
||||
$nptr=$nptr+1;
|
||||
}
|
||||
$rptr=0;
|
||||
while($rptr<count($narefs)) {
|
||||
if(($narefs[$rptr]==$chainarray[$mptr]) && ( ! in_array($nanote[$rptr],$chainarray))) {
|
||||
array_push($chainarray,$nanote[$rptr]);
|
||||
// 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];
|
||||
}
|
||||
$rptr=$rptr+1;
|
||||
$tptr=$tptr+1;
|
||||
}
|
||||
$mptr=$mptr+1;
|
||||
$captr=$captr+1;
|
||||
}
|
||||
// sort and return the output array
|
||||
sort($chainarray);
|
||||
return($chainarray);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
gpl.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
login.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
lognotes.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
@@ -42,14 +42,14 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
||||
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,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
$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)) {
|
||||
$reftonote=$tablerow["lognoteid"];
|
||||
$refs=" <a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
if (islink($tablerow["lognoteid"])) {
|
||||
$refs=$refs." <a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
$thisnote=$tablerow["lognoteid"];
|
||||
$refs=" <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." <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"]);
|
||||
@@ -59,27 +59,24 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
||||
$flagid=$allflagids[0];
|
||||
$flag_tbl="flag_".$flagid;
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
|
||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
||||
$flagcolor=$flagparam["flagcolor"];
|
||||
$flagsym=$flagparam["flagsym"];
|
||||
$flagname=$flagparam["flagname"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
}
|
||||
$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> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$fmtnote=$fmtnote."<br>".$flagstring." ";
|
||||
} 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=\"$reftonote\""))) {
|
||||
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1¬eid=$reftonote\">PARTS</a>";
|
||||
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1¬eid=$thisnote\">PARTS</a>";
|
||||
}
|
||||
}
|
||||
// now print the line in the table
|
||||
@@ -134,14 +131,14 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
||||
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,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
$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)) {
|
||||
$reftonote=$tablerow["lognoteid"];
|
||||
$refs=" <a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
$thisnote=$tablerow["lognoteid"];
|
||||
$refs=" <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." <a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
$refs=$refs." <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"]);
|
||||
@@ -151,17 +148,13 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
||||
$flagid=$allflagids[0];
|
||||
$flag_tbl="flag_".$flagid;
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
|
||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
||||
$flagcolor=$flagparam["flagcolor"];
|
||||
$flagsym=$flagparam["flagsym"];
|
||||
$flagname=$flagparam["flagname"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
}
|
||||
$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> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$fmtnote=$fmtnote."<br>".$flagstring." ";
|
||||
@@ -170,8 +163,8 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
||||
}
|
||||
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=\"$reftonote\""))) {
|
||||
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1¬eid=$reftonote\" 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¬eid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
|
||||
}
|
||||
}
|
||||
// now print the line in the table
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
maintform.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
maintformentry.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
partentry.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
parts.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
profile.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
/*
|
||||
refchain.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
include("functions.php");
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$print=$_REQUEST['print'] ?? "";
|
||||
$chainnote=$_REQUEST['chainnote'];
|
||||
|
||||
$logname=LOG_NAME;
|
||||
@@ -59,17 +59,29 @@ while($mptr<count($master)) {
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
||||
$flagid=$allflagids[0];
|
||||
$flag_tbl="flag_".$flagid;
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
|
||||
$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> ";
|
||||
}
|
||||
}
|
||||
|
||||
//$allflagqry=mysqli_query($db,"select flagid from flags");
|
||||
//while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
||||
//$flagid=$allflagids[0];
|
||||
//$flag_tbl="flag_".$flagid;
|
||||
//if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
|
||||
//$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> ";
|
||||
//}
|
||||
//}
|
||||
|
||||
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
|
||||
printf("
|
||||
<tr>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
blankpage.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
search.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
settings.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2025 Rod Wright
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
616
distfiles/templates.php
Normal file
616
distfiles/templates.php
Normal file
@@ -0,0 +1,616 @@
|
||||
<?php
|
||||
/*
|
||||
templates.php
|
||||
OpenLog Online Logbook
|
||||
Copyright (C) 2026 Rod Wright
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
*/
|
||||
|
||||
include("functions.php");
|
||||
|
||||
if (!$_SESSION['login'] && !$_REQUEST['partview']) {
|
||||
header ("Location: login.php");
|
||||
}
|
||||
|
||||
$techid=$_SESSION['login'] ?? NULL;
|
||||
$isadmin=dblookup($db,"techs","techid","admin",$techid);
|
||||
$print=$_REQUEST['print'] ?? NULL;
|
||||
$tech=$_REQUEST['tech'] ?? 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;
|
||||
$add=$_REQUEST['add'] ?? NULL;
|
||||
$edit=$_REQUEST['edit'] ?? NULL;
|
||||
$delete=$_REQUEST['delete'] ?? 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;
|
||||
|
||||
$defaultshift=dblookup($db,"techs","techid","shift",$techid);
|
||||
|
||||
if ($print=="Printer Friendly") {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
}
|
||||
|
||||
framework("begin","$logname","Note Templates",$print);
|
||||
if ($isadmin) {
|
||||
$add_auth=TRUE;
|
||||
$edit_auth=TRUE;
|
||||
$del_auth=TRUE;
|
||||
} else if ($efftechid==$techid) {
|
||||
$add_auth=TRUE;
|
||||
$edit_auth=TRUE;
|
||||
$del_auth=TRUE;
|
||||
} else if ($tech==$techid) {
|
||||
$add_auth=TRUE;
|
||||
$edit_auth=TRUE;
|
||||
$del_auth=TRUE;
|
||||
} else {
|
||||
$add_auth=FALSE;
|
||||
$edit_auth=FALSE;
|
||||
$del_auth=FALSE;
|
||||
}
|
||||
|
||||
var_dump($_REQUEST);
|
||||
|
||||
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);
|
||||
if (mysqli_num_rows($templatequery)) {
|
||||
$hastemplates=TRUE;
|
||||
} else {
|
||||
$hastemplates=FALSE;
|
||||
}
|
||||
|
||||
echo "<b><font size=\"+1\">";
|
||||
if ($hastemplates) {
|
||||
// print the user header
|
||||
if ($user=="0") {
|
||||
echo "Global Templates</font></b>";
|
||||
if ($isadmin) {
|
||||
echo " <a href=\"templates.php?add=1\">Create or copy a global template</a><br>";
|
||||
}
|
||||
} else {
|
||||
if ($user==$techid) {
|
||||
echo "My templates</font></b>";
|
||||
echo " <a href=\"templates.php?add=1\">Create or copy a template</a><br>";
|
||||
} else {
|
||||
echo "Templates for $tblusername</font></b>";
|
||||
}
|
||||
}
|
||||
// print the table
|
||||
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"];
|
||||
// convert shift number to name
|
||||
$shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
|
||||
// convert subject number to name
|
||||
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
|
||||
// create links of urls in note
|
||||
$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> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$fmtnote=$fmtnote."<br>".$flagstring." ";
|
||||
} 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];
|
||||
}
|
||||
// now print the line in the table
|
||||
if (!$isadmin && $user=="0") {
|
||||
$nameblock="$templatename</a>";
|
||||
} else {
|
||||
$nameblock="<a href=\"templates.php?edit=1&templateid=$templateid\">$templatename</a>";
|
||||
}
|
||||
printf(
|
||||
"<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
|
||||
);
|
||||
};
|
||||
echo "</table><br><hr><br>";
|
||||
} else {
|
||||
if ($user=="0") {
|
||||
echo "There are no global templates</font></b>";
|
||||
if ($isadmin) {
|
||||
echo " <a href=\"templates.php?add=1&tech=$user\">Add a new global template</a>";
|
||||
}
|
||||
} else {
|
||||
if ($user==$techid) {
|
||||
echo "You have no templates</font></b>";
|
||||
} else {
|
||||
echo "$tblusername has no templates</font></b>";
|
||||
}
|
||||
if (($user==$techid) || $isadmin) {
|
||||
echo " <a href=\"templates.php?add=1&tech=$user\">Add a new template</a><br>";
|
||||
}
|
||||
}
|
||||
echo "<br><hr>";
|
||||
}
|
||||
echo "<br>";
|
||||
}
|
||||
|
||||
function templateselect($db,$techid) {
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
";
|
||||
// generate template selection line
|
||||
echo "
|
||||
<table border=\"0\" cellpadding=\"10\"><tr>
|
||||
";
|
||||
// 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.\">
|
||||
";
|
||||
$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> or
|
||||
";
|
||||
// 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.\">
|
||||
";
|
||||
$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>
|
||||
";
|
||||
// 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>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
if ($usertemplateid) {
|
||||
$templateid=$usertemplateid;
|
||||
} else if ($globaltemplateid) {
|
||||
$templateid=$globaltemplateid;
|
||||
} else {
|
||||
$loadtemplate=NULL;
|
||||
}
|
||||
|
||||
if ($add) {
|
||||
if ($submit) {
|
||||
if ($note) {
|
||||
// remove cruft from note text
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
if ($add_auth) {
|
||||
// check if name supplied
|
||||
if ($templatename) {
|
||||
$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\""))) {
|
||||
// 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);
|
||||
|
||||
// update the flagmap table
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
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);
|
||||
foreach ($refarray as $target) {
|
||||
mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)");
|
||||
}
|
||||
}
|
||||
$templateid=$newtemplateid;
|
||||
} else {
|
||||
$nameexists=TRUE;
|
||||
}
|
||||
} else {
|
||||
$namesupplied=FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($edit) {
|
||||
if ($submit) {
|
||||
if ($note) {
|
||||
// remove cruft from note text
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
if ($edit_auth) {
|
||||
// check if name was supplied
|
||||
if ($templatename) {
|
||||
$namesupplied=TRUE;
|
||||
// update notetemplates
|
||||
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\"");
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")");
|
||||
}
|
||||
|
||||
// update the reflinks table
|
||||
mysqli_query($db,"delete from reflinks where templateid=\"$templateid\"");
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refarray=explode(" ",$refstring);
|
||||
foreach ($refarray as $target) {
|
||||
mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$namesupplied=FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($delete) {
|
||||
if ($del_auth) {
|
||||
// update notetemplates
|
||||
mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\"");
|
||||
// update the flagmap table
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ******** end database manipulation ********
|
||||
|
||||
pagetable("begin");
|
||||
if (!$print) {
|
||||
pageblock("left","begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
banner($print);
|
||||
|
||||
|
||||
if ($submit || $delete) {
|
||||
// show success/failure messages
|
||||
$nameexists=$nameexists ?? NULL;
|
||||
$namesupplied=$namesupplied ?? NULL;
|
||||
if ($delete) {
|
||||
format_message(0,"<strong>Template deleted.</strong>");
|
||||
} else {
|
||||
$addfail=FALSE;
|
||||
if ($add) {
|
||||
if ($nameexists) {
|
||||
format_message(1,"Template save failed because the name you supplied already exists. Please try again.");
|
||||
$addfail=TRUE;
|
||||
}
|
||||
if (!$namesupplied) {
|
||||
format_message(1,"Template save failed because you didn't supply a name. Please try again.");
|
||||
$addfail=TRUE;
|
||||
}
|
||||
if (!$note) {
|
||||
format_message(1,"Template save failed because you didn't enter any note text. Please try again.");
|
||||
$addfail=TRUE;
|
||||
}
|
||||
if (!$addfail) format_message(0,"<strong>Template added.</strong>");
|
||||
}
|
||||
$editfail=FALSE;
|
||||
if ($edit) {
|
||||
if (!$namesupplied) {
|
||||
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;
|
||||
}
|
||||
if (!$editfail) format_message(0,"<strong>Template modified.</strong>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($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 ($add || $edit) {
|
||||
// Display the input form
|
||||
if ($loadtemplate) {
|
||||
// make templateid the selected template
|
||||
if ($usertemplateid) {
|
||||
$templateid=$usertemplateid;
|
||||
} else if ($globaltemplateid) {
|
||||
$templateid=$globaltemplateid;
|
||||
} else {
|
||||
$templateid=NULL;
|
||||
}
|
||||
}
|
||||
if ($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"];
|
||||
if ($tech) {
|
||||
$filltech=$tech;
|
||||
} else if ($efftechid) {
|
||||
$filltech=$efftechid;
|
||||
} else {
|
||||
$filltech=$techid;
|
||||
}
|
||||
$fillshift=$loadeddata["shift"];
|
||||
$fillsubject=$loadeddata["subject"];
|
||||
$fillnote=$loadeddata["lognote"];
|
||||
} else {
|
||||
// use empty values with a defined tech id
|
||||
$filltemplatename=NULL;
|
||||
if ($tech) {
|
||||
$filltech=$tech;
|
||||
} else if ($efftechid) {
|
||||
$filltech=$efftechid;
|
||||
} else {
|
||||
$filltech=$techid;
|
||||
}
|
||||
$fillshift=$defaultshift;
|
||||
$fillsubject=NULL;
|
||||
$fillnote=NULL;
|
||||
}
|
||||
|
||||
if ($add) $optext="Adding new";
|
||||
if ($edit) $optext="Editing";
|
||||
if ($isadmin && $filltech==0) {
|
||||
echo "
|
||||
<br><b>$optext global template</b><br><hr>
|
||||
";
|
||||
} else {
|
||||
echo "
|
||||
<br><b>$optext user template</b><br><hr>
|
||||
";
|
||||
}
|
||||
|
||||
// show the template selection line
|
||||
templateselect($db,$techid);
|
||||
|
||||
// start template entry section
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
<table border=\"0\" cellpadding=\"5\">
|
||||
<tr><td colspan=\"2\"><b>Template Name: </b>
|
||||
<input type=\"text\" name=\"templatename\" size=\"30\" value=\"$filltemplatename\" title=\"What you'd like to name the template.\"></td></tr>
|
||||
";
|
||||
if ($isadmin) {
|
||||
if ($filltech!="0") {
|
||||
// allow tech selection
|
||||
echo "
|
||||
<tr><td colspan=\"2\"><b>Tech: </b>
|
||||
<select name=\"efftechid\">
|
||||
";
|
||||
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"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select></td></tr>
|
||||
";
|
||||
} else {
|
||||
// don't show tech line, just force value to 0
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"efftechid\" value=\"0\">
|
||||
";
|
||||
}
|
||||
} else {
|
||||
$add_auth=TRUE;
|
||||
$edit_auth=TRUE;
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"efftechid\" value=\"$techid\">
|
||||
";
|
||||
}
|
||||
echo "
|
||||
<tr>
|
||||
<td><b>Shift: </b>
|
||||
<select name=\"shift\">
|
||||
";
|
||||
$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"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select></td>
|
||||
<td><b>Subject: </b>
|
||||
<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"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$subjitem["subjectid"],$subjitem["subjectname"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'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\">$fillnote";
|
||||
echo "</textarea><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>
|
||||
";
|
||||
|
||||
// create an array called theseflags and optionally load it with flagids set for this template
|
||||
unset($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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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 ($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"]);
|
||||
}
|
||||
}
|
||||
if ($flagcount<$flagsperline) {
|
||||
echo " ";
|
||||
$flagcount++;
|
||||
} else {
|
||||
echo "<br>";
|
||||
$flagcount=1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($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];
|
||||
}
|
||||
}
|
||||
echo "
|
||||
<br><br><b>References: </b>
|
||||
<input type=\"text\" name=\"refstring\" size=\"20\" value=\"$refstring\" title=\"One or more Note ID numbers separated by spaces\">
|
||||
|
||||
";
|
||||
|
||||
if ($add && $add_auth) {
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"add\" value=\"1\">
|
||||
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
|
||||
";
|
||||
}
|
||||
if ($edit && $edit_auth) {
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"edit\" value=\"1\">
|
||||
<input type=\"hidden\" name=\"templateid\" value=\"$templateid\">
|
||||
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
|
||||
";
|
||||
if ($del_auth) {
|
||||
echo"
|
||||
<br><br>
|
||||
<input type=\"submit\" name=\"delete\" value=\"Delete this template\"><font color=\"#FF0000\"><b>Deleted templates are irretrievable!</b></font>
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
echo "
|
||||
</form>
|
||||
<br>
|
||||
";
|
||||
} else {
|
||||
echo "<br>";
|
||||
// Show my user template table
|
||||
templatetable($db,$techid,$techid);
|
||||
|
||||
// Show global template table
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
@@ -41,8 +41,3 @@ fi
|
||||
# ---------- version 5.2.4.4 -----------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.5 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
APP_NAME="OpenLog"
|
||||
DEFAULT_DB_NAME="openlog"
|
||||
APP_VERSION="5.2.5"
|
||||
APP_VERSION="5.3.0"
|
||||
DOC_ROOT="/var/www"
|
||||
INSTALL_LOC="openlog"
|
||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||
|
||||
Reference in New Issue
Block a user