Compare commits
55 Commits
f20b4cd8b6
...
Issue-2
| Author | SHA1 | Date | |
|---|---|---|---|
| c17c4d4608 | |||
| 5d3296c3bc | |||
| 09464aace5 | |||
| e3de786766 | |||
| b0aaf70e4d | |||
| b70996b4d9 | |||
| 8647c9b4d8 | |||
| b201ac6d24 | |||
| 1480feecf0 | |||
| f84395f79a | |||
| f3db1c1523 | |||
| 962bd7b504 | |||
| ec8efec61e | |||
| d23a19a3eb | |||
| 152bb30029 | |||
| 11c876886a | |||
| 9cce143cf9 | |||
| eb29a3799c | |||
| ba7db9279d | |||
| ce8e5d9ca7 | |||
| 0600ba18cd | |||
| ef0599342b | |||
| 5129d30992 | |||
| ed7a25cea3 | |||
| 968964e3fe | |||
| d41519ba91 | |||
| 513017d3cb | |||
| 3385954624 | |||
| 5a50400a56 | |||
| b138f462d9 | |||
| dd86d2e519 | |||
| 41c5b4560b | |||
| 01fd47814b | |||
| 9122040863 | |||
| 86f1512cc0 | |||
| 0145f5849f | |||
| c4d2d4334e | |||
| 5e1856f1dc | |||
| 262bd6dcdc | |||
| ff71083b49 | |||
| 1a4c9a9c2a | |||
| 5396f3367b | |||
| 557af4db04 | |||
| cc2b638a6a | |||
| 63bb7a3445 | |||
| 35173f6faa | |||
| 71f60d353f | |||
| f74385d8f3 | |||
| 9e392faa4d | |||
| d2cb1851d0 | |||
| 07a6d352b0 | |||
| 0547e97479 | |||
| a79f73a8ca | |||
| 78ee18f03b | |||
| c11ef1ad8c |
3
BUGS
3
BUGS
@@ -1,4 +1,5 @@
|
|||||||
BUGS
|
BUGS
|
||||||
|
|
||||||
1. Adding a reference to a note using the magnifying glass icon is possible even if not logged in. This results in a blank tech and shift.
|
1. Adding a reference to a note using the magnifying glass icon is possible even if not logged in. This results in a blank tech and shift.
|
||||||
SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There needs to be a specific view only state.)
|
SOMEWHAT FIXED. If not logged in and the partview argument is not 1, redirects to login page. (This is not the optimal solution. There
|
||||||
|
needs to be a specific view only state.)
|
||||||
|
|||||||
46
CHANGELOG
46
CHANGELOG
@@ -1,6 +1,6 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
@@ -244,3 +244,47 @@
|
|||||||
5.2.5 - 2026-02-10
|
5.2.5 - 2026-02-10
|
||||||
This is just a version number bump to get on a major-minor-patch
|
This is just a version number bump to get on a major-minor-patch
|
||||||
scheme. There are no code changes for this release.
|
scheme. There are no code changes for this release.
|
||||||
|
|
||||||
|
5.3.0 - 2026-02-20
|
||||||
|
- Moved the template Create/Copy/Edit/Delete/Rename functionality to
|
||||||
|
its own page to make it less confusing and to fix some strange
|
||||||
|
behavior.
|
||||||
|
- Added global templates which can be used by anyone but can only be
|
||||||
|
created, modified, or deleted by administrators. This makes it
|
||||||
|
easier to employ standardized templates.
|
||||||
|
- Changed the character encoding of the database to utf8mb4 to enable
|
||||||
|
using emojis in text fields.
|
||||||
|
- Changed the insert link functionality. There are now two fields, link
|
||||||
|
text, and URL. The full URL string will now not be displayed in the
|
||||||
|
note, since it frequently was too long and deformed the table,
|
||||||
|
causing the user to have to scroll right to see the entire note. If
|
||||||
|
a URL is entered in the URL field and no link text is entered in the
|
||||||
|
link text field, the link will show up as just the last part of the
|
||||||
|
URL. For example, "http://somewhere.com/myfile.pdf" will show as
|
||||||
|
"myfile.pdf" in the note text. If text is entered in the link text
|
||||||
|
field, that is what will show as the clickable link in the note text.
|
||||||
|
NOTE: URLs in previously entered notes will not automatically be
|
||||||
|
converted.
|
||||||
|
- Changed the flag handling code to no longer dynamically create flag_
|
||||||
|
tables in the database to track assignments. This is now done using
|
||||||
|
a flagmap table.
|
||||||
|
NOTE: The database will be modified to support this and the
|
||||||
|
importation of the previous data will take some time during
|
||||||
|
installation.
|
||||||
|
- References will no longer be stored in the lognotes table with the note.
|
||||||
|
There is now a reflinks table that stores the link information.
|
||||||
|
NOTE: The database will be modified to support this and the
|
||||||
|
importation of the previous data will take some time during
|
||||||
|
installation.
|
||||||
|
- Various code cleanups to prevent php warnings in the logs if logging
|
||||||
|
is enabled.
|
||||||
|
- Validate all date and time fields to prevent user entered invalid date
|
||||||
|
formats from crashing php.
|
||||||
|
- Fixed profile page to automatically refresh page to show the results
|
||||||
|
when a user changes their color preferences.
|
||||||
|
|
||||||
|
5.3.1 - 2026-02-25
|
||||||
|
- Fixed bug reported as Issue 1 where failure to select an action for a
|
||||||
|
part entered in a lognote crashed php in logentry.php.
|
||||||
|
- Fixed bug where the prompt to set flags on reference chain appeared
|
||||||
|
even when no flags were available to select in logentry.php.
|
||||||
|
|||||||
6
INSTALL
6
INSTALL
@@ -1,10 +1,9 @@
|
|||||||
INSTALL
|
INSTALL
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
|
||||||
Installation of OpenLog is straightforward.
|
Installation of OpenLog is straightforward.
|
||||||
|
|
||||||
1. Gather the required information.
|
1. Gather the required information.
|
||||||
@@ -31,5 +30,4 @@ settings. You will need to log in as OpenLogAdmin. The initial default password
|
|||||||
is "OpenLog-1". From the Administration page, you can click on the links at the
|
is "OpenLog-1". From the Administration page, you can click on the links at the
|
||||||
top to add techs, subjects, shifts, etc.
|
top to add techs, subjects, shifts, etc.
|
||||||
|
|
||||||
7. Start using OpenLog.
|
6. Start using OpenLog.
|
||||||
|
|
||||||
|
|||||||
52
README.md
52
README.md
@@ -0,0 +1,52 @@
|
|||||||
|
# OpenLog #
|
||||||
|
|
||||||
|
OpenLog is an online logbook application. It allows anyone with a web browser to read, enter, and search for notes on any subject.
|
||||||
|
|
||||||
|
The available shifts, employees, and subjects are easily configured. Notes can be referred to other notes and the entire chain of referenced notes can be displayed in a single page. This makes it convenient to track ongoing projects or actions on a particular piece of equipment over a long period of time.
|
||||||
|
|
||||||
|
Version 5.0 adds parts tracking functionality. Notes can have parts change information associated with them and maintenance/repair forms can be generated for parts. Parts related functions can be disabled to reduce clutter if they are not needed.
|
||||||
|
|
||||||
|
Version 5.1 adds scheduled maintenance functionality, which can also be disabled if not needed. Notes, parts, and maintenance forms can be searched for based on a number of criteria.
|
||||||
|
|
||||||
|
The look and feel of the OpenLog pages are easily changed. Settings that affect all users can be changed in the Administration menu. Each user can personalize his or her own settings in the My Profile menu.
|
||||||
|
|
||||||
|
No browser specific HTML is used in OpenLog, so it should be useable in any browser, and it has been tested using Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, and Edge.
|
||||||
|
|
||||||
|
## Prerequisites ##
|
||||||
|
|
||||||
|
- Linux - The installer is written to automate installation on Debian based Linux servers, but OpenLog itself should run on any current Linux distribution, albeit installation will need to be accomplished manually.
|
||||||
|
- Apache2 - Current development is using version 2.4.65
|
||||||
|
- MySQL or MariaDB - Current development is using MariaDB version 11.8.3
|
||||||
|
- php - Current development is using version 8.4.11
|
||||||
|
|
||||||
|
## Installation ##
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> These instructions are used to either install a new instance of OpenLog or upgrade an existing one.
|
||||||
|
|
||||||
|
1. Unzip the OpenLog-x.x.x.tar.gz file you've downloaded into a convenient place.
|
||||||
|
2. `cd OpenLog-x.x.x`
|
||||||
|
3. `sudo ./install.sh`
|
||||||
|
|
||||||
|
* The installer will check for installation of the required packages and prompt for their installation if not found.
|
||||||
|
* You'll then be prompted for the webserver's install location. The default should work for standard installations.
|
||||||
|
* You'll then be prompted for the installation location of this instance of OpenLog. You should come up with a unique name.
|
||||||
|
* If this directory already exists and contains an instance of OpenLog, you will be prompted to cancel the process or upgrade this instance.
|
||||||
|
* If you choose to upgrade, your OpenLog instance will be upgraded and you're done.
|
||||||
|
* If this directory does not exist, it will be created and a new instance will be installed. You can have multiple instances of OpenLog running under different names in different directories. For example, if you wanted to create an Operations Log, you could enter `opslog`.
|
||||||
|
* In the Operations Log example referred to above, you could enter `OpsLog` or `Operations Log`.
|
||||||
|
* You'll br prompted for the name of the database to be created. You should choose something appropriate, like `opslog` for the example given.
|
||||||
|
* Next, you'll be prompted to enable the apache2 configuration for this instance.
|
||||||
|
*The new instance will now be installed and accessible. You will be given some important information.
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> The default login credentials for the initial admin user are:
|
||||||
|
> login: `OpenLogAdmin`
|
||||||
|
> password: `OpenLog-1`
|
||||||
|
> Make note of these credentials, otherwise you will not be able to login and configure your new installation.
|
||||||
|
>
|
||||||
|
> It is highly recommended that you change the OpenLogAdmin user password and/or create your own admin user (with a secure password) and disable this default account after logging in for the first time.
|
||||||
|
|
||||||
|
|
||||||
|
## History ##
|
||||||
|
|
||||||
|
OpenLog was written to replace a creaky old inefficient error prone Access database which had in turn replaced stacks of paper logbooks. Now, with some improvements and over 15 years and 44000 notes later in a production environment, it's still going strong.
|
||||||
|
|||||||
8
TODO.txt
8
TODO.txt
@@ -1,15 +1,15 @@
|
|||||||
TODO.txt
|
TODO.txt
|
||||||
|
|
||||||
1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE
|
1. Create a weblink hot button on the add logbook entry page to insert a weblink. DONE
|
||||||
2. Allow admins to create global templates.
|
2. Allow admins to create global templates. DONE
|
||||||
3. Create a way to restore the global page colors. (db change reqd)
|
3. Create a way to restore the global page colors. (db change reqd)
|
||||||
4. Pick a logbook subject to associate with a scheduled task to populate for the logbook entry. (db change reqd)
|
4. Pick a logbook subject to associate with a scheduled task to populate for the logbook entry. (db change reqd)
|
||||||
5. Add info messages to scheduled task page edits.
|
5. Add info messages to scheduled task page edits.
|
||||||
6. Allow scheduled tasks to be completed as a group instead of having to complete each member.
|
6. Allow scheduled tasks to be completed as a group instead of having to complete each member.
|
||||||
7. Implement popup calendars for date entry fields. DONE
|
7. Implement popup calendars for date entry fields. DONE
|
||||||
8. Improve template management interface. It can be confusing. It needs its own page.
|
8. Improve template management interface. It can be confusing. It needs its own page. DONE
|
||||||
9. Remove refs from templates. (db change reqd)
|
9. Remove refs from templates. (db change reqd) DONE
|
||||||
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd)
|
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd) DONE
|
||||||
11. allow partids to be autogenerated if user doesn't supply one (db change reqd)
|
11. allow partids to be autogenerated if user doesn't supply one (db change reqd)
|
||||||
12. If there are no flags, don't offer to set them on reference chain
|
12. If there are no flags, don't offer to set them on reference chain
|
||||||
13. make some flags immutable so they won't be synced on reference chain.
|
13. make some flags immutable so they won't be synced on reference chain.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5.2.5
|
5.3.1
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,19 @@
|
|||||||
|
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
|
function spinner() {
|
||||||
|
local pid="$1"
|
||||||
|
local delay="0.1"
|
||||||
|
local spinstr='|/-\\'
|
||||||
|
local i=0
|
||||||
|
|
||||||
|
while ps -p "$pid" > /dev/null; do
|
||||||
|
i=$(( (i+1) % 4 ))
|
||||||
|
printf "\r[%c]" "${spinstr:$i:1}"
|
||||||
|
sleep "$delay"
|
||||||
|
done
|
||||||
|
printf "\r \r" # Clear the spinner line
|
||||||
|
}
|
||||||
|
|
||||||
if [[ $1 == "" ]]
|
if [[ $1 == "" ]]
|
||||||
then
|
then
|
||||||
@@ -37,3 +50,101 @@ margs="--defaults-extra-file=$mysql_opt_file"
|
|||||||
# ---------- version 5.2.5 ------------
|
# ---------- version 5.2.5 ------------
|
||||||
# Nothing to do
|
# Nothing to do
|
||||||
# -------------------------------------
|
# -------------------------------------
|
||||||
|
|
||||||
|
# ---------- version 5.3.0 ------------
|
||||||
|
#
|
||||||
|
echo "Started database updates for OpenLog version 5.3.0..."
|
||||||
|
|
||||||
|
# Import old flag data from old scheme to new flagmap table
|
||||||
|
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
|
||||||
|
then
|
||||||
|
echo "Importing flag data from old scheme to new flagmap table."
|
||||||
|
echo "This may take some time..."
|
||||||
|
(
|
||||||
|
for flagnumber in $(mysql $margs -e "select flagid from flags")
|
||||||
|
do
|
||||||
|
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
|
||||||
|
if [[ -n "$flag_x" ]]
|
||||||
|
then
|
||||||
|
for tgtid in $(mysql $margs -e "select id from flag_$flagnumber")
|
||||||
|
do
|
||||||
|
target=$(mysql $margs -e "select target from flag_$flagnumber where id=$tgtid")
|
||||||
|
if [[ $target == "lognotes" ]]
|
||||||
|
then
|
||||||
|
mysql $margs -e "insert into flagmap(flagid,lognoteid) values($flagnumber,$tgtid)"
|
||||||
|
elif [[ $target == "maintforms" ]]
|
||||||
|
then
|
||||||
|
mysql $margs -e "insert into flagmap(flagid,maintformid) values($flagnumber,$tgtid)"
|
||||||
|
elif [[ $target == "notetemplates" ]]
|
||||||
|
then
|
||||||
|
mysql $margs -e "insert into flagmap(flagid,notetemplateid) values($flagnumber,$tgtid)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
mysql $margs -e "drop table flag_$flagnumber"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
task_pid=$!
|
||||||
|
spinner $task_pid
|
||||||
|
echo "...done."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Import reference chain data into new reflinks table
|
||||||
|
if [[ $(mysql $margs -e "select count(*) from reflinks") == 0 ]]
|
||||||
|
then
|
||||||
|
echo "Importing lognote reference chain data into new reflinks table."
|
||||||
|
echo "This may take some time..."
|
||||||
|
(
|
||||||
|
for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
|
||||||
|
do
|
||||||
|
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
|
||||||
|
oldifs=$IFS
|
||||||
|
IFS=', '
|
||||||
|
for target in $refstring
|
||||||
|
do
|
||||||
|
target=$(echo "$target" | xargs)
|
||||||
|
mysql $margs -e "insert into reflinks(noteid,target) values($note,$target)"
|
||||||
|
done
|
||||||
|
IFS=$oldifs
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
task_pid=$!
|
||||||
|
spinner $task_pid
|
||||||
|
echo "...done."
|
||||||
|
echo "Importing template reference chain data into new reflinks table."
|
||||||
|
echo "This may take some time..."
|
||||||
|
(
|
||||||
|
for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
|
||||||
|
do
|
||||||
|
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
|
||||||
|
oldifs=$IFS
|
||||||
|
IFS=', '
|
||||||
|
for target in $refstring
|
||||||
|
do
|
||||||
|
target=$(echo "$target" | xargs)
|
||||||
|
mysql $margs -e "insert into reflinks(templateid,target) values($template,$target)"
|
||||||
|
done
|
||||||
|
IFS=$oldifs
|
||||||
|
done
|
||||||
|
) &
|
||||||
|
task_pid=$!
|
||||||
|
spinner $task_pid
|
||||||
|
echo "...done."
|
||||||
|
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1
|
||||||
|
mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Convert database to utf8mb4/utf8mb4_unicode_ci
|
||||||
|
echo "Converting database to utf8mb4 encoding..."
|
||||||
|
mysql $margs -e "ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"
|
||||||
|
for table in $(mysql $margs -e "show tables")
|
||||||
|
do
|
||||||
|
mysql $margs -e "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||||
|
done
|
||||||
|
echo "...done."
|
||||||
|
# -------------------------------------
|
||||||
|
|
||||||
|
# ---------- version 5.3.1 ------------
|
||||||
|
# Nothing to do
|
||||||
|
# -------------------------------------
|
||||||
@@ -6,11 +6,15 @@ ALTER TABLE configs ADD UNIQUE(confname);
|
|||||||
|
|
||||||
-- Delete db name, user, and password configs
|
-- Delete db name, user, and password configs
|
||||||
DELETE FROM configs where confname = "ol_dbname";
|
DELETE FROM configs where confname = "ol_dbname";
|
||||||
|
|
||||||
DELETE FROM configs where confname = "ol_dbuser";
|
DELETE FROM configs where confname = "ol_dbuser";
|
||||||
|
|
||||||
DELETE FROM configs where confname = "ol_dbpass";
|
DELETE FROM configs where confname = "ol_dbpass";
|
||||||
|
|
||||||
-- Add config option for server side error logging
|
-- Add config option for server side error logging
|
||||||
INSERT IGNORE INTO configs(confname,confvalue) values('log_errors','0')
|
INSERT IGNORE INTO
|
||||||
|
configs (confname, confvalue)
|
||||||
|
values ('log_errors', '0')
|
||||||
|
|
||||||
-- Update version number
|
-- Update version number
|
||||||
UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version";
|
UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version";
|
||||||
@@ -55,3 +59,33 @@ UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version";
|
|||||||
-- Update version number
|
-- Update version number
|
||||||
UPDATE configs SET confvalue = "5.2.5" WHERE confname = "ol_version";
|
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";
|
||||||
|
|
||||||
|
-- Create the flagmap table
|
||||||
|
CREATE TABLE IF NOT EXISTS `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_unicode_ci;
|
||||||
|
|
||||||
|
-- Create the reflinks table
|
||||||
|
CREATE TABLE IF NOT EXISTS `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_unicode_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------
|
||||||
|
|
||||||
|
-- ---------- version 5.3.1 -------------
|
||||||
|
-- Update version number
|
||||||
|
UPDATE configs SET confvalue = "5.3.1" WHERE confname = "ol_version";
|
||||||
|
-- --------------------------------------
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
/*
|
/*
|
||||||
db.php
|
db.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|||||||
13
default-apache.conf
Normal file
13
default-apache.conf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# _APPNAME_ default Apache configuration
|
||||||
|
|
||||||
|
Alias /_BASEURL_ _DOCROOTIN_/_BASEURL_
|
||||||
|
|
||||||
|
<Directory _DOCROOTIN_/_BASEURL_>
|
||||||
|
AllowOverride Options
|
||||||
|
Options FollowSymLinks
|
||||||
|
DirectoryIndex index.php
|
||||||
|
|
||||||
|
#RewriteEngine On
|
||||||
|
#RewriteBase /_BASEURL_/
|
||||||
|
#RewriteRule . maintenancemode.php [L]
|
||||||
|
</Directory>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
@@ -245,3 +245,47 @@
|
|||||||
This is just a version number bump to get on a major-minor-patch
|
This is just a version number bump to get on a major-minor-patch
|
||||||
scheme. There are no code changes for this release.
|
scheme. There are no code changes for this release.
|
||||||
|
|
||||||
|
5.3.0 - 2026-02-20
|
||||||
|
- Moved the template Create/Copy/Edit/Delete/Rename functionality to
|
||||||
|
its own page to make it less confusing and to fix some strange
|
||||||
|
behavior.
|
||||||
|
- Added global templates which can be used by anyone but can only be
|
||||||
|
created, modified, or deleted by administrators. This makes it
|
||||||
|
easier to employ standardized templates.
|
||||||
|
- Changed the character encoding of the database to utf8mb4 to enable
|
||||||
|
using emojis in text fields.
|
||||||
|
- Changed the insert link functionality. There are now two fields, link
|
||||||
|
text, and URL. The full URL string will now not be displayed in the
|
||||||
|
note, since it frequently was too long and deformed the table,
|
||||||
|
causing the user to have to scroll right to see the entire note. If
|
||||||
|
a URL is entered in the URL field and no link text is entered in the
|
||||||
|
link text field, the link will show up as just the last part of the
|
||||||
|
URL. For example, "http://somewhere.com/myfile.pdf" will show as
|
||||||
|
"myfile.pdf" in the note text. If text is entered in the link text
|
||||||
|
field, that is what will show as the clickable link in the note text.
|
||||||
|
NOTE: URLs in previously entered notes will not automatically be
|
||||||
|
converted.
|
||||||
|
- Changed the flag handling code to no longer dynamically create flag_
|
||||||
|
tables in the database to track assignments. This is now done using
|
||||||
|
a flagmap table.
|
||||||
|
NOTE: The database will be modified to support this and the
|
||||||
|
importation of the previous data will take some time during
|
||||||
|
installation.
|
||||||
|
- References will no longer be stored in the lognotes table with the note.
|
||||||
|
There is now a reflinks table that stores the link information.
|
||||||
|
NOTE: The database will be modified to support this and the
|
||||||
|
importation of the previous data will take some time during
|
||||||
|
installation.
|
||||||
|
- Various code cleanups to prevent php warnings in the logs if logging
|
||||||
|
is enabled.
|
||||||
|
- Validate all date and time fields to prevent user entered invalid date
|
||||||
|
formats from crashing php.
|
||||||
|
- Fixed profile page to automatically refresh page to show the results
|
||||||
|
when a user changes their color preferences.
|
||||||
|
|
||||||
|
5.3.1 - 2026-02-25
|
||||||
|
- Fixed bug reported as Issue 1 where failure to select an action for a
|
||||||
|
part entered in a lognote crashed php in logentry.php.
|
||||||
|
- Fixed bug where the prompt to set flags on reference chain appeared
|
||||||
|
even when no flags were available to select in logentry.php.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
INSTALL
|
INSTALL
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
@@ -14,16 +14,14 @@ allow clients to reach them. You'll also need to know the username and
|
|||||||
password of the MySQL administrator.
|
password of the MySQL administrator.
|
||||||
|
|
||||||
2. Unpack
|
2. Unpack
|
||||||
Unpack the distribution in a convenient place (such as /tmp or My Documents).
|
Unpack the distribution in a convenient place.
|
||||||
A directory will be created called OpenLog-x.x.x.
|
A directory will be created called OpenLog-x.x.x.
|
||||||
|
|
||||||
3. Review License
|
3. Review License
|
||||||
Change to the openlog-x.x.x directory and review the LICENSE file.
|
Change to the OpenLog-x.x.x directory and review the LICENSE file.
|
||||||
|
|
||||||
4. Run the install script
|
4. Run the install script
|
||||||
If installing on a Linux or Unix based system, type ./install.sh at a
|
Type ./install.sh at a command prompt. Follow the prompts.
|
||||||
command prompt. If installing on a Windows based system, double click
|
|
||||||
install.bat. Follow the prompts.
|
|
||||||
|
|
||||||
5. Check and set Configuration
|
5. Check and set Configuration
|
||||||
Click on the Administration menu option on the main page to adjust the initial
|
Click on the Administration menu option on the main page to adjust the initial
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
about.php
|
about.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -92,5 +92,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
admin.php
|
admin.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -76,29 +76,31 @@ if(!$print){
|
|||||||
if ($add) {
|
if ($add) {
|
||||||
switch ($table) {
|
switch ($table) {
|
||||||
case "techs":
|
case "techs":
|
||||||
if ($admin) $admin=1; else $admin=0;
|
if ($admin) $admin = 1;
|
||||||
if ($active) $active=1; else $active=0;
|
else $admin = 0;
|
||||||
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for matching passwords
|
// test for matching passwords
|
||||||
if ($pass == $passconf) {
|
if ($pass == $passconf) {
|
||||||
$passmatch=1;
|
$passmatch = TRUE;
|
||||||
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
||||||
} else {
|
} else {
|
||||||
$passmatch=0;
|
$passmatch = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $passmatch) {
|
if ($namesuppld && $nameunique && $passmatch) {
|
||||||
@@ -108,21 +110,22 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "shifts":
|
case "shifts":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -131,21 +134,22 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "subjects":
|
case "subjects":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -154,27 +158,28 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "links":
|
case "links":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for urltxt supplied
|
// test for urltxt supplied
|
||||||
if (strlen(trim($url))) {
|
if (strlen(trim($url))) {
|
||||||
$urlsuppld=1;
|
$urlsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$urlsuppld=0;
|
$urlsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL text cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL text cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $urlsuppld) {
|
if ($namesuppld && $nameunique && $urlsuppld) {
|
||||||
@@ -188,60 +193,59 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "flags":
|
case "flags":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for symbol supplied
|
// test for symbol supplied
|
||||||
if (strlen(trim($flagsym))) {
|
if (strlen(trim($flagsym))) {
|
||||||
$symsuppld=1;
|
$symsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$symsuppld=0;
|
$symsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for symbol unique
|
// test for symbol unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) {
|
||||||
$symunique=0;
|
$symunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$symunique=1;
|
$symunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $symsuppld && $symunique) {
|
if ($namesuppld && $nameunique && $symsuppld && $symunique) {
|
||||||
// insert record in links table
|
// insert record in flags table
|
||||||
mysqli_query($db, "insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")");
|
mysqli_query($db, "insert into flags(flagname,flagsym,flagcolor,status) values(\"$name\",\"$flagsym\",\"$flagcolor\",\"$active\")");
|
||||||
// create sub tables for this link
|
|
||||||
$lastflagid=mysqli_insert_id($db);
|
|
||||||
mysqli_query($db,"create table flag_$lastflagid(target tinytext,id int not null)");
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "logpartactions":
|
case "logpartactions":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -253,17 +257,17 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -281,29 +285,31 @@ if(!$print){
|
|||||||
if ($edit) {
|
if ($edit) {
|
||||||
switch ($table) {
|
switch ($table) {
|
||||||
case "techs":
|
case "techs":
|
||||||
if ($admin) $admin=1; else $admin=0;
|
if ($admin) $admin = 1;
|
||||||
if ($active) $active=1; else $active=0;
|
else $admin = 0;
|
||||||
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
// check for log notes by this tech
|
// check for log notes by this tech
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where tech=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where tech=\"$id\""))) {
|
||||||
$hasnotes=1;
|
$hasnotes = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has notes in logbook and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has notes in logbook and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasnotes=0;
|
$hasnotes = FALSE;
|
||||||
}
|
}
|
||||||
// check for maintenance forms by this tech
|
// check for maintenance forms by this tech
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$id\""))) {
|
||||||
$hasmfs=1;
|
$hasmfs = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has maintenance forms and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has maintenance forms and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasmfs=0;
|
$hasmfs = FALSE;
|
||||||
}
|
}
|
||||||
// check for maintenance actions by this tech
|
// check for maintenance actions by this tech
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select maintactionid from maintactions where actiontech=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select maintactionid from maintactions where actiontech=\"$id\""))) {
|
||||||
$hasmas=1;
|
$hasmas = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has maintenance actions and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech has maintenance actions and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasmas=0;
|
$hasmas = FALSE;
|
||||||
}
|
}
|
||||||
if (!$hasnotes && !$hasmfs && !$hasmas) {
|
if (!$hasnotes && !$hasmfs && !$hasmas) {
|
||||||
// delete entity
|
// delete entity
|
||||||
@@ -314,34 +320,34 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for matching passwords
|
// test for matching passwords
|
||||||
if ($pass != "password_is_unchanged") {
|
if ($pass != "password_is_unchanged") {
|
||||||
if ($pass == $passconf) {
|
if ($pass == $passconf) {
|
||||||
$passmatch=1;
|
$passmatch = TRUE;
|
||||||
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
||||||
$updqry = ("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\"");
|
$updqry = ("update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",techpass=\"$passhash\",status=\"$active\" where techid=\"$id\"");
|
||||||
} else {
|
} else {
|
||||||
$passmatch=0;
|
$passmatch = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$passmatch=1;
|
$passmatch = TRUE;
|
||||||
$updqry = "update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\"";
|
$updqry = "update techs set techname=\"$name\",admin=\"$admin\",shift=\"$shift\",status=\"$active\" where techid=\"$id\"";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $passmatch) {
|
if ($namesuppld && $nameunique && $passmatch) {
|
||||||
@@ -351,14 +357,15 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "shifts":
|
case "shifts":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
// check for log notes with this shift
|
// check for log notes with this shift
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where shift=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where shift=\"$id\""))) {
|
||||||
$hasnotes=1;
|
$hasnotes = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift has notes in logbook and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift has notes in logbook and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasnotes=0;
|
$hasnotes = FALSE;
|
||||||
}
|
}
|
||||||
if (!$hasnotes) {
|
if (!$hasnotes) {
|
||||||
// delete entity
|
// delete entity
|
||||||
@@ -369,21 +376,21 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\" and shiftid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select shiftid from shifts where shiftname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Shift name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -392,14 +399,15 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "subjects":
|
case "subjects":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
// check for log notes with this subject
|
// check for log notes with this subject
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where subject=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lognoteid from lognotes where subject=\"$id\""))) {
|
||||||
$hasnotes=1;
|
$hasnotes = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject has notes in logbook and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject has notes in logbook and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasnotes=0;
|
$hasnotes = FALSE;
|
||||||
}
|
}
|
||||||
if (!$hasnotes) {
|
if (!$hasnotes) {
|
||||||
// delete entity
|
// delete entity
|
||||||
@@ -410,21 +418,21 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\" and subjectid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select subjectid from subjects where subjectname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Subject name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -433,7 +441,8 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "links":
|
case "links":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
mysqli_query($db, "delete from links where linkid=\"$id\"");
|
mysqli_query($db, "delete from links where linkid=\"$id\"");
|
||||||
}
|
}
|
||||||
@@ -441,27 +450,27 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\" and linkid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select linkid from links where displaytxt=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Display text already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for urltxt supplied
|
// test for urltxt supplied
|
||||||
if (strlen(trim($url))) {
|
if (strlen(trim($url))) {
|
||||||
$urlsuppld=1;
|
$urlsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$urlsuppld=0;
|
$urlsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL text cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL text cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $urlsuppld) {
|
if ($namesuppld && $nameunique && $urlsuppld) {
|
||||||
@@ -476,58 +485,58 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "flags":
|
case "flags":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
// check for things using this flag
|
// check for things using this flag
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select * from flag_$id"))) {
|
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$id\""))) {
|
||||||
$used=1;
|
$used = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag is used by other tables and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag is used by other tables and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$used=0;
|
$used = FALSE;
|
||||||
}
|
}
|
||||||
if (!$used) {
|
if (!$used) {
|
||||||
// delete entity
|
// delete entity
|
||||||
mysqli_query($db, "delete from flags where flagid=\"$id\"");
|
mysqli_query($db, "delete from flags where flagid=\"$id\"");
|
||||||
mysqli_query($db,"drop table flag_$id");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($update) {
|
if ($update) {
|
||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\" and flagid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for symbol supplied
|
// test for symbol supplied
|
||||||
if (strlen(trim($flagsym))) {
|
if (strlen(trim($flagsym))) {
|
||||||
$symsuppld=1;
|
$symsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$symsuppld=0;
|
$symsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for symbol unique
|
// test for symbol unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\" and flagid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagsym=\"$flagsym\""))) {
|
||||||
$symunique=0;
|
$symunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Flag symbol already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$symunique=1;
|
$symunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$symunique=1;
|
$symunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $symsuppld && $symunique) {
|
if ($namesuppld && $nameunique && $symsuppld && $symunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -536,14 +545,15 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "logpartactions":
|
case "logpartactions":
|
||||||
if ($active) $active=1; else $active=0;
|
if ($active) $active = 1;
|
||||||
|
else $active = 0;
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
// check for logparts with this part action
|
// check for logparts with this part action
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where action=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where action=\"$id\""))) {
|
||||||
$hasparts=1;
|
$hasparts = TRUE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Action is assigned to parts in logbook notes and cannot be deleted.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Action is assigned to parts in logbook notes and cannot be deleted.<br>";
|
||||||
} else {
|
} else {
|
||||||
$hasparts=0;
|
$hasparts = FALSE;
|
||||||
}
|
}
|
||||||
if (!$hasparts) {
|
if (!$hasparts) {
|
||||||
// delete entity
|
// delete entity
|
||||||
@@ -554,21 +564,21 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\" and lpactionid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select lpactionid from logpartactions where lpactionname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Part Action name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -585,21 +595,21 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\" and bannerid!=\"$id\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select bannerid from banners where bannername=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Banner name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique) {
|
if ($namesuppld && $nameunique) {
|
||||||
// modify the table
|
// modify the table
|
||||||
@@ -610,21 +620,24 @@ if(!$print){
|
|||||||
case "configs":
|
case "configs":
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "display":
|
case "display":
|
||||||
if ($display_showts) $display_showts=1; else $display_showts=0;
|
if ($display_showts) $display_showts = 1;
|
||||||
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0;
|
else $display_showts = 0;
|
||||||
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0;
|
if ($display_techalpha == "a") $display_techalpha = 1;
|
||||||
|
else $display_techalpha = 0;
|
||||||
|
if ($display_subjalpha == "a") $display_subjalpha = 1;
|
||||||
|
else $display_subjalpha = 0;
|
||||||
// test for logname supplied
|
// test for logname supplied
|
||||||
if (strlen(trim($display_logname))) {
|
if (strlen(trim($display_logname))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Log name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Log name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for urlchunk supplied
|
// test for urlchunk supplied
|
||||||
if (strlen(trim($display_urlchunk))) {
|
if (strlen(trim($display_urlchunk))) {
|
||||||
$chunksuppld=1;
|
$chunksuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$chunksuppld=0;
|
$chunksuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $chunksuppld) {
|
if ($namesuppld && $chunksuppld) {
|
||||||
@@ -666,16 +679,16 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
// test for sessttl supplied
|
// test for sessttl supplied
|
||||||
if (strlen(trim($misc_sessttl))) {
|
if (strlen(trim($misc_sessttl))) {
|
||||||
$ttlsuppld=1;
|
$ttlsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$ttlsuppld=0;
|
$ttlsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Session expiration time cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Session expiration time cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for sessdir supplied
|
// test for sessdir supplied
|
||||||
if (strlen(trim($misc_sessdir))) {
|
if (strlen(trim($misc_sessdir))) {
|
||||||
$dirsuppld=1;
|
$dirsuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$dirsuppld=0;
|
$dirsuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Server session file directory cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Server session file directory cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
if ($ttlsuppld && $dirsuppld) {
|
if ($ttlsuppld && $dirsuppld) {
|
||||||
@@ -751,6 +764,7 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from techs where techid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["techname"];
|
$name = $currentvalues["techname"];
|
||||||
$pass = $passconf = "password_is_unchanged";
|
$pass = $passconf = "password_is_unchanged";
|
||||||
$shift = $currentvalues["shift"];
|
$shift = $currentvalues["shift"];
|
||||||
@@ -764,6 +778,13 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$pass = NULL;
|
||||||
|
$shift = NULL;
|
||||||
|
$admintag = "<input type=\"checkbox\" name=\"admin\">";
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// set form options for add
|
// set form options for add
|
||||||
$sectiontitle = "<b>Add New Tech</b><br><br>";
|
$sectiontitle = "<b>Add New Tech</b><br><br>";
|
||||||
@@ -794,7 +815,7 @@ switch($table) {
|
|||||||
$shiftrow = mysqli_query($db, "select * from shifts");
|
$shiftrow = mysqli_query($db, "select * from shifts");
|
||||||
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
|
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
|
||||||
if ($shiftitem["status"] == 1) {
|
if ($shiftitem["status"] == 1) {
|
||||||
if ($shiftitem["shiftid"]==$customshiftnum) {
|
if ($shiftitem["shiftid"] == $shift) {
|
||||||
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||||
} else {
|
} else {
|
||||||
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||||
@@ -830,8 +851,9 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
$shiftname=dblookup($db,"shifts","shiftname","shiftid",$shift);
|
$shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
@@ -839,11 +861,13 @@ switch($table) {
|
|||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["techid"],$tablerow["techid"],
|
$tablerow["techid"],
|
||||||
|
$tablerow["techid"],
|
||||||
$tablerow["techname"],
|
$tablerow["techname"],
|
||||||
$shiftname,
|
$shiftname,
|
||||||
$admdef,
|
$admdef,
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -862,12 +886,17 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from shifts where shiftid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["shiftname"];
|
$name = $currentvalues["shiftname"];
|
||||||
if ($currentvalues["status"] == 1) {
|
if ($currentvalues["status"] == 1) {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
||||||
} else {
|
} else {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// set form options for add
|
// set form options for add
|
||||||
$sectiontitle = "<b>Add New Shift</b><br><br>";
|
$sectiontitle = "<b>Add New Shift</b><br><br>";
|
||||||
@@ -906,15 +935,18 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["shiftid"],$tablerow["shiftid"],
|
$tablerow["shiftid"],
|
||||||
|
$tablerow["shiftid"],
|
||||||
$tablerow["shiftname"],
|
$tablerow["shiftname"],
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -933,12 +965,17 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from subjects where subjectid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["subjectname"];
|
$name = $currentvalues["subjectname"];
|
||||||
if ($currentvalues["status"] == 1) {
|
if ($currentvalues["status"] == 1) {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
||||||
} else {
|
} else {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$name = "";
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// set form options for add
|
// set form options for add
|
||||||
$sectiontitle = "<b>Add New Subject</b><br><br>";
|
$sectiontitle = "<b>Add New Subject</b><br><br>";
|
||||||
@@ -977,15 +1014,18 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["subjectid"],$tablerow["subjectid"],
|
$tablerow["subjectid"],
|
||||||
|
$tablerow["subjectid"],
|
||||||
$tablerow["subjectname"],
|
$tablerow["subjectname"],
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -1004,6 +1044,7 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from links where linkid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["displaytxt"];
|
$name = $currentvalues["displaytxt"];
|
||||||
$priority = $currentvalues["linkpriority"];
|
$priority = $currentvalues["linkpriority"];
|
||||||
$url = $currentvalues["urltxt"];
|
$url = $currentvalues["urltxt"];
|
||||||
@@ -1012,6 +1053,12 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$priority = NULL;
|
||||||
|
$url = NULL;
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
// determine where we are in the priority stack
|
// determine where we are in the priority stack
|
||||||
$prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links"));
|
$prow = mysqli_fetch_assoc(mysqli_query($db, "select min(linkpriority) as highest from links"));
|
||||||
if ($prow["highest"] == $priority) {
|
if ($prow["highest"] == $priority) {
|
||||||
@@ -1090,17 +1137,21 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td><a href=\"%s\">%s</a></td>
|
<td><a href=\"%s\">%s</a></td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["linkid"],$tablerow["linkid"],
|
$tablerow["linkid"],
|
||||||
|
$tablerow["linkid"],
|
||||||
$tablerow["displaytxt"],
|
$tablerow["displaytxt"],
|
||||||
$tablerow["urltxt"],$tablerow["urltxt"],
|
$tablerow["urltxt"],
|
||||||
$statdef);
|
$tablerow["urltxt"],
|
||||||
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -1119,10 +1170,22 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["flagname"];
|
$name = $currentvalues["flagname"];
|
||||||
$flagsym = $currentvalues["flagsym"];
|
$flagsym = $currentvalues["flagsym"];
|
||||||
$flagcolor = $currentvalues["flagcolor"];
|
$flagcolor = $currentvalues["flagcolor"];
|
||||||
$flagcoloropts = "";
|
$flagcoloropts = "";
|
||||||
|
if ($currentvalues["status"] == 1) {
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
||||||
|
} else {
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$flagsym = NULL;
|
||||||
|
$flagcolor = NULL;
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
foreach ($basic_colors as $cname => $chex) {
|
foreach ($basic_colors as $cname => $chex) {
|
||||||
if ($chex == $flagcolor) {
|
if ($chex == $flagcolor) {
|
||||||
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\" selected>$cname</option>";
|
||||||
@@ -1130,11 +1193,6 @@ switch($table) {
|
|||||||
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\">$cname</option>";
|
$flagcoloropts = $flagcoloropts . "<option value=\"$chex\">$cname</option>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($currentvalues["status"]==1) {
|
|
||||||
$activetag="<input type=\"checkbox\" name=\"active\" checked>";
|
|
||||||
} else {
|
|
||||||
$activetag="<input type=\"checkbox\" name=\"active\">";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// set form options for add
|
// set form options for add
|
||||||
$sectiontitle = "<b>Add New Flag</b><br><br>";
|
$sectiontitle = "<b>Add New Flag</b><br><br>";
|
||||||
@@ -1187,17 +1245,21 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\"><font color=\"%s\">%s</font></td>
|
<td align=\"center\"><font color=\"%s\">%s</font></td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["flagid"],$tablerow["flagid"],
|
$tablerow["flagid"],
|
||||||
|
$tablerow["flagid"],
|
||||||
$tablerow["flagname"],
|
$tablerow["flagname"],
|
||||||
$tablerow["flagcolor"],$tablerow["flagsym"],
|
$tablerow["flagcolor"],
|
||||||
$statdef);
|
$tablerow["flagsym"],
|
||||||
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -1216,12 +1278,17 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from logpartactions where lpactionid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["lpactionname"];
|
$name = $currentvalues["lpactionname"];
|
||||||
if ($currentvalues["status"] == 1) {
|
if ($currentvalues["status"] == 1) {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
$activetag = "<input type=\"checkbox\" name=\"active\" checked>";
|
||||||
} else {
|
} else {
|
||||||
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$activetag = "<input type=\"checkbox\" name=\"active\">";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// set form options for add
|
// set form options for add
|
||||||
$sectiontitle = "<b>Add New Part Action</b><br><br>";
|
$sectiontitle = "<b>Add New Part Action</b><br><br>";
|
||||||
@@ -1260,15 +1327,18 @@ switch($table) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["lpactionid"],$tablerow["lpactionid"],
|
$tablerow["lpactionid"],
|
||||||
|
$tablerow["lpactionid"],
|
||||||
$tablerow["lpactionname"],
|
$tablerow["lpactionname"],
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -1287,9 +1357,15 @@ switch($table) {
|
|||||||
";
|
";
|
||||||
// pull current values from database
|
// pull current values from database
|
||||||
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id"));
|
$currentvalues = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=$id"));
|
||||||
|
if (!empty($currentvalues)) {
|
||||||
$name = $currentvalues["bannername"];
|
$name = $currentvalues["bannername"];
|
||||||
$bnrcolor = $currentvalues["bannercolor"];
|
$bnrcolor = $currentvalues["bannercolor"];
|
||||||
$bnrtextcolor = $currentvalues["textcolor"];
|
$bnrtextcolor = $currentvalues["textcolor"];
|
||||||
|
} else {
|
||||||
|
$name = NULL;
|
||||||
|
$bnrcolor = NULL;
|
||||||
|
$bnrtextcolor = NULL;
|
||||||
|
}
|
||||||
$bnrcoloropts = "";
|
$bnrcoloropts = "";
|
||||||
foreach ($basic_colors as $cname => $chex) {
|
foreach ($basic_colors as $cname => $chex) {
|
||||||
if ($chex == $bnrcolor) {
|
if ($chex == $bnrcolor) {
|
||||||
@@ -1363,13 +1439,18 @@ switch($table) {
|
|||||||
<tr><th>Banner ID</th><th>Banner</th></tr>
|
<tr><th>Banner ID</th><th>Banner</th></tr>
|
||||||
";
|
";
|
||||||
while ($tablerow = mysqli_fetch_assoc($existingdata)) {
|
while ($tablerow = mysqli_fetch_assoc($existingdata)) {
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>
|
||||||
<td align=\"center\" bgcolor=\"%s\"><font color=\"%s\">%s</font></td>
|
<td align=\"center\" bgcolor=\"%s\"><font color=\"%s\">%s</font></td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["bannerid"],$tablerow["bannerid"],
|
$tablerow["bannerid"],
|
||||||
$tablerow["bannercolor"],$tablerow["textcolor"],$tablerow["bannername"]);
|
$tablerow["bannerid"],
|
||||||
|
$tablerow["bannercolor"],
|
||||||
|
$tablerow["textcolor"],
|
||||||
|
$tablerow["bannername"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
break;
|
break;
|
||||||
@@ -1586,5 +1667,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
functions.php
|
functions.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -45,11 +45,13 @@ $basic_colors=array(
|
|||||||
"Blue" => "#0000FF",
|
"Blue" => "#0000FF",
|
||||||
"Navy" => "#000080",
|
"Navy" => "#000080",
|
||||||
"Fuchsia" => "#FF00FF",
|
"Fuchsia" => "#FF00FF",
|
||||||
"Purple" => "#800080");
|
"Purple" => "#800080"
|
||||||
|
);
|
||||||
|
|
||||||
// Generic functions
|
// Generic functions
|
||||||
|
|
||||||
function framework($option,$htmltitle,$pagetitle,$print) {
|
function framework($option, $htmltitle, $pagetitle, $print)
|
||||||
|
{
|
||||||
// generates html code for the beginning and end of all pages
|
// generates html code for the beginning and end of all pages
|
||||||
if ($option == "begin") {
|
if ($option == "begin") {
|
||||||
// generates everything down to the first horiz rule inclusive
|
// generates everything down to the first horiz rule inclusive
|
||||||
@@ -181,17 +183,28 @@ function framework($option,$htmltitle,$pagetitle,$print) {
|
|||||||
}
|
}
|
||||||
}).datepicker(\"setDate\", defdate);
|
}).datepicker(\"setDate\", defdate);
|
||||||
|
|
||||||
function insertUrlAtCaret(outputAreaId, inputAreaId) {
|
function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) {
|
||||||
var rawlinktext=document.getElementById(inputAreaId).value;
|
var linktext=document.getElementById(inputTextAreaId).value;
|
||||||
var url='<a href=\"' + rawlinktext.replace(/ /g,'\%20') + '\">' + rawlinktext + '</a>';
|
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 txtarea = document.getElementById(outputAreaId);
|
||||||
var scrollPos = txtarea.scrollTop;
|
var scrollPos = txtarea.scrollTop;
|
||||||
var caretPos = txtarea.selectionStart;
|
var caretPos = txtarea.selectionStart;
|
||||||
|
|
||||||
var front = (txtarea.value).substring(0, caretPos);
|
var front = (txtarea.value).substring(0, caretPos);
|
||||||
var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
|
var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
|
||||||
txtarea.value = front + url + back;
|
txtarea.value = front + link + back;
|
||||||
caretPos = caretPos + url.length;
|
caretPos = caretPos + link.length;
|
||||||
txtarea.selectionStart = caretPos;
|
txtarea.selectionStart = caretPos;
|
||||||
txtarea.selectionEnd = caretPos;
|
txtarea.selectionEnd = caretPos;
|
||||||
txtarea.focus();
|
txtarea.focus();
|
||||||
@@ -210,7 +223,8 @@ function framework($option,$htmltitle,$pagetitle,$print) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pagetable($option) {
|
function pagetable($option)
|
||||||
|
{
|
||||||
if ($option == "begin") {
|
if ($option == "begin") {
|
||||||
echo "
|
echo "
|
||||||
<br>
|
<br>
|
||||||
@@ -229,7 +243,8 @@ function pagetable($option) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function pageblock($block,$option) {
|
function pageblock($block, $option)
|
||||||
|
{
|
||||||
global $sbcolor;
|
global $sbcolor;
|
||||||
if ($block == "left") {
|
if ($block == "left") {
|
||||||
if ($option == "begin") {
|
if ($option == "begin") {
|
||||||
@@ -269,7 +284,8 @@ function pageblock($block,$option) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sidemenu($noprint=false) {
|
function sidemenu($noprint = false)
|
||||||
|
{
|
||||||
// Displays sidebar menu
|
// Displays sidebar menu
|
||||||
global $db, $mbgcolor, $noprint;
|
global $db, $mbgcolor, $noprint;
|
||||||
$doparts = PARTS_FUNCTIONS;
|
$doparts = PARTS_FUNCTIONS;
|
||||||
@@ -311,6 +327,7 @@ function sidemenu($noprint=false) {
|
|||||||
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
|
<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=\"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=\"profile.php\">My Profile</a></td></tr>
|
||||||
|
<tr><td align=\"center\"><a href=\"templates.php\">Manage Templates</a></td></tr>
|
||||||
</table>
|
</table>
|
||||||
";
|
";
|
||||||
if (!isset($_SESSION['login'])) {
|
if (!isset($_SESSION['login'])) {
|
||||||
@@ -347,7 +364,8 @@ function sidemenu($noprint=false) {
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
function banner($print) {
|
function banner($print)
|
||||||
|
{
|
||||||
// displays a banner
|
// displays a banner
|
||||||
global $db;
|
global $db;
|
||||||
$bannerid = BANNER;
|
$bannerid = BANNER;
|
||||||
@@ -373,13 +391,20 @@ function banner($print) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
|
function dblookup($dbhandle, $table, $in_field, $out_field, $in_data)
|
||||||
|
{
|
||||||
// look up a single field in a database given a value for a single field
|
// 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\""));
|
$dbqry = mysqli_query($dbhandle, "select $out_field from $table where $in_field=\"$in_data\"");
|
||||||
return($out_data[0]);
|
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) {
|
function calendar($year, $month, $day, $link_url)
|
||||||
|
{
|
||||||
// takes a numeric year, month, day, and the basic url for the day links as arguments
|
// takes a numeric year, month, day, and the basic url for the day links as arguments
|
||||||
// Shows a calendar with clickable dates.
|
// Shows a calendar with clickable dates.
|
||||||
// Based on an embeddable calendar by Yves Glodt.
|
// Based on an embeddable calendar by Yves Glodt.
|
||||||
@@ -495,7 +520,8 @@ EOT;
|
|||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function colorpicker($baseurl) {
|
function colorpicker($baseurl)
|
||||||
|
{
|
||||||
// takes a standard url and tacks the color number on to the end of it
|
// takes a standard url and tacks the color number on to the end of it
|
||||||
// giving a palette of links
|
// giving a palette of links
|
||||||
echo "
|
echo "
|
||||||
@@ -578,7 +604,8 @@ function colorpicker($baseurl) {
|
|||||||
// Project functions
|
// Project functions
|
||||||
|
|
||||||
|
|
||||||
function getsetting($setting_name,$tech_id) {
|
function getsetting($setting_name, $tech_id)
|
||||||
|
{
|
||||||
// get the value of a setting for a tech
|
// get the value of a setting for a tech
|
||||||
global $db;
|
global $db;
|
||||||
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||||
@@ -600,7 +627,8 @@ function getsetting($setting_name,$tech_id) {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function putsetting($setting_name,$setting_value,$tech_id) {
|
function putsetting($setting_name, $setting_value, $tech_id)
|
||||||
|
{
|
||||||
// set the value of a setting for a tech
|
// set the value of a setting for a tech
|
||||||
global $db;
|
global $db;
|
||||||
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||||
@@ -620,73 +648,66 @@ function putsetting($setting_name,$setting_value,$tech_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function islink($il_note) {
|
function islink($il_note)
|
||||||
|
{
|
||||||
// takes a noteid number as an argument
|
// takes a noteid number as an argument
|
||||||
// determines if the argument is a link in a reference chain
|
// determines if the argument is a link in a reference chain
|
||||||
// returns 1 if note is a link, 0 if not
|
// returns 1 if note is a link, 0 if not
|
||||||
global $db;
|
global $db;
|
||||||
$il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\""));
|
$refqry = mysqli_query($db, "select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
|
||||||
if ($il_pq[0]=="") {
|
if (mysqli_num_rows($refqry)) {
|
||||||
$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) {
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_chain($chainlink) {
|
|
||||||
|
function generate_chain($chainlink)
|
||||||
|
{
|
||||||
// generate a reference chain
|
// generate a reference chain
|
||||||
// takes a single parameter, a noteid
|
// takes a single parameter, a noteid
|
||||||
// finds all notes that are members of a chain containing the supplied 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;
|
global $db;
|
||||||
$refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\"");
|
// create notes and refs arrays from the reflinks table
|
||||||
$nanote=array();
|
$notes = [];
|
||||||
$narefs=array();
|
$targets = [];
|
||||||
while ($allrefs=mysqli_fetch_row($refsqry)) {
|
$linkqry = mysqli_query($db, "select noteid,target from reflinks where noteid is not null");
|
||||||
$spltrefs=explode(",",$allrefs[1]);
|
while ($link = mysqli_fetch_assoc($linkqry)) {
|
||||||
$iptr=0;
|
$notes[] = $link['noteid'];
|
||||||
while ($iptr<count($spltrefs)) {
|
$targets[] = $link['target'];
|
||||||
array_push($nanote,$allrefs[0]);
|
|
||||||
array_push($narefs,$spltrefs[$iptr]);
|
|
||||||
$iptr=$iptr+1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$chainarray=array($chainlink);
|
$chainarray = array(); // create the chainarray
|
||||||
$results=array();
|
$chainarray[] = $chainlink; // add the incoming noteid for which the chain should be generated
|
||||||
$mptr=0;
|
$captr = 0; // chainarray pointer
|
||||||
while($mptr<count($chainarray)) {
|
while ($captr < count($chainarray)) { // as long as the chainarray is growing
|
||||||
$nptr=0;
|
$nptr = 0; // note pointer
|
||||||
while($nptr<count($nanote)) {
|
// run through the notes array, adding all targets for this note to the chainarray
|
||||||
if(($nanote[$nptr]==$chainarray[$mptr]) && ( ! in_array($narefs[$nptr],$chainarray))) {
|
while ($nptr < count($notes)) {
|
||||||
array_push($chainarray,$narefs[$nptr]);
|
if (($notes[$nptr] == $chainarray[$captr]) && (! in_array($targets[$nptr], $chainarray))) {
|
||||||
|
$chainarray[] = $targets[$nptr];
|
||||||
}
|
}
|
||||||
$nptr = $nptr + 1;
|
$nptr = $nptr + 1;
|
||||||
}
|
}
|
||||||
$rptr=0;
|
// run through the targets array, adding all notes for this target to the chainarray
|
||||||
while($rptr<count($narefs)) {
|
$tptr = 0; //target pointer
|
||||||
if(($narefs[$rptr]==$chainarray[$mptr]) && ( ! in_array($nanote[$rptr],$chainarray))) {
|
while ($tptr < count($targets)) {
|
||||||
array_push($chainarray,$nanote[$rptr]);
|
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);
|
sort($chainarray);
|
||||||
return ($chainarray);
|
return ($chainarray);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertweblinks($rawstring) {
|
function convertweblinks($rawstring)
|
||||||
|
{
|
||||||
// takes a string, finds urls, and returns the string with urls converted to clickable links
|
// takes a string, finds urls, and returns the string with urls converted to clickable links
|
||||||
$urlchunksize = URL_CHUNK_SIZE;
|
$urlchunksize = URL_CHUNK_SIZE;
|
||||||
// define regex pattern for urls
|
// define regex pattern for urls
|
||||||
@@ -705,7 +726,8 @@ function convertweblinks($rawstring) {
|
|||||||
return $rawstring;
|
return $rawstring;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showlinklist($print) {
|
function showlinklist($print)
|
||||||
|
{
|
||||||
global $db;
|
global $db;
|
||||||
$linkresult = mysqli_query($db, "select linkid from links where status=\"1\"");
|
$linkresult = mysqli_query($db, "select linkid from links where status=\"1\"");
|
||||||
if (mysqli_num_rows($linkresult) && !$print) {
|
if (mysqli_num_rows($linkresult) && !$print) {
|
||||||
@@ -719,7 +741,8 @@ function showlinklist($print) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nag($tech_id) {
|
function nag($tech_id)
|
||||||
|
{
|
||||||
// nags the user if something is pending
|
// nags the user if something is pending
|
||||||
global $db, $today;
|
global $db, $today;
|
||||||
// maintenance forms
|
// maintenance forms
|
||||||
@@ -744,17 +767,20 @@ function nag($tech_id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_part_data($partinputdata) {
|
function get_part_data($partinputdata)
|
||||||
|
{
|
||||||
// given an associative array of partid, uid, partnum, sernum,
|
// given an associative array of partid, uid, partnum, sernum,
|
||||||
// return an associative array of
|
// return an associative array of
|
||||||
// partid, uid, partnum, sernum, partname, result
|
// partid, uid, partnum, sernum, partname, result
|
||||||
// where result=0 for success, 1 for no data found, 2 for mismatch
|
// where result=0 for success, 1 for no data found, 2 for mismatch
|
||||||
global $db;
|
global $db;
|
||||||
|
$checkmm = FALSE;
|
||||||
|
$result = 0;
|
||||||
// pull input data from input array
|
// pull input data from input array
|
||||||
if ($partinputdata['partid'] && $partinputdata['partid'] != "") $partid= $partinputdata['partid'];
|
$partid = (array_key_exists('partid', $partinputdata) && $partinputdata['partid'] != "") ? $partinputdata['partid'] : NULL;
|
||||||
if ($partinputdata['uid'] && $partinputdata['uid'] != "") $uid= $partinputdata['uid'];
|
$uid = (array_key_exists('uid', $partinputdata) && $partinputdata['uid'] != "") ? $partinputdata['uid'] : NULL;
|
||||||
if ($partinputdata['partnum'] && $partinputdata['partnum'] != "") $partnum= $partinputdata['partnum'];
|
$partnum = (array_key_exists('partnum', $partinputdata) && $partinputdata['partnum'] != "") ? $partinputdata['partnum'] : NULL;
|
||||||
if ($partinputdata['sernum'] && $partinputdata['sernum'] != "") $sernum= $partinputdata['sernum'];
|
$sernum = (array_key_exists('sernum', $partinputdata) && $partinputdata['sernum'] != "") ? $partinputdata['sernum'] : NULL;
|
||||||
// for part data supplied, see what info is available
|
// for part data supplied, see what info is available
|
||||||
// if a partid is supplied, pull other info from parts
|
// if a partid is supplied, pull other info from parts
|
||||||
if ($partid) { // if partid supplied
|
if ($partid) { // if partid supplied
|
||||||
@@ -765,21 +791,21 @@ function get_part_data($partinputdata) {
|
|||||||
$partqry = mysqli_query($db, "select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
|
$partqry = mysqli_query($db, "select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
|
||||||
} else if ($uid && $partnum && $sernum) { //if uid and pn/sn supplied
|
} else if ($uid && $partnum && $sernum) { //if uid and pn/sn supplied
|
||||||
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\"");
|
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\" and sernum=\"$sernum\"");
|
||||||
$checkmm=1;
|
$checkmm = TRUE;
|
||||||
$mismatchqry = mysqli_query($db, "select * from parts where
|
$mismatchqry = mysqli_query($db, "select * from parts where
|
||||||
(uid like \"$uid\" and ((partnum !=\"$partnum\" and partnum !=\"\")or (sernum !=\"$sernum\" and sernum !=\"\"))) or
|
(uid like \"$uid\" and ((partnum !=\"$partnum\" and partnum !=\"\")or (sernum !=\"$sernum\" and sernum !=\"\"))) or
|
||||||
((uid not like \"$uid\" and uid not like \"\") and (partnum =\"$partnum\" and sernum =\"$sernum\"))
|
((uid not like \"$uid\" and uid not like \"\") and (partnum =\"$partnum\" and sernum =\"$sernum\"))
|
||||||
");
|
");
|
||||||
} else if ($uid && $partnum && ! $sernum) { //if uid and pn only supplied
|
} else if ($uid && $partnum && ! $sernum) { //if uid and pn only supplied
|
||||||
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\"");
|
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and partnum=\"$partnum\"");
|
||||||
$checkmm=1;
|
$checkmm = TRUE;
|
||||||
$mismatchqry = mysqli_query($db, "select partid from parts where
|
$mismatchqry = mysqli_query($db, "select partid from parts where
|
||||||
(uid like \"$uid\" and partnum !=\"$partnum\") or
|
(uid like \"$uid\" and partnum !=\"$partnum\") or
|
||||||
(uid not like \"$uid\" and partnum =\"$partnum\")
|
(uid not like \"$uid\" and partnum =\"$partnum\")
|
||||||
");
|
");
|
||||||
} else if ($uid && ! $partnum && $sernum) { //if uid and sn only supplied
|
} else if ($uid && ! $partnum && $sernum) { //if uid and sn only supplied
|
||||||
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and sernum=\"$sernum\"");
|
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\" and sernum=\"$sernum\"");
|
||||||
$checkmm=1;
|
$checkmm = TRUE;
|
||||||
$mismatchqry = mysqli_query($db, "select partid from parts where
|
$mismatchqry = mysqli_query($db, "select partid from parts where
|
||||||
(uid like \"$uid\" and sernum !=\"$sernum\") or
|
(uid like \"$uid\" and sernum !=\"$sernum\") or
|
||||||
(uid not like \"$uid\" and sernum =\"$sernum\")
|
(uid not like \"$uid\" and sernum =\"$sernum\")
|
||||||
@@ -800,9 +826,6 @@ function get_part_data($partinputdata) {
|
|||||||
if ($checkmm) {
|
if ($checkmm) {
|
||||||
if (mysqli_num_rows($mismatchqry)) {
|
if (mysqli_num_rows($mismatchqry)) {
|
||||||
$result = 2;
|
$result = 2;
|
||||||
//while ($mmdata=mysqli_fetch_assoc($mismatchqry)) {
|
|
||||||
//var_dump($mmdata);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,7 +838,8 @@ function get_part_data($partinputdata) {
|
|||||||
return $partdata;
|
return $partdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_upcoming_events() {
|
function get_upcoming_events()
|
||||||
|
{
|
||||||
// build array of upcoming events
|
// build array of upcoming events
|
||||||
// takes no arguments
|
// takes no arguments
|
||||||
// returns an array containing arrays of upcoming event data
|
// returns an array containing arrays of upcoming event data
|
||||||
@@ -904,7 +928,8 @@ function get_upcoming_events() {
|
|||||||
return $ucevents;
|
return $ucevents;
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_message($msgtype,$msgtxt) {
|
function format_message($msgtype, $msgtxt)
|
||||||
|
{
|
||||||
// displays a formatted message
|
// displays a formatted message
|
||||||
// $msgtype is 0 for success or anything else for failure
|
// $msgtype is 0 for success or anything else for failure
|
||||||
// $msgtxt is the string to display
|
// $msgtxt is the string to display
|
||||||
@@ -924,4 +949,92 @@ function format_message($msgtype,$msgtxt) {
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
function templateselect($techid, $operation)
|
||||||
|
{
|
||||||
|
// Displays a line enabling selection of a user or global template
|
||||||
|
// $techid is the id number of the current tech
|
||||||
|
// $operation is one of "add" "edit" "delete" or NULL
|
||||||
|
global $db;
|
||||||
|
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
|
||||||
|
echo "
|
||||||
|
<form method=\"post\">
|
||||||
|
";
|
||||||
|
// 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.\">
|
||||||
|
";
|
||||||
|
if ($isadmin && $operation != NULL) {
|
||||||
|
$templaterow = mysqli_query($db, "select * from notetemplates where tech!=\"0\" order by tech asc, templatename asc");
|
||||||
|
} else {
|
||||||
|
$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)) {
|
||||||
|
if ($isadmin && $operation != NULL) {
|
||||||
|
$techname = dblookup($db, "techs", "techid", "techname", $templateitem["tech"]);
|
||||||
|
printf("<option value=\"%s\">%s(%s)</option>", $templateitem["templateid"], $templateitem["templatename"], $techname);
|
||||||
|
} else {
|
||||||
|
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=\"hidden\" name=\"operation\" value=\"$operation\">
|
||||||
|
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href=\"templates.php\">Manage templates</a>
|
||||||
|
</td>
|
||||||
|
</tr></table>
|
||||||
|
<hr>
|
||||||
|
</form>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
function fix_date($datestring)
|
||||||
|
{
|
||||||
|
// accepts a string as an argument
|
||||||
|
// returns a valid date string in the format YYYY-MM-DD
|
||||||
|
// if input string is not a valid date, return the current date
|
||||||
|
global $db, $today;
|
||||||
|
|
||||||
|
if (!$datestring) $datestring = $today;
|
||||||
|
$datepatt = '/^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/';
|
||||||
|
if (!preg_match($datepatt, $datestring)) $datestring = $today;
|
||||||
|
$datestring = mysqli_real_escape_string($db, $datestring);
|
||||||
|
return $datestring;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fix_time($timestring)
|
||||||
|
{
|
||||||
|
// accepts a string as an argument
|
||||||
|
// returns a valid time string in the format HH:MM:SS
|
||||||
|
// if input string is not a valid time, return the current time
|
||||||
|
global $db, $now;
|
||||||
|
|
||||||
|
if (!$timestring) $timestring = $now;
|
||||||
|
$timepatt = '/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/';
|
||||||
|
if (!preg_match($timepatt, $timestring)) $timestring = $now;
|
||||||
|
$timestring = mysqli_real_escape_string($db, $timestring);
|
||||||
|
return $timestring;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
gpl.php
|
gpl.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
|
|
||||||
if ($print) {
|
if ($print) {
|
||||||
$sbcolor = P_SIDEBAR_COLOR;
|
$sbcolor = P_SIDEBAR_COLOR;
|
||||||
@@ -380,5 +380,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
/*
|
/*
|
||||||
logentry.php
|
logentry.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
if (!$_SESSION['login'] && !$_REQUEST['partview']) {
|
if (!array_key_exists("login", $_SESSION) && !array_key_exists("partview", $_REQUEST)) {
|
||||||
header("Location: login.php");
|
header("Location: login.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,22 +18,20 @@ $isadmin=dblookup($db,"techs","techid","admin",$techid);
|
|||||||
$efftechid = $_REQUEST['efftechid'] ?? NULL;
|
$efftechid = $_REQUEST['efftechid'] ?? NULL;
|
||||||
$noteid = $_REQUEST['noteid'] ?? NULL;
|
$noteid = $_REQUEST['noteid'] ?? NULL;
|
||||||
$print = $_REQUEST['print'] ?? NULL;
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
$refto=$_REQUEST['refto'] ?? NULL;
|
|
||||||
$date = $_REQUEST['date'] ?? NULL;
|
$date = $_REQUEST['date'] ?? NULL;
|
||||||
$time = $_REQUEST['time'] ?? NULL;
|
$time = $_REQUEST['time'] ?? NULL;
|
||||||
$note = $_REQUEST['note'] ?? NULL;
|
$note = $_REQUEST['note'] ?? NULL;
|
||||||
$shift = $_REQUEST['shift'] ?? NULL;
|
$shift = $_REQUEST['shift'] ?? NULL;
|
||||||
$subject = $_REQUEST['subject'] ?? NULL;
|
$subject = $_REQUEST['subject'] ?? NULL;
|
||||||
$refs=$_REQUEST['refs'] ?? NULL;
|
$refstring = $_REQUEST['refstring'] ?? NULL;
|
||||||
|
$refto = $_REQUEST['refto'] ?? NULL;
|
||||||
$submit = $_REQUEST['submit'] ?? NULL;
|
$submit = $_REQUEST['submit'] ?? NULL;
|
||||||
$add = $_REQUEST['add'] ?? NULL;
|
$add = $_REQUEST['add'] ?? NULL;
|
||||||
$edit = $_REQUEST['edit'] ?? NULL;
|
$edit = $_REQUEST['edit'] ?? NULL;
|
||||||
$delete = $_REQUEST['delete'] ?? NULL;
|
$delete = $_REQUEST['delete'] ?? NULL;
|
||||||
$templateid=$_REQUEST['templateid'] ?? NULL;
|
$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL;
|
||||||
|
$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL;
|
||||||
$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL;
|
$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL;
|
||||||
$savetemplate=$_REQUEST['savetemplate'] ?? NULL;
|
|
||||||
$copytemplate=$_REQUEST['copytemplate'] ?? NULL;
|
|
||||||
$deltemplate=$_REQUEST['deltemplate'] ?? NULL;
|
|
||||||
$templatename = $_REQUEST['templatename'] ?? NULL;
|
$templatename = $_REQUEST['templatename'] ?? NULL;
|
||||||
$removepart = $_REQUEST['removepart'] ?? NULL;
|
$removepart = $_REQUEST['removepart'] ?? NULL;
|
||||||
$syncflags = $_REQUEST['syncflags'] ?? NULL;
|
$syncflags = $_REQUEST['syncflags'] ?? NULL;
|
||||||
@@ -42,7 +40,7 @@ $uids=$_POST['uids'] ?? [];
|
|||||||
$partnums = $_POST['partnums'] ?? [];
|
$partnums = $_POST['partnums'] ?? [];
|
||||||
$sernums = $_POST['sernums'] ?? [];
|
$sernums = $_POST['sernums'] ?? [];
|
||||||
$actions = $_POST['actions'] ?? [];
|
$actions = $_POST['actions'] ?? [];
|
||||||
$mfreqs=$_POST['mfreqs'] ?? [];
|
$mfreqs = $_POST['mfreqs'] ?? ["off"];
|
||||||
$schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL;
|
$schedmaintcomplete = $_REQUEST['schedmaintcomplete'] ?? NULL;
|
||||||
$partview = $_REQUEST['partview'] ?? NULL;
|
$partview = $_REQUEST['partview'] ?? NULL;
|
||||||
|
|
||||||
@@ -63,29 +61,44 @@ if ($print=="Printer Friendly") {
|
|||||||
}
|
}
|
||||||
if ($partview) $edit = 1;
|
if ($partview) $edit = 1;
|
||||||
if (!$add && !$edit && !$delete && !$submit) $add = 1;
|
if (!$add && !$edit && !$delete && !$submit) $add = 1;
|
||||||
|
|
||||||
|
if ($isadmin) {
|
||||||
|
$authorized = TRUE;
|
||||||
|
} else {
|
||||||
|
$authorized = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ($add) {
|
if ($add) {
|
||||||
framework("begin", "$logname", "Note Entry", $print);
|
framework("begin", "$logname", "Note Entry", $print);
|
||||||
$authorized=1;
|
$authorized = TRUE;
|
||||||
}
|
}
|
||||||
if ($edit || $delete) {
|
if ($edit || $delete) {
|
||||||
framework("begin", "$logname", "Note Edit", $print);
|
framework("begin", "$logname", "Note Edit", $print);
|
||||||
$owner = dblookup($db, "lognotes", "lognoteid", "tech", $noteid);
|
$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 ********
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
if ($usertemplateid) {
|
||||||
|
$templateid = $usertemplateid;
|
||||||
|
} else if ($globaltemplateid) {
|
||||||
|
$templateid = $globaltemplateid;
|
||||||
|
} else {
|
||||||
|
$templateid = NULL;
|
||||||
|
$loadtemplate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ($add) {
|
if ($add) {
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
// add the entry if submit is pressed
|
// add the entry if submit is pressed
|
||||||
if ($note) {
|
if ($note) {
|
||||||
// sanitize and fix blank date and time
|
// sanitize and fix blank date and time
|
||||||
$date=mysqli_real_escape_string($db,$date);
|
$date = fix_date($date);
|
||||||
$time=mysqli_real_escape_string($db,$time);
|
$time = fix_time($time);
|
||||||
if (!$date) $date=$today;
|
|
||||||
if (!$time) $time=$now;
|
|
||||||
// determine whether supplied date is future or past
|
// determine whether supplied date is future or past
|
||||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$date\",CURRENT_DATE)"));
|
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$date\",CURRENT_DATE)"));
|
||||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||||
@@ -100,9 +113,12 @@ if ($add) {
|
|||||||
$note = strip_tags($note, "<a>");
|
$note = strip_tags($note, "<a>");
|
||||||
$note = mysqli_real_escape_string($db, $note);
|
$note = mysqli_real_escape_string($db, $note);
|
||||||
|
|
||||||
// remove cruft from references and sanitize
|
if (strlen($refstring)) {
|
||||||
$refs=preg_replace("#[a-zA-Z]{1,}#","",$refs);
|
// remove everything except numbers and spaces from references and sanitize
|
||||||
$refs=mysqli_real_escape_string($db,$refs);
|
$refstring = preg_replace("#[^\d ]{1,}#", " ", $refstring);
|
||||||
|
$refstring = mysqli_real_escape_string($db, $refstring);
|
||||||
|
$refstring = trim($refstring);
|
||||||
|
}
|
||||||
|
|
||||||
if ($doparts == 1) {
|
if ($doparts == 1) {
|
||||||
// inspect part data
|
// inspect part data
|
||||||
@@ -137,19 +153,29 @@ if ($add) {
|
|||||||
}
|
}
|
||||||
if ($authorized) {
|
if ($authorized) {
|
||||||
// add the record to lognotes
|
// 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);
|
$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);
|
$chainmembers = generate_chain($newnoteid);
|
||||||
foreach ($flags as $flagtblnum) {
|
|
||||||
$flagtblname="flag_".$flagtblnum;
|
// update the flagmap table
|
||||||
|
foreach ($flags as $thisflag) {
|
||||||
// set flag for this note
|
// 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) {
|
if ($syncflags) {
|
||||||
//set flag for reference chain notes
|
//set flag for reference chain notes
|
||||||
foreach ($chainmembers as $refdnote) {
|
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\")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,7 +199,7 @@ if ($add) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +217,7 @@ if ($add) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,10 +235,9 @@ if ($add) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$newnoteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$newnoteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no part info was entered
|
// no part info was entered
|
||||||
}
|
}
|
||||||
@@ -220,110 +245,36 @@ if ($add) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($loadtemplate) {
|
} else {
|
||||||
if ($templateid) {
|
if ($loadtemplate) {
|
||||||
$templatevalues = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""));
|
$templatevalues = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""));
|
||||||
$defaultshift = $templatevalues["shift"];
|
$defaultshift = $templatevalues["shift"];
|
||||||
$defaultsubject = $templatevalues["subject"];
|
$defaultsubject = $templatevalues["subject"];
|
||||||
$note = $templatevalues["lognote"];
|
$note = $templatevalues["lognote"];
|
||||||
$refto=$templatevalues["refs"];
|
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
|
||||||
$techid=$templatevalues["tech"];
|
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) {
|
if ($edit) {
|
||||||
if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\"");
|
if ($removepart && $authorized) mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\" and logpartid=\"$removepart\"");
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
if ($note) {
|
if ($note) {
|
||||||
|
// sanitize and fix blank date and time
|
||||||
|
$date = fix_date($date);
|
||||||
|
$time = fix_time($time);
|
||||||
|
|
||||||
// remove cruft from note text
|
// remove cruft from note text
|
||||||
$note = strip_tags($note, "<a>");
|
$note = strip_tags($note, "<a>");
|
||||||
$note = mysqli_real_escape_string($db, $note);
|
$note = mysqli_real_escape_string($db, $note);
|
||||||
|
|
||||||
// remove cruft from references
|
// 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) {
|
if ($doparts == 1) {
|
||||||
// inspect part data
|
// inspect part data
|
||||||
@@ -359,31 +310,37 @@ if ($edit) {
|
|||||||
|
|
||||||
if ($authorized) {
|
if ($authorized) {
|
||||||
// update lognotes table
|
// 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
|
// update the reflinks table
|
||||||
$flagids=mysqli_query($db,"select flagid from flags");
|
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);
|
$chainmembers = generate_chain($noteid);
|
||||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
|
||||||
$thisflag_tbl="flag_".$thisflagid[0];
|
// update the flagmap table
|
||||||
if ($flags[0]=="") $flags=[];
|
mysqli_query($db, "delete from flagmap where lognoteid=\"$noteid\"");
|
||||||
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) {
|
if ($syncflags) {
|
||||||
foreach ($chainmembers as $refdnote) {
|
foreach ($chainmembers as $refdnote) {
|
||||||
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"lognotes\" and id=\"$refdnote\""))) {
|
if ($refdnote != $noteid) {
|
||||||
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"lognotes\",\"$refdnote\")");
|
mysqli_query($db, "delete from flagmap where lognoteid=\"$refdnote\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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\")");
|
||||||
}
|
}
|
||||||
} 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\"");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -407,7 +364,7 @@ if ($edit) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +382,7 @@ if ($edit) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,31 +400,53 @@ if ($edit) {
|
|||||||
// add it to logparts table
|
// add it to logparts table
|
||||||
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
mysqli_query($db, "insert into logparts(lognoteid,partid,action) values(\"$noteid\",\"$lpid\",\"$actions[$plidx]\")");
|
||||||
// create a maintenance form if required
|
// create a maintenance form if required
|
||||||
if ($mfreqs[$plidx]=="on") {
|
if (array_key_exists($plidx,$mfreqs) && $mfreqs[$plidx] == "on") {
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
mysqli_query($db, "insert into maintforms(mfdate,mftech,mfpart,pending,lognoteid) values(\"$date\",\"$techid\",\"$lpid\",1,\"$noteid\")");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no part info was entered
|
// no part info was entered
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
// refresh the note in question from the database
|
||||||
$getnote = mysqli_query($db, "select * from lognotes where lognoteid=\"$noteid\"");
|
$getnote = mysqli_query($db, "select * from lognotes where lognoteid=\"$noteid\"");
|
||||||
|
}
|
||||||
$notetoedit = mysqli_fetch_assoc($getnote);
|
$notetoedit = mysqli_fetch_assoc($getnote);
|
||||||
}
|
}
|
||||||
if ($delete) {
|
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
|
// delete from lognotes table
|
||||||
mysqli_query($db, "delete from lognotes where lognoteid=\"$noteid\"");
|
mysqli_query($db, "delete from lognotes where lognoteid=\"$noteid\"");
|
||||||
// delete occurances from the flag_ tables
|
|
||||||
$flagids=mysqli_query($db,"select flagid from flags");
|
// delete occurances from the flagmap table
|
||||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
mysqli_query($db, "delete from flagmap where lognoteid=\"$noteid\"");
|
||||||
$delflag_tbl="flag_".$thisflagid[0];
|
|
||||||
mysqli_query($db,"delete from $delflag_tbl where target=\"lognotes\" and id=\"$noteid\"");
|
|
||||||
}
|
|
||||||
// delete occurances from the logparts table
|
// delete occurances from the logparts table
|
||||||
mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\"");
|
mysqli_query($db, "delete from logparts where lognoteid=\"$noteid\"");
|
||||||
}
|
}
|
||||||
@@ -488,17 +467,23 @@ if ($add) {
|
|||||||
$notetime = $now;
|
$notetime = $now;
|
||||||
}
|
}
|
||||||
if ($edit || $delete) {
|
if ($edit || $delete) {
|
||||||
$notedate=$notetoedit["date"];
|
$notedate = $notetoedit["date"] ?? $today;
|
||||||
$notetime=$notetoedit["time"];
|
$notetime = $notetoedit["time"] ?? $now;
|
||||||
$defaultshift = $notetoedit["shift"];
|
$defaultshift = $notetoedit["shift"];
|
||||||
$defaultsubject = $notetoedit["subject"];
|
$defaultsubject = $notetoedit["subject"];
|
||||||
|
|
||||||
$note = $notetoedit["lognote"];
|
$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"];
|
$techid = $notetoedit["tech"];
|
||||||
}
|
}
|
||||||
$techname = dblookup($db, "techs", "techid", "techname", $techid);
|
$techname = dblookup($db, "techs", "techid", "techname", $techid);
|
||||||
$copy_nameexists=$copy_nameexists ?? NULL;
|
|
||||||
$save_nameexists=$save_nameexists ?? NULL;
|
|
||||||
if ($submit) {
|
if ($submit) {
|
||||||
if ($note) {
|
if ($note) {
|
||||||
if ($add) {
|
if ($add) {
|
||||||
@@ -514,60 +499,15 @@ if ($submit) {
|
|||||||
if ($delete) {
|
if ($delete) {
|
||||||
format_message(0, "<strong>Note deleted.</strong> <a href=\"lognotes.php\">Return to main page.</a>");
|
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.\">
|
|
||||||
";
|
|
||||||
if ($loadtemplate) $templatename=dblookup($db,"notetemplates","templateid","templatename",$templateid);
|
|
||||||
$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");
|
|
||||||
} else {
|
|
||||||
printf("<option value=\"%s\" selected>%s</option>","0","Select template");
|
|
||||||
}
|
|
||||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
|
||||||
if ($loadtemplate && ($templateitem["templateid"] == $templateid)) {
|
|
||||||
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>
|
|
||||||
";
|
|
||||||
|
|
||||||
if ($loadtemplate) {
|
if (array_key_exists('login', $_SESSION)) {
|
||||||
echo "
|
// show the template selection line
|
||||||
<!-- <input type=\"hidden\" name=\"templateid\" value=\"$templateid\"> -->
|
templateselect($techid, NULL);
|
||||||
<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>
|
|
||||||
";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "
|
|
||||||
</tr></table>
|
|
||||||
<hr>
|
|
||||||
";
|
|
||||||
}
|
|
||||||
// start note entry section
|
// start note entry section
|
||||||
echo "
|
echo "
|
||||||
|
<form method=\"post\" action=\"logentry.php\">
|
||||||
<table border=\"0\" cellpadding=\"5\">
|
<table border=\"0\" cellpadding=\"5\">
|
||||||
<tr>
|
<tr>
|
||||||
<td align=\"center\" colspan=\"2\"><b>Date: </b>
|
<td align=\"center\" colspan=\"2\"><b>Date: </b>
|
||||||
@@ -581,7 +521,8 @@ if ($isadmin) {
|
|||||||
<td><b>Tech: </b>
|
<td><b>Tech: </b>
|
||||||
<select name=\"efftechid\">
|
<select name=\"efftechid\">
|
||||||
";
|
";
|
||||||
if ($techalpha) $torder="techname"; else $torder="techid";
|
if ($techalpha) $torder = "techname";
|
||||||
|
else $torder = "techid";
|
||||||
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||||
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||||
if ($techitem["status"] == 1) {
|
if ($techitem["status"] == 1) {
|
||||||
@@ -624,7 +565,8 @@ echo "
|
|||||||
<td colspan=\"2\"><b>Subject: </b>
|
<td colspan=\"2\"><b>Subject: </b>
|
||||||
<select name=\"subject\">
|
<select name=\"subject\">
|
||||||
";
|
";
|
||||||
if ($subjalpha) $sorder="subjectname"; else $sorder="subjectid";
|
if ($subjalpha) $sorder = "subjectname";
|
||||||
|
else $sorder = "subjectid";
|
||||||
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
|
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
|
||||||
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
|
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
|
||||||
if ($subjitem["status"] == 1) {
|
if ($subjitem["status"] == 1) {
|
||||||
@@ -641,28 +583,32 @@ echo "
|
|||||||
</select></td>
|
</select></td>
|
||||||
</tr></table>
|
</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\">";
|
<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>
|
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");
|
$allflags = mysqli_query($db, "select flagid from flags");
|
||||||
unset($theseflags);
|
unset($theseflags);
|
||||||
$theseflags = [];
|
$theseflags = [];
|
||||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||||
$thisflagtbl="flag_".$thisflag[0];
|
|
||||||
if ($templateid) {
|
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];
|
$theseflags[] = $thisflag[0];
|
||||||
}
|
}
|
||||||
} else {
|
} 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];
|
$theseflags[] = $thisflag[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if adding a note/template, only show active flags, otherwise, show all flags
|
||||||
if ($add) {
|
if ($add) {
|
||||||
$flagslist = mysqli_query($db, "select * from flags where status=1");
|
$flagslist = mysqli_query($db, "select * from flags where status=1");
|
||||||
} else {
|
} else {
|
||||||
@@ -670,16 +616,27 @@ if ($add) {
|
|||||||
}
|
}
|
||||||
$flagsperline = 8;
|
$flagsperline = 8;
|
||||||
$flagcount = 1;
|
$flagcount = 1;
|
||||||
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
|
||||||
|
|
||||||
|
// 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)) {
|
if (in_array($flagcheckbox["flagid"], $theseflags)) {
|
||||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$flagid = $flagcheckbox["flagid"];
|
$flagid = $flagcheckbox["flagid"];
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
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>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($flagcount < $flagsperline) {
|
if ($flagcount < $flagsperline) {
|
||||||
@@ -690,10 +647,20 @@ while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
|||||||
$flagcount = 1;
|
$flagcount = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mysqli_num_rows($flagslist)) {
|
||||||
echo "
|
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>
|
<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>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "
|
||||||
|
<input type=\"hidden\" name=\"syncflags\" value=\"0\">
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($add && $refto) $refstring = $refto;
|
||||||
|
echo "
|
||||||
<br><br><b>References: </b>
|
<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) {
|
if ($add) {
|
||||||
@@ -716,18 +683,14 @@ if ($add) {
|
|||||||
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
|
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
|
||||||
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
|
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
|
||||||
<td align=\"center\"><select name=\"actions[$partline]\">
|
<td align=\"center\"><select name=\"actions[$partline]\">
|
||||||
<option value=\"select\">Select Action</option>
|
<option value=\"$defaultaction\" selected>Select Action</option>
|
||||||
";
|
";
|
||||||
$actrow = mysqli_query($db, "select * from logpartactions");
|
$actrow = mysqli_query($db, "select * from logpartactions");
|
||||||
while ($actitem = mysqli_fetch_assoc($actrow)) {
|
while ($actitem = mysqli_fetch_assoc($actrow)) {
|
||||||
if ($actitem["status"] == 1) {
|
if ($actitem["status"] == 1) {
|
||||||
if ($actitem["lpactionid"]==$defaultaction) {
|
|
||||||
printf("<option value=\"%s\" selected>%s</option>",$actitem["lpactionid"],$actitem["lpactionname"]);
|
|
||||||
} else {
|
|
||||||
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
|
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
echo "
|
echo "
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -777,19 +740,28 @@ if ($edit) {
|
|||||||
<td align=\"center\">$epsn</td>
|
<td align=\"center\">$epsn</td>
|
||||||
<td align=\"center\">
|
<td align=\"center\">
|
||||||
";
|
";
|
||||||
$actrow=mysqli_query($db,"select * from logpartactions");
|
if ($defaultaction) {
|
||||||
while ($actitem=mysqli_fetch_assoc($actrow)) {
|
// an action was selected previously, so just display it
|
||||||
if ($actitem["lpactionid"]==$defaultaction) {
|
$actname = dblookup($db, "logpartactions", "lpactionid", "lpactionname", $defaultaction);
|
||||||
echo "$actitem[lpactionname]";
|
echo "$actname";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
echo "
|
echo "
|
||||||
</td>
|
</td>
|
||||||
";
|
";
|
||||||
// find maint form for this line and show link
|
// find maint form for this line and show link
|
||||||
$mflinknum=mysqli_fetch_assoc(mysqli_query($db,"select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\""))["maintformid"];
|
|
||||||
echo "
|
echo "
|
||||||
<td align=\"center\"><a href=\"maintformentry.php?mfedit=1&maintformid=$mflinknum\" title=\"Click to view/edit this maintenance form\">$mflinknum</a></td>
|
<td align=\"center\">
|
||||||
|
";
|
||||||
|
$mflinkqry = mysqli_query($db, "select maintformid from maintforms where lognoteid=\"$noteid\" and mfpart=\"$lpidvar\"");
|
||||||
|
if (mysqli_num_rows($mflinkqry)) {
|
||||||
|
$mflinkdata = mysqli_fetch_assoc($mflinkqry);
|
||||||
|
$mflinknum = $mflinkdata["maintformid"];
|
||||||
|
echo "
|
||||||
|
<a href=\"maintformentry.php?mfedit=1&maintformid=$mflinknum\" title=\"Click to view/edit this maintenance form\">$mflinknum</a>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
@@ -802,18 +774,14 @@ if ($edit) {
|
|||||||
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
|
<td align=\"center\"><input type=\"text\" name=\"partnums[$partline]\" size=\"20\"></td>
|
||||||
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
|
<td align=\"center\"><input type=\"text\" name=\"sernums[$partline]\" size=\"20\"></td>
|
||||||
<td align=\"center\"><select name=\"actions[$partline]\">
|
<td align=\"center\"><select name=\"actions[$partline]\">
|
||||||
<option value=\"select\">Select Action</option>
|
<option value=\"$defaultaction\" selected>Select Action</option>
|
||||||
";
|
";
|
||||||
$actrow = mysqli_query($db, "select * from logpartactions");
|
$actrow = mysqli_query($db, "select * from logpartactions");
|
||||||
while ($actitem = mysqli_fetch_assoc($actrow)) {
|
while ($actitem = mysqli_fetch_assoc($actrow)) {
|
||||||
if ($actitem["status"] == 1) {
|
if ($actitem["status"] == 1) {
|
||||||
if ($actitem["lpactionid"]==$defaultaction) {
|
|
||||||
printf("<option value=\"%s\" selected>%s</option>",$actitem["lpactionid"],$actitem["lpactionname"]);
|
|
||||||
} else {
|
|
||||||
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
|
printf("<option value=\"%s\">%s</option>", $actitem["lpactionid"], $actitem["lpactionname"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
echo "
|
echo "
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
@@ -837,5 +805,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
/*
|
/*
|
||||||
login.php
|
login.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
$tech=$_REQUEST['tech'];
|
$tech = $_REQUEST['tech'] ?? NULL;
|
||||||
$pass=$_REQUEST['pass'];
|
$pass = $_REQUEST['pass'] ?? NULL;
|
||||||
$login=$_REQUEST['login'];
|
$login = $_REQUEST['login'] ?? NULL;
|
||||||
$cancel=$_REQUEST['cancel'];
|
$cancel = $_REQUEST['cancel'] ?? NULL;
|
||||||
|
|
||||||
if ($cancel) {
|
if ($cancel) {
|
||||||
session_destroy();
|
session_destroy();
|
||||||
@@ -58,7 +58,6 @@ if ($login) {
|
|||||||
while ($admintech = mysqli_fetch_row($adminqry)[0]) {
|
while ($admintech = mysqli_fetch_row($adminqry)[0]) {
|
||||||
echo "$admintech <br>";
|
echo "$admintech <br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if ($cancel) {
|
} else if ($cancel) {
|
||||||
echo "
|
echo "
|
||||||
@@ -72,7 +71,8 @@ if ($login) {
|
|||||||
<b>Tech: </b>
|
<b>Tech: </b>
|
||||||
<select name=\"tech\">
|
<select name=\"tech\">
|
||||||
";
|
";
|
||||||
if ($techalpha) $torder="techname"; else $torder="techid";
|
if ($techalpha) $torder = "techname";
|
||||||
|
else $torder = "techid";
|
||||||
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||||
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||||
if ($techitem["status"] == 1) {
|
if ($techitem["status"] == 1) {
|
||||||
@@ -98,5 +98,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
lognotes.php
|
lognotes.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -32,7 +32,8 @@ if ($print) {
|
|||||||
if ($tgt_date == "") $tgt_date = $today;
|
if ($tgt_date == "") $tgt_date = $today;
|
||||||
|
|
||||||
// define shifttable_classic function
|
// define shifttable_classic function
|
||||||
function shifttable_classic($shift, $tgt_date, $db) {
|
function shifttable_classic($shift, $tgt_date, $db)
|
||||||
|
{
|
||||||
// convert the shift number to a name for display
|
// convert the shift number to a name for display
|
||||||
$doparts = PARTS_FUNCTIONS;
|
$doparts = PARTS_FUNCTIONS;
|
||||||
$showtime = SHOW_TS;
|
$showtime = SHOW_TS;
|
||||||
@@ -42,14 +43,14 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
|||||||
if ($dshdr) {
|
if ($dshdr) {
|
||||||
// print the shift header
|
// print the shift header
|
||||||
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
|
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 "<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";
|
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)) {
|
while ($tablerow = mysqli_fetch_assoc($note)) {
|
||||||
$reftonote=$tablerow["lognoteid"];
|
$thisnote = $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>";
|
$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"])) {
|
if (islink($thisnote)) {
|
||||||
$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
|
// convert tech number to name
|
||||||
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
||||||
@@ -59,27 +60,24 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
|||||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||||
// generate the flags string
|
// generate the flags string
|
||||||
$flagstring = "";
|
$flagstring = "";
|
||||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
|
||||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
while ($flagid = mysqli_fetch_row($flagqry)) {
|
||||||
$flagid=$allflagids[0];
|
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
|
||||||
$flag_tbl="flag_".$flagid;
|
$flagcolor = $flagparams["flagcolor"];
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
|
$flagsym = $flagparams["flagsym"];
|
||||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
$flagname = $flagparams["flagname"];
|
||||||
$flagcolor=$flagparam["flagcolor"];
|
|
||||||
$flagsym=$flagparam["flagsym"];
|
|
||||||
$flagname=$flagparam["flagname"];
|
|
||||||
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($flagstring) {
|
if ($flagstring) {
|
||||||
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
||||||
} else {
|
} else {
|
||||||
$fmtnote = $fmtnote . "<br>";
|
$fmtnote = $fmtnote . "<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($doparts) {
|
if ($doparts) {
|
||||||
// turn on the parts indicator if parts were entered with the note
|
// 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\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||||
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1¬eid=$reftonote\">PARTS</a>";
|
$fmtnote = $fmtnote . "<a href=\"logentry.php?partview=1¬eid=$thisnote\">PARTS</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now print the line in the table
|
// now print the line in the table
|
||||||
@@ -92,7 +90,9 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
</tr>\n",
|
</tr>\n",
|
||||||
$tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"],
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["time"],
|
||||||
$tname,
|
$tname,
|
||||||
$subjname,
|
$subjname,
|
||||||
$fmtnote,
|
$fmtnote,
|
||||||
@@ -107,7 +107,8 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
</tr>\n",
|
</tr>\n",
|
||||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["lognoteid"],
|
||||||
$tname,
|
$tname,
|
||||||
$subjname,
|
$subjname,
|
||||||
$fmtnote,
|
$fmtnote,
|
||||||
@@ -124,7 +125,8 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// define the shifttable_clean function
|
// define the shifttable_clean function
|
||||||
function shifttable_clean($shift, $tgt_date, $db) {
|
function shifttable_clean($shift, $tgt_date, $db)
|
||||||
|
{
|
||||||
// convert the shift number to a name for display
|
// convert the shift number to a name for display
|
||||||
$doparts = PARTS_FUNCTIONS;
|
$doparts = PARTS_FUNCTIONS;
|
||||||
$showtime = SHOW_TS;
|
$showtime = SHOW_TS;
|
||||||
@@ -134,14 +136,14 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
|||||||
if ($dshdr) {
|
if ($dshdr) {
|
||||||
// print the shift header
|
// print the shift header
|
||||||
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
|
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 "<br><br>";
|
||||||
echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
|
echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
|
||||||
while ($tablerow = mysqli_fetch_assoc($note)) {
|
while ($tablerow = mysqli_fetch_assoc($note)) {
|
||||||
$reftonote=$tablerow["lognoteid"];
|
$thisnote = $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>";
|
$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"])) {
|
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
|
// convert tech number to name
|
||||||
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
||||||
@@ -151,18 +153,14 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
|||||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||||
// generate the flags string
|
// generate the flags string
|
||||||
$flagstring = "";
|
$flagstring = "";
|
||||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
|
||||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
while ($flagid = mysqli_fetch_row($flagqry)) {
|
||||||
$flagid=$allflagids[0];
|
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
|
||||||
$flag_tbl="flag_".$flagid;
|
$flagcolor = $flagparams["flagcolor"];
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
|
$flagsym = $flagparams["flagsym"];
|
||||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
$flagname = $flagparams["flagname"];
|
||||||
$flagcolor=$flagparam["flagcolor"];
|
|
||||||
$flagsym=$flagparam["flagsym"];
|
|
||||||
$flagname=$flagparam["flagname"];
|
|
||||||
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($flagstring) {
|
if ($flagstring) {
|
||||||
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
||||||
} else {
|
} else {
|
||||||
@@ -170,8 +168,8 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
|||||||
}
|
}
|
||||||
if ($doparts) {
|
if ($doparts) {
|
||||||
// turn on the parts indicator if parts were entered with the note
|
// 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\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||||
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1¬eid=$reftonote\" title=\"Click here to see note and parts data.\">PARTS</a>";
|
$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
|
// now print the line in the table
|
||||||
@@ -184,7 +182,8 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
|||||||
%s</b>
|
%s</b>
|
||||||
<br>%s<br>
|
<br>%s<br>
|
||||||
<hr>\n",
|
<hr>\n",
|
||||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["lognoteid"],
|
||||||
$tablerow["time"],
|
$tablerow["time"],
|
||||||
$tname,
|
$tname,
|
||||||
$subjname,
|
$subjname,
|
||||||
@@ -199,7 +198,8 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
|||||||
%s</b>
|
%s</b>
|
||||||
<br>%s<br>
|
<br>%s<br>
|
||||||
<hr>\n",
|
<hr>\n",
|
||||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["lognoteid"],
|
||||||
$tname,
|
$tname,
|
||||||
$subjname,
|
$subjname,
|
||||||
$refs,
|
$refs,
|
||||||
@@ -256,5 +256,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
maintform.php
|
maintform.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -11,8 +11,9 @@ include("functions.php");
|
|||||||
|
|
||||||
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
|
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
|
||||||
|
|
||||||
$histdays=$_REQUEST['histdays'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
$submit=$_REQUEST['submit'];
|
$histdays = $_REQUEST['histdays'] ?? NULL;
|
||||||
|
$submit = $_REQUEST['submit'] ?? NULL;
|
||||||
|
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
@@ -28,7 +29,8 @@ if ($print) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// define pendtable function
|
// define pendtable function
|
||||||
function pendtable($tech_id, $db) {
|
function pendtable($tech_id, $db)
|
||||||
|
{
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
// print section header
|
// print section header
|
||||||
if ($tech_id) {
|
if ($tech_id) {
|
||||||
@@ -88,14 +90,16 @@ function pendtable($tech_id, $db) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$pendrow["maintformid"],$pendrow["maintformid"],
|
$pendrow["maintformid"],
|
||||||
|
$pendrow["maintformid"],
|
||||||
$pendrow["mfdate"],
|
$pendrow["mfdate"],
|
||||||
$tname,
|
$tname,
|
||||||
$uid,
|
$uid,
|
||||||
$partno,
|
$partno,
|
||||||
$serno,
|
$serno,
|
||||||
$partname,
|
$partname,
|
||||||
$noteidval,$noteidval
|
$noteidval,
|
||||||
|
$noteidval
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
printf(
|
printf(
|
||||||
@@ -108,13 +112,15 @@ function pendtable($tech_id, $db) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$pendrow["maintformid"],$pendrow["maintformid"],
|
$pendrow["maintformid"],
|
||||||
|
$pendrow["maintformid"],
|
||||||
$pendrow["mfdate"],
|
$pendrow["mfdate"],
|
||||||
$uid,
|
$uid,
|
||||||
$partno,
|
$partno,
|
||||||
$serno,
|
$serno,
|
||||||
$partname,
|
$partname,
|
||||||
$noteidval,$noteidval
|
$noteidval,
|
||||||
|
$noteidval
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,7 +130,8 @@ function pendtable($tech_id, $db) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// define histtable function
|
// define histtable function
|
||||||
function histtable($hist_days,$db) {
|
function histtable($hist_days, $db)
|
||||||
|
{
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
$dayopts = array(30, 90, 180, 365);
|
$dayopts = array(30, 90, 180, 365);
|
||||||
// print section header
|
// print section header
|
||||||
@@ -186,14 +193,16 @@ function histtable($hist_days,$db) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$histrow["maintformid"],$histrow["maintformid"],
|
$histrow["maintformid"],
|
||||||
|
$histrow["maintformid"],
|
||||||
$histrow["mfdate"],
|
$histrow["mfdate"],
|
||||||
$tname,
|
$tname,
|
||||||
$uid,
|
$uid,
|
||||||
$partno,
|
$partno,
|
||||||
$serno,
|
$serno,
|
||||||
$partname,
|
$partname,
|
||||||
$noteidval,$noteidval
|
$noteidval,
|
||||||
|
$noteidval
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo "
|
echo "
|
||||||
@@ -226,5 +235,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
maintformentry.php
|
maintformentry.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -17,52 +17,54 @@ if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
|
|||||||
$loggedinas = $_SESSION['login'];
|
$loggedinas = $_SESSION['login'];
|
||||||
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
||||||
|
|
||||||
function getmfdata($maintformid) {
|
function getmfdata($maintformid)
|
||||||
|
{
|
||||||
// pull maintenance form data from maintforms table
|
// pull maintenance form data from maintforms table
|
||||||
global $db;
|
global $db;
|
||||||
$mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\""));
|
$mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\""));
|
||||||
return $mfdata;
|
return $mfdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getactiondata($maintactionid) {
|
function getactiondata($maintactionid)
|
||||||
|
{
|
||||||
// pull maintenance action data from maintactions table
|
// pull maintenance action data from maintactions table
|
||||||
global $db;
|
global $db;
|
||||||
$actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\""));
|
$actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\""));
|
||||||
return $actiondata;
|
return $actiondata;
|
||||||
}
|
}
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
|
|
||||||
$maintformid=$_REQUEST['maintformid'];
|
$maintformid = $_REQUEST['maintformid'] ?? NULL;
|
||||||
$lognoteid=$_REQUEST['lognoteid'];
|
$lognoteid = $_REQUEST['lognoteid'] ?? NULL;
|
||||||
$mfdate=$_REQUEST['date'];
|
$mfdate = $_REQUEST['date'] ?? NULL;
|
||||||
$mftime=$_REQUEST['time'];
|
$mftime = $_REQUEST['time'] ?? NULL;
|
||||||
$mfsubmit=$_REQUEST['mfsubmit'];
|
$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL;
|
||||||
$mfadd=$_REQUEST['mfadd'];
|
$mfadd = $_REQUEST['mfadd'] ?? NULL;
|
||||||
$mfedit=$_REQUEST['mfedit'];
|
$mfedit = $_REQUEST['mfedit'] ?? NULL;
|
||||||
$mfdelete=$_REQUEST['mfdelete'];
|
$mfdelete = $_REQUEST['mfdelete'] ?? NULL;
|
||||||
$mfpartloc=$_REQUEST['mfpartloc'];
|
$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL;
|
||||||
$mfmalfunction=$_REQUEST['mfmalfunction'];
|
$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL;
|
||||||
$nha=$_REQUEST['nha'];
|
$nha = $_REQUEST['nha'] ?? NULL;
|
||||||
$repord=$_REQUEST['repord'];
|
$repord = $_REQUEST['repord'] ?? NULL;
|
||||||
$mfpart=$_REQUEST['mfpart'];
|
$mfpart = $_REQUEST['mfpart'] ?? NULL;
|
||||||
$uid=$_REQUEST['uid'];
|
$uid = $_REQUEST['uid'] ?? NULL;
|
||||||
$partnum=$_REQUEST['partnum'];
|
$partnum = $_REQUEST['partnum'] ?? NULL;
|
||||||
$sernum=$_REQUEST['sernum'];
|
$sernum = $_REQUEST['sernum'] ?? NULL;
|
||||||
$partname=$_REQUEST['partname'];
|
$partname = $_REQUEST['partname'] ?? NULL;
|
||||||
$actionadd=$_REQUEST['actionadd'];
|
$actionadd = $_REQUEST['actionadd'] ?? NULL;
|
||||||
$actionedit=$_REQUEST['actionedit'];
|
$actionedit = $_REQUEST['actionedit'] ?? NULL;
|
||||||
$actiondelete=$_REQUEST['actiondelete'];
|
$actiondelete = $_REQUEST['actiondelete'] ?? NULL;
|
||||||
$maintactionid=$_REQUEST['maintactionid'];
|
$maintactionid = $_REQUEST['maintactionid'] ?? NULL;
|
||||||
$actiondate=$_REQUEST['actiondate'];
|
$actiondate = $_REQUEST['actiondate'] ?? NULL;
|
||||||
$actiontime=$_REQUEST['actiontime'];
|
$actiontime = $_REQUEST['actiontime'] ?? NULL;
|
||||||
$actiontech=$_REQUEST['actiontech'];
|
$actiontech = $_REQUEST['actiontech'] ?? NULL;
|
||||||
$action=$_REQUEST['action'];
|
$action = $_REQUEST['action'] ?? NULL;
|
||||||
$actionaddsubmit=$_REQUEST['actionaddsubmit'];
|
$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL;
|
||||||
$actioneditsubmit=$_REQUEST['actioneditsubmit'];
|
$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL;
|
||||||
$printfmt=$_REQUEST['printfmt'];
|
$printfmt = $_REQUEST['printfmt'] ?? NULL;
|
||||||
if ($printfmt) $print=1;
|
if ($printfmt) $print = TRUE;
|
||||||
$flags=$_POST['flags'];
|
$flags = $_POST['flags'] ?? [];
|
||||||
|
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
@@ -78,48 +80,49 @@ if ($printfmt) {
|
|||||||
framework("begin", "", "", $print);
|
framework("begin", "", "", $print);
|
||||||
} else if ($mfedit) {
|
} else if ($mfedit) {
|
||||||
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
||||||
if ($loggedinas) $mfauthorized=1;
|
if ($loggedinas) $mfauthorized = TRUE;
|
||||||
} else if ($mfdelete) {
|
} else if ($mfdelete) {
|
||||||
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
||||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||||
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=1;
|
if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE;
|
||||||
} else if ($actionadd) {
|
} else if ($actionadd) {
|
||||||
framework("begin", "$logname", "Maintenance Action Entry", $print);
|
framework("begin", "$logname", "Maintenance Action Entry", $print);
|
||||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||||
if ($loggedinas) {
|
if ($loggedinas) {
|
||||||
$mfauthorized=1;
|
$mfauthorized = TRUE;
|
||||||
$actionauthorized=1;
|
$actionauthorized = TRUE;
|
||||||
}
|
}
|
||||||
} else if ($actionedit || $actiondelete) {
|
} else if ($actionedit || $actiondelete) {
|
||||||
framework("begin", "$logname", "Maintenance Action Edit", $print);
|
framework("begin", "$logname", "Maintenance Action Edit", $print);
|
||||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||||
if ($loggedinas) $mfauthorized=1;
|
if ($loggedinas) $mfauthorized = TRUE;
|
||||||
$actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
|
$actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
|
||||||
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1;
|
if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$mfadd=1;
|
$mfadd = TRUE;
|
||||||
framework("begin", "$logname", "Maintenance Form Entry", $print);
|
framework("begin", "$logname", "Maintenance Form Entry", $print);
|
||||||
$mftech = $loggedinas;
|
$mftech = $loggedinas;
|
||||||
$mfauthorized=1;
|
$mfauthorized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ******** begin database manipulation ********
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
//var_dump($_REQUEST);
|
//var_dump($_REQUEST);
|
||||||
|
|
||||||
|
$pdatamismatch = NULL;
|
||||||
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
|
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
|
||||||
// pull mf data from database
|
// pull mf data from database
|
||||||
$mftoedit = getmfdata($maintformid);
|
$mftoedit = getmfdata($maintformid);
|
||||||
$partdatainput=array();
|
$partdatainput = [];
|
||||||
if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart'];
|
if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart'];
|
||||||
if ($uid) $partdatainput['uid'] = $uid;
|
if ($uid) $partdatainput['uid'] = $uid;
|
||||||
if ($partnum) $partdatainput['partnum'] = $partnum;
|
if ($partnum) $partdatainput['partnum'] = $partnum;
|
||||||
if ($sernum) $partdatainput['sernum'] = $sernum;
|
if ($sernum) $partdatainput['sernum'] = $sernum;
|
||||||
$partinfo = get_part_data($partdatainput);
|
$partinfo = get_part_data($partdatainput);
|
||||||
if ($partinfo['result'] == 2) {
|
if ($partinfo['result'] == 2) {
|
||||||
$pdatamismatch=1;
|
$pdatamismatch = TRUE;
|
||||||
} else {
|
} else {
|
||||||
unset($pdatamismatch);
|
$pdatamismatch = FALSE;
|
||||||
if ($partinfo['partid']) $mfpart = $partinfo['partid'];
|
if ($partinfo['partid']) $mfpart = $partinfo['partid'];
|
||||||
if ($partinfo['uid']) $uid = $partinfo['uid'];
|
if ($partinfo['uid']) $uid = $partinfo['uid'];
|
||||||
if ($partinfo['partnum']) $partnum = $partinfo['partnum'];
|
if ($partinfo['partnum']) $partnum = $partinfo['partnum'];
|
||||||
@@ -132,6 +135,9 @@ if ($mfadd) {
|
|||||||
if ($mfsubmit) {
|
if ($mfsubmit) {
|
||||||
// add the entry if submit is pressed
|
// add the entry if submit is pressed
|
||||||
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
|
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
|
||||||
|
// sanitize and fix blank date and time
|
||||||
|
$mfdate = fix_date($mfdate);
|
||||||
|
$mftime = fix_time($mftime);
|
||||||
// determine whether supplied date is future or past
|
// determine whether supplied date is future or past
|
||||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)"));
|
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)"));
|
||||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||||
@@ -157,9 +163,10 @@ if ($mfadd) {
|
|||||||
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
||||||
$mfpart = mysqli_insert_id($db);
|
$mfpart = mysqli_insert_id($db);
|
||||||
} else if ($partinfo['result'] == 2) {
|
} else if ($partinfo['result'] == 2) {
|
||||||
$pdatamismatch=1;
|
$pdatamismatch = TRUE;
|
||||||
} else {
|
} else {
|
||||||
// if it is in parts table, get partid for this record
|
// if it is in parts table, get partid for this record
|
||||||
|
$pdatamismatch = FALSE;
|
||||||
$mfpart = $partinfo['partid'];
|
$mfpart = $partinfo['partid'];
|
||||||
}
|
}
|
||||||
if ($uid == "" || $partnum == "" || $sernum == "") {
|
if ($uid == "" || $partnum == "" || $sernum == "") {
|
||||||
@@ -171,15 +178,16 @@ if ($mfadd) {
|
|||||||
|
|
||||||
// add the record to maintforms
|
// add the record to maintforms
|
||||||
if (! $pdatamismatch) {
|
if (! $pdatamismatch) {
|
||||||
|
$lognoteid = ($lognoteid == NULL) ? 0 : $lognoteid;
|
||||||
mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
|
mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
|
||||||
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
|
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
|
||||||
$newmaintformid = mysqli_insert_id($db);
|
$newmaintformid = mysqli_insert_id($db);
|
||||||
$mfidtoprint = $newmaintformid;
|
$mfidtoprint = $newmaintformid;
|
||||||
|
|
||||||
// add this maintformid to the appropriate flag_tables
|
// update the flagmap table
|
||||||
foreach ($flags as $flagtblnum) {
|
foreach ($flags as $thisflag) {
|
||||||
$flagtblname="flag_".$flagtblnum;
|
// set flag for this maintenance form
|
||||||
mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$newmaintformid\")");
|
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$newmaintformid\")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,20 +217,12 @@ if ($mfedit) {
|
|||||||
if (! $pdatamismatch) {
|
if (! $pdatamismatch) {
|
||||||
mysqli_query($db, "update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
|
mysqli_query($db, "update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
|
||||||
mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\"");
|
mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\"");
|
||||||
// update the appropriate flag_tables
|
|
||||||
$flagids=mysqli_query($db,"select flagid from flags");
|
// update the flagmap table
|
||||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
|
||||||
$thisflag_tbl="flag_".$thisflagid[0];
|
foreach ($flags as $thisflag) {
|
||||||
if ($flags[0]=="") $flags=[];
|
// set flag for this maintenance form
|
||||||
if (in_array($thisflagid[0],$flags)) {
|
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")");
|
||||||
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
|
||||||
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
|
||||||
mysqli_query($db,"delete from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,17 +233,16 @@ if ($mfedit) {
|
|||||||
if ($mfdelete && $mfauthorized) {
|
if ($mfdelete && $mfauthorized) {
|
||||||
// delete from maintforms table
|
// delete from maintforms table
|
||||||
mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\"");
|
mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\"");
|
||||||
// delete occurances from the flag_ tables
|
// delete occurances from the flagmap table
|
||||||
$flagids=mysqli_query($db,"select flagid from flags");
|
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
|
||||||
while ($thisflagid=mysqli_fetch_row($flagids)) {
|
|
||||||
$delflag_tbl="flag_".$thisflagid[0];
|
|
||||||
mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($actionadd) {
|
if ($actionadd) {
|
||||||
if ($actionaddsubmit) {
|
if ($actionaddsubmit) {
|
||||||
if ($action) {
|
if ($action) {
|
||||||
|
// sanitize and fix blank date and time
|
||||||
|
$actiondate = fix_date($actiondate);
|
||||||
|
$actiontime = fix_time($actiontime);
|
||||||
// determine whether supplied date is future or past
|
// determine whether supplied date is future or past
|
||||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)"));
|
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)"));
|
||||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||||
@@ -268,6 +267,9 @@ if ($actionadd) {
|
|||||||
if ($actionedit) {
|
if ($actionedit) {
|
||||||
if ($actioneditsubmit && $actionauthorized) {
|
if ($actioneditsubmit && $actionauthorized) {
|
||||||
// update the action
|
// update the action
|
||||||
|
// sanitize and fix blank date and time
|
||||||
|
$actiondate = fix_date($actiondate);
|
||||||
|
$actiontime = fix_time($actiontime);
|
||||||
// remove cruft from action text
|
// remove cruft from action text
|
||||||
$action = htmlentities($action);
|
$action = htmlentities($action);
|
||||||
$action = addslashes($action);
|
$action = addslashes($action);
|
||||||
@@ -324,7 +326,8 @@ if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit |
|
|||||||
$sernum = $partinfo['sernum'];
|
$sernum = $partinfo['sernum'];
|
||||||
$partname = $partinfo['partname'];
|
$partname = $partinfo['partname'];
|
||||||
$pluresult = $partinfo['result'];
|
$pluresult = $partinfo['result'];
|
||||||
if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch);
|
if ($pluresult == 2) $pdatamismatch = TRUE;
|
||||||
|
else $pdatamismatch = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$techname = dblookup($db, "techs", "techid", "techname", $mftech);
|
$techname = dblookup($db, "techs", "techid", "techname", $mftech);
|
||||||
@@ -384,19 +387,21 @@ if ($printfmt) {
|
|||||||
<b><u>Flags</u></b><br>
|
<b><u>Flags</u></b><br>
|
||||||
<table width=\"100%\" border=\"0\">
|
<table width=\"100%\" border=\"0\">
|
||||||
";
|
";
|
||||||
// get an array of flagids set for this maintformid
|
|
||||||
|
// create an array called theseflags of flagids set for this maintformid
|
||||||
$allflags = mysqli_query($db, "select flagid from flags");
|
$allflags = mysqli_query($db, "select flagid from flags");
|
||||||
unset($theseflags);
|
unset($theseflags);
|
||||||
|
$theseflags = [];
|
||||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||||
$thisflagtbl="flag_".$thisflag[0];
|
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
|
||||||
$theseflags[] = $thisflag[0];
|
$theseflags[] = $thisflag[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// display flag symbols for set flags
|
||||||
$flagslist = mysqli_query($db, "select * from flags");
|
$flagslist = mysqli_query($db, "select * from flags");
|
||||||
while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
|
while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
|
||||||
if ($theseflags[0] == "") $theseflags = [];
|
if ($theseflags[0] == "") $theseflags = [];
|
||||||
if (in_array($flagsymbol["flagid"],$theseflags)) {
|
if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) {
|
||||||
echo $flagsymbol['flagsym'] . " ";
|
echo $flagsymbol['flagsym'] . " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -470,13 +475,12 @@ if ($printfmt) {
|
|||||||
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
|
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
";
|
";
|
||||||
// get an array of flagids set for this maintformid
|
// create an array called theseflags of flagids set for this maintformid
|
||||||
$allflags = mysqli_query($db, "select flagid from flags");
|
$allflags = mysqli_query($db, "select flagid from flags");
|
||||||
unset($theseflags);
|
unset($theseflags);
|
||||||
$theseflags = [];
|
$theseflags = [];
|
||||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||||
$thisflagtbl="flag_".$thisflag[0];
|
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
|
||||||
$theseflags[] = $thisflag[0];
|
$theseflags[] = $thisflag[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -488,15 +492,25 @@ if ($printfmt) {
|
|||||||
$flagsperline = 8;
|
$flagsperline = 8;
|
||||||
$flagcount = 1;
|
$flagcount = 1;
|
||||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||||
if ($theseflags[0]=="") $theseflags=[];
|
//if ($theseflags[0]=="") $theseflags=[];
|
||||||
if (in_array($flagcheckbox["flagid"], $theseflags)) {
|
if (in_array($flagcheckbox["flagid"], $theseflags)) {
|
||||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$flagid = $flagcheckbox["flagid"];
|
$flagid = $flagcheckbox["flagid"];
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
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>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($flagcount < $flagsperline) {
|
if ($flagcount < $flagsperline) {
|
||||||
@@ -658,5 +672,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
partentry.php
|
partentry.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -17,17 +17,17 @@ if (!isset($_SESSION['login'])) {
|
|||||||
$loggedinas = $_SESSION['login'];
|
$loggedinas = $_SESSION['login'];
|
||||||
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
$add=$_REQUEST['add'];
|
$add = $_REQUEST['add'] ?? NULL;
|
||||||
$edit=$_REQUEST['edit'];
|
$edit = $_REQUEST['edit'] ?? NULL;
|
||||||
$delete=$_REQUEST['delete'];
|
$delete = $_REQUEST['delete'] ?? NULL;
|
||||||
|
|
||||||
$partid=$_REQUEST['partid'];
|
$partid = $_REQUEST['partid'] ?? NULL;
|
||||||
$uid=$_REQUEST['uid'];
|
$uid = $_REQUEST['uid'] ?? NULL;
|
||||||
$partnum=$_REQUEST['partnum'];
|
$partnum = $_REQUEST['partnum'] ?? NULL;
|
||||||
$sernum=$_REQUEST['sernum'];
|
$sernum = $_REQUEST['sernum'] ?? NULL;
|
||||||
$partname=$_REQUEST['partname'];
|
$partname = $_REQUEST['partname'] ?? NULL;
|
||||||
$submit=$_REQUEST['submit'];
|
$submit = $_REQUEST['submit'] ?? NULL;
|
||||||
|
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
@@ -96,13 +96,13 @@ $partdatainput=array();
|
|||||||
$partdatainput['partid'] = $partid;
|
$partdatainput['partid'] = $partid;
|
||||||
$partinfo = get_part_data($partdatainput);
|
$partinfo = get_part_data($partdatainput);
|
||||||
if ($partinfo['result'] == 2) {
|
if ($partinfo['result'] == 2) {
|
||||||
$pdatamismatch=1;
|
$pdatamismatch = TRUE;
|
||||||
} else {
|
} else {
|
||||||
unset($pdatamismatch);
|
$pdatamismatch = FALSE;
|
||||||
if ($partinfo['uid']) $uid=$partinfo['uid'];
|
$uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL;
|
||||||
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
|
$partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL;
|
||||||
if ($partinfo['sernum']) $sernum=$partinfo['sernum'];
|
$sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL;
|
||||||
if ($partinfo['partname']) $partname=$partinfo['partname'];
|
$partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL;
|
||||||
}
|
}
|
||||||
if ($delete) {
|
if ($delete) {
|
||||||
if ($inmaintforms) {
|
if ($inmaintforms) {
|
||||||
@@ -172,5 +172,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
parts.php
|
parts.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -10,15 +10,15 @@
|
|||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
if (isset($_SESSION['login'])) {
|
if (isset($_SESSION['login'])) {
|
||||||
$loggedin=1;
|
$loggedin = TRUE;
|
||||||
} else {
|
} else {
|
||||||
unset($loggedin);
|
$loggedin = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
$add=$_REQUEST['add'];
|
$add = $_REQUEST['add'] ?? NULL;
|
||||||
$sort=$_REQUEST['sort'];
|
$sort = $_REQUEST['sort'] ?? NULL;
|
||||||
$order=$_REQUEST['order'];
|
$order = $_REQUEST['order'] ?? NULL;
|
||||||
|
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
$uidtext = UID_TEXT;
|
$uidtext = UID_TEXT;
|
||||||
@@ -79,7 +79,8 @@ while ($partline=mysqli_fetch_assoc($partqry)) {
|
|||||||
$pluidtxt = $partline['uid'];
|
$pluidtxt = $partline['uid'];
|
||||||
}
|
}
|
||||||
if ($loggedin) {
|
if ($loggedin) {
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
|
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
|
||||||
@@ -87,13 +88,15 @@ while ($partline=mysqli_fetch_assoc($partqry)) {
|
|||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td>%s</td>",
|
<td>%s</td>",
|
||||||
$partline['partid'],$pluidtxt,
|
$partline['partid'],
|
||||||
|
$pluidtxt,
|
||||||
$partline['partnum'],
|
$partline['partnum'],
|
||||||
$partline['sernum'],
|
$partline['sernum'],
|
||||||
$partline['partname']
|
$partline['partname']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
@@ -119,5 +122,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
profile.php
|
profile.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -54,34 +54,34 @@ if(!$print){
|
|||||||
// do error checking
|
// do error checking
|
||||||
// test for name supplied
|
// test for name supplied
|
||||||
if (strlen(trim($name))) {
|
if (strlen(trim($name))) {
|
||||||
$namesuppld=1;
|
$namesuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$namesuppld=0;
|
$namesuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
// test for name unique
|
// test for name unique
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
||||||
$nameunique=0;
|
$nameunique = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nameunique=1;
|
$nameunique = TRUE;
|
||||||
}
|
}
|
||||||
// test for matching passwords
|
// test for matching passwords
|
||||||
if ($pass != "password_is_unchanged") {
|
if ($pass != "password_is_unchanged") {
|
||||||
if ($pass == $passconf) {
|
if ($pass == $passconf) {
|
||||||
$passmatch=1;
|
$passmatch = TRUE;
|
||||||
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
||||||
$namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
|
$namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
|
||||||
} else {
|
} else {
|
||||||
$passmatch=0;
|
$passmatch = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$passmatch=1;
|
$passmatch = TRUE;
|
||||||
$namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\"";
|
$namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\"";
|
||||||
}
|
}
|
||||||
if ($namesuppld && $nameunique && $passmatch) {
|
if ($namesuppld && $nameunique && $passmatch) {
|
||||||
@@ -91,14 +91,17 @@ if(!$print){
|
|||||||
}
|
}
|
||||||
if ($updatedisplay) {
|
if ($updatedisplay) {
|
||||||
// display settings
|
// display settings
|
||||||
if ($display_showts) $display_showts=1; else $display_showts=0;
|
if ($display_showts) $display_showts = 1;
|
||||||
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0;
|
else $display_showts = 0;
|
||||||
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0;
|
if ($display_techalpha == "a") $display_techalpha = 1;
|
||||||
|
else $display_techalpha = 0;
|
||||||
|
if ($display_subjalpha == "a") $display_subjalpha = 1;
|
||||||
|
else $display_subjalpha = 0;
|
||||||
// test for urlchunk supplied
|
// test for urlchunk supplied
|
||||||
if (strlen(trim($display_urlchunk))) {
|
if (strlen(trim($display_urlchunk))) {
|
||||||
$chunksuppld=1;
|
$chunksuppld = TRUE;
|
||||||
} else {
|
} else {
|
||||||
$chunksuppld=0;
|
$chunksuppld = FALSE;
|
||||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
||||||
}
|
}
|
||||||
if ($chunksuppld) {
|
if ($chunksuppld) {
|
||||||
@@ -113,6 +116,8 @@ if(!$print){
|
|||||||
// color settings
|
// color settings
|
||||||
$hexcolor = "#" . ltrim($hexcolor);
|
$hexcolor = "#" . ltrim($hexcolor);
|
||||||
putsetting($modcolor, $hexcolor, $techid);
|
putsetting($modcolor, $hexcolor, $techid);
|
||||||
|
$currentpage = $_SERVER['PHP_SELF'];
|
||||||
|
header("Refresh: .1; url=$currentpage");
|
||||||
}
|
}
|
||||||
if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\"");
|
if ($resetcustom) mysqli_query($db, "delete from customs where customtech=\"$techid\"");
|
||||||
|
|
||||||
@@ -294,5 +299,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
/*
|
/*
|
||||||
refchain.php
|
refchain.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
$print=$_REQUEST['print'];
|
$print = $_REQUEST['print'] ?? "";
|
||||||
$chainnote=$_REQUEST['chainnote'];
|
$chainnote = $_REQUEST['chainnote'] ?? NULL;
|
||||||
|
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
|
|
||||||
@@ -59,19 +59,20 @@ while($mptr<count($master)) {
|
|||||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||||
// generate the flags string
|
// generate the flags string
|
||||||
$flagstring = "";
|
$flagstring = "";
|
||||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
$flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid");
|
||||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
if (mysqli_num_rows($flagmapqry)) {
|
||||||
$flagid=$allflagids[0];
|
while ($flagids = mysqli_fetch_row($flagmapqry)) {
|
||||||
$flag_tbl="flag_".$flagid;
|
$flagid = $flagids[0];
|
||||||
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\""));
|
$flagparam = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid\""));
|
||||||
$flagcolor = $flagparam["flagcolor"];
|
$flagcolor = $flagparam["flagcolor"];
|
||||||
$flagsym = $flagparam["flagsym"];
|
$flagsym = $flagparam["flagsym"];
|
||||||
$flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font> ";
|
$flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font> ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
|
if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"logentry.php?edit=1¬eid=%s\">%s</a></td>
|
<td><a href=\"logentry.php?edit=1¬eid=%s\">%s</a></td>
|
||||||
<td>%s / %s</td>
|
<td>%s / %s</td>
|
||||||
@@ -81,13 +82,16 @@ while($mptr<count($master)) {
|
|||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
$tablerow["lognoteid"],
|
||||||
$tablerow["date"],$tablerow["time"],
|
$tablerow["lognoteid"],
|
||||||
|
$tablerow["date"],
|
||||||
|
$tablerow["time"],
|
||||||
$shname,
|
$shname,
|
||||||
$tname,
|
$tname,
|
||||||
$subjname,
|
$subjname,
|
||||||
$fmtnote,
|
$fmtnote,
|
||||||
$refs);
|
$refs
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n", $master[$mptr]);
|
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n", $master[$mptr]);
|
||||||
}
|
}
|
||||||
@@ -99,5 +103,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
blankpage.php
|
schedmaint.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -73,9 +73,9 @@ $errorstack=array();
|
|||||||
if ($action) {
|
if ($action) {
|
||||||
if ($complete) {
|
if ($complete) {
|
||||||
// sanitize user input
|
// sanitize user input
|
||||||
$completedate=mysqli_real_escape_string($db,$completedate);
|
$completedate = fix_date($completedate);
|
||||||
// update events
|
// update events
|
||||||
mysqli_query($db,"update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0000-00-00\" where eventid=\"$id\"");
|
mysqli_query($db, "update events set last_date=\"$completedate\", deferred_flag=0, deferred_date=\"0001-01-01\" where eventid=\"$id\"");
|
||||||
if ($addlognote) {
|
if ($addlognote) {
|
||||||
$compltaskname = mysqli_fetch_row(mysqli_query($db, "select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0];
|
$compltaskname = mysqli_fetch_row(mysqli_query($db, "select tasks.taskname from tasks,events where events.eventid=\"$id\" and tasks.taskid=events.task"))[0];
|
||||||
$compldevicename = mysqli_fetch_row(mysqli_query($db, "select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0];
|
$compldevicename = mysqli_fetch_row(mysqli_query($db, "select devices.devicename from devices,events where events.eventid=\"$id\" and devices.deviceid=events.device"))[0];
|
||||||
@@ -88,6 +88,7 @@ if ($action) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($defer) {
|
if ($defer) {
|
||||||
|
$deferuntil = fix_date($deferuntil);
|
||||||
// update events
|
// update events
|
||||||
mysqli_query($db, "update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\"");
|
mysqli_query($db, "update events set deferred_flag=1, deferred_date=\"$deferuntil\" where eventid=\"$id\"");
|
||||||
}
|
}
|
||||||
@@ -110,9 +111,12 @@ if ($add) {
|
|||||||
$errorstack[] = "<img src=\"icons/exclamation-red.png\" border=\"0\"> You didn't select a device.<br>";
|
$errorstack[] = "<img src=\"icons/exclamation-red.png\" border=\"0\"> You didn't select a device.<br>";
|
||||||
}
|
}
|
||||||
// sanitize text data
|
// sanitize text data
|
||||||
$start_date=mysqli_real_escape_string($db,$start_date);
|
if ($start_date == NULL) $start_date = $today;
|
||||||
$last_date=mysqli_real_escape_string($db,$last_date);
|
if ($last_date == NULL) $last_date = "0001-01-01";
|
||||||
$deferred_date=mysqli_real_escape_string($db,$deferred_date);
|
if ($deferred_date == NULL) $deferred_date = "0001-01-01";
|
||||||
|
$start_date = fix_date($start_date);
|
||||||
|
$last_date = fix_date($last_date);
|
||||||
|
$deferred_date = fix_date($deferred_date);
|
||||||
if ($taskselected && $deviceselected) {
|
if ($taskselected && $deviceselected) {
|
||||||
// determine if device represents a group and break out individual devices
|
// determine if device represents a group and break out individual devices
|
||||||
if (dblookup($db, "devices", "deviceid", "group_flag", $device)) {
|
if (dblookup($db, "devices", "deviceid", "group_flag", $device)) {
|
||||||
@@ -126,9 +130,6 @@ if ($add) {
|
|||||||
}
|
}
|
||||||
// run through the memberlist and modify the table
|
// run through the memberlist and modify the table
|
||||||
foreach ($memberlist as $memberdev) {
|
foreach ($memberlist as $memberdev) {
|
||||||
if ($start_date==NULL) $start_date=$today;
|
|
||||||
if ($last_date==NULL) $last_date="0000-00-00";
|
|
||||||
if ($deferred_date==NULL) $deferred_date="0000-00-00";
|
|
||||||
$addqry = ("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag)
|
$addqry = ("insert into events(task,device,start_date,last_date,deferred_flag,deferred_date,active_flag)
|
||||||
values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")");
|
values(\"$task\",\"$memberdev\",\"$start_date\",\"$last_date\",\"$deferred_flag\",\"$deferred_date\",\"$active_flag\")");
|
||||||
mysqli_query($db, $addqry);
|
mysqli_query($db, $addqry);
|
||||||
@@ -199,13 +200,13 @@ if ($edit) {
|
|||||||
if ($update) {
|
if ($update) {
|
||||||
// do error checking
|
// do error checking
|
||||||
// sanitize text data
|
// sanitize text data
|
||||||
$start_date=mysqli_real_escape_string($db,$start_date);
|
|
||||||
$last_date=mysqli_real_escape_string($db,$last_date);
|
|
||||||
$deferred_date=mysqli_real_escape_string($db,$deferred_date);
|
|
||||||
// update the tasks table
|
|
||||||
if ($start_date == NULL) $start_date = $today;
|
if ($start_date == NULL) $start_date = $today;
|
||||||
if ($last_date==NULL) $last_date="0000-00-00";
|
if ($last_date == NULL) $last_date = "0001-01-01";
|
||||||
if ($deferred_date==NULL) $deferred_date="0000-00-00";
|
if ($deferred_date == NULL) $deferred_date = "0001-01-01";
|
||||||
|
$start_date = fix_date($start_date);
|
||||||
|
$last_date = fix_date($last_date);
|
||||||
|
$deferred_date = fix_date($deferred_date);
|
||||||
|
// update the tasks table
|
||||||
mysqli_query($db, "update events
|
mysqli_query($db, "update events
|
||||||
set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\",
|
set task=\"$task\",device=\"$device\",start_date=\"$start_date\",last_date=\"$last_date\",deferred_flag=\"$deferred_flag\",
|
||||||
deferred_date=\"$deferred_date\",active_flag=\"$active_flag\"
|
deferred_date=\"$deferred_date\",active_flag=\"$active_flag\"
|
||||||
@@ -404,9 +405,9 @@ if ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$deferredtag = "<input type=\"checkbox\" name=\"deferred_flag\" value=\"1\">";
|
$deferredtag = "<input type=\"checkbox\" name=\"deferred_flag\" value=\"1\">";
|
||||||
}
|
}
|
||||||
if ($start_date=="0000-00-00") $start_date=$today;
|
if ($start_date == "0001-01-01") $start_date = $today;
|
||||||
if ($last_date=="0000-00-00") $last_date="";
|
//if ($last_date == "0001-01-01") $last_date = "";
|
||||||
if ($deferred_date=="0000-00-00") $deferred_date=$tomorrow;
|
if ($deferred_date == "0001-01-01") $deferred_date = $tomorrow;
|
||||||
$deferuntiltag = "<input type=\"text\" name=\"deferred_date\" id=\"deferdatepicker\" size=\"10\" maxlength=\"10\" value=\"$deferred_date\" title=\"Format: YYYY-MM-DD\">";
|
$deferuntiltag = "<input type=\"text\" name=\"deferred_date\" id=\"deferdatepicker\" size=\"10\" maxlength=\"10\" value=\"$deferred_date\" title=\"Format: YYYY-MM-DD\">";
|
||||||
$startdatetag = "<input type=\"text\" name=\"start_date\" id=\"startdatepicker\" size=\"10\" maxlength=\"10\" value=\"$start_date\" title=\"Format: YYYY-MM-DD\">";
|
$startdatetag = "<input type=\"text\" name=\"start_date\" id=\"startdatepicker\" size=\"10\" maxlength=\"10\" value=\"$start_date\" title=\"Format: YYYY-MM-DD\">";
|
||||||
$lastdatetag = "<input type=\"text\" name=\"last_date\" id=\"completedatepicker\" size=\"10\" maxlength=\"10\" value=\"$last_date\" title=\"Format: YYYY-MM-DD\">";
|
$lastdatetag = "<input type=\"text\" name=\"last_date\" id=\"completedatepicker\" size=\"10\" maxlength=\"10\" value=\"$last_date\" title=\"Format: YYYY-MM-DD\">";
|
||||||
@@ -487,9 +488,9 @@ if ($action) {
|
|||||||
";
|
";
|
||||||
while ($tablerow = mysqli_fetch_assoc($existingdata)) {
|
while ($tablerow = mysqli_fetch_assoc($existingdata)) {
|
||||||
extract($tablerow);
|
extract($tablerow);
|
||||||
if ($start_date=="0000-00-00") $start_date=$today;
|
if ($start_date == "0001-01-01") $start_date = $today;
|
||||||
if ($last_date=="0000-00-00") $last_date="";
|
if ($last_date == "0001-01-01") $last_date = "";
|
||||||
if ($deferred_date=="0000-00-00") $deferred_date="";
|
if ($deferred_date == "0001-01-01") $deferred_date = "";
|
||||||
if ($active_flag) {
|
if ($active_flag) {
|
||||||
$statdef = "<img src=\"icons/tick.png\" title=\"active\" alt=\"active\">";
|
$statdef = "<img src=\"icons/tick.png\" title=\"active\" alt=\"active\">";
|
||||||
} else {
|
} else {
|
||||||
@@ -509,7 +510,8 @@ if ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$tasktitle = "Repeat every $taskdata_frequency $taskdata_period";
|
$tasktitle = "Repeat every $taskdata_frequency $taskdata_period";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"schedmaint.php?schedule=1&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"schedmaint.php?schedule=1&edit=1&id=%s\">%s</a></td>
|
||||||
<td title=\"%s\">%s</td>
|
<td title=\"%s\">%s</td>
|
||||||
@@ -520,14 +522,17 @@ if ($action) {
|
|||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$eventid,$eventid,
|
$eventid,
|
||||||
$tasktitle,$taskdata_taskname,
|
$eventid,
|
||||||
|
$tasktitle,
|
||||||
|
$taskdata_taskname,
|
||||||
$devicedata_devicename,
|
$devicedata_devicename,
|
||||||
$start_date,
|
$start_date,
|
||||||
$last_date,
|
$last_date,
|
||||||
$deferredflag,
|
$deferredflag,
|
||||||
$deferred_date,
|
$deferred_date,
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
} else if ($tasks) {
|
} else if ($tasks) {
|
||||||
@@ -650,7 +655,8 @@ if ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$wdoflag = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$wdoflag = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"schedmaint.php?tasks=1&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"schedmaint.php?tasks=1&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
@@ -660,16 +666,17 @@ if ($action) {
|
|||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$taskid,$taskname,
|
$taskid,
|
||||||
|
$taskname,
|
||||||
$taskdesc,
|
$taskdesc,
|
||||||
$rptstrg,
|
$rptstrg,
|
||||||
$duecalc,
|
$duecalc,
|
||||||
$wdoflag,
|
$wdoflag,
|
||||||
$refstrg,
|
$refstrg,
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
|
|
||||||
} else if ($devices) {
|
} else if ($devices) {
|
||||||
// manage devices
|
// manage devices
|
||||||
if ($edit) {
|
if ($edit) {
|
||||||
@@ -735,7 +742,8 @@ if ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$memberdef = "<input type=\"checkbox\" name=\"members[]\" value=\"$gtbl_deviceid\">";
|
$memberdef = "<input type=\"checkbox\" name=\"members[]\" value=\"$gtbl_deviceid\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
@@ -743,7 +751,8 @@ if ($action) {
|
|||||||
</tr>",
|
</tr>",
|
||||||
$gtbl_devicename,
|
$gtbl_devicename,
|
||||||
$gtbl_devicedesc,
|
$gtbl_devicedesc,
|
||||||
$memberdef);
|
$memberdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table><br>";
|
echo "</table><br>";
|
||||||
}
|
}
|
||||||
@@ -774,7 +783,8 @@ if ($action) {
|
|||||||
} else {
|
} else {
|
||||||
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
$statdef = "<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
|
||||||
}
|
}
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"schedmaint.php?devices=1&edit=1&id=%s\">%s</a></td>
|
<td><a href=\"schedmaint.php?devices=1&edit=1&id=%s\">%s</a></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
@@ -782,18 +792,23 @@ if ($action) {
|
|||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
<td align=\"center\">%s</td>
|
<td align=\"center\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$deviceid,$deviceid,
|
$deviceid,
|
||||||
|
$deviceid,
|
||||||
$devicename,
|
$devicename,
|
||||||
$devicedesc,
|
$devicedesc,
|
||||||
$groupdef,
|
$groupdef,
|
||||||
$statdef);
|
$statdef
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
} else {
|
} else {
|
||||||
$ucevents = get_upcoming_events();
|
$ucevents = get_upcoming_events();
|
||||||
|
|
||||||
// sort the upcoming events
|
// sort the upcoming events
|
||||||
function uc_cmp($a,$b) { return strcmp($a["duedate"], $b["duedate"]); }
|
function uc_cmp($a, $b)
|
||||||
|
{
|
||||||
|
return strcmp($a["duedate"], $b["duedate"]);
|
||||||
|
}
|
||||||
uasort($ucevents, 'uc_cmp');
|
uasort($ucevents, 'uc_cmp');
|
||||||
|
|
||||||
// show upcoming events table
|
// show upcoming events table
|
||||||
@@ -806,16 +821,20 @@ if ($action) {
|
|||||||
";
|
";
|
||||||
foreach ($ucevents as $ucline) {
|
foreach ($ucevents as $ucline) {
|
||||||
extract($ucline);
|
extract($ucline);
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"schedmaint.php?action=1&id=%s\" title=\"Click to complete or defer this scheduled maintenance event\">%s</a></td>
|
<td><a href=\"schedmaint.php?action=1&id=%s\" title=\"Click to complete or defer this scheduled maintenance event\">%s</a></td>
|
||||||
<td><font title=\"%s\">%s</font></td>
|
<td><font title=\"%s\">%s</font></td>
|
||||||
<td><font title=\"%s\">%s</font></td>
|
<td><font title=\"%s\">%s</font></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$eventdata_eventid,$duedatestrg,
|
$eventdata_eventid,
|
||||||
$devicedata_devicedesc,$devicedata_devicename,
|
$duedatestrg,
|
||||||
$taskdata_taskdesc,$taskdata_taskname,
|
$devicedata_devicedesc,
|
||||||
|
$devicedata_devicename,
|
||||||
|
$taskdata_taskdesc,
|
||||||
|
$taskdata_taskname,
|
||||||
$lastdatestrg
|
$lastdatestrg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -837,7 +856,7 @@ if ($action) {
|
|||||||
$taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$def_task\""));
|
$taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$def_task\""));
|
||||||
extract($taskdata, EXTR_PREFIX_ALL, "taskdata");
|
extract($taskdata, EXTR_PREFIX_ALL, "taskdata");
|
||||||
if (! ($taskdata_period == "once" && $def_last_date > $def_start_date)) {
|
if (! ($taskdata_period == "once" && $def_last_date > $def_start_date)) {
|
||||||
if ($def_last_date=="0000-00-00") {
|
if ($def_last_date == "0001-01-01") {
|
||||||
$lastdatestrg = "never";
|
$lastdatestrg = "never";
|
||||||
} else {
|
} else {
|
||||||
$lastdatestrg = "$def_last_date";
|
$lastdatestrg = "$def_last_date";
|
||||||
@@ -865,16 +884,20 @@ if ($action) {
|
|||||||
";
|
";
|
||||||
foreach ($defevents as $defline) {
|
foreach ($defevents as $defline) {
|
||||||
extract($defline);
|
extract($defline);
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href=\"schedmaint.php?action=1&id=%s\" title=\"Click to complete or defer this scheduled maintenance event\"><font color=\"#FFA500\">%s</font></a></td>
|
<td><a href=\"schedmaint.php?action=1&id=%s\" title=\"Click to complete or defer this scheduled maintenance event\"><font color=\"#FFA500\">%s</font></a></td>
|
||||||
<td><font title=\"%s\">%s</font></td>
|
<td><font title=\"%s\">%s</font></td>
|
||||||
<td><font title=\"%s\">%s</font></td>
|
<td><font title=\"%s\">%s</font></td>
|
||||||
<td>%s</td>
|
<td>%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$def_eventid,$def_deferred_date,
|
$def_eventid,
|
||||||
$devicedata_devicedesc,$devicedata_devicename,
|
$def_deferred_date,
|
||||||
$taskdata_taskdesc,$taskdata_taskname,
|
$devicedata_devicedesc,
|
||||||
|
$devicedata_devicename,
|
||||||
|
$taskdata_taskdesc,
|
||||||
|
$taskdata_taskname,
|
||||||
$lastdatestrg
|
$lastdatestrg
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -890,5 +913,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,19 +2,19 @@
|
|||||||
/*
|
/*
|
||||||
search.php
|
search.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
include("functions.php");
|
include("functions.php");
|
||||||
|
|
||||||
$noprint=1;
|
$noprint = TRUE;
|
||||||
|
|
||||||
if (isset($_SESSION['login'])) {
|
if (isset($_SESSION['login'])) {
|
||||||
$loggedin=1;
|
$loggedin = TRUE;
|
||||||
} else {
|
} else {
|
||||||
unset($loggedin);
|
$loggedin = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$print = $_REQUEST['print'] ?? NULL;
|
$print = $_REQUEST['print'] ?? NULL;
|
||||||
@@ -34,8 +34,8 @@ $srchpname=$_REQUEST['srchpname'] ?? NULL;
|
|||||||
$srchploc = $_REQUEST['srchploc'] ?? NULL;
|
$srchploc = $_REQUEST['srchploc'] ?? NULL;
|
||||||
$srchnha = $_REQUEST['srchnha'] ?? NULL;
|
$srchnha = $_REQUEST['srchnha'] ?? NULL;
|
||||||
$srchrepord = $_REQUEST['srchrepord'] ?? NULL;
|
$srchrepord = $_REQUEST['srchrepord'] ?? NULL;
|
||||||
$srchflags=$_REQUEST['srchflags'] ?? NULL;
|
$srchflags = $_REQUEST['srchflags'] ?? [];
|
||||||
$target=$_REQUEST['target'] ?? NULL;
|
$target = $_REQUEST['target'] ?? ["log", "maintform", "part"];
|
||||||
|
|
||||||
$doparts = PARTS_FUNCTIONS;
|
$doparts = PARTS_FUNCTIONS;
|
||||||
$logname = LOG_NAME;
|
$logname = LOG_NAME;
|
||||||
@@ -54,9 +54,20 @@ if ($print) {
|
|||||||
|
|
||||||
framework("begin", "$logname Search", "Search", $print);
|
framework("begin", "$logname Search", "Search", $print);
|
||||||
|
|
||||||
|
// echo "REQUEST variables: <br>";
|
||||||
// var_dump($_REQUEST);
|
// var_dump($_REQUEST);
|
||||||
|
// echo "<br>";
|
||||||
|
|
||||||
// ******** begin database manipulation ********
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
// define the arrays
|
||||||
|
$logfromtables = [];
|
||||||
|
$mffromtables = [];
|
||||||
|
$pfromtables = [];
|
||||||
|
$logconstraints = [];
|
||||||
|
$mfconstraints = [];
|
||||||
|
$pconstraints = [];
|
||||||
|
|
||||||
// get the date range of lognotes
|
// get the date range of lognotes
|
||||||
$logdateqry = mysqli_query($db, "select min(date), max(date) from lognotes");
|
$logdateqry = mysqli_query($db, "select min(date), max(date) from lognotes");
|
||||||
$logdateresults = mysqli_fetch_row($logdateqry);
|
$logdateresults = mysqli_fetch_row($logdateqry);
|
||||||
@@ -75,15 +86,12 @@ if ($mfmaxdate == "") $mfmaxdate = $today;
|
|||||||
$mindate = min($logmindate, $mfmindate);
|
$mindate = min($logmindate, $mfmindate);
|
||||||
$maxdate = max($logmaxdate, $mfmaxdate);
|
$maxdate = max($logmaxdate, $mfmaxdate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($search) {
|
if ($search) {
|
||||||
// strip whitespace from beginning and end of text fields
|
// strip whitespace from beginning and end of text fields
|
||||||
$srchtext = trim($srchtext);
|
$srchtext = trim($srchtext);
|
||||||
$srchpname = trim($srchpname);
|
$srchpname = trim($srchpname);
|
||||||
$srchploc = trim($srchploc);
|
$srchploc = trim($srchploc);
|
||||||
$srchnha = trim($srchnha);
|
$srchnha = trim($srchnha);
|
||||||
if ($target[0]=="") $target=[];
|
|
||||||
if (in_array("log", $target)) {
|
if (in_array("log", $target)) {
|
||||||
// define the query constraints
|
// define the query constraints
|
||||||
// log note id
|
// log note id
|
||||||
@@ -122,15 +130,6 @@ if ($search) {
|
|||||||
$logfromtables[] = "lognotes";
|
$logfromtables[] = "lognotes";
|
||||||
$logconstraints[] = "lognotes.lognote like \"%$srchtext%\"";
|
$logconstraints[] = "lognotes.lognote like \"%$srchtext%\"";
|
||||||
}
|
}
|
||||||
// flags
|
|
||||||
if ($srchflags != NULL) {
|
|
||||||
foreach ($srchflags as $flagtblnum) {
|
|
||||||
$flagtblname="flag_{$flagtblnum}";
|
|
||||||
$logfromtables[]="lognotes";
|
|
||||||
$logfromtables[]=$flagtblname;
|
|
||||||
$logconstraints[]="lognotes.lognoteid={$flagtblname}.id and {$flagtblname}.target=\"lognotes\"";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// uid
|
// uid
|
||||||
if ($srchuid != "any" && $srchuid != "") {
|
if ($srchuid != "any" && $srchuid != "") {
|
||||||
$logfromtables[] = "lognotes";
|
$logfromtables[] = "lognotes";
|
||||||
@@ -183,12 +182,28 @@ if ($search) {
|
|||||||
$logfromtables[] = "maintforms";
|
$logfromtables[] = "maintforms";
|
||||||
$logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
$logconstraints[] = "lognotes.lognoteid=logparts.lognoteid and logparts.partid=parts.partid and maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
||||||
}
|
}
|
||||||
|
// flags
|
||||||
|
if (!empty($srchflags)) {
|
||||||
|
unset($flagconstraints);
|
||||||
|
$flagcount = count($srchflags);
|
||||||
|
$logfromtables[] = "lognotes";
|
||||||
|
$logfromtables[] = "flagmap";
|
||||||
|
$flagconstraints[] = "flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in (";
|
||||||
|
foreach ($srchflags as $flagid) {
|
||||||
|
$flagconstraints[] = "\"$flagid\"";
|
||||||
|
$flagconstraints[] = ",";
|
||||||
|
}
|
||||||
|
// remove final comma
|
||||||
|
array_splice($flagconstraints, -1, 1);
|
||||||
|
$flagconstraints[] = ") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount";
|
||||||
|
// make flagconstraints a single string so that the final implode doesn't split it
|
||||||
|
$logconstraints[] = join('', $flagconstraints);
|
||||||
|
}
|
||||||
// build the clauses and run the query
|
// build the clauses and run the query
|
||||||
$logfromclause = implode(",", array_unique($logfromtables));
|
$logfromclause = implode(",", array_unique($logfromtables));
|
||||||
$logwhereclause = implode(" and ", $logconstraints);
|
$logwhereclause = implode(" and ", $logconstraints);
|
||||||
$logrowqry = mysqli_query($db, "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc");
|
$logrowqry = mysqli_query($db, "select lognotes.* from $logfromclause where $logwhereclause order by lognotes.date asc, lognotes.time asc");
|
||||||
}
|
}
|
||||||
if ($target[0]=="") $target=[];
|
|
||||||
if (in_array("maintform", $target)) {
|
if (in_array("maintform", $target)) {
|
||||||
// maintforms search
|
// maintforms search
|
||||||
// define the query constraints
|
// define the query constraints
|
||||||
@@ -231,13 +246,6 @@ if ($search) {
|
|||||||
$mffromtables[] = "maintactions";
|
$mffromtables[] = "maintactions";
|
||||||
$mfconstraints[] = "maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
|
$mfconstraints[] = "maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
|
||||||
}
|
}
|
||||||
// flags
|
|
||||||
foreach ($srchflags as $flagtblnum) {
|
|
||||||
$flagtblname="flag_{$flagtblnum}";
|
|
||||||
$mffromtables[]="maintforms";
|
|
||||||
$mffromtables[]=$flagtblname;
|
|
||||||
$mfconstraints[]="maintforms.maintformid={$flagtblname}.id and {$flagtblname}.target=\"maintforms\"";
|
|
||||||
}
|
|
||||||
// uid
|
// uid
|
||||||
if ($srchuid != "any" && $srchuid != "") {
|
if ($srchuid != "any" && $srchuid != "") {
|
||||||
$mffromtables[] = "maintforms";
|
$mffromtables[] = "maintforms";
|
||||||
@@ -280,12 +288,28 @@ if ($search) {
|
|||||||
$mffromtables[] = "maintforms";
|
$mffromtables[] = "maintforms";
|
||||||
$mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
$mfconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
||||||
}
|
}
|
||||||
|
// flags
|
||||||
|
if (!empty($srchflags)) {
|
||||||
|
unset($flagconstraints);
|
||||||
|
$flagcount = count($srchflags);
|
||||||
|
$mffromtables[] = "maintforms";
|
||||||
|
$mffromtables[] = "flagmap";
|
||||||
|
$flagconstraints[] = "flagmap.maintformid=maintforms.maintformid and flagmap.flagid in (";
|
||||||
|
foreach ($srchflags as $thisflagid) {
|
||||||
|
$flagconstraints[] = "\"$thisflagid\"";
|
||||||
|
$flagconstraints[] = ",";
|
||||||
|
}
|
||||||
|
// remove final comma
|
||||||
|
array_splice($flagconstraints, -1, 1);
|
||||||
|
$flagconstraints[] = ") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount";
|
||||||
|
// make flagconstraints a single string so that the final implode doesn't split it
|
||||||
|
$mfconstraints[] = join('', $flagconstraints);
|
||||||
|
}
|
||||||
// build the clauses and run the query
|
// build the clauses and run the query
|
||||||
$mffromclause = implode(",", array_unique($mffromtables));
|
$mffromclause = implode(",", array_unique($mffromtables));
|
||||||
$mfwhereclause = implode(" and ", $mfconstraints);
|
$mfwhereclause = implode(" and ", $mfconstraints);
|
||||||
$mfrowqry = mysqli_query($db, "select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc");
|
$mfrowqry = mysqli_query($db, "select maintforms.* from $mffromclause where $mfwhereclause order by maintforms.mfdate asc, maintforms.mftime asc");
|
||||||
}
|
}
|
||||||
if ($target[0]=="") $target=[];
|
|
||||||
if (in_array("part", $target)) {
|
if (in_array("part", $target)) {
|
||||||
// parts search
|
// parts search
|
||||||
// define the query constraints
|
// define the query constraints
|
||||||
@@ -307,7 +331,6 @@ if ($search) {
|
|||||||
// tech doesn't apply to parts
|
// tech doesn't apply to parts
|
||||||
// subject doesn't apply to parts
|
// subject doesn't apply to parts
|
||||||
// search text doesn't apply to parts
|
// search text doesn't apply to parts
|
||||||
// flags doesn't apply to parts
|
|
||||||
// uid
|
// uid
|
||||||
if ($srchuid != "any" && $srchuid != "") {
|
if ($srchuid != "any" && $srchuid != "") {
|
||||||
$pfromtables[] = "parts";
|
$pfromtables[] = "parts";
|
||||||
@@ -346,6 +369,7 @@ if ($search) {
|
|||||||
$pfromtables[] = "maintforms";
|
$pfromtables[] = "maintforms";
|
||||||
$pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
$pconstraints[] = "maintforms.mfpart=parts.partid and maintforms.repord=\"{$srchrepord}\"";
|
||||||
}
|
}
|
||||||
|
// flags doesn't apply to parts
|
||||||
// build the clauses and run the query
|
// build the clauses and run the query
|
||||||
$pfromclause = implode(",", array_unique($pfromtables));
|
$pfromclause = implode(",", array_unique($pfromtables));
|
||||||
$pwhereclause = implode(" and ", $pconstraints);
|
$pwhereclause = implode(" and ", $pconstraints);
|
||||||
@@ -363,21 +387,36 @@ if(!$print){
|
|||||||
pageblock("right", "begin");
|
pageblock("right", "begin");
|
||||||
banner($print);
|
banner($print);
|
||||||
// display the form
|
// display the form
|
||||||
if ($srchnoteid) $noteidval=$srchnoteid; else $noteidval="any";
|
if ($srchnoteid) $noteidval = $srchnoteid;
|
||||||
if ($srchmfid) $mfidval=$srchmfid; else $mfidval="any";
|
else $noteidval = "any";
|
||||||
if ($srchbdate) $bdateval=$srchbdate; else $bdateval=$mindate;
|
if ($srchmfid) $mfidval = $srchmfid;
|
||||||
if ($srchedate) $edateval=$srchedate; else $edateval=$maxdate;
|
else $mfidval = "any";
|
||||||
if ($srchshift) $shiftval=$srchshift; else $shiftval=0;
|
if ($srchbdate) $bdateval = $srchbdate;
|
||||||
if ($srchtech) $techval=$srchtech; else $techval=0;
|
else $bdateval = $mindate;
|
||||||
if ($srchsubj) $subjval=$srchsubj; else $subjval=0;
|
if ($srchedate) $edateval = $srchedate;
|
||||||
if ($srchtext) $textval=$srchtext; else $textval="";
|
else $edateval = $maxdate;
|
||||||
if ($srchuid) $uidval=$srchuid; else $uidval="any";
|
if ($srchshift) $shiftval = $srchshift;
|
||||||
if ($srchpn) $pnval=$srchpn; else $pnval="any";
|
else $shiftval = 0;
|
||||||
if ($srchsn) $snval=$srchsn; else $snval="any";
|
if ($srchtech) $techval = $srchtech;
|
||||||
if ($srchpname) $pnameval=$srchpname; else $pnameval="any";
|
else $techval = 0;
|
||||||
if ($srchploc) $plocval=$srchploc; else $plocval="any";
|
if ($srchsubj) $subjval = $srchsubj;
|
||||||
if ($srchnha) $nhaval=$srchnha; else $nhaval="any";
|
else $subjval = 0;
|
||||||
if ($srchrepord) $repordval=$srchrepord; else $repordval="any";
|
if ($srchtext) $textval = $srchtext;
|
||||||
|
else $textval = "";
|
||||||
|
if ($srchuid) $uidval = $srchuid;
|
||||||
|
else $uidval = "any";
|
||||||
|
if ($srchpn) $pnval = $srchpn;
|
||||||
|
else $pnval = "any";
|
||||||
|
if ($srchsn) $snval = $srchsn;
|
||||||
|
else $snval = "any";
|
||||||
|
if ($srchpname) $pnameval = $srchpname;
|
||||||
|
else $pnameval = "any";
|
||||||
|
if ($srchploc) $plocval = $srchploc;
|
||||||
|
else $plocval = "any";
|
||||||
|
if ($srchnha) $nhaval = $srchnha;
|
||||||
|
else $nhaval = "any";
|
||||||
|
if ($srchrepord) $repordval = $srchrepord;
|
||||||
|
else $repordval = "any";
|
||||||
|
|
||||||
if (!$print) {
|
if (!$print) {
|
||||||
echo "
|
echo "
|
||||||
@@ -412,7 +451,8 @@ if (!$print) {
|
|||||||
} else {
|
} else {
|
||||||
echo "<option value=\"0\">any</option>";
|
echo "<option value=\"0\">any</option>";
|
||||||
}
|
}
|
||||||
if ($techalpha) $torder="techname"; else $torder="techid";
|
if ($techalpha) $torder = "techname";
|
||||||
|
else $torder = "techid";
|
||||||
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||||
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||||
if ($techitem['techid'] == $techval) {
|
if ($techitem['techid'] == $techval) {
|
||||||
@@ -430,7 +470,8 @@ if (!$print) {
|
|||||||
} else {
|
} else {
|
||||||
echo "<option value=\"0\">any</option>";
|
echo "<option value=\"0\">any</option>";
|
||||||
}
|
}
|
||||||
if ($subjalpha) $sorder="subjectname"; else $sorder="subjectid";
|
if ($subjalpha) $sorder = "subjectname";
|
||||||
|
else $sorder = "subjectid";
|
||||||
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
|
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
|
||||||
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
|
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
|
||||||
if ($subjitem['subjectid'] == $subjval) {
|
if ($subjitem['subjectid'] == $subjval) {
|
||||||
@@ -467,15 +508,25 @@ if (!$print) {
|
|||||||
$flagsperline = 8;
|
$flagsperline = 8;
|
||||||
$flagcount = 1;
|
$flagcount = 1;
|
||||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||||
if ($srchflags[0]=="") $srchflags=[];
|
//if ($srchflags[0] == "") $srchflags = [];
|
||||||
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
||||||
printf("<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$flagid = $flagcheckbox["flagid"];
|
$flagid = $flagcheckbox["flagid"];
|
||||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||||
printf("<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
printf(
|
||||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($flagcount < $flagsperline) {
|
if ($flagcount < $flagsperline) {
|
||||||
@@ -595,8 +646,11 @@ if (!$print) {
|
|||||||
if ($srchflags) {
|
if ($srchflags) {
|
||||||
if ($srchflags[0] == "") $srchflags = [];
|
if ($srchflags[0] == "") $srchflags = [];
|
||||||
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
if (in_array($flagcheckbox["flagid"], $srchflags)) {
|
||||||
printf("<font color=\"%s\">%s</font>",
|
printf(
|
||||||
$flagcheckbox["flagcolor"],$flagcheckbox["flagsym"]);
|
"<font color=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($flagcount < $flagsperline) {
|
if ($flagcount < $flagsperline) {
|
||||||
@@ -637,9 +691,10 @@ if ($search) {
|
|||||||
if ($target[0] == "") $target = [];
|
if ($target[0] == "") $target = [];
|
||||||
if (in_array("log", $target)) {
|
if (in_array("log", $target)) {
|
||||||
// run lognotes query and show results
|
// run lognotes query and show results
|
||||||
if(mysqli_num_rows($logrowqry)) {
|
$log_num_results = mysqli_num_rows($logrowqry);
|
||||||
|
if ($log_num_results) {
|
||||||
echo "
|
echo "
|
||||||
<b>Results from Logbook</b><br><br>
|
<b>Results from Logbook: $log_num_results</b><br><br>
|
||||||
<table border=\"1\" width=\"100%\">
|
<table border=\"1\" width=\"100%\">
|
||||||
<tr><th>Note ID</th><th>Date/Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>
|
<tr><th>Note ID</th><th>Date/Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>
|
||||||
";
|
";
|
||||||
@@ -656,21 +711,25 @@ if ($search) {
|
|||||||
$logsubjname = dblookup($db, "subjects", "subjectid", "subjectname", $logtablerow['subject']);
|
$logsubjname = dblookup($db, "subjects", "subjectid", "subjectname", $logtablerow['subject']);
|
||||||
// create links of urls in note
|
// create links of urls in note
|
||||||
$logfmtnote = convertweblinks($logtablerow['lognote']);
|
$logfmtnote = convertweblinks($logtablerow['lognote']);
|
||||||
|
|
||||||
// generate the flags string
|
// generate the flags string
|
||||||
$flagstring = "";
|
$flagstring = "";
|
||||||
$allflagqry=mysqli_query($db,"select flagid from flags");
|
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$logtablerow[lognoteid]");
|
||||||
while ($allflagids=mysqli_fetch_row($allflagqry)) {
|
while ($flagid = mysqli_fetch_row($flagqry)) {
|
||||||
$flagid=$allflagids[0];
|
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
|
||||||
$flag_tbl="flag_".$flagid;
|
$flagcolor = $flagparams["flagcolor"];
|
||||||
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$logtablerow[lognoteid]\""))) {
|
$flagsym = $flagparams["flagsym"];
|
||||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
$flagname = $flagparams["flagname"];
|
||||||
$flagcolor=$flagparam["flagcolor"];
|
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||||
$flagsym=$flagparam["flagsym"];
|
|
||||||
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font> ";
|
|
||||||
}
|
}
|
||||||
|
if ($flagstring) {
|
||||||
|
$logfmtnote = $logfmtnote . "<br>" . $flagstring . " ";
|
||||||
|
} else {
|
||||||
|
$logfmtnote = $logfmtnote . "<br>";
|
||||||
}
|
}
|
||||||
if ($flagstring) $logfmtnote=$logfmtnote."<br>".$flagstring;
|
|
||||||
printf("<tr>
|
printf(
|
||||||
|
"<tr>
|
||||||
<td valign=\"top\"><a href=logentry.php?edit=1¬eid=%s>%s</a></td>
|
<td valign=\"top\"><a href=logentry.php?edit=1¬eid=%s>%s</a></td>
|
||||||
<td valign=\"top\">%s / %s</td>
|
<td valign=\"top\">%s / %s</td>
|
||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
@@ -679,13 +738,16 @@ if ($search) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$logtablerow['lognoteid'],$logtablerow['lognoteid'],
|
$logtablerow['lognoteid'],
|
||||||
$logtablerow['date'],$logtablerow['time'],
|
$logtablerow['lognoteid'],
|
||||||
|
$logtablerow['date'],
|
||||||
|
$logtablerow['time'],
|
||||||
$logshname,
|
$logshname,
|
||||||
$logtname,
|
$logtname,
|
||||||
$logsubjname,
|
$logsubjname,
|
||||||
$logfmtnote,
|
$logfmtnote,
|
||||||
$logrefs);
|
$logrefs
|
||||||
|
);
|
||||||
}
|
}
|
||||||
echo "</table><br><hr>";
|
echo "</table><br><hr>";
|
||||||
} else {
|
} else {
|
||||||
@@ -695,9 +757,10 @@ if ($search) {
|
|||||||
if ($target[0] == "") $target = [];
|
if ($target[0] == "") $target = [];
|
||||||
if (in_array("maintform", $target)) {
|
if (in_array("maintform", $target)) {
|
||||||
// run maintforms query and show results
|
// run maintforms query and show results
|
||||||
if(mysqli_num_rows($mfrowqry)) {
|
$mf_num_results = mysqli_num_rows($mfrowqry);
|
||||||
|
if ($mf_num_results) {
|
||||||
echo "
|
echo "
|
||||||
<b>Results from Maintenance Forms</b><br><br>
|
<b>Results from Maintenance Forms: $mf_num_results</b><br><br>
|
||||||
<br><table border=\"1\" width=\"100%\">
|
<br><table border=\"1\" width=\"100%\">
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
@@ -740,14 +803,16 @@ if ($search) {
|
|||||||
<td valign=\"top\">%s</td>
|
<td valign=\"top\">%s</td>
|
||||||
<td align=\"center\" valign=\"top\">$mfnotetag</td>
|
<td align=\"center\" valign=\"top\">$mfnotetag</td>
|
||||||
</tr>",
|
</tr>",
|
||||||
$mfrow["maintformid"],$mfrow["maintformid"],
|
$mfrow["maintformid"],
|
||||||
|
$mfrow["maintformid"],
|
||||||
$mfrow["mfdate"],
|
$mfrow["mfdate"],
|
||||||
$mftname,
|
$mftname,
|
||||||
$mfuid,
|
$mfuid,
|
||||||
$mfpartno,
|
$mfpartno,
|
||||||
$mfserno,
|
$mfserno,
|
||||||
$mfpartname,
|
$mfpartname,
|
||||||
$mfnoteidval,$mfnoteidval
|
$mfnoteidval,
|
||||||
|
$mfnoteidval
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo "</table><br><hr>";
|
echo "</table><br><hr>";
|
||||||
@@ -758,21 +823,23 @@ if ($search) {
|
|||||||
if ($target[0] == "") $target = [];
|
if ($target[0] == "") $target = [];
|
||||||
if (in_array("part", $target)) {
|
if (in_array("part", $target)) {
|
||||||
// run parts query and show results
|
// run parts query and show results
|
||||||
if(mysqli_num_rows($prowqry)) {
|
$p_num_results = mysqli_num_rows($prowqry);
|
||||||
|
if ($p_num_results) {
|
||||||
echo "
|
echo "
|
||||||
<b>Results from Parts</b><br><br>
|
<b>Results from Parts: $p_num_results</b><br><br>
|
||||||
<table width=\"100%\" border=\"1\" cellpadding=\"5\">
|
<table width=\"100%\" border=\"1\" cellpadding=\"5\">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
<th><a href=\"parts.php?sort=uid&order=$order\" title=\"Sort by $uidtext\">$uidtext</a></th>
|
<th>$uidtext</th>
|
||||||
<th><a href=\"parts.php?sort=partnum&order=$order\" title=\"Sort by Part Number\">Part Number</a></th>
|
<th>Part Number</th>
|
||||||
<th><a href=\"parts.php?sort=sernum&order=$order\" title=\"Sort by Serial Number\">Serial Number</a></th>
|
<th>Serial Number</th>
|
||||||
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
|
<th>Part Name</th>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
while ($partrow = mysqli_fetch_assoc($prowqry)) {
|
while ($partrow = mysqli_fetch_assoc($prowqry)) {
|
||||||
if ($loggedin) {
|
if ($loggedin) {
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href=\"partentry.php?edit=1&partid=%s\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this part\" alt=\"Edit this part\"></a>
|
<a href=\"partentry.php?edit=1&partid=%s\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this part\" alt=\"Edit this part\"></a>
|
||||||
@@ -788,7 +855,8 @@ if ($search) {
|
|||||||
$partrow['partname']
|
$partrow['partname']
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
printf("
|
printf(
|
||||||
|
"
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"You must be logged in to edit a part\" alt=\"You must be logged in to edit a part\">
|
<img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"You must be logged in to edit a part\" alt=\"You must be logged in to edit a part\">
|
||||||
@@ -821,5 +889,3 @@ pageblock("right","end");
|
|||||||
pagetable("end");
|
pagetable("end");
|
||||||
|
|
||||||
framework("end", "", "", $print);
|
framework("end", "", "", $print);
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
settings.php
|
settings.php
|
||||||
OpenLog Online Logbook
|
OpenLog Online Logbook
|
||||||
Copyright (C) 2025 Rod Wright
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
SPDX-License-Identifier: GPL-2.0
|
SPDX-License-Identifier: GPL-2.0
|
||||||
*/
|
*/
|
||||||
@@ -61,5 +61,3 @@ if ($logerrors==1) {
|
|||||||
} else {
|
} else {
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|||||||
571
distfiles/templates.php
Normal file
571
distfiles/templates.php
Normal file
@@ -0,0 +1,571 @@
|
|||||||
|
<?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;
|
||||||
|
$efftechid = $_REQUEST['efftechid'] ?? NULL;
|
||||||
|
$shift = $_REQUEST['shift'] ?? NULL;
|
||||||
|
$subject = $_REQUEST['subject'] ?? NULL;
|
||||||
|
$note = $_REQUEST['note'] ?? NULL;
|
||||||
|
$flags = $_POST['flags'] ?? [];
|
||||||
|
$refstring = $_REQUEST['refstring'] ?? NULL;
|
||||||
|
$submit = $_REQUEST['submit'] ?? NULL;
|
||||||
|
$operation = $_REQUEST['operation'] ?? NULL;
|
||||||
|
$templateid = $_REQUEST['templateid'] ?? NULL;
|
||||||
|
$templatename = $_REQUEST['templatename'] ?? NULL;
|
||||||
|
$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL;
|
||||||
|
$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL;
|
||||||
|
$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL;
|
||||||
|
|
||||||
|
|
||||||
|
$logname = LOG_NAME;
|
||||||
|
$techalpha = TECH_ALPHA;
|
||||||
|
$subjalpha = SUBJ_ALPHA;
|
||||||
|
|
||||||
|
$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);
|
||||||
|
|
||||||
|
// make basic determination about authorization
|
||||||
|
if ($isadmin) {
|
||||||
|
$authorized = TRUE;
|
||||||
|
} else if ($efftechid == $techid) {
|
||||||
|
$authorized = TRUE;
|
||||||
|
} else {
|
||||||
|
$authorized = 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>";
|
||||||
|
} else {
|
||||||
|
if ($user == $techid) {
|
||||||
|
echo "My templates</font></b>";
|
||||||
|
} 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?operation=edit&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>";
|
||||||
|
} else {
|
||||||
|
if ($user == $techid) {
|
||||||
|
echo "You have no templates</font></b>";
|
||||||
|
} else {
|
||||||
|
echo "$tblusername has no templates</font></b>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "<br><hr>";
|
||||||
|
}
|
||||||
|
echo "<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******** begin database manipulation ********
|
||||||
|
|
||||||
|
if ($usertemplateid) {
|
||||||
|
$templateid = $usertemplateid;
|
||||||
|
} else if ($globaltemplateid) {
|
||||||
|
$templateid = $globaltemplateid;
|
||||||
|
} else {
|
||||||
|
$loadtemplate = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// determine original owner of template
|
||||||
|
$orig_owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid);
|
||||||
|
if ($efftechid != NULL && $efftechid != $orig_owner) {
|
||||||
|
$operation = "add";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($operation == "add") {
|
||||||
|
if ($submit) {
|
||||||
|
if ($note) {
|
||||||
|
// remove cruft from note text
|
||||||
|
$note = strip_tags($note, "<a>");
|
||||||
|
$note = mysqli_real_escape_string($db, $note);
|
||||||
|
|
||||||
|
if ($authorized) {
|
||||||
|
// 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 ($operation == "edit" || $operation == "delete") {
|
||||||
|
// test to see if this templateid is owned by techid to prevent hijacking
|
||||||
|
$owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid);
|
||||||
|
if (!$isadmin && ($owner != $techid)) $authorized = FALSE;
|
||||||
|
|
||||||
|
if ($submit) {
|
||||||
|
if ($note) {
|
||||||
|
// remove cruft from note text
|
||||||
|
$note = strip_tags($note, "<a>");
|
||||||
|
$note = mysqli_real_escape_string($db, $note);
|
||||||
|
|
||||||
|
if ($templatename) {
|
||||||
|
$namesupplied = TRUE;
|
||||||
|
} else {
|
||||||
|
$namesupplied = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($authorized) {
|
||||||
|
// check if name was supplied
|
||||||
|
if ($templatename) {
|
||||||
|
// update notetemplates
|
||||||
|
mysqli_query($db, "update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\"");
|
||||||
|
|
||||||
|
// 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)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($operation == "delete") {
|
||||||
|
if ($authorized) {
|
||||||
|
// 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 || $operation == "delete") {
|
||||||
|
// show success/failure messages
|
||||||
|
$nameexists = $nameexists ?? NULL;
|
||||||
|
$namesupplied = $namesupplied ?? NULL;
|
||||||
|
|
||||||
|
if ($operation == "add") {
|
||||||
|
$addfail = FALSE;
|
||||||
|
if ($nameexists) {
|
||||||
|
format_message(1, "Template creation failed because the name you supplied already exists. Please try again.");
|
||||||
|
$addfail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$namesupplied) {
|
||||||
|
format_message(1, "Template creation failed because you didn't supply a name. Please try again.");
|
||||||
|
$addfail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$note) {
|
||||||
|
format_message(1, "Template creation failed because you didn't enter any note text. Please try again.");
|
||||||
|
$addfail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$authorized) {
|
||||||
|
format_message(1, "Template creation failed because you are not authorized to do so.");
|
||||||
|
$addfail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$addfail) format_message(0, "<strong>Template created.</strong>");
|
||||||
|
}
|
||||||
|
if ($operation == "edit") {
|
||||||
|
$editfail = FALSE;
|
||||||
|
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 (!$authorized) {
|
||||||
|
format_message(1, "Template save failed because you are not authorized to do so.");
|
||||||
|
$editfail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$editfail) format_message(0, "<strong>Template modified.</strong>");
|
||||||
|
}
|
||||||
|
if ($operation == "delete") {
|
||||||
|
$deletefail = FALSE;
|
||||||
|
if (!$authorized) {
|
||||||
|
format_message(1, "Template delete failed because you are not authorized to do so.");
|
||||||
|
$deletefail = TRUE;
|
||||||
|
}
|
||||||
|
if (!$deletefail) format_message(0, "<strong>Template deleted.</strong>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($operation == "delete") {
|
||||||
|
// just show the link back to the templates page
|
||||||
|
echo "
|
||||||
|
<br><a href=\"templates.php\">Manage templates</a><br><br><br><br>
|
||||||
|
";
|
||||||
|
} else if ($operation == "add" || $operation == "edit") {
|
||||||
|
// Display the input form
|
||||||
|
if ($loadtemplate) {
|
||||||
|
// make templateid the selected template
|
||||||
|
if ($usertemplateid) {
|
||||||
|
$templateid = $usertemplateid;
|
||||||
|
} else if ($globaltemplateid) {
|
||||||
|
$templateid = $globaltemplateid;
|
||||||
|
} else {
|
||||||
|
$templateid = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($operation == "edit" || $loadtemplate) {
|
||||||
|
// use values from the templateid supplied with a defined tech id
|
||||||
|
$loadeddata = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""));
|
||||||
|
$filltemplatename = $loadeddata["templatename"];
|
||||||
|
if ($efftechid) {
|
||||||
|
$filltech = $efftechid;
|
||||||
|
} else if ($isadmin && $loadeddata["tech"] == "0") {
|
||||||
|
$filltech = "0";
|
||||||
|
} else {
|
||||||
|
$filltech = $techid;
|
||||||
|
}
|
||||||
|
$fillshift = $loadeddata["shift"];
|
||||||
|
$fillsubject = $loadeddata["subject"];
|
||||||
|
$fillnote = $loadeddata["lognote"];
|
||||||
|
} else {
|
||||||
|
// use empty values with a defined tech id
|
||||||
|
$filltemplatename = NULL;
|
||||||
|
if ($efftechid) {
|
||||||
|
$filltech = $efftechid;
|
||||||
|
} else {
|
||||||
|
$filltech = $techid;
|
||||||
|
}
|
||||||
|
$fillshift = $defaultshift;
|
||||||
|
$fillsubject = NULL;
|
||||||
|
$fillnote = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($operation == "add") $optext = "Creating new";
|
||||||
|
if ($operation == "edit") $optext = "Editing";
|
||||||
|
echo "
|
||||||
|
<br><b>$optext template</b><br><hr>
|
||||||
|
";
|
||||||
|
|
||||||
|
// show the template selection line
|
||||||
|
templateselect($techid, $operation);
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
echo "
|
||||||
|
<tr><td colspan=\"2\"><b>Tech: </b>
|
||||||
|
<select name=\"efftechid\">
|
||||||
|
";
|
||||||
|
if ($filltech == "0") {
|
||||||
|
echo "<option value=\"0\" selected>--Global Template--</option>";
|
||||||
|
} else {
|
||||||
|
echo "<option value=\"0\">--Global Template--</option>";
|
||||||
|
}
|
||||||
|
if ($techalpha) $torder = "techname";
|
||||||
|
else $torder = "techid";
|
||||||
|
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||||
|
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||||
|
if ($techitem["techid"] == $filltech) {
|
||||||
|
printf("<option value=\"%s\" selected>%s</option>", $techitem["techid"], $techitem["techname"]);
|
||||||
|
} else {
|
||||||
|
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
</select></td></tr>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
$authorized = 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 ($operation == "edit" && in_array($flagcheckbox["flagid"], $theseflags)) {
|
||||||
|
printf(
|
||||||
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$flagid = $flagcheckbox["flagid"];
|
||||||
|
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||||
|
printf(
|
||||||
|
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||||
|
$flagcheckbox["flagid"],
|
||||||
|
$flagcheckbox["flagcolor"],
|
||||||
|
$flagcheckbox["flagname"],
|
||||||
|
$flagcheckbox["flagsym"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($flagcount < $flagsperline) {
|
||||||
|
echo " ";
|
||||||
|
$flagcount++;
|
||||||
|
} else {
|
||||||
|
echo "<br>";
|
||||||
|
$flagcount = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($operation == "edit" || $loadtemplate) {
|
||||||
|
// generate a reference string
|
||||||
|
$refstring = NULL;
|
||||||
|
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
|
||||||
|
while ($tgt = mysqli_fetch_row($refstringqry)) {
|
||||||
|
$refstring = $refstring . " " . $tgt[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 ($operation == "add" && $authorized) {
|
||||||
|
echo "
|
||||||
|
<input type=\"hidden\" name=\"operation\" value=\"add\">
|
||||||
|
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
|
||||||
|
";
|
||||||
|
}
|
||||||
|
if ($operation == "edit" && $authorized) {
|
||||||
|
echo "
|
||||||
|
<input type=\"hidden\" name=\"operation\" value=\"edit\">
|
||||||
|
<input type=\"hidden\" name=\"templateid\" value=\"$templateid\">
|
||||||
|
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
|
||||||
|
<br><br>
|
||||||
|
<button type=\"submit\" name=\"operation\" value=\"delete\">Delete this template</button><font color=\"#FF0000\"><b>Deleted templates are irretrievable!</b></font>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "
|
||||||
|
</form>
|
||||||
|
<br>
|
||||||
|
";
|
||||||
|
} else {
|
||||||
|
echo "<br><font size= \"+1\"><b><a href=\"templates.php?operation=add\">Create or copy a template</a></b></font><br><hr>";
|
||||||
|
|
||||||
|
// Show my user template table
|
||||||
|
templatetable($db, $techid, $techid);
|
||||||
|
|
||||||
|
// 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);
|
||||||
@@ -46,3 +46,10 @@ fi
|
|||||||
# No changes
|
# No changes
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
|
|
||||||
|
# ---------- version 5.3.0 -------------
|
||||||
|
# No changes
|
||||||
|
# --------------------------------------
|
||||||
|
|
||||||
|
# ---------- version 5.3.1 -------------
|
||||||
|
# No changes
|
||||||
|
# --------------------------------------
|
||||||
155
install.sh
155
install.sh
@@ -2,17 +2,16 @@
|
|||||||
|
|
||||||
# install.sh
|
# install.sh
|
||||||
# OpenLog Online Logbook
|
# OpenLog Online Logbook
|
||||||
# Copyright (C) 2025 Rod Wright
|
# Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
|
|
||||||
APP_NAME="OpenLog"
|
APP_NAME="OpenLog"
|
||||||
DEFAULT_DB_NAME="openlog"
|
DEFAULT_DB_NAME="openlog"
|
||||||
APP_VERSION="5.2.5"
|
APP_VERSION="5.3.1"
|
||||||
DOC_ROOT="/var/www"
|
DOC_ROOT="/var/www"
|
||||||
INSTALL_LOC="openlog"
|
INSTALL_LOC="openlog"
|
||||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||||
BACKUP_DIR="openlog-previous-installation"
|
|
||||||
LANDING_PAGE="lognotes.php"
|
LANDING_PAGE="lognotes.php"
|
||||||
CONFIG_TABLE="configs"
|
CONFIG_TABLE="configs"
|
||||||
CONFIG_NAME_COLUMN="confname"
|
CONFIG_NAME_COLUMN="confname"
|
||||||
@@ -22,7 +21,7 @@ CONFIG_DEFAULT_COLUMN=""
|
|||||||
|
|
||||||
function privilege_check() {
|
function privilege_check() {
|
||||||
# test for superuser rights
|
# test for superuser rights
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ "$EUID" != 0 ]]; then
|
||||||
echo "This script must be run with superuser privileges. Try sudo $0"
|
echo "This script must be run with superuser privileges. Try sudo $0"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -37,11 +36,11 @@ function get_new_password() {
|
|||||||
echo ""
|
echo ""
|
||||||
read -p "Re-type new password: " -s -r rnewpw
|
read -p "Re-type new password: " -s -r rnewpw
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$newpassword" = "" -o "$rnewpw" = "" ]
|
if [[ "$newpassword" == "" || "$rnewpw" == "" ]]
|
||||||
then
|
then
|
||||||
echo "Password cannot be blank. Please try again."
|
echo "Password cannot be blank. Please try again."
|
||||||
echo ""
|
echo ""
|
||||||
elif [ "$newpassword" != "$rnewpw" ]
|
elif [[ "$newpassword" != "$rnewpw" ]]
|
||||||
then
|
then
|
||||||
echo "Passwords do not match. Please try again."
|
echo "Passwords do not match. Please try again."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -64,7 +63,7 @@ function install_required_packages() {
|
|||||||
gpattern=""
|
gpattern=""
|
||||||
for pkg_option in $(echo $prereq)
|
for pkg_option in $(echo $prereq)
|
||||||
do
|
do
|
||||||
if [ "$pkg_option" != "or" ]
|
if [[ "$pkg_option" != "or" ]]
|
||||||
then
|
then
|
||||||
gpattern+=" -e $pkg_option"
|
gpattern+=" -e $pkg_option"
|
||||||
preferred_pkg=$pkg_option
|
preferred_pkg=$pkg_option
|
||||||
@@ -77,7 +76,7 @@ function install_required_packages() {
|
|||||||
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
|
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
|
||||||
echo -n "Install $preferred_pkg now? [Y/n]: "
|
echo -n "Install $preferred_pkg now? [Y/n]: "
|
||||||
read reqinstall
|
read reqinstall
|
||||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]]
|
||||||
then
|
then
|
||||||
echo "$APP_NAME requires $prereq, but you have elected not to install it."
|
echo "$APP_NAME requires $prereq, but you have elected not to install it."
|
||||||
echo "Installation cannot continue."
|
echo "Installation cannot continue."
|
||||||
@@ -173,20 +172,20 @@ echo ""
|
|||||||
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
|
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
|
||||||
read install_loc_in
|
read install_loc_in
|
||||||
echo ""
|
echo ""
|
||||||
if [ "$doc_root_in" = "" ]
|
if [[ "$doc_root_in" == "" ]]
|
||||||
then
|
then
|
||||||
doc_root_in=$DOC_ROOT
|
doc_root_in=$DOC_ROOT
|
||||||
fi
|
fi
|
||||||
if [ "$install_loc_in" = "" ]
|
if [[ "$install_loc_in" == "" ]]
|
||||||
then
|
then
|
||||||
install_loc_in=$INSTALL_LOC
|
install_loc_in=$INSTALL_LOC
|
||||||
fi
|
fi
|
||||||
install_path="$doc_root_in/$install_loc_in"
|
install_path="$doc_root_in/$install_loc_in"
|
||||||
if [ -d "$install_path" ]
|
if [[ -d "$install_path" ]]
|
||||||
then
|
then
|
||||||
echo "The installation path you chose already exists."
|
echo "The installation path you chose already exists."
|
||||||
# Install path exists.
|
# Install path exists.
|
||||||
if [ -e "$install_path/db.php" ]
|
if [[ -e "$install_path/db.php" ]]
|
||||||
then
|
then
|
||||||
# A db.php file was found in the install path
|
# A db.php file was found in the install path
|
||||||
if grep -q -e "$APP_NAME" $install_path/db.php
|
if grep -q -e "$APP_NAME" $install_path/db.php
|
||||||
@@ -196,13 +195,47 @@ then
|
|||||||
echo "and restart the install using a new installation location."
|
echo "and restart the install using a new installation location."
|
||||||
echo -n "[U]pgrade or [C]ancel? [U] :"
|
echo -n "[U]pgrade or [C]ancel? [U] :"
|
||||||
read upgrade_choice
|
read upgrade_choice
|
||||||
if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen
|
if [[ "$upgrade_choice" == "C" || "$upgrade_choice" == "c" ]] # Cancel chosen
|
||||||
then
|
then
|
||||||
echo "Cancelling installation"
|
echo "Cancelling installation"
|
||||||
abort_exit
|
abort_exit
|
||||||
else
|
else
|
||||||
# proceed with upgrade
|
# proceed with upgrade
|
||||||
mkdir -p backups
|
# put app in maintenance mode
|
||||||
|
echo "Putting the application in maintenance mode..."
|
||||||
|
# make sure mod_rewrite is enabled
|
||||||
|
if [[ ! -e "$APACHE_CONF_DIR/../mods-enabled/rewrite.load" ]]
|
||||||
|
then
|
||||||
|
a2enmod -q rewrite
|
||||||
|
systemctl restart apache2
|
||||||
|
fi
|
||||||
|
# disable the app
|
||||||
|
a2disconf -q $install_loc_in
|
||||||
|
systemctl reload apache2
|
||||||
|
# modify the apache conf file
|
||||||
|
if ! grep -q "RewriteEngine" "$APACHE_CONF_DIR/$install_loc_in.conf"
|
||||||
|
then
|
||||||
|
# this is an old version of the conf file. Replace with new version
|
||||||
|
cp -f default-apache.conf $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
sed -i "s|_BASEURL_|$install_loc_in|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
fi
|
||||||
|
sed -i "s|#Rewrite|Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
# copy in the default maintenancemode.php if it's not already there
|
||||||
|
if [[ ! -e "$install_path/maintenancemode.php" ]]
|
||||||
|
then
|
||||||
|
cp maintenancemode.php $install_path/
|
||||||
|
# modify the maintenancemode.php file
|
||||||
|
sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php
|
||||||
|
fi
|
||||||
|
# re-enable the app in maintenance mode
|
||||||
|
a2enconf -q $install_loc_in
|
||||||
|
systemctl reload apache2
|
||||||
|
|
||||||
|
datestamp=$(date +%Y-%m-%d_%H:%M:%S)
|
||||||
|
backupdir=backups/$datestamp
|
||||||
|
mkdir -p $backupdir
|
||||||
operation="upgraded"
|
operation="upgraded"
|
||||||
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
|
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
|
||||||
|
|
||||||
@@ -219,25 +252,21 @@ then
|
|||||||
|
|
||||||
# back up existing database
|
# back up existing database
|
||||||
echo "Backing up the current database to the package directory."
|
echo "Backing up the current database to the package directory."
|
||||||
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
|
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > $backupdir/$curr_dbname-$datestamp-backup.sql
|
||||||
|
|
||||||
# back up existing installation
|
# back up existing installation
|
||||||
echo "Backing up current installation to the package directory."
|
echo "Backing up current installation to the package directory."
|
||||||
cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
|
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
|
||||||
|
|
||||||
# delete all existing installation files except db.php
|
# delete all existing installation files except db.php and maintenancemode.php
|
||||||
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
|
find $install_path/ -mindepth 1 ! \( -name 'db.php' -o -name 'maintenancemode.php' \) -delete
|
||||||
|
|
||||||
echo "Performing database updates. This may take a while..."
|
echo "Performing database updates..."
|
||||||
# apply database updates from sql file
|
# apply database updates from sql file
|
||||||
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
|
mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1
|
||||||
task_pid=$!
|
|
||||||
spinner $task_pid
|
|
||||||
|
|
||||||
# apply database updates via script
|
# apply database updates via script
|
||||||
(bash ./database-update.sh $mysql_opt_file) &
|
bash ./database-update.sh $mysql_opt_file
|
||||||
task_pid=$!
|
|
||||||
spinner $task_pid
|
|
||||||
|
|
||||||
echo "... finished with database updates."
|
echo "... finished with database updates."
|
||||||
rm -f $mysql_opt_file
|
rm -f $mysql_opt_file
|
||||||
@@ -249,12 +278,12 @@ then
|
|||||||
echo "Installing distribution . . ."
|
echo "Installing distribution . . ."
|
||||||
cp -R distfiles/* $install_path
|
cp -R distfiles/* $install_path
|
||||||
# set symlink for jquery-ui
|
# set symlink for jquery-ui
|
||||||
if [ ! -L "$install_path/jquery-ui" ]
|
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||||
then
|
then
|
||||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||||
fi
|
fi
|
||||||
# set symlink for index.php
|
# set symlink for index.php
|
||||||
if [ ! -L "$install_path/index.php" ]
|
if [[ ! -L "$install_path/index.php" ]]
|
||||||
then
|
then
|
||||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||||
fi
|
fi
|
||||||
@@ -267,6 +296,19 @@ then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Setting file ownership . . ."
|
echo "Setting file ownership . . ."
|
||||||
chown -R $httpd_user_group $install_path
|
chown -R $httpd_user_group $install_path
|
||||||
|
echo "Backups of the previous openlog files and the previous database were made"
|
||||||
|
echo "and are located in the $backupdir directory."
|
||||||
|
|
||||||
|
# take app out of maintenance mode
|
||||||
|
echo "Taking the app out of maintenance mode..."
|
||||||
|
# disable the app
|
||||||
|
a2disconf -q $install_loc_in
|
||||||
|
systemctl reload apache2
|
||||||
|
# modify the apache conf file
|
||||||
|
sed -i "s|Rewrite|#Rewrite|g" $APACHE_CONF_DIR/$install_loc_in.conf
|
||||||
|
# re-enable the app in production mode
|
||||||
|
a2enconf -q $install_loc_in
|
||||||
|
systemctl reload apache2
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# This was a mistake. Exit now to avoid clobbering another app.
|
# This was a mistake. Exit now to avoid clobbering another app.
|
||||||
@@ -284,11 +326,11 @@ then
|
|||||||
echo "Would you like to use this location for a fresh installation or quit and"
|
echo "Would you like to use this location for a fresh installation or quit and"
|
||||||
echo "investigate further? It's probably safest to quit and investigate."
|
echo "investigate further? It's probably safest to quit and investigate."
|
||||||
proceed=""
|
proceed=""
|
||||||
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
|
while [[ "$proceed" != "P" && "$proceed" != "p" && "$proceed" != "Q" && "$proceed" != "q" ]]
|
||||||
do
|
do
|
||||||
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
||||||
done
|
done
|
||||||
if [[ $proceed == "Q" || $proceed == "q" ]]
|
if [[ "$proceed" == "Q" || "$proceed" == "q" ]]
|
||||||
then
|
then
|
||||||
abort_exit
|
abort_exit
|
||||||
fi
|
fi
|
||||||
@@ -303,7 +345,7 @@ else
|
|||||||
echo "This can be changed later in the application itself."
|
echo "This can be changed later in the application itself."
|
||||||
echo -n "Installation name [$APP_NAME]: "
|
echo -n "Installation name [$APP_NAME]: "
|
||||||
read new_inst_name
|
read new_inst_name
|
||||||
if [ "$new_inst_name" = "" ]
|
if [[ "$new_inst_name" == "" ]]
|
||||||
then
|
then
|
||||||
new_inst_name="$APP_NAME"
|
new_inst_name="$APP_NAME"
|
||||||
fi
|
fi
|
||||||
@@ -320,7 +362,7 @@ else
|
|||||||
echo "distinctive name."
|
echo "distinctive name."
|
||||||
echo -n "database name [$DEFAULT_DB_NAME]: "
|
echo -n "database name [$DEFAULT_DB_NAME]: "
|
||||||
read new_db_name
|
read new_db_name
|
||||||
if [ "$new_db_name" = "" ]
|
if [[ "$new_db_name" == "" ]]
|
||||||
then
|
then
|
||||||
new_db_name=$DEFAULT_DB_NAME
|
new_db_name=$DEFAULT_DB_NAME
|
||||||
fi
|
fi
|
||||||
@@ -333,7 +375,7 @@ else
|
|||||||
echo "This probably means the database already exists."
|
echo "This probably means the database already exists."
|
||||||
echo -n "Try again with a different database name? [Y/N]: "
|
echo -n "Try again with a different database name? [Y/N]: "
|
||||||
read dbcreatetry
|
read dbcreatetry
|
||||||
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
|
if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]]
|
||||||
then
|
then
|
||||||
abort_exit
|
abort_exit
|
||||||
fi
|
fi
|
||||||
@@ -353,7 +395,7 @@ else
|
|||||||
# Set the installation name
|
# Set the installation name
|
||||||
export MYSQL_PWD="$db_pass"
|
export MYSQL_PWD="$db_pass"
|
||||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
||||||
if [ "$CONFIG_DEFAULT_COLUMN" != "" ]
|
if [[ "$CONFIG_DEFAULT_COLUMN" != "" ]]
|
||||||
then
|
then
|
||||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
||||||
fi
|
fi
|
||||||
@@ -362,23 +404,29 @@ else
|
|||||||
mkdir $install_path
|
mkdir $install_path
|
||||||
|
|
||||||
# Create db.php if it doesn't exist
|
# Create db.php if it doesn't exist
|
||||||
if [ ! -f "$install_path/db.php" ]
|
if [[ ! -f "$install_path/db.php" ]]
|
||||||
then
|
then
|
||||||
cp db.php.template $install_path/db.php
|
cp db.php.template $install_path/db.php
|
||||||
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
|
sed -i "s|DBNAME|$new_db_name|g" $install_path/db.php
|
||||||
sed -i "s/DBUSER/$db_user/g" $install_path/db.php
|
sed -i "s|DBUSER|$db_user|g" $install_path/db.php
|
||||||
sed -i "s/DBPASS/$db_pass/g" $install_path/db.php
|
sed -i "s|DBPASS|$db_pass|g" $install_path/db.php
|
||||||
sed -i "s/APPNAME/$APP_NAME/g" $install_path/db.php
|
sed -i "s|APPNAME|$APP_NAME|g" $install_path/db.php
|
||||||
|
fi
|
||||||
|
# Create maintenancemode.php if it doesn't exist
|
||||||
|
if [[ ! -f "$install_path/maintenancemode.php" ]]
|
||||||
|
then
|
||||||
|
cp maintenancemode.php $install_path/maintenancemode.php
|
||||||
|
sed -i "s|_APPNAME_|$APP_NAME|g" $install_path/maintenancemode.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# copy distribution to install location
|
# copy distribution to install location
|
||||||
echo "Installing distribution . . ."
|
echo "Installing distribution . . ."
|
||||||
cp -R distfiles/* $install_path
|
cp -R distfiles/* $install_path
|
||||||
if [ ! -L "$install_path/jquery-ui" ]
|
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||||
then
|
then
|
||||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||||
fi
|
fi
|
||||||
if [ ! -L "$install_path/index.php" ]
|
if [[ ! -L "$install_path/index.php" ]]
|
||||||
then
|
then
|
||||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||||
fi
|
fi
|
||||||
@@ -401,23 +449,24 @@ echo ""
|
|||||||
echo ""
|
echo ""
|
||||||
echo "$APP_NAME has been $operation."
|
echo "$APP_NAME has been $operation."
|
||||||
base_url=$install_loc_in
|
base_url=$install_loc_in
|
||||||
if [ "$operation" = "installed" ]
|
if [[ "$operation" == "upgraded" ]]
|
||||||
then
|
then
|
||||||
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
a2enconf -q $base_url
|
||||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
systemctl reload apache2
|
||||||
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
|
fi
|
||||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
if [[ "$operation" == "installed" ]]
|
||||||
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
|
then
|
||||||
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
|
cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf
|
||||||
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
|
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf
|
||||||
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
|
sed -i "s|_BASEURL_|$base_url|g" $APACHE_CONF_DIR/$base_url.conf
|
||||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
sed -i "s|_DOCROOTIN_|$doc_root_in|g" $APACHE_CONF_DIR/$base_url.conf
|
||||||
|
|
||||||
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
|
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
|
||||||
read enconf
|
read enconf
|
||||||
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
|
if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
|
||||||
then
|
then
|
||||||
a2enconf $base_url.conf >/dev/null
|
a2enconf -q $base_url.conf >/dev/null
|
||||||
service apache2 reload
|
systemctl reload apache2
|
||||||
echo "You can now point a web browser to $base_url on your web server "
|
echo "You can now point a web browser to $base_url on your web server "
|
||||||
echo "to set up and configure $APP_NAME."
|
echo "to set up and configure $APP_NAME."
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
26
maintenancemode.php
Normal file
26
maintenancemode.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
maintenancemode.php
|
||||||
|
OpenLog Online Logbook
|
||||||
|
Copyright (C) 2026 Rod Wright
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
echo "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>_APPNAME_</title>
|
||||||
|
<style type=\"text/css\">
|
||||||
|
* {font-family: Arial, Helvetica, sans-serif;}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<br><br><br><br>
|
||||||
|
_APPNAME_ is currently down for maintenance. Please try again later.
|
||||||
|
<br><br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user