Compare commits
45 Commits
63bb7a3445
...
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 | |||
| f20b4cd8b6 |
3
BUGS
3
BUGS
@@ -1,4 +1,5 @@
|
||||
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.
|
||||
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.)
|
||||
|
||||
48
CHANGELOG
48
CHANGELOG
@@ -240,3 +240,51 @@
|
||||
treating the $today variable as global.
|
||||
- In install.php, if a previous installation was found, make upgrade
|
||||
the default choice.
|
||||
|
||||
5.2.5 - 2026-02-10
|
||||
This is just a version number bump to get on a major-minor-patch
|
||||
scheme. There are no code changes for this release.
|
||||
|
||||
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.
|
||||
|
||||
32
INSTALL
32
INSTALL
@@ -4,32 +4,30 @@
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
|
||||
Installation of OpenLog is straightforward.
|
||||
|
||||
1. Gather the required information.
|
||||
You'll need to know how to configure your web server. This means where
|
||||
you want to put the files to be served and any configuration required to
|
||||
allow clients to reach them. You'll also need to know the username and
|
||||
password of the MySQL administrator.
|
||||
You'll need to know how to configure your web server. This means where
|
||||
you want to put the files to be served and any configuration required to
|
||||
allow clients to reach them. You'll also need to know the username and
|
||||
password of the MySQL administrator.
|
||||
|
||||
2. Unpack
|
||||
Unpack the distribution in a convenient place (such as /tmp or My Documents).
|
||||
A directory will be created called OpenLog-x.x.x.
|
||||
Unpack the distribution in a convenient place (such as /tmp or My Documents).
|
||||
A directory will be created called OpenLog-x.x.x.
|
||||
|
||||
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
|
||||
If installing on a Linux or Unix based system, type ./install.sh at a
|
||||
command prompt. If installing on a Windows based system, double click
|
||||
install.bat. Follow the prompts.
|
||||
If installing on a Linux or Unix based system, type ./install.sh at a
|
||||
command prompt. If installing on a Windows based system, double click
|
||||
install.bat. Follow the prompts.
|
||||
|
||||
5. Check and set Configuration
|
||||
Click on the Administration menu option on the main page to adjust the initial
|
||||
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
|
||||
top to add techs, subjects, shifts, etc.
|
||||
|
||||
7. Start using OpenLog.
|
||||
Click on the Administration menu option on the main page to adjust the initial
|
||||
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
|
||||
top to add techs, subjects, shifts, etc.
|
||||
|
||||
6. Start using OpenLog.
|
||||
|
||||
8
TODO.txt
8
TODO.txt
@@ -1,15 +1,15 @@
|
||||
TODO.txt
|
||||
|
||||
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)
|
||||
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.
|
||||
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
|
||||
8. Improve template management interface. It can be confusing. It needs its own page.
|
||||
9. Remove refs from templates. (db change reqd)
|
||||
10. Replace dynamic flag_ table creation with a flagassignment table. (db change reqd)
|
||||
8. Improve template management interface. It can be confusing. It needs its own page. DONE
|
||||
9. Remove refs from templates. (db change reqd) DONE
|
||||
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)
|
||||
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.
|
||||
|
||||
@@ -1 +1 @@
|
||||
5.3.0
|
||||
5.3.1
|
||||
|
||||
1025
database-initial.sql
1025
database-initial.sql
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,19 @@
|
||||
|
||||
# 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 == "" ]]
|
||||
then
|
||||
@@ -45,7 +58,9 @@ 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 "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'")
|
||||
@@ -69,13 +84,18 @@ then
|
||||
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 "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")
|
||||
@@ -88,8 +108,13 @@ then
|
||||
done
|
||||
IFS=$oldifs
|
||||
done
|
||||
) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
echo "...done."
|
||||
echo "Importing template reference chain data into new reflinks table..."
|
||||
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")
|
||||
@@ -102,6 +127,9 @@ then
|
||||
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
|
||||
@@ -116,3 +144,7 @@ do
|
||||
done
|
||||
echo "...done."
|
||||
# -------------------------------------
|
||||
|
||||
# ---------- version 5.3.1 ------------
|
||||
# Nothing to do
|
||||
# -------------------------------------
|
||||
@@ -2,81 +2,90 @@
|
||||
|
||||
-- ---------- version 5.2.1 -------------
|
||||
-- Make confname a unique column
|
||||
ALTER TABLE configs ADD UNIQUE(confname);
|
||||
ALTER TABLE configs ADD UNIQUE (confname);
|
||||
|
||||
-- Delete db name, user, and password configs
|
||||
DELETE FROM configs where confname="ol_dbname";
|
||||
DELETE FROM configs where confname="ol_dbuser";
|
||||
DELETE FROM configs where confname="ol_dbpass";
|
||||
DELETE FROM configs where confname = "ol_dbname";
|
||||
|
||||
DELETE FROM configs where confname = "ol_dbuser";
|
||||
|
||||
DELETE FROM configs where confname = "ol_dbpass";
|
||||
|
||||
-- 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 configs SET confvalue="5.2.1" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.1" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.2 -------------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.2" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.2" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.3 -------------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.3" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.3" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4 -------------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.4" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.1 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.1" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.4.1" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.2 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.2" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.4.2" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.3 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.3" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.4.3" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.4.4 -----------
|
||||
-- Update version number
|
||||
UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version";
|
||||
UPDATE configs SET confvalue = "5.2.4.4" WHERE confname = "ol_version";
|
||||
-- --------------------------------------
|
||||
|
||||
-- ---------- version 5.2.5 -------------
|
||||
-- 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";
|
||||
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;
|
||||
`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;
|
||||
`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";
|
||||
-- --------------------------------------
|
||||
@@ -14,10 +14,10 @@
|
||||
** DO NOT EDIT **
|
||||
************************************************************************
|
||||
*/
|
||||
$appname="APPNAME";
|
||||
$dbname="DBNAME";
|
||||
$username="DBUSER";
|
||||
$dbpass="DBPASS";
|
||||
$appname = "APPNAME";
|
||||
$dbname = "DBNAME";
|
||||
$username = "DBUSER";
|
||||
$dbpass = "DBPASS";
|
||||
|
||||
function dberrmsg($dbname) {
|
||||
echo "
|
||||
@@ -34,7 +34,7 @@ function dberrmsg($dbname) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$db=@mysqli_connect("localhost",$username,$dbpass,$dbname);
|
||||
$db = @mysqli_connect("localhost",$username,$dbpass,$dbname);
|
||||
if (mysqli_errno($db)) {
|
||||
dberrmsg($dbname);
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -233,10 +233,59 @@
|
||||
installers.
|
||||
|
||||
5.2.4.4 - 2025-12-19
|
||||
-Fixed bugs that caused crashes on the Scheduled Maintenance page
|
||||
- Fixed bugs that caused crashes on the Scheduled Maintenance page
|
||||
that were caused by more strict behavior of php regarding mysql
|
||||
queries.
|
||||
- Fixed bug where some functions defined in functions.php were not
|
||||
treating the $today variable as global.
|
||||
- In install.php, if a previous installation was found, make upgrade
|
||||
the default choice.
|
||||
|
||||
5.2.5 - 2026-02-10
|
||||
This is just a version number bump to get on a major-minor-patch
|
||||
scheme. There are no code changes for this release.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -14,16 +14,14 @@ allow clients to reach them. You'll also need to know the username and
|
||||
password of the MySQL administrator.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
If installing on a Linux or Unix based system, type ./install.sh at a
|
||||
command prompt. If installing on a Windows based system, double click
|
||||
install.bat. Follow the prompts.
|
||||
Type ./install.sh at a command prompt. Follow the prompts.
|
||||
|
||||
5. Check and set Configuration
|
||||
Click on the Administration menu option on the main page to adjust the initial
|
||||
|
||||
@@ -8,27 +8,27 @@
|
||||
*/
|
||||
|
||||
include("functions.php");
|
||||
$version=OL_VERSION;
|
||||
$version = OL_VERSION;
|
||||
|
||||
$print=$_REQUEST['print'] ?? NULL;
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
framework("begin","About OpenLog","About OpenLog",$print);
|
||||
framework("begin", "About OpenLog", "About OpenLog", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print){
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
echo "
|
||||
<h3 align=\"center\">
|
||||
OpenLog $version
|
||||
@@ -87,10 +87,8 @@ border=0></a></td><td><b>Fugue<br>Icons</b></td><td>The icons used in OpenLog ar
|
||||
|
||||
</table>
|
||||
</p>
|
||||
";
|
||||
pageblock("right","end");
|
||||
";
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
1209
distfiles/admin.php
1209
distfiles/admin.php
File diff suppressed because it is too large
Load Diff
@@ -28,48 +28,50 @@ include("settings.php");
|
||||
|
||||
|
||||
// build the basic color array
|
||||
$basic_colors=array(
|
||||
"White" => "#FFFFFF",
|
||||
"Silver" => "#C0C0C0",
|
||||
"Gray" => "#808080",
|
||||
"Black" => "#000000",
|
||||
"Red" => "#FF0000",
|
||||
"Maroon" => "#800000",
|
||||
"Orange" => "#FFA500",
|
||||
"Yellow" => "#FFFF00",
|
||||
"Olive" => "#808000",
|
||||
"Lime" => "#00FF00",
|
||||
"Green" => "#008000",
|
||||
"Aqua" => "#00FFFF",
|
||||
"Teal" => "#008080",
|
||||
"Blue" => "#0000FF",
|
||||
"Navy" => "#000080",
|
||||
"Fuchsia" => "#FF00FF",
|
||||
"Purple" => "#800080");
|
||||
$basic_colors = array(
|
||||
"White" => "#FFFFFF",
|
||||
"Silver" => "#C0C0C0",
|
||||
"Gray" => "#808080",
|
||||
"Black" => "#000000",
|
||||
"Red" => "#FF0000",
|
||||
"Maroon" => "#800000",
|
||||
"Orange" => "#FFA500",
|
||||
"Yellow" => "#FFFF00",
|
||||
"Olive" => "#808000",
|
||||
"Lime" => "#00FF00",
|
||||
"Green" => "#008000",
|
||||
"Aqua" => "#00FFFF",
|
||||
"Teal" => "#008080",
|
||||
"Blue" => "#0000FF",
|
||||
"Navy" => "#000080",
|
||||
"Fuchsia" => "#FF00FF",
|
||||
"Purple" => "#800080"
|
||||
);
|
||||
|
||||
// Generic functions
|
||||
|
||||
function framework($option,$htmltitle,$pagetitle,$print) {
|
||||
function framework($option, $htmltitle, $pagetitle, $print)
|
||||
{
|
||||
// generates html code for the beginning and end of all pages
|
||||
if ($option=="begin") {
|
||||
if ($option == "begin") {
|
||||
// generates everything down to the first horiz rule inclusive
|
||||
// htmltitle is the page title that appears in the window titlebar
|
||||
// pagetitle is what will appear as the title of the page itself
|
||||
// print is whether to format for printing or not
|
||||
if ($print) {
|
||||
$bgcolor=P_BACKGROUND_COLOR;
|
||||
$textcolor=P_TEXT_COLOR;
|
||||
$linkcolor=P_LINK_COLOR;
|
||||
$vlinkcolor=P_VLINK_COLOR;
|
||||
$hdgcolor=P_HEADING_COLOR;
|
||||
$bgcolor = P_BACKGROUND_COLOR;
|
||||
$textcolor = P_TEXT_COLOR;
|
||||
$linkcolor = P_LINK_COLOR;
|
||||
$vlinkcolor = P_VLINK_COLOR;
|
||||
$hdgcolor = P_HEADING_COLOR;
|
||||
} else {
|
||||
$bgcolor=BACKGROUND_COLOR;
|
||||
$textcolor=TEXT_COLOR;
|
||||
$linkcolor=LINK_COLOR;
|
||||
$vlinkcolor=VLINK_COLOR;
|
||||
$hdgcolor=HEADING_COLOR;
|
||||
$bgcolor = BACKGROUND_COLOR;
|
||||
$textcolor = TEXT_COLOR;
|
||||
$linkcolor = LINK_COLOR;
|
||||
$vlinkcolor = VLINK_COLOR;
|
||||
$hdgcolor = HEADING_COLOR;
|
||||
}
|
||||
|
||||
|
||||
echo "
|
||||
<html>
|
||||
<head>
|
||||
@@ -91,13 +93,13 @@ function framework($option,$htmltitle,$pagetitle,$print) {
|
||||
<font size=5 color=\"$hdgcolor\"><b> $htmltitle - $pagetitle</b></font><br>
|
||||
";
|
||||
}
|
||||
} else if ($option=="end") {
|
||||
} else if ($option == "end") {
|
||||
// generates everything from the last horiz rule down to end of page
|
||||
echo "
|
||||
<hr><br><br>
|
||||
";
|
||||
if (defined("FOOTER_MESSAGE")) {
|
||||
$footer_msg=FOOTER_MESSAGE;
|
||||
$footer_msg = FOOTER_MESSAGE;
|
||||
echo "
|
||||
<center>$footer_msg</center><br>
|
||||
";
|
||||
@@ -221,14 +223,15 @@ function framework($option,$htmltitle,$pagetitle,$print) {
|
||||
}
|
||||
}
|
||||
|
||||
function pagetable($option) {
|
||||
if ($option=="begin") {
|
||||
function pagetable($option)
|
||||
{
|
||||
if ($option == "begin") {
|
||||
echo "
|
||||
<br>
|
||||
<table border=\"0\" width=\"100%\" cellpadding=\"10\">
|
||||
<tr>
|
||||
";
|
||||
} else if ($option=="end") {
|
||||
} else if ($option == "end") {
|
||||
echo "
|
||||
</tr></table>
|
||||
";
|
||||
@@ -240,14 +243,15 @@ function pagetable($option) {
|
||||
}
|
||||
}
|
||||
|
||||
function pageblock($block,$option) {
|
||||
function pageblock($block, $option)
|
||||
{
|
||||
global $sbcolor;
|
||||
if ($block=="left") {
|
||||
if ($option=="begin") {
|
||||
if ($block == "left") {
|
||||
if ($option == "begin") {
|
||||
echo "
|
||||
<td width=\"210\" bgcolor=\"$sbcolor\" valign=\"top\">
|
||||
";
|
||||
} else if ($option=="end") {
|
||||
} else if ($option == "end") {
|
||||
echo "
|
||||
</td>
|
||||
";
|
||||
@@ -257,12 +261,12 @@ function pageblock($block,$option) {
|
||||
";
|
||||
exit(1);
|
||||
}
|
||||
} else if ($block=="right") {
|
||||
if ($option=="begin") {
|
||||
} else if ($block == "right") {
|
||||
if ($option == "begin") {
|
||||
echo "
|
||||
<td valign=\"top\">
|
||||
";
|
||||
} else if ($option=="end") {
|
||||
} else if ($option == "end") {
|
||||
echo "
|
||||
</td>
|
||||
";
|
||||
@@ -280,11 +284,12 @@ function pageblock($block,$option) {
|
||||
}
|
||||
}
|
||||
|
||||
function sidemenu($noprint=false) {
|
||||
function sidemenu($noprint = false)
|
||||
{
|
||||
// Displays sidebar menu
|
||||
global $db,$mbgcolor,$noprint;
|
||||
$doparts=PARTS_FUNCTIONS;
|
||||
$doschedmaint=SCHEDMAINT_FUNCTIONS;
|
||||
global $db, $mbgcolor, $noprint;
|
||||
$doparts = PARTS_FUNCTIONS;
|
||||
$doschedmaint = SCHEDMAINT_FUNCTIONS;
|
||||
echo "
|
||||
<hr><br>
|
||||
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
|
||||
@@ -333,8 +338,8 @@ function sidemenu($noprint=false) {
|
||||
</table>
|
||||
";
|
||||
} else {
|
||||
$loginid=$_SESSION['login'];
|
||||
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0];
|
||||
$loginid = $_SESSION['login'];
|
||||
$loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
|
||||
echo "
|
||||
<hr>
|
||||
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
|
||||
@@ -359,22 +364,23 @@ function sidemenu($noprint=false) {
|
||||
";
|
||||
}
|
||||
|
||||
function banner($print) {
|
||||
function banner($print)
|
||||
{
|
||||
// displays a banner
|
||||
global $db;
|
||||
$bannerid=BANNER;
|
||||
$bannerid = BANNER;
|
||||
// get banner parameters from banner table
|
||||
$banrow=mysqli_fetch_assoc(mysqli_query($db,"select * from banners where bannerid=\"$bannerid\""));
|
||||
$banrow = mysqli_fetch_assoc(mysqli_query($db, "select * from banners where bannerid=\"$bannerid\""));
|
||||
if (!$banrow) {
|
||||
$bannerid=1;
|
||||
$bannerid = 1;
|
||||
} else {
|
||||
$bannertext=$banrow["bannername"];
|
||||
$bannertext = $banrow["bannername"];
|
||||
if ($print) {
|
||||
$bannercolor="#FFFFFF";
|
||||
$bannertxtcolor="#000000";
|
||||
$bannercolor = "#FFFFFF";
|
||||
$bannertxtcolor = "#000000";
|
||||
} else {
|
||||
$bannercolor=$banrow["bannercolor"];
|
||||
$bannertxtcolor=$banrow["textcolor"];
|
||||
$bannercolor = $banrow["bannercolor"];
|
||||
$bannertxtcolor = $banrow["textcolor"];
|
||||
}
|
||||
}
|
||||
if ($bannerid != 1) {
|
||||
@@ -385,47 +391,49 @@ function banner($print) {
|
||||
}
|
||||
}
|
||||
|
||||
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
|
||||
function dblookup($dbhandle, $table, $in_field, $out_field, $in_data)
|
||||
{
|
||||
// look up a single field in a database given a value for a single field
|
||||
$dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"");
|
||||
$dbqry = mysqli_query($dbhandle, "select $out_field from $table where $in_field=\"$in_data\"");
|
||||
if (mysqli_num_rows($dbqry)) {
|
||||
$out_data=mysqli_fetch_row($dbqry)[0];
|
||||
$out_data = mysqli_fetch_row($dbqry)[0];
|
||||
} else {
|
||||
$out_data=NULL;
|
||||
$out_data = NULL;
|
||||
}
|
||||
return($out_data);
|
||||
return ($out_data);
|
||||
}
|
||||
|
||||
function calendar($year,$month,$day,$link_url) {
|
||||
function calendar($year, $month, $day, $link_url)
|
||||
{
|
||||
// takes a numeric year, month, day, and the basic url for the day links as arguments
|
||||
// Shows a calendar with clickable dates.
|
||||
// Based on an embeddable calendar by Yves Glodt.
|
||||
// See http://www.mind.lu/~yg/stuff/
|
||||
|
||||
|
||||
$YearToShow = $year;
|
||||
$MonthToShow = $month;
|
||||
$DayToShow = $day;
|
||||
$NumberOfDays = date(t,mktime(0,0,0,$MonthToShow+1,0,$YearToShow,-1));
|
||||
if ($month==1) {
|
||||
$mbackyear=$year-1;
|
||||
$mbackmonth=12;
|
||||
$NumberOfDays = date(t, mktime(0, 0, 0, $MonthToShow + 1, 0, $YearToShow, -1));
|
||||
if ($month == 1) {
|
||||
$mbackyear = $year - 1;
|
||||
$mbackmonth = 12;
|
||||
} else {
|
||||
$mbackyear=$year;
|
||||
$mbackmonth=$month-1;
|
||||
$mbackyear = $year;
|
||||
$mbackmonth = $month - 1;
|
||||
}
|
||||
if ($month==12) {
|
||||
$mfwdyear=$year+1;
|
||||
$mfwdmonth=1;
|
||||
if ($month == 12) {
|
||||
$mfwdyear = $year + 1;
|
||||
$mfwdmonth = 1;
|
||||
} else {
|
||||
$mfwdyear=$year;
|
||||
$mfwdmonth=$month+1;
|
||||
$mfwdyear = $year;
|
||||
$mfwdmonth = $month + 1;
|
||||
}
|
||||
$ybackyear=$year-1;
|
||||
$ybackmonth=$month;
|
||||
$yfwdyear=$year+1;
|
||||
$yfwdmonth=$month;
|
||||
|
||||
$MonthNames = array(1=>'January','February','March','April','May','June','July','August','September','October','November','December');
|
||||
$ybackyear = $year - 1;
|
||||
$ybackmonth = $month;
|
||||
$yfwdyear = $year + 1;
|
||||
$yfwdmonth = $month;
|
||||
|
||||
$MonthNames = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
|
||||
|
||||
echo <<<EOT
|
||||
<table border="1" cellpadding="1" cellspacing="0">
|
||||
@@ -452,39 +460,39 @@ function calendar($year,$month,$day,$link_url) {
|
||||
|
||||
EOT;
|
||||
|
||||
$FirstDayOfWeek = date(l,mktime(0,0,0,$MonthToShow,1,$YearToShow));
|
||||
$FirstDayOfWeek = date(l, mktime(0, 0, 0, $MonthToShow, 1, $YearToShow));
|
||||
|
||||
switch ($FirstDayOfWeek) {
|
||||
case 'Monday':
|
||||
$offset = 1;
|
||||
break;
|
||||
break;
|
||||
case 'Tuesday':
|
||||
$offset = 2;
|
||||
break;
|
||||
break;
|
||||
case 'Wednesday':
|
||||
$offset = 3;
|
||||
break;
|
||||
break;
|
||||
case 'Thursday':
|
||||
$offset = 4;
|
||||
break;
|
||||
break;
|
||||
case 'Friday':
|
||||
$offset = 5;
|
||||
break;
|
||||
break;
|
||||
case 'Saturday':
|
||||
$offset = 6;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
$offset = 0;
|
||||
}
|
||||
|
||||
if ($offset > 0) {
|
||||
print "<tr align=\"center\">\n";
|
||||
echo str_repeat("<td class=\"n\"> </td>\n",$offset);
|
||||
echo str_repeat("<td class=\"n\"> </td>\n", $offset);
|
||||
}
|
||||
|
||||
for ($i=1; $i <= $NumberOfDays; $i++) {
|
||||
$DayOfWeek = date(l,mktime(0,0,0,$MonthToShow,$i,$YearToShow));
|
||||
if($DayOfWeek == 'Sunday') {
|
||||
for ($i = 1; $i <= $NumberOfDays; $i++) {
|
||||
$DayOfWeek = date(l, mktime(0, 0, 0, $MonthToShow, $i, $YearToShow));
|
||||
if ($DayOfWeek == 'Sunday') {
|
||||
print "<tr align=\"center\">\n";
|
||||
}
|
||||
if ($i != $DayToShow) {
|
||||
@@ -492,27 +500,28 @@ EOT;
|
||||
} else {
|
||||
print "<td><a href=\"$link_url?y=$YearToShow&m=$MonthToShow&d=$i\"><b><font size=\"+1\" color=\"#FF0000\">$i</font></b></a></td>\n";
|
||||
}
|
||||
if($DayOfWeek == 'Saturday') {
|
||||
if ($DayOfWeek == 'Saturday') {
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( ($offset == 5) && ($NumberOfDays > 30) ) || ( ($offset == 6) && ($NumberOfDays > 29) ) ) {
|
||||
if (42-$NumberOfDays-$offset > 0) {
|
||||
echo str_repeat("<td class=\"n\"> </td>\n",42-$NumberOfDays-$offset);
|
||||
if ((($offset == 5) && ($NumberOfDays > 30)) || (($offset == 6) && ($NumberOfDays > 29))) {
|
||||
if (42 - $NumberOfDays - $offset > 0) {
|
||||
echo str_repeat("<td class=\"n\"> </td>\n", 42 - $NumberOfDays - $offset);
|
||||
}
|
||||
print "</tr>\n";
|
||||
} elseif ( ($NumberOfDays != 28) || ($offset > 0) ) {
|
||||
if (35-$NumberOfDays-$offset > 0) {
|
||||
echo str_repeat("<td class=\"n\"> </td>\n",35-$NumberOfDays-$offset);
|
||||
print "</tr>\n";
|
||||
} elseif (($NumberOfDays != 28) || ($offset > 0)) {
|
||||
if (35 - $NumberOfDays - $offset > 0) {
|
||||
echo str_repeat("<td class=\"n\"> </td>\n", 35 - $NumberOfDays - $offset);
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
function colorpicker($baseurl) {
|
||||
function colorpicker($baseurl)
|
||||
{
|
||||
// takes a standard url and tacks the color number on to the end of it
|
||||
// giving a palette of links
|
||||
echo "
|
||||
@@ -595,54 +604,57 @@ function colorpicker($baseurl) {
|
||||
// Project functions
|
||||
|
||||
|
||||
function getsetting($setting_name,$tech_id) {
|
||||
function getsetting($setting_name, $tech_id)
|
||||
{
|
||||
// get the value of a setting for a tech
|
||||
global $db;
|
||||
$confinfo=mysqli_fetch_assoc(mysqli_query($db,"select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||
$confid=$confinfo["confid"];
|
||||
$confvalue=$confinfo["confvalue"];
|
||||
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||
$confid = $confinfo["confid"];
|
||||
$confvalue = $confinfo["confvalue"];
|
||||
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
if (mysqli_num_rows($custqry)) {
|
||||
$custvalue=mysqli_fetch_row($custqry)[0];
|
||||
$custvalue = mysqli_fetch_row($custqry)[0];
|
||||
}
|
||||
// if value in custom table, use it
|
||||
if (mysqli_num_rows($custqry)) {
|
||||
$retvalue=$custvalue;
|
||||
$table="customs";
|
||||
$retvalue = $custvalue;
|
||||
$table = "customs";
|
||||
} else {
|
||||
$retvalue=$confvalue;
|
||||
$table="configs";
|
||||
$retvalue = $confvalue;
|
||||
$table = "configs";
|
||||
}
|
||||
$result=array('value' => $retvalue,'table' => $table,'id' => $confid);
|
||||
$result = array('value' => $retvalue, 'table' => $table, 'id' => $confid);
|
||||
return $result;
|
||||
}
|
||||
|
||||
function putsetting($setting_name,$setting_value,$tech_id) {
|
||||
function putsetting($setting_name, $setting_value, $tech_id)
|
||||
{
|
||||
// set the value of a setting for a tech
|
||||
global $db;
|
||||
$confinfo=mysqli_fetch_assoc(mysqli_query($db,"select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||
$confid=$confinfo["confid"];
|
||||
$confvalue=$confinfo["confvalue"];
|
||||
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
$confinfo = mysqli_fetch_assoc(mysqli_query($db, "select confid,confvalue from configs where confname=\"$setting_name\""));
|
||||
$confid = $confinfo["confid"];
|
||||
$confvalue = $confinfo["confvalue"];
|
||||
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
if (mysqli_num_rows($custqry)) {
|
||||
if ($setting_value == $confvalue) {
|
||||
mysqli_query($db,"delete from customs where customtech=\"$tech_id\" and customconfnum=\"$confid\"");
|
||||
mysqli_query($db, "delete from customs where customtech=\"$tech_id\" and customconfnum=\"$confid\"");
|
||||
}
|
||||
$custvalue=mysqli_fetch_row($custqry)[0];
|
||||
$custvalue = mysqli_fetch_row($custqry)[0];
|
||||
if ($custvalue != $setting_value) {
|
||||
mysqli_query($db,"update customs set customconfvalue=\"$setting_value\" where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
mysqli_query($db, "update customs set customconfvalue=\"$setting_value\" where customconfnum=\"$confid\" and customtech=\"$tech_id\"");
|
||||
}
|
||||
} else {
|
||||
mysqli_query($db,"insert into customs(customtech,customconfnum,customconfvalue) values(\"$tech_id\",\"$confid\",\"$setting_value\")");
|
||||
mysqli_query($db, "insert into customs(customtech,customconfnum,customconfvalue) values(\"$tech_id\",\"$confid\",\"$setting_value\")");
|
||||
}
|
||||
}
|
||||
|
||||
function islink($il_note) {
|
||||
function islink($il_note)
|
||||
{
|
||||
// takes a noteid number as an argument
|
||||
// determines if the argument is a link in a reference chain
|
||||
// returns 1 if note is a link, 0 if not
|
||||
global $db;
|
||||
$refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
|
||||
$refqry = mysqli_query($db, "select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
|
||||
if (mysqli_num_rows($refqry)) {
|
||||
return 1;
|
||||
} else {
|
||||
@@ -651,97 +663,101 @@ function islink($il_note) {
|
||||
}
|
||||
|
||||
|
||||
function generate_chain($chainlink) {
|
||||
function generate_chain($chainlink)
|
||||
{
|
||||
// generate a reference chain
|
||||
// takes a single parameter, a noteid
|
||||
// finds all notes that are members of a chain containing the supplied noteid
|
||||
// returns a sorted array (chainarray) of all notes in chain
|
||||
global $db;
|
||||
// create notes and refs arrays from the reflinks table
|
||||
$notes=[];
|
||||
$targets=[];
|
||||
$linkqry=mysqli_query($db,"select noteid,target from reflinks where noteid is not null");
|
||||
while ($link=mysqli_fetch_assoc($linkqry)) {
|
||||
$notes[]=$link['noteid'];
|
||||
$targets[]=$link['target'];
|
||||
$notes = [];
|
||||
$targets = [];
|
||||
$linkqry = mysqli_query($db, "select noteid,target from reflinks where noteid is not null");
|
||||
while ($link = mysqli_fetch_assoc($linkqry)) {
|
||||
$notes[] = $link['noteid'];
|
||||
$targets[] = $link['target'];
|
||||
}
|
||||
|
||||
$chainarray=array(); // create the chainarray
|
||||
$chainarray[]=$chainlink; // add the incoming noteid for which the chain should be generated
|
||||
$captr=0; // chainarray pointer
|
||||
while($captr<count($chainarray)) { // as long as the chainarray is growing
|
||||
$nptr=0; // note pointer
|
||||
|
||||
$chainarray = array(); // create the chainarray
|
||||
$chainarray[] = $chainlink; // add the incoming noteid for which the chain should be generated
|
||||
$captr = 0; // chainarray pointer
|
||||
while ($captr < count($chainarray)) { // as long as the chainarray is growing
|
||||
$nptr = 0; // note pointer
|
||||
// run through the notes array, adding all targets for this note to the chainarray
|
||||
while($nptr<count($notes)) {
|
||||
if(($notes[$nptr]==$chainarray[$captr]) && ( ! in_array($targets[$nptr],$chainarray))) {
|
||||
$chainarray[]=$targets[$nptr];
|
||||
while ($nptr < count($notes)) {
|
||||
if (($notes[$nptr] == $chainarray[$captr]) && (! in_array($targets[$nptr], $chainarray))) {
|
||||
$chainarray[] = $targets[$nptr];
|
||||
}
|
||||
$nptr=$nptr+1;
|
||||
$nptr = $nptr + 1;
|
||||
}
|
||||
// run through the targets array, adding all notes for this target to the chainarray
|
||||
$tptr=0; //target pointer
|
||||
while($tptr<count($targets)) {
|
||||
if(($targets[$tptr]==$chainarray[$captr]) && ( ! in_array($notes[$tptr],$chainarray))) {
|
||||
$chainarray[]=$notes[$tptr];
|
||||
$tptr = 0; //target pointer
|
||||
while ($tptr < count($targets)) {
|
||||
if (($targets[$tptr] == $chainarray[$captr]) && (! in_array($notes[$tptr], $chainarray))) {
|
||||
$chainarray[] = $notes[$tptr];
|
||||
}
|
||||
$tptr=$tptr+1;
|
||||
$tptr = $tptr + 1;
|
||||
}
|
||||
$captr=$captr+1;
|
||||
$captr = $captr + 1;
|
||||
}
|
||||
// sort and return the output array
|
||||
sort($chainarray);
|
||||
return($chainarray);
|
||||
return ($chainarray);
|
||||
}
|
||||
|
||||
function convertweblinks($rawstring) {
|
||||
function convertweblinks($rawstring)
|
||||
{
|
||||
// takes a string, finds urls, and returns the string with urls converted to clickable links
|
||||
$urlchunksize=URL_CHUNK_SIZE;
|
||||
$urlchunksize = URL_CHUNK_SIZE;
|
||||
// define regex pattern for urls
|
||||
$urlpatt="/<weblink\b[^>]*>(.*?)<\/weblink>/";
|
||||
preg_match_all($urlpatt,$rawstring,$weblinks, PREG_SET_ORDER);
|
||||
$urlpatt = "/<weblink\b[^>]*>(.*?)<\/weblink>/";
|
||||
preg_match_all($urlpatt, $rawstring, $weblinks, PREG_SET_ORDER);
|
||||
foreach ($weblinks as $urlblock) {
|
||||
// split up really long url
|
||||
$spliturl=str_split($urlblock[1],$urlchunksize);
|
||||
$spliturl = str_split($urlblock[1], $urlchunksize);
|
||||
unset($urlstack);
|
||||
foreach ($spliturl as $urlchunk) {
|
||||
$urlstack[]="<a href=\"$urlblock[1]\" target=\"_blank\">$urlchunk</a>";
|
||||
$urlstack[] = "<a href=\"$urlblock[1]\" target=\"_blank\">$urlchunk</a>";
|
||||
}
|
||||
$hyperlink=implode("<br>",$urlstack);
|
||||
$rawstring=str_replace($urlblock[0],$hyperlink,$rawstring);
|
||||
$hyperlink = implode("<br>", $urlstack);
|
||||
$rawstring = str_replace($urlblock[0], $hyperlink, $rawstring);
|
||||
}
|
||||
return $rawstring;
|
||||
}
|
||||
|
||||
function showlinklist($print) {
|
||||
function showlinklist($print)
|
||||
{
|
||||
global $db;
|
||||
$linkresult=mysqli_query($db,"select linkid from links where status=\"1\"");
|
||||
$linkresult = mysqli_query($db, "select linkid from links where status=\"1\"");
|
||||
if (mysqli_num_rows($linkresult) && !$print) {
|
||||
echo "
|
||||
<b>Links</b><br>
|
||||
";
|
||||
$link=mysqli_query($db,"select displaytxt,urltxt from links where status=\"1\" order by linkpriority asc");
|
||||
$link = mysqli_query($db, "select displaytxt,urltxt from links where status=\"1\" order by linkpriority asc");
|
||||
while ($linkrow = mysqli_fetch_row($link)) {
|
||||
printf("<a href=\"%s\">%s</a><br>",$linkrow[1],$linkrow[0]);
|
||||
printf("<a href=\"%s\">%s</a><br>", $linkrow[1], $linkrow[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nag($tech_id) {
|
||||
function nag($tech_id)
|
||||
{
|
||||
// nags the user if something is pending
|
||||
global $db, $today;
|
||||
// maintenance forms
|
||||
$mfpending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
|
||||
$mfpending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$tech_id\" and pending=1"));
|
||||
if ($mfpending) {
|
||||
echo "<font color=\"#FF0000\">NOTICE</font>: You have one or more maintenance forms to complete. <a href=\"maintform.php\">Click here to complete them</a>.<br><hr>";
|
||||
}
|
||||
|
||||
|
||||
// scheduled maintenance events
|
||||
$ucevents=get_upcoming_events();
|
||||
$due=false;
|
||||
$overdue=false;
|
||||
$ucevents = get_upcoming_events();
|
||||
$due = false;
|
||||
$overdue = false;
|
||||
foreach ($ucevents as $event) {
|
||||
if ($event['duedate'] == $today) $due=true;
|
||||
if ($event['duedate'] < $today) $overdue=true;
|
||||
if ($event['duedate'] == $today) $due = true;
|
||||
if ($event['duedate'] < $today) $overdue = true;
|
||||
}
|
||||
if ($due) {
|
||||
echo "<font color=\"#FF0000\">NOTICE</font>: One or more scheduled maintenance events are due today. <a href=\"schedmaint.php\">Click here to view them</a>.<br><hr>";
|
||||
@@ -751,178 +767,180 @@ function nag($tech_id) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_part_data($partinputdata) {
|
||||
function get_part_data($partinputdata)
|
||||
{
|
||||
// given an associative array of partid, uid, partnum, sernum,
|
||||
// return an associative array of
|
||||
// partid, uid, partnum, sernum, partname, result
|
||||
// where result=0 for success, 1 for no data found, 2 for mismatch
|
||||
global $db;
|
||||
$checkmm = FALSE;
|
||||
$result = 0;
|
||||
// pull input data from input array
|
||||
if ($partinputdata['partid'] && $partinputdata['partid'] != "") $partid= $partinputdata['partid'];
|
||||
if ($partinputdata['uid'] && $partinputdata['uid'] != "") $uid= $partinputdata['uid'];
|
||||
if ($partinputdata['partnum'] && $partinputdata['partnum'] != "") $partnum= $partinputdata['partnum'];
|
||||
if ($partinputdata['sernum'] && $partinputdata['sernum'] != "") $sernum= $partinputdata['sernum'];
|
||||
$partid = (array_key_exists('partid', $partinputdata) && $partinputdata['partid'] != "") ? $partinputdata['partid'] : NULL;
|
||||
$uid = (array_key_exists('uid', $partinputdata) && $partinputdata['uid'] != "") ? $partinputdata['uid'] : NULL;
|
||||
$partnum = (array_key_exists('partnum', $partinputdata) && $partinputdata['partnum'] != "") ? $partinputdata['partnum'] : NULL;
|
||||
$sernum = (array_key_exists('sernum', $partinputdata) && $partinputdata['sernum'] != "") ? $partinputdata['sernum'] : NULL;
|
||||
// for part data supplied, see what info is available
|
||||
// if a partid is supplied, pull other info from parts
|
||||
if ($partid) { // if partid supplied
|
||||
$partqry=mysqli_query($db,"select * from parts where partid=\"$partid\"");
|
||||
$partqry = mysqli_query($db, "select * from parts where partid=\"$partid\"");
|
||||
} else if ($uid && (!$partnum && !$sernum)) { // if uid only supplied
|
||||
$partqry=mysqli_query($db,"select * from parts where uid like \"$uid\"");
|
||||
$partqry = mysqli_query($db, "select * from parts where uid like \"$uid\"");
|
||||
} else if (($partnum && $sernum) && !$uid) { // if pn/sn only supplied
|
||||
$partqry=mysqli_query($db,"select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
|
||||
} 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\"");
|
||||
$checkmm=1;
|
||||
$mismatchqry=mysqli_query($db,"select * from parts where
|
||||
$partqry = mysqli_query($db, "select * from parts where partnum=\"$partnum\" and sernum=\"$sernum\"");
|
||||
} 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\"");
|
||||
$checkmm = TRUE;
|
||||
$mismatchqry = mysqli_query($db, "select * from parts where
|
||||
(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\"))
|
||||
");
|
||||
} 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\"");
|
||||
$checkmm=1;
|
||||
$mismatchqry=mysqli_query($db,"select partid from parts where
|
||||
} 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\"");
|
||||
$checkmm = TRUE;
|
||||
$mismatchqry = mysqli_query($db, "select partid from parts where
|
||||
(uid like \"$uid\" and partnum !=\"$partnum\") or
|
||||
(uid not like \"$uid\" and partnum =\"$partnum\")
|
||||
");
|
||||
} 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\"");
|
||||
$checkmm=1;
|
||||
$mismatchqry=mysqli_query($db,"select partid from parts where
|
||||
} 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\"");
|
||||
$checkmm = TRUE;
|
||||
$mismatchqry = mysqli_query($db, "select partid from parts where
|
||||
(uid like \"$uid\" and sernum !=\"$sernum\") or
|
||||
(uid not like \"$uid\" and sernum =\"$sernum\")
|
||||
");
|
||||
} else {
|
||||
// not enough input data supplied, so return result of 1
|
||||
$result=1;
|
||||
$result = 1;
|
||||
}
|
||||
if (! $result) {
|
||||
if (! $result) {
|
||||
if (mysqli_num_rows($partqry)) {
|
||||
$partdata=mysqli_fetch_assoc($partqry);
|
||||
$partdata = mysqli_fetch_assoc($partqry);
|
||||
} else {
|
||||
$result=1;
|
||||
$result = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// detect mismatched input data
|
||||
if ($checkmm) {
|
||||
if (mysqli_num_rows($mismatchqry)) {
|
||||
$result=2;
|
||||
//while ($mmdata=mysqli_fetch_assoc($mismatchqry)) {
|
||||
//var_dump($mmdata);
|
||||
//}
|
||||
$result = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($result) {
|
||||
$partdata=array();
|
||||
$partdata['result']=$result;
|
||||
$partdata = array();
|
||||
$partdata['result'] = $result;
|
||||
} else {
|
||||
$partdata['result']=0;
|
||||
$partdata['result'] = 0;
|
||||
}
|
||||
return $partdata;
|
||||
}
|
||||
|
||||
function get_upcoming_events() {
|
||||
function get_upcoming_events()
|
||||
{
|
||||
// build array of upcoming events
|
||||
// takes no arguments
|
||||
// returns an array containing arrays of upcoming event data
|
||||
global $db, $today;
|
||||
$uceventsqry=mysqli_query($db,"select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
|
||||
$ucevents=array();
|
||||
while ($uceventrow=mysqli_fetch_assoc($uceventsqry)) {
|
||||
$uceventsqry = mysqli_query($db, "select * from events where active_flag=\"1\" and (deferred_flag=\"0\" or (deferred_flag=\"1\" and deferred_date <= \"$today\"))");
|
||||
$ucevents = array();
|
||||
while ($uceventrow = mysqli_fetch_assoc($uceventsqry)) {
|
||||
// provide eventid,task,device,start_date,last_date,deferred_flag,deferred_date,active_flag
|
||||
extract($uceventrow,EXTR_PREFIX_ALL,"eventdata");
|
||||
|
||||
extract($uceventrow, EXTR_PREFIX_ALL, "eventdata");
|
||||
|
||||
// provide deviceid,devicename,devicedesc,group_flag,active_flag
|
||||
$devicedata=mysqli_fetch_assoc(mysqli_query($db,"select * from devices where deviceid=\"$eventdata_device\""));
|
||||
extract($devicedata,EXTR_PREFIX_ALL,"devicedata");
|
||||
|
||||
$devicedata = mysqli_fetch_assoc(mysqli_query($db, "select * from devices where deviceid=\"$eventdata_device\""));
|
||||
extract($devicedata, EXTR_PREFIX_ALL, "devicedata");
|
||||
|
||||
// provide taskid,taskname,taskdesc,frequency,period,weekdays_only,nextdue_relative,refdoc_name,refdoc_url,active_flag
|
||||
$taskdata=mysqli_fetch_assoc(mysqli_query($db,"select * from tasks where taskid=\"$eventdata_task\""));
|
||||
extract($taskdata,EXTR_PREFIX_ALL,"taskdata");
|
||||
|
||||
if ( ! ($taskdata_period == "once" && $eventdata_last_date >= $eventdata_start_date)) { // ignore completed one-time events
|
||||
$start=date_create($eventdata_start_date); // create start date object
|
||||
if ($eventdata_last_date=="0000-00-00") { // event has never been done. last date object will be start date object
|
||||
$lastdatestrg="never";
|
||||
$last=$start;
|
||||
$taskdata = mysqli_fetch_assoc(mysqli_query($db, "select * from tasks where taskid=\"$eventdata_task\""));
|
||||
extract($taskdata, EXTR_PREFIX_ALL, "taskdata");
|
||||
|
||||
if (! ($taskdata_period == "once" && $eventdata_last_date >= $eventdata_start_date)) { // ignore completed one-time events
|
||||
$start = date_create($eventdata_start_date); // create start date object
|
||||
if ($eventdata_last_date == "0000-00-00") { // event has never been done. last date object will be start date object
|
||||
$lastdatestrg = "never";
|
||||
$last = $start;
|
||||
} else { // create last date object
|
||||
$lastdatestrg="$eventdata_last_date";
|
||||
$last=date_create($eventdata_last_date);
|
||||
$lastdatestrg = "$eventdata_last_date";
|
||||
$last = date_create($eventdata_last_date);
|
||||
}
|
||||
if ($taskdata_period=="once") { // nextdue object will be start date object
|
||||
$nextdue=$start;
|
||||
if ($taskdata_period == "once") { // nextdue object will be start date object
|
||||
$nextdue = $start;
|
||||
} else { // determine nextdue object from last date object (relative) or interval from start date object (absolute)
|
||||
if ($lastdatestrg=="never") { // event has been scheduled to start today but has not been completed
|
||||
$nextdue=$start;
|
||||
} else if ($last==$start) { // event was completed for the first time on the start date
|
||||
$nextdue=$start;
|
||||
if ($lastdatestrg == "never") { // event has been scheduled to start today but has not been completed
|
||||
$nextdue = $start;
|
||||
} else if ($last == $start) { // event was completed for the first time on the start date
|
||||
$nextdue = $start;
|
||||
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
|
||||
} else {
|
||||
if ($taskdata_nextdue_relative) { // calculate from day of last done date
|
||||
$nextdue=$last;
|
||||
$nextdue = $last;
|
||||
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
|
||||
} else { // calculate from day of start date
|
||||
$nextdue=$start;
|
||||
$testdate=date_create("1970-01-01");
|
||||
$nextdue = $start;
|
||||
$testdate = date_create("1970-01-01");
|
||||
while ($testdate <= $last) {
|
||||
date_add($nextdue, date_interval_create_from_date_string("$taskdata_frequency $taskdata_period"));
|
||||
$testdate=$nextdue;
|
||||
$testdate = $nextdue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($taskdata_weekdays_only) { // move forward off the weekend if required
|
||||
$nextduedow=date("w",date_timestamp_get($nextdue));
|
||||
if ($nextduedow==0) { // due on a Sunday
|
||||
$nextduedow = date("w", date_timestamp_get($nextdue));
|
||||
if ($nextduedow == 0) { // due on a Sunday
|
||||
date_add($nextdue, date_interval_create_from_date_string("1 days"));
|
||||
}
|
||||
if ($nextduedow==6) { // due on a Saturday
|
||||
if ($nextduedow == 6) { // due on a Saturday
|
||||
date_add($nextdue, date_interval_create_from_date_string("2 days"));
|
||||
}
|
||||
}
|
||||
$duedate=date_format($nextdue, 'Y-m-d');
|
||||
$daysaway=date_diff(date_create($today),$nextdue)->format('%a');
|
||||
$direction=date_diff(date_create($today),$nextdue)->format('%R');
|
||||
if ($direction=="+") {
|
||||
$duedate = date_format($nextdue, 'Y-m-d');
|
||||
$daysaway = date_diff(date_create($today), $nextdue)->format('%a');
|
||||
$direction = date_diff(date_create($today), $nextdue)->format('%R');
|
||||
if ($direction == "+") {
|
||||
if ($daysaway == 0) {
|
||||
$duedatestrg="<font color=\"#FF0000\"> $duedate </font>";
|
||||
$duedatestrg = "<font color=\"#FF0000\"> $duedate </font>";
|
||||
} else if ($daysaway < 4) {
|
||||
$duedatestrg="<font color=\"#FFFF00\"> $duedate </font>";
|
||||
$duedatestrg = "<font color=\"#FFFF00\"> $duedate </font>";
|
||||
} else {
|
||||
$duedatestrg="<font color=\"#00FF00\"> $duedate </font>";
|
||||
$duedatestrg = "<font color=\"#00FF00\"> $duedate </font>";
|
||||
}
|
||||
} else {
|
||||
$duedatestrg="<font size=\"+1\" color=\"#FF0000\"><b> $duedate </b></font><img src=\"icons/exclamation-red.png\" border=\"0\">";
|
||||
$duedatestrg = "<font size=\"+1\" color=\"#FF0000\"><b> $duedate </b></font><img src=\"icons/exclamation-red.png\" border=\"0\">";
|
||||
}
|
||||
$uceventline=array(
|
||||
'eventdata_eventid'=>$eventdata_eventid,
|
||||
'duedate'=>$duedate,
|
||||
'duedatestrg'=>$duedatestrg,
|
||||
'devicedata_devicedesc'=>$devicedata_devicedesc,
|
||||
'devicedata_devicename'=>$devicedata_devicename,
|
||||
'taskdata_taskdesc'=>$taskdata_taskdesc,
|
||||
'taskdata_taskname'=>$taskdata_taskname,
|
||||
'lastdatestrg'=>$lastdatestrg
|
||||
$uceventline = array(
|
||||
'eventdata_eventid' => $eventdata_eventid,
|
||||
'duedate' => $duedate,
|
||||
'duedatestrg' => $duedatestrg,
|
||||
'devicedata_devicedesc' => $devicedata_devicedesc,
|
||||
'devicedata_devicename' => $devicedata_devicename,
|
||||
'taskdata_taskdesc' => $taskdata_taskdesc,
|
||||
'taskdata_taskname' => $taskdata_taskname,
|
||||
'lastdatestrg' => $lastdatestrg
|
||||
);
|
||||
$ucevents[]=$uceventline;
|
||||
$ucevents[] = $uceventline;
|
||||
}
|
||||
}
|
||||
return $ucevents;
|
||||
}
|
||||
|
||||
function format_message($msgtype,$msgtxt) {
|
||||
function format_message($msgtype, $msgtxt)
|
||||
{
|
||||
// displays a formatted message
|
||||
// $msgtype is 0 for success or anything else for failure
|
||||
// $msgtxt is the string to display
|
||||
if ($msgtype == 0) {
|
||||
$state="ui-state-highlight";
|
||||
$icon="ui-icon-info";
|
||||
$state = "ui-state-highlight";
|
||||
$icon = "ui-icon-info";
|
||||
} else {
|
||||
$state="ui-state-error";
|
||||
$icon="ui-icon-alert";
|
||||
$state = "ui-state-error";
|
||||
$icon = "ui-icon-alert";
|
||||
}
|
||||
if ($msgtxt == "") $msgtxt="PROGRAM ERROR: No message text was supplied.";
|
||||
if ($msgtxt == "") $msgtxt = "PROGRAM ERROR: No message text was supplied.";
|
||||
echo "
|
||||
<div class=\"$state ui-corner-all\" style=\"margin-top: 20px; padding: 0 .7em;\">
|
||||
<p><span class=\"ui-icon $icon\" style=\"float: left; margin-right: .3em;\"></span>
|
||||
@@ -931,13 +949,15 @@ function format_message($msgtype,$msgtxt) {
|
||||
";
|
||||
}
|
||||
|
||||
function templateselect($techid,$operation) {
|
||||
function templateselect($techid, $operation)
|
||||
{
|
||||
// Displays a line enabling selection of a user or global template
|
||||
// $techid is the id number of the current tech
|
||||
// $operation is one of "add" "edit" "delete"
|
||||
// $operation is one of "add" "edit" "delete" or NULL
|
||||
global $db;
|
||||
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
<form method=\"post\">
|
||||
";
|
||||
// generate template selection line
|
||||
echo "
|
||||
@@ -948,10 +968,19 @@ function templateselect($techid,$operation) {
|
||||
<td>
|
||||
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
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
|
||||
@@ -960,10 +989,10 @@ function templateselect($techid,$operation) {
|
||||
echo "
|
||||
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
|
||||
";
|
||||
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
|
||||
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
|
||||
$templaterow = mysqli_query($db, "select * from notetemplates where tech=\"0\" order by templatename asc");
|
||||
printf("<option value=\"%s\" selected>%s</option>", "0", "Select global template");
|
||||
while ($templateitem = mysqli_fetch_assoc($templaterow)) {
|
||||
printf("<option value=\"%s\">%s</option>", $templateitem["templateid"], $templateitem["templatename"]);
|
||||
}
|
||||
echo "
|
||||
</select>
|
||||
@@ -981,4 +1010,31 @@ function templateselect($techid,$operation) {
|
||||
</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;
|
||||
}
|
||||
|
||||
@@ -10,25 +10,25 @@
|
||||
include("functions.php");
|
||||
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
framework("begin","OpenLog License","OpenLog License",$print);
|
||||
framework("begin", "OpenLog License", "OpenLog License", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print){
|
||||
pageblock("left","begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
echo "
|
||||
<pre>
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
@@ -375,10 +375,8 @@ Public License instead of this License.
|
||||
|
||||
</pre>
|
||||
";
|
||||
|
||||
pageblock("right","end");
|
||||
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,56 +9,55 @@
|
||||
|
||||
include("functions.php");
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$tech=$_REQUEST['tech'];
|
||||
$pass=$_REQUEST['pass'];
|
||||
$login=$_REQUEST['login'];
|
||||
$cancel=$_REQUEST['cancel'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$tech = $_REQUEST['tech'] ?? NULL;
|
||||
$pass = $_REQUEST['pass'] ?? NULL;
|
||||
$login = $_REQUEST['login'] ?? NULL;
|
||||
$cancel = $_REQUEST['cancel'] ?? NULL;
|
||||
|
||||
if ($cancel) {
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
$techalpha=TECH_ALPHA;
|
||||
$logname=LOG_NAME;
|
||||
$techalpha = TECH_ALPHA;
|
||||
$logname = LOG_NAME;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
|
||||
framework("begin","$logname","Login Page",$print);
|
||||
framework("begin", "$logname", "Login Page", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print){
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu("no print");
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
if ($login) {
|
||||
// log me in
|
||||
$pwhash=mysqli_fetch_row(mysqli_query($db,"select techpass from techs where techid=\"$tech\""))[0];
|
||||
$pwhash = mysqli_fetch_row(mysqli_query($db, "select techpass from techs where techid=\"$tech\""))[0];
|
||||
if (password_verify($pass, $pwhash)) {
|
||||
$_SESSION['login']=$tech;
|
||||
$techname=dblookup($db,"techs","techid","techname",$tech);
|
||||
$_SESSION['login'] = $tech;
|
||||
$techname = dblookup($db, "techs", "techid", "techname", $tech);
|
||||
echo "
|
||||
Welcome $techname. Please select a menu option at the left to continue.
|
||||
";
|
||||
} else {
|
||||
$adminqry=mysqli_query($db,"select techname from techs where admin=1 and status=1");
|
||||
$adminqry = mysqli_query($db, "select techname from techs where admin=1 and status=1");
|
||||
echo "
|
||||
Incorrect password. Please <a href=\"login.php\">try again</a>.<br><br>
|
||||
Forgot your password? Contact an administrator:<br><br>
|
||||
";
|
||||
while ($admintech=mysqli_fetch_row($adminqry)[0]) {
|
||||
while ($admintech = mysqli_fetch_row($adminqry)[0]) {
|
||||
echo "$admintech <br>";
|
||||
}
|
||||
|
||||
}
|
||||
} else if ($cancel) {
|
||||
echo "
|
||||
@@ -72,11 +71,12 @@ if ($login) {
|
||||
<b>Tech: </b>
|
||||
<select name=\"tech\">
|
||||
";
|
||||
if ($techalpha) $torder="techname"; else $torder="techid";
|
||||
$techrow=mysqli_query($db,"select * from techs order by $torder asc");
|
||||
while ($techitem=mysqli_fetch_assoc($techrow)) {
|
||||
if ($techitem["status"]==1) {
|
||||
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]);
|
||||
if ($techalpha) $torder = "techname";
|
||||
else $torder = "techid";
|
||||
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||
if ($techitem["status"] == 1) {
|
||||
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
|
||||
}
|
||||
}
|
||||
echo "</select><br><br>
|
||||
@@ -87,16 +87,14 @@ if ($login) {
|
||||
<br><hr>
|
||||
";
|
||||
} else {
|
||||
$loginid=$_SESSION['login'];
|
||||
$loggedinas=mysqli_fetch_row(mysqli_query($db,"select techname from techs where techid=\"$loginid\""))[0];
|
||||
$loginid = $_SESSION['login'];
|
||||
$loggedinas = mysqli_fetch_row(mysqli_query($db, "select techname from techs where techid=\"$loginid\""))[0];
|
||||
echo "
|
||||
You are already logged in as $loggedinas. Please select a menu option at the left to continue.<br><hr>
|
||||
";
|
||||
}
|
||||
}
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -12,103 +12,107 @@ include("functions.php");
|
||||
//$tgt_year=$_REQUEST['y'];
|
||||
//$tgt_month=$_REQUEST['m'];
|
||||
//$tgt_day=$_REQUEST['d'];
|
||||
$tgt_date=$_REQUEST['tgt_date'] ?? "";
|
||||
$print=$_REQUEST['print'] ?? "";
|
||||
if (isset($_SESSION['login'])) $techid=$_SESSION['login'];
|
||||
$tgt_date = $_REQUEST['tgt_date'] ?? "";
|
||||
$print = $_REQUEST['print'] ?? "";
|
||||
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
|
||||
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$tablestyle=LOG_STYLE;
|
||||
$logname = LOG_NAME;
|
||||
$tablestyle = LOG_STYLE;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
// use default date values if not supplied
|
||||
if ($tgt_date=="") $tgt_date=$today;
|
||||
if ($tgt_date == "") $tgt_date = $today;
|
||||
|
||||
// define shifttable_classic function
|
||||
function shifttable_classic($shift, $tgt_date, $db) {
|
||||
function shifttable_classic($shift, $tgt_date, $db)
|
||||
{
|
||||
// convert the shift number to a name for display
|
||||
$doparts=PARTS_FUNCTIONS;
|
||||
$showtime=SHOW_TS;
|
||||
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift);
|
||||
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
|
||||
$dshdr=mysqli_fetch_row($dshdrdata);
|
||||
$doparts = PARTS_FUNCTIONS;
|
||||
$showtime = SHOW_TS;
|
||||
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
|
||||
$dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
|
||||
$dshdr = mysqli_fetch_row($dshdrdata);
|
||||
if ($dshdr) {
|
||||
// print the shift header
|
||||
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
|
||||
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
|
||||
$note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
echo "<br><table border=\"1\" width=\"100%\">\n";
|
||||
echo "<tr><th width=\"70\">Note ID</th><th width=\"70\">Tech</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>\n";
|
||||
while ($tablerow = mysqli_fetch_assoc($note)) {
|
||||
$thisnote=$tablerow["lognoteid"];
|
||||
$refs=" <a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
$thisnote = $tablerow["lognoteid"];
|
||||
$refs = " <a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
if (islink($thisnote)) {
|
||||
$refs=$refs." <a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
$refs = $refs . " <a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
}
|
||||
// convert tech number to name
|
||||
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
||||
//convert subject number to name
|
||||
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
|
||||
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
|
||||
// create links of urls in note
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
|
||||
while ($flagid=mysqli_fetch_row($flagqry)) {
|
||||
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
|
||||
$flagcolor=$flagparams["flagcolor"];
|
||||
$flagsym=$flagparams["flagsym"];
|
||||
$flagname=$flagparams["flagname"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
$flagstring = "";
|
||||
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
|
||||
while ($flagid = mysqli_fetch_row($flagqry)) {
|
||||
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
|
||||
$flagcolor = $flagparams["flagcolor"];
|
||||
$flagsym = $flagparams["flagsym"];
|
||||
$flagname = $flagparams["flagname"];
|
||||
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$fmtnote=$fmtnote."<br>".$flagstring." ";
|
||||
} else {
|
||||
$fmtnote=$fmtnote."<br>";
|
||||
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
||||
} else {
|
||||
$fmtnote = $fmtnote . "<br>";
|
||||
}
|
||||
|
||||
|
||||
if ($doparts) {
|
||||
// turn on the parts indicator if parts were entered with the note
|
||||
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1¬eid=$thisnote\">PARTS</a>";
|
||||
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||
$fmtnote = $fmtnote . "<a href=\"logentry.php?partview=1¬eid=$thisnote\">PARTS</a>";
|
||||
}
|
||||
}
|
||||
// now print the line in the table
|
||||
if ($showtime) {
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td valign=\"top\"><a href=\"logentry.php?edit=1¬eid=%s\" title=\"Edit this note\">%s</a> %s</td>
|
||||
<td valign=\"top\"> %s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
</tr>\n",
|
||||
$tablerow["lognoteid"],$tablerow["lognoteid"],$tablerow["time"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["time"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td valign=\"top\"><a href=\"logentry.php?edit=1¬eid=%s\">%s</a></td>
|
||||
<td valign=\"top\"> %s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
</tr>\n",
|
||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["lognoteid"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -121,82 +125,85 @@ function shifttable_classic($shift, $tgt_date, $db) {
|
||||
}
|
||||
|
||||
// define the shifttable_clean function
|
||||
function shifttable_clean($shift, $tgt_date, $db) {
|
||||
function shifttable_clean($shift, $tgt_date, $db)
|
||||
{
|
||||
// convert the shift number to a name for display
|
||||
$doparts=PARTS_FUNCTIONS;
|
||||
$showtime=SHOW_TS;
|
||||
$shname=dblookup($db,"shifts","shiftid","shiftname",$shift);
|
||||
$dshdrdata=mysqli_query($db,"select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
|
||||
$dshdr=mysqli_fetch_row($dshdrdata);
|
||||
$doparts = PARTS_FUNCTIONS;
|
||||
$showtime = SHOW_TS;
|
||||
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $shift);
|
||||
$dshdrdata = mysqli_query($db, "select date,shift from lognotes where date=\"$tgt_date\" and shift=\"$shift\"");
|
||||
$dshdr = mysqli_fetch_row($dshdrdata);
|
||||
if ($dshdr) {
|
||||
// print the shift header
|
||||
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
|
||||
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
printf("<b><font size=\"+1\">%s</font></b>\n", $shname);
|
||||
$note = mysqli_query($db, "select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
|
||||
echo "<br><br>";
|
||||
echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
|
||||
while ($tablerow = mysqli_fetch_assoc($note)) {
|
||||
$thisnote=$tablerow["lognoteid"];
|
||||
$refs=" <a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
$thisnote = $tablerow["lognoteid"];
|
||||
$refs = " <a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
|
||||
if (islink($tablerow["lognoteid"])) {
|
||||
$refs=$refs." <a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
$refs = $refs . " <a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
|
||||
}
|
||||
// convert tech number to name
|
||||
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
||||
//convert subject number to name
|
||||
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
|
||||
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
|
||||
// create links of urls in note
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
|
||||
while ($flagid=mysqli_fetch_row($flagqry)) {
|
||||
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
|
||||
$flagcolor=$flagparams["flagcolor"];
|
||||
$flagsym=$flagparams["flagsym"];
|
||||
$flagname=$flagparams["flagname"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
$flagstring = "";
|
||||
$flagqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$thisnote");
|
||||
while ($flagid = mysqli_fetch_row($flagqry)) {
|
||||
$flagparams = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid[0]\""));
|
||||
$flagcolor = $flagparams["flagcolor"];
|
||||
$flagsym = $flagparams["flagsym"];
|
||||
$flagname = $flagparams["flagname"];
|
||||
$flagstring = $flagstring . "<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
}
|
||||
if ($flagstring) {
|
||||
$fmtnote=$fmtnote."<br>".$flagstring." ";
|
||||
} else {
|
||||
$fmtnote=$fmtnote."<br>";
|
||||
$fmtnote = $fmtnote . "<br>" . $flagstring . " ";
|
||||
} else {
|
||||
$fmtnote = $fmtnote . "<br>";
|
||||
}
|
||||
if ($doparts) {
|
||||
// turn on the parts indicator if parts were entered with the note
|
||||
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1¬eid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
|
||||
if (mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where lognoteid=\"$thisnote\""))) {
|
||||
$fmtnote = $fmtnote . "<a href=\"logentry.php?edit=1¬eid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
|
||||
}
|
||||
}
|
||||
// now print the line in the table
|
||||
if ($showtime) {
|
||||
printf(
|
||||
"<a href=\"logentry.php?edit=1¬eid=%s\" title=\"Note ID. Click to edit.\">%s</a>
|
||||
"<a href=\"logentry.php?edit=1¬eid=%s\" title=\"Note ID. Click to edit.\">%s</a>
|
||||
<b>%s
|
||||
%s
|
||||
%s
|
||||
%s</b>
|
||||
<br>%s<br>
|
||||
<hr>\n",
|
||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
||||
$tablerow["time"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$refs,
|
||||
$fmtnote
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["time"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$refs,
|
||||
$fmtnote
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
"<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>
|
||||
"<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>
|
||||
<b>%s
|
||||
%s
|
||||
%s</b>
|
||||
<br>%s<br>
|
||||
<hr>\n",
|
||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$refs,
|
||||
$fmtnote
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["lognoteid"],
|
||||
$tname,
|
||||
$subjname,
|
||||
$refs,
|
||||
$fmtnote
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -208,11 +215,11 @@ function shifttable_clean($shift, $tgt_date, $db) {
|
||||
echo "<br><br>\n";
|
||||
}
|
||||
|
||||
framework("begin","$logname","Online Logbook",$print);
|
||||
framework("begin", "$logname", "Online Logbook", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print) {
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
//calendar($tgt_year,$tgt_month,$tgt_day,"lognotes.php");
|
||||
echo "<div id=\"caldate\" style=\"display: none;\">";
|
||||
echo htmlspecialchars($tgt_date);
|
||||
@@ -225,29 +232,27 @@ if(!$print) {
|
||||
sidemenu();
|
||||
echo "<br><br>";
|
||||
showlinklist($print);
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
} else {
|
||||
echo "
|
||||
<center><b>$tgt_year-$tgt_month-$tgt_day</b></center><br>
|
||||
";
|
||||
}
|
||||
pageblock("right","begin");
|
||||
banner($print);
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
if (isset($techid)) nag($techid);
|
||||
//$date=date("Y-m-d",mktime(0,0,0,$tgt_month,$tgt_day,$tgt_year));
|
||||
$qry=mysqli_query($db,"select shiftid from shifts where status=1 order by shiftid asc");
|
||||
while ($shnum=mysqli_fetch_row($qry)) {
|
||||
if ($tablestyle==1) {
|
||||
shifttable_classic($shnum[0],$tgt_date,$db);
|
||||
} else if ($tablestyle==2) {
|
||||
shifttable_clean($shnum[0],$tgt_date,$db);
|
||||
$qry = mysqli_query($db, "select shiftid from shifts where status=1 order by shiftid asc");
|
||||
while ($shnum = mysqli_fetch_row($qry)) {
|
||||
if ($tablestyle == 1) {
|
||||
shifttable_classic($shnum[0], $tgt_date, $db);
|
||||
} else if ($tablestyle == 2) {
|
||||
shifttable_clean($shnum[0], $tgt_date, $db);
|
||||
}
|
||||
}
|
||||
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -9,38 +9,40 @@
|
||||
|
||||
include("functions.php");
|
||||
|
||||
if (isset($_SESSION['login'])) $techid=$_SESSION['login'];
|
||||
if (isset($_SESSION['login'])) $techid = $_SESSION['login'];
|
||||
|
||||
$histdays=$_REQUEST['histdays'];
|
||||
$submit=$_REQUEST['submit'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$histdays = $_REQUEST['histdays'] ?? NULL;
|
||||
$submit = $_REQUEST['submit'] ?? NULL;
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$uidtext=UID_TEXT;
|
||||
$logname = LOG_NAME;
|
||||
$uidtext = UID_TEXT;
|
||||
|
||||
if ($histdays=="") $histdays=30;
|
||||
if ($histdays == "") $histdays = 30;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
// define pendtable function
|
||||
function pendtable($tech_id, $db) {
|
||||
$uidtext=UID_TEXT;
|
||||
function pendtable($tech_id, $db)
|
||||
{
|
||||
$uidtext = UID_TEXT;
|
||||
// print section header
|
||||
if ($tech_id) {
|
||||
echo "
|
||||
<b><font size=\"+1\">Your Pending Maintenance Forms</font></b><br>
|
||||
";
|
||||
$pmf=mysqli_query($db,"select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc");
|
||||
$pmf = mysqli_query($db, "select * from maintforms where mftech=\"$tech_id\" and pending=\"1\" order by mfdate desc, mftime desc");
|
||||
} else {
|
||||
echo "
|
||||
<b><font size=\"+1\">All Pending Maintenance Forms</font></b><br>
|
||||
";
|
||||
$pmf=mysqli_query($db,"select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc");
|
||||
$pmf = mysqli_query($db, "select * from maintforms where pending=\"1\" order by mfdate desc, mftime desc");
|
||||
}
|
||||
echo "
|
||||
<br><table border=\"1\" width=\"100%\">
|
||||
@@ -59,26 +61,26 @@ function pendtable($tech_id, $db) {
|
||||
";
|
||||
while ($pendrow = mysqli_fetch_assoc($pmf)) {
|
||||
// look up part data
|
||||
$uid=dblookup($db,"parts","partid","uid",$pendrow["mfpart"]);
|
||||
if ($uid=="") $uid=" ";
|
||||
$partno=dblookup($db,"parts","partid","partnum",$pendrow["mfpart"]);
|
||||
if ($partno=="") $partno=" ";
|
||||
$serno=dblookup($db,"parts","partid","sernum",$pendrow["mfpart"]);
|
||||
if ($serno=="") $serno=" ";
|
||||
$partname=dblookup($db,"parts","partid","partname",$pendrow["mfpart"]);
|
||||
if ($partname=="") $partname=" ";
|
||||
$uid = dblookup($db, "parts", "partid", "uid", $pendrow["mfpart"]);
|
||||
if ($uid == "") $uid = " ";
|
||||
$partno = dblookup($db, "parts", "partid", "partnum", $pendrow["mfpart"]);
|
||||
if ($partno == "") $partno = " ";
|
||||
$serno = dblookup($db, "parts", "partid", "sernum", $pendrow["mfpart"]);
|
||||
if ($serno == "") $serno = " ";
|
||||
$partname = dblookup($db, "parts", "partid", "partname", $pendrow["mfpart"]);
|
||||
if ($partname == "") $partname = " ";
|
||||
// look up tech name
|
||||
$tname=dblookup($db,"techs","techid","techname",$pendrow["mftech"]);
|
||||
if ($pendrow["lognoteid"]==0) {
|
||||
$noteidval=" ";
|
||||
$notetag="%s%s";
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $pendrow["mftech"]);
|
||||
if ($pendrow["lognoteid"] == 0) {
|
||||
$noteidval = " ";
|
||||
$notetag = "%s%s";
|
||||
} else {
|
||||
$noteidval=$pendrow["lognoteid"];
|
||||
$notetag="<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>";
|
||||
$noteidval = $pendrow["lognoteid"];
|
||||
$notetag = "<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>";
|
||||
}
|
||||
if (!$tech_id) {
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
@@ -88,18 +90,20 @@ function pendtable($tech_id, $db) {
|
||||
<td valign=\"top\">%s</td>
|
||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||
</tr>",
|
||||
$pendrow["maintformid"],$pendrow["maintformid"],
|
||||
$pendrow["mfdate"],
|
||||
$tname,
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,$noteidval
|
||||
$pendrow["maintformid"],
|
||||
$pendrow["maintformid"],
|
||||
$pendrow["mfdate"],
|
||||
$tname,
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,
|
||||
$noteidval
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
@@ -108,13 +112,15 @@ function pendtable($tech_id, $db) {
|
||||
<td valign=\"top\">%s</td>
|
||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||
</tr>",
|
||||
$pendrow["maintformid"],$pendrow["maintformid"],
|
||||
$pendrow["mfdate"],
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,$noteidval
|
||||
$pendrow["maintformid"],
|
||||
$pendrow["maintformid"],
|
||||
$pendrow["mfdate"],
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,
|
||||
$noteidval
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -124,9 +130,10 @@ function pendtable($tech_id, $db) {
|
||||
}
|
||||
|
||||
// define histtable function
|
||||
function histtable($hist_days,$db) {
|
||||
$uidtext=UID_TEXT;
|
||||
$dayopts=array(30,90,180,365);
|
||||
function histtable($hist_days, $db)
|
||||
{
|
||||
$uidtext = UID_TEXT;
|
||||
$dayopts = array(30, 90, 180, 365);
|
||||
// print section header
|
||||
echo "
|
||||
<form method=\"post\" action=\"maintform.php\">
|
||||
@@ -134,13 +141,13 @@ function histtable($hist_days,$db) {
|
||||
<select name=\"histdays\">
|
||||
";
|
||||
foreach ($dayopts as $chunk) {
|
||||
if ($chunk==$hist_days) {
|
||||
if ($chunk == $hist_days) {
|
||||
echo "<option value=\"$chunk\" selected>$chunk</option>";
|
||||
} else {
|
||||
echo "<option value=\"$chunk\">$chunk</option>";
|
||||
}
|
||||
}
|
||||
$histqry=mysqli_query($db,"select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc");
|
||||
$histqry = mysqli_query($db, "select * from maintforms where mfdate > subdate(now(), interval $hist_days day) order by mfdate desc, mftime desc");
|
||||
echo "
|
||||
</select>
|
||||
<b><font size=\"+1\"> Days</font></b>
|
||||
@@ -159,24 +166,24 @@ function histtable($hist_days,$db) {
|
||||
";
|
||||
while ($histrow = mysqli_fetch_assoc($histqry)) {
|
||||
// look up part data
|
||||
$uid=dblookup($db,"parts","partid","uid",$histrow["mfpart"]);
|
||||
$partno=dblookup($db,"parts","partid","partnum",$histrow["mfpart"]);
|
||||
if ($partno=="") $partno=" ";
|
||||
$serno=dblookup($db,"parts","partid","sernum",$histrow["mfpart"]);
|
||||
if ($serno=="") $serno=" ";
|
||||
$partname=dblookup($db,"parts","partid","partname",$histrow["mfpart"]);
|
||||
if ($partname=="") $partname=" ";
|
||||
$uid = dblookup($db, "parts", "partid", "uid", $histrow["mfpart"]);
|
||||
$partno = dblookup($db, "parts", "partid", "partnum", $histrow["mfpart"]);
|
||||
if ($partno == "") $partno = " ";
|
||||
$serno = dblookup($db, "parts", "partid", "sernum", $histrow["mfpart"]);
|
||||
if ($serno == "") $serno = " ";
|
||||
$partname = dblookup($db, "parts", "partid", "partname", $histrow["mfpart"]);
|
||||
if ($partname == "") $partname = " ";
|
||||
// look up tech name
|
||||
$tname=dblookup($db,"techs","techid","techname",$histrow["mftech"]);
|
||||
if ($histrow["lognoteid"]==0) {
|
||||
$noteidval=" ";
|
||||
$notetag="%s%s";
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $histrow["mftech"]);
|
||||
if ($histrow["lognoteid"] == 0) {
|
||||
$noteidval = " ";
|
||||
$notetag = "%s%s";
|
||||
} else {
|
||||
$noteidval=$histrow["lognoteid"];
|
||||
$notetag="<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>";
|
||||
$noteidval = $histrow["lognoteid"];
|
||||
$notetag = "<a href=\"logentry.php?edit=1¬eid=%s\">%s</a>";
|
||||
}
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td align=\"center\" valign=\"top\"><a href=\"maintformentry.php?mfedit=1&maintformid=%s\">%s</a></td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
@@ -186,14 +193,16 @@ function histtable($hist_days,$db) {
|
||||
<td valign=\"top\">%s</td>
|
||||
<td align=\"center\" valign=\"top\">$notetag</td>
|
||||
</tr>",
|
||||
$histrow["maintformid"],$histrow["maintformid"],
|
||||
$histrow["mfdate"],
|
||||
$tname,
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,$noteidval
|
||||
$histrow["maintformid"],
|
||||
$histrow["maintformid"],
|
||||
$histrow["mfdate"],
|
||||
$tname,
|
||||
$uid,
|
||||
$partno,
|
||||
$serno,
|
||||
$partname,
|
||||
$noteidval,
|
||||
$noteidval
|
||||
);
|
||||
}
|
||||
echo "
|
||||
@@ -201,30 +210,28 @@ function histtable($hist_days,$db) {
|
||||
";
|
||||
}
|
||||
|
||||
framework("begin","$logname","Maintenance Forms",$print);
|
||||
framework("begin", "$logname", "Maintenance Forms", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print) {
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
banner($print);
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
echo "<br>";
|
||||
$haspending=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\""));
|
||||
$haspending = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mftech=\"$techid\" and pending=\"1\""));
|
||||
if ($haspending) {
|
||||
pendtable($techid,$db);
|
||||
pendtable($techid, $db);
|
||||
echo "<br><hr><br>";
|
||||
}
|
||||
pendtable(0,$db);
|
||||
pendtable(0, $db);
|
||||
echo "<br><hr><br>";
|
||||
histtable($histdays,$db);
|
||||
histtable($histdays, $db);
|
||||
echo "<br><br>";
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -11,120 +11,123 @@ include("functions.php");
|
||||
|
||||
|
||||
if (!$_SESSION['login'] && ($_REQUEST['mfadd'] || $_REQUEST['actionadd'])) {
|
||||
header ("Location: login.php");
|
||||
header("Location: login.php");
|
||||
}
|
||||
|
||||
$loggedinas=$_SESSION['login'];
|
||||
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
|
||||
$loggedinas = $_SESSION['login'];
|
||||
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
||||
|
||||
function getmfdata($maintformid) {
|
||||
function getmfdata($maintformid)
|
||||
{
|
||||
// pull maintenance form data from maintforms table
|
||||
global $db;
|
||||
$mfdata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintforms where maintformid=\"$maintformid\""));
|
||||
$mfdata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintforms where maintformid=\"$maintformid\""));
|
||||
return $mfdata;
|
||||
}
|
||||
|
||||
function getactiondata($maintactionid) {
|
||||
function getactiondata($maintactionid)
|
||||
{
|
||||
// pull maintenance action data from maintactions table
|
||||
global $db;
|
||||
$actiondata=mysqli_fetch_assoc(mysqli_query($db,"select * from maintactions where maintactionid=\"$maintactionid\""));
|
||||
$actiondata = mysqli_fetch_assoc(mysqli_query($db, "select * from maintactions where maintactionid=\"$maintactionid\""));
|
||||
return $actiondata;
|
||||
}
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
|
||||
$maintformid=$_REQUEST['maintformid'];
|
||||
$lognoteid=$_REQUEST['lognoteid'];
|
||||
$mfdate=$_REQUEST['date'];
|
||||
$mftime=$_REQUEST['time'];
|
||||
$mfsubmit=$_REQUEST['mfsubmit'];
|
||||
$mfadd=$_REQUEST['mfadd'];
|
||||
$mfedit=$_REQUEST['mfedit'];
|
||||
$mfdelete=$_REQUEST['mfdelete'];
|
||||
$mfpartloc=$_REQUEST['mfpartloc'];
|
||||
$mfmalfunction=$_REQUEST['mfmalfunction'];
|
||||
$nha=$_REQUEST['nha'];
|
||||
$repord=$_REQUEST['repord'];
|
||||
$mfpart=$_REQUEST['mfpart'];
|
||||
$uid=$_REQUEST['uid'];
|
||||
$partnum=$_REQUEST['partnum'];
|
||||
$sernum=$_REQUEST['sernum'];
|
||||
$partname=$_REQUEST['partname'];
|
||||
$actionadd=$_REQUEST['actionadd'];
|
||||
$actionedit=$_REQUEST['actionedit'];
|
||||
$actiondelete=$_REQUEST['actiondelete'];
|
||||
$maintactionid=$_REQUEST['maintactionid'];
|
||||
$actiondate=$_REQUEST['actiondate'];
|
||||
$actiontime=$_REQUEST['actiontime'];
|
||||
$actiontech=$_REQUEST['actiontech'];
|
||||
$action=$_REQUEST['action'];
|
||||
$actionaddsubmit=$_REQUEST['actionaddsubmit'];
|
||||
$actioneditsubmit=$_REQUEST['actioneditsubmit'];
|
||||
$printfmt=$_REQUEST['printfmt'];
|
||||
if ($printfmt) $print=1;
|
||||
$flags=$_POST['flags'];
|
||||
$maintformid = $_REQUEST['maintformid'] ?? NULL;
|
||||
$lognoteid = $_REQUEST['lognoteid'] ?? NULL;
|
||||
$mfdate = $_REQUEST['date'] ?? NULL;
|
||||
$mftime = $_REQUEST['time'] ?? NULL;
|
||||
$mfsubmit = $_REQUEST['mfsubmit'] ?? NULL;
|
||||
$mfadd = $_REQUEST['mfadd'] ?? NULL;
|
||||
$mfedit = $_REQUEST['mfedit'] ?? NULL;
|
||||
$mfdelete = $_REQUEST['mfdelete'] ?? NULL;
|
||||
$mfpartloc = $_REQUEST['mfpartloc'] ?? NULL;
|
||||
$mfmalfunction = $_REQUEST['mfmalfunction'] ?? NULL;
|
||||
$nha = $_REQUEST['nha'] ?? NULL;
|
||||
$repord = $_REQUEST['repord'] ?? NULL;
|
||||
$mfpart = $_REQUEST['mfpart'] ?? NULL;
|
||||
$uid = $_REQUEST['uid'] ?? NULL;
|
||||
$partnum = $_REQUEST['partnum'] ?? NULL;
|
||||
$sernum = $_REQUEST['sernum'] ?? NULL;
|
||||
$partname = $_REQUEST['partname'] ?? NULL;
|
||||
$actionadd = $_REQUEST['actionadd'] ?? NULL;
|
||||
$actionedit = $_REQUEST['actionedit'] ?? NULL;
|
||||
$actiondelete = $_REQUEST['actiondelete'] ?? NULL;
|
||||
$maintactionid = $_REQUEST['maintactionid'] ?? NULL;
|
||||
$actiondate = $_REQUEST['actiondate'] ?? NULL;
|
||||
$actiontime = $_REQUEST['actiontime'] ?? NULL;
|
||||
$actiontech = $_REQUEST['actiontech'] ?? NULL;
|
||||
$action = $_REQUEST['action'] ?? NULL;
|
||||
$actionaddsubmit = $_REQUEST['actionaddsubmit'] ?? NULL;
|
||||
$actioneditsubmit = $_REQUEST['actioneditsubmit'] ?? NULL;
|
||||
$printfmt = $_REQUEST['printfmt'] ?? NULL;
|
||||
if ($printfmt) $print = TRUE;
|
||||
$flags = $_POST['flags'] ?? [];
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$uidtext=UID_TEXT;
|
||||
$logname = LOG_NAME;
|
||||
$uidtext = UID_TEXT;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
if ($printfmt) {
|
||||
framework("begin","","",$print);
|
||||
framework("begin", "", "", $print);
|
||||
} else if ($mfedit) {
|
||||
framework("begin","$logname","Maintenance Form Edit",$print);
|
||||
if ($loggedinas) $mfauthorized=1;
|
||||
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
||||
if ($loggedinas) $mfauthorized = TRUE;
|
||||
} else if ($mfdelete) {
|
||||
framework("begin","$logname","Maintenance Form Edit",$print);
|
||||
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
|
||||
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=1;
|
||||
framework("begin", "$logname", "Maintenance Form Edit", $print);
|
||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||
if (($loggedinas == $mfowner) || $isadmin) $mfauthorized = TRUE;
|
||||
} else if ($actionadd) {
|
||||
framework("begin","$logname","Maintenance Action Entry",$print);
|
||||
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
|
||||
framework("begin", "$logname", "Maintenance Action Entry", $print);
|
||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||
if ($loggedinas) {
|
||||
$mfauthorized=1;
|
||||
$actionauthorized=1;
|
||||
$mfauthorized = TRUE;
|
||||
$actionauthorized = TRUE;
|
||||
}
|
||||
} else if ($actionedit || $actiondelete) {
|
||||
framework("begin","$logname","Maintenance Action Edit",$print);
|
||||
$mfowner=dblookup($db,"maintforms","maintformid","mftech",$maintformid);
|
||||
if ($loggedinas) $mfauthorized=1;
|
||||
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid);
|
||||
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1;
|
||||
framework("begin", "$logname", "Maintenance Action Edit", $print);
|
||||
$mfowner = dblookup($db, "maintforms", "maintformid", "mftech", $maintformid);
|
||||
if ($loggedinas) $mfauthorized = TRUE;
|
||||
$actionowner = dblookup($db, "maintactions", "maintactionid", "actiontech", $maintactionid);
|
||||
if (($loggedinas == $actionowner) || $isadmin) $actionauthorized = TRUE;
|
||||
} else {
|
||||
$mfadd=1;
|
||||
framework("begin","$logname","Maintenance Form Entry",$print);
|
||||
$mftech=$loggedinas;
|
||||
$mfauthorized=1;
|
||||
$mfadd = TRUE;
|
||||
framework("begin", "$logname", "Maintenance Form Entry", $print);
|
||||
$mftech = $loggedinas;
|
||||
$mfauthorized = TRUE;
|
||||
}
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
//var_dump($_REQUEST);
|
||||
|
||||
$pdatamismatch = NULL;
|
||||
if ((($mfedit || $actionadd || $actionedit) && ! $mfsubmit) || $printfmt) {
|
||||
// pull mf data from database
|
||||
$mftoedit=getmfdata($maintformid);
|
||||
$partdatainput=array();
|
||||
if ($mftoedit['mfpart']) $partdatainput['partid']=$mftoedit['mfpart'];
|
||||
if ($uid) $partdatainput['uid']=$uid;
|
||||
if ($partnum) $partdatainput['partnum']=$partnum;
|
||||
if ($sernum) $partdatainput['sernum']=$sernum;
|
||||
$partinfo=get_part_data($partdatainput);
|
||||
if ($partinfo['result']==2) {
|
||||
$pdatamismatch=1;
|
||||
$mftoedit = getmfdata($maintformid);
|
||||
$partdatainput = [];
|
||||
if ($mftoedit['mfpart']) $partdatainput['partid'] = $mftoedit['mfpart'];
|
||||
if ($uid) $partdatainput['uid'] = $uid;
|
||||
if ($partnum) $partdatainput['partnum'] = $partnum;
|
||||
if ($sernum) $partdatainput['sernum'] = $sernum;
|
||||
$partinfo = get_part_data($partdatainput);
|
||||
if ($partinfo['result'] == 2) {
|
||||
$pdatamismatch = TRUE;
|
||||
} else {
|
||||
unset($pdatamismatch);
|
||||
if ($partinfo['partid']) $mfpart=$partinfo['partid'];
|
||||
if ($partinfo['uid']) $uid=$partinfo['uid'];
|
||||
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
|
||||
if ($partinfo['sernum']) $sernum=$partinfo['sernum'];
|
||||
if ($partinfo['partname']) $partname=$partinfo['partname'];
|
||||
$pdatamismatch = FALSE;
|
||||
if ($partinfo['partid']) $mfpart = $partinfo['partid'];
|
||||
if ($partinfo['uid']) $uid = $partinfo['uid'];
|
||||
if ($partinfo['partnum']) $partnum = $partinfo['partnum'];
|
||||
if ($partinfo['sernum']) $sernum = $partinfo['sernum'];
|
||||
if ($partinfo['partname']) $partname = $partinfo['partname'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,54 +135,59 @@ if ($mfadd) {
|
||||
if ($mfsubmit) {
|
||||
// add the entry if submit is pressed
|
||||
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
|
||||
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$mfdate\",CURRENT_DATE)"));
|
||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$mfdate\",CURRENT_DATE)"));
|
||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||
if ($datediff[0]<0) {
|
||||
$mftime="23:59:59:";
|
||||
if ($datediff[0] < 0) {
|
||||
$mftime = "23:59:59:";
|
||||
}
|
||||
if ($datediff[0]>0) {
|
||||
$mftime="00:00:01:";
|
||||
if ($datediff[0] > 0) {
|
||||
$mftime = "00:00:01:";
|
||||
}
|
||||
// remove cruft from malfunction text
|
||||
$mfmalfunction=htmlentities($mfmalfunction);
|
||||
$mfmalfunction=addslashes($mfmalfunction);
|
||||
|
||||
$mfmalfunction = htmlentities($mfmalfunction);
|
||||
$mfmalfunction = addslashes($mfmalfunction);
|
||||
|
||||
if ($mfauthorized) {
|
||||
$partdatainput=array();
|
||||
if ($uid) $partdatainput['uid']=$uid;
|
||||
if ($partnum) $partdatainput['partnum']=$partnum;
|
||||
if ($sernum) $partdatainput['sernum']=$sernum;
|
||||
$partinfo=get_part_data($partdatainput);
|
||||
$partdatainput = array();
|
||||
if ($uid) $partdatainput['uid'] = $uid;
|
||||
if ($partnum) $partdatainput['partnum'] = $partnum;
|
||||
if ($sernum) $partdatainput['sernum'] = $sernum;
|
||||
$partinfo = get_part_data($partdatainput);
|
||||
// add to parts table
|
||||
if ($partinfo['result']==1) {
|
||||
if ($partinfo['result'] == 1) {
|
||||
// if this part has not been seen before, add it to the parts table and get partid
|
||||
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
||||
$mfpart=mysqli_insert_id($db);
|
||||
} else if ($partinfo['result']==2) {
|
||||
$pdatamismatch=1;
|
||||
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
||||
$mfpart = mysqli_insert_id($db);
|
||||
} else if ($partinfo['result'] == 2) {
|
||||
$pdatamismatch = TRUE;
|
||||
} else {
|
||||
// if it is in parts table, get partid for this record
|
||||
$mfpart=$partinfo['partid'];
|
||||
$pdatamismatch = FALSE;
|
||||
$mfpart = $partinfo['partid'];
|
||||
}
|
||||
if ($uid =="" || $partnum == "" || $sernum == "") {
|
||||
if ($uid == "" || $partnum == "" || $sernum == "") {
|
||||
// have the maintenance form stay pending due to incomplete part data
|
||||
$pending=1;
|
||||
$pending = 1;
|
||||
} else {
|
||||
$pending=0;
|
||||
$pending = 0;
|
||||
}
|
||||
|
||||
|
||||
// add the record to maintforms
|
||||
if (! $pdatamismatch) {
|
||||
mysqli_query($db,"insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
|
||||
$lognoteid = ($lognoteid == NULL) ? 0 : $lognoteid;
|
||||
mysqli_query($db, "insert into maintforms(mfdate,mftime,mftech,mfpart,mfpartloc,mfmalfunction,nha,repord,lognoteid,pending)
|
||||
values (\"$mfdate\", \"$mftime\",\"$loggedinas\",\"$mfpart\",\"$mfpartloc\",\"$mfmalfunction\",\"$nha\",\"$repord\",\"$lognoteid\",\"$pending\")");
|
||||
$newmaintformid=mysqli_insert_id($db);
|
||||
$mfidtoprint=$newmaintformid;
|
||||
$newmaintformid = mysqli_insert_id($db);
|
||||
$mfidtoprint = $newmaintformid;
|
||||
|
||||
// update the flagmap table
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this maintenance form
|
||||
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$newmaintformid\")");
|
||||
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$newmaintformid\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,66 +195,69 @@ if ($mfadd) {
|
||||
}
|
||||
}
|
||||
if ($mfedit) {
|
||||
$mfidtoprint=$maintformid;
|
||||
$mfidtoprint = $maintformid;
|
||||
if ($mfsubmit && $mfauthorized) {
|
||||
if ($mfmalfunction && ($uid || ($partnum && $sernum))) {
|
||||
// remove cruft from malfunction text
|
||||
$mfmalfunction=htmlentities($mfmalfunction);
|
||||
$mfmalfunction=addslashes($mfmalfunction);
|
||||
|
||||
$mfmalfunction = htmlentities($mfmalfunction);
|
||||
$mfmalfunction = addslashes($mfmalfunction);
|
||||
|
||||
// update parts table
|
||||
if ($uid =="" || $partnum == "" || $sernum == "") {
|
||||
if ($uid == "" || $partnum == "" || $sernum == "") {
|
||||
// have the maintenance form stay pending due to incomplete part data
|
||||
$pending=1;
|
||||
$pending = 1;
|
||||
} else {
|
||||
$pending=0;
|
||||
$pending = 0;
|
||||
}
|
||||
if (! $pdatamismatch) {
|
||||
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
|
||||
mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$mfpart\"");
|
||||
}
|
||||
|
||||
|
||||
// update the record in maintforms
|
||||
if (! $pdatamismatch) {
|
||||
mysqli_query($db,"update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
|
||||
mysqli_query($db, "update maintforms set mfdate=\"$mfdate\", mftime=\"$mftime\", mfpart=\"$mfpart\", mfpartloc=\"$mfpartloc\",
|
||||
mfmalfunction=\"$mfmalfunction\", nha=\"$nha\", repord=\"$repord\", lognoteid=\"$lognoteid\", pending=\"$pending\" where maintformid=\"$maintformid\"");
|
||||
|
||||
|
||||
// update the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
|
||||
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this maintenance form
|
||||
mysqli_query($db,"insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$$maintformid\")");
|
||||
mysqli_query($db, "insert into flagmap(flagid,maintformid) values(\"$thisflag\",\"$maintformid\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// refresh the maintenance form in question from the database
|
||||
$mftoedit=getmfdata($maintformid);
|
||||
$mftoedit = getmfdata($maintformid);
|
||||
}
|
||||
if ($mfdelete && $mfauthorized) {
|
||||
// delete from maintforms table
|
||||
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
|
||||
mysqli_query($db, "delete from maintforms where maintformid=\"$maintformid\"");
|
||||
// delete occurances from the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
|
||||
mysqli_query($db, "delete from flagmap where maintformid=\"$maintformid\"");
|
||||
}
|
||||
|
||||
if ($actionadd) {
|
||||
if ($actionaddsubmit) {
|
||||
if ($action) {
|
||||
// sanitize and fix blank date and time
|
||||
$actiondate = fix_date($actiondate);
|
||||
$actiontime = fix_time($actiontime);
|
||||
// determine whether supplied date is future or past
|
||||
$datediff=mysqli_fetch_row(mysqli_query($db,"select datediff(\"$actiondate\",CURRENT_DATE)"));
|
||||
$datediff = mysqli_fetch_row(mysqli_query($db, "select datediff(\"$actiondate\",CURRENT_DATE)"));
|
||||
// if future, set time to 00:00:01, if past, set to 23:59:59
|
||||
if ($datediff[0]<0) {
|
||||
$actiontime="23:59:59:";
|
||||
if ($datediff[0] < 0) {
|
||||
$actiontime = "23:59:59:";
|
||||
}
|
||||
if ($datediff[0]>0) {
|
||||
$actiontime="00:00:01:";
|
||||
if ($datediff[0] > 0) {
|
||||
$actiontime = "00:00:01:";
|
||||
}
|
||||
// remove cruft from action text
|
||||
$action=htmlentities($action);
|
||||
$action=addslashes($action);
|
||||
|
||||
$action = htmlentities($action);
|
||||
$action = addslashes($action);
|
||||
|
||||
// add to maintactions table
|
||||
mysqli_query($db,"insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
|
||||
mysqli_query($db, "insert into maintactions (actiondate,actiontime,maintformnum,actiontech,action)
|
||||
values (\"$actiondate\",\"$actiontime\",\"$maintformid\",\"$loggedinas\",\"$action\")");
|
||||
echo mysqli_error($db);
|
||||
}
|
||||
@@ -256,20 +267,23 @@ if ($actionadd) {
|
||||
if ($actionedit) {
|
||||
if ($actioneditsubmit && $actionauthorized) {
|
||||
// update the action
|
||||
// sanitize and fix blank date and time
|
||||
$actiondate = fix_date($actiondate);
|
||||
$actiontime = fix_time($actiontime);
|
||||
// remove cruft from action text
|
||||
$action=htmlentities($action);
|
||||
$action=addslashes($action);
|
||||
|
||||
$action = htmlentities($action);
|
||||
$action = addslashes($action);
|
||||
|
||||
// update maintactions table
|
||||
mysqli_query($db,"update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
|
||||
mysqli_query($db, "update maintactions set actiondate=\"$actiondate\", actiontime=\"$actiontime\", action=\"$action\" where maintactionid=\"$maintactionid\"");
|
||||
}
|
||||
// refresh the action in question from the database
|
||||
$actiontoedit=getactiondata($maintactionid);
|
||||
$actiontoedit = getactiondata($maintactionid);
|
||||
}
|
||||
|
||||
if ($actiondelete && $actionauthorized) {
|
||||
// delete the action
|
||||
mysqli_query($db,"delete from maintactions where maintactionid=\"$maintactionid\"");
|
||||
mysqli_query($db, "delete from maintactions where maintactionid=\"$maintactionid\"");
|
||||
}
|
||||
|
||||
|
||||
@@ -277,66 +291,67 @@ if ($actiondelete && $actionauthorized) {
|
||||
|
||||
pagetable("begin");
|
||||
if (!$print) {
|
||||
pageblock("left","begin");
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
// display the form
|
||||
if ($mfadd || $actionadd) {
|
||||
$mfdate=$today;
|
||||
$mftime=$now;
|
||||
$actiondate=$today;
|
||||
$actiontime=$now;
|
||||
$mfdate = $today;
|
||||
$mftime = $now;
|
||||
$actiondate = $today;
|
||||
$actiontime = $now;
|
||||
}
|
||||
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) {
|
||||
$mfdate=$mftoedit["mfdate"];
|
||||
$mftime=$mftoedit["mftime"];
|
||||
$mfpart=$mftoedit["mfpart"];
|
||||
$mfpartloc=$mftoedit["mfpartloc"];
|
||||
$mfmalfunction=$mftoedit["mfmalfunction"];
|
||||
$nha=$mftoedit["nha"];
|
||||
$repord=$mftoedit["repord"];
|
||||
$lognoteid=$mftoedit["lognoteid"];
|
||||
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech=$mftoedit["mftech"];
|
||||
if (! $mftime) $mftime=$now;
|
||||
$mfdate = $mftoedit["mfdate"];
|
||||
$mftime = $mftoedit["mftime"];
|
||||
$mfpart = $mftoedit["mfpart"];
|
||||
$mfpartloc = $mftoedit["mfpartloc"];
|
||||
$mfmalfunction = $mftoedit["mfmalfunction"];
|
||||
$nha = $mftoedit["nha"];
|
||||
$repord = $mftoedit["repord"];
|
||||
$lognoteid = $mftoedit["lognoteid"];
|
||||
if ($mfedit || $mfdelete || $actionadd || $actionedit || $actiondelete || $printfmt) $mftech = $mftoedit["mftech"];
|
||||
if (! $mftime) $mftime = $now;
|
||||
}
|
||||
if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit || $actioneditsubmit)) {
|
||||
$partinfo=array();
|
||||
$partinfoinput['partid']=$mfpart;
|
||||
$partinfo=get_part_data($partinfoinput);
|
||||
$mfpart=$partinfo['partid'];
|
||||
$uid=$partinfo['uid'];
|
||||
$partnum=$partinfo['partnum'];
|
||||
$sernum=$partinfo['sernum'];
|
||||
$partname=$partinfo['partname'];
|
||||
$pluresult=$partinfo['result'];
|
||||
if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch);
|
||||
$partinfo = array();
|
||||
$partinfoinput['partid'] = $mfpart;
|
||||
$partinfo = get_part_data($partinfoinput);
|
||||
$mfpart = $partinfo['partid'];
|
||||
$uid = $partinfo['uid'];
|
||||
$partnum = $partinfo['partnum'];
|
||||
$sernum = $partinfo['sernum'];
|
||||
$partname = $partinfo['partname'];
|
||||
$pluresult = $partinfo['result'];
|
||||
if ($pluresult == 2) $pdatamismatch = TRUE;
|
||||
else $pdatamismatch = FALSE;
|
||||
}
|
||||
|
||||
$techname=dblookup($db,"techs","techid","techname",$mftech);
|
||||
$techname = dblookup($db, "techs", "techid", "techname", $mftech);
|
||||
if ($mfsubmit) {
|
||||
if ($mfmalfunction) {
|
||||
if (($uid || ($partnum && $sernum)) || $mfpart) {
|
||||
if ($mfadd) {
|
||||
format_message(0,"Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
|
||||
format_message(0, "Maintenance Form added. You may enter another one or <a href=\"maintform.php\">return to Maintenance Forms page.</a>");
|
||||
}
|
||||
if ($mfedit) {
|
||||
format_message(0,"Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
|
||||
format_message(0, "Maintenance Form changed. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
|
||||
}
|
||||
} else {
|
||||
format_message(1,"You didn't enter any part information. Please try again.");
|
||||
format_message(1, "You didn't enter any part information. Please try again.");
|
||||
}
|
||||
} else {
|
||||
format_message(1,"You didn't enter any malfunction description. Please try again.");
|
||||
format_message(1, "You didn't enter any malfunction description. Please try again.");
|
||||
}
|
||||
}
|
||||
if ($mfdelete) {
|
||||
format_message(0,"Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
|
||||
format_message(0, "Maintenance Form Deleted. <a href=\"maintform.php\">Return to Maintenance Forms page.</a>");
|
||||
}
|
||||
if ($pdatamismatch) {
|
||||
$advtxt="
|
||||
$advtxt = "
|
||||
<img src=\"icons/exclamation-red.png\" border=\"0\">
|
||||
<b>Warning:</b> The $uidtext doesn't match the Part Number/Serial Number associated
|
||||
with it in our database. Please ensure the part information
|
||||
@@ -344,7 +359,7 @@ if ($pdatamismatch) {
|
||||
the <a href=\"parts.php\">Parts</a> page to correct the database.</b>
|
||||
";
|
||||
} else {
|
||||
$advtxt="
|
||||
$advtxt = "
|
||||
<font size=\"-1\">You can enter a $uidtext or Part Number/Serial Number or both.</font>
|
||||
";
|
||||
}
|
||||
@@ -372,43 +387,34 @@ if ($printfmt) {
|
||||
<b><u>Flags</u></b><br>
|
||||
<table width=\"100%\" border=\"0\">
|
||||
";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// // get an array of flagids set for this maintformid
|
||||
// $allflags=mysqli_query($db,"select flagid from flags");
|
||||
// unset($theseflags);
|
||||
// while ($thisflag=mysqli_fetch_row($allflags)) {
|
||||
// $thisflagtbl="flag_".$thisflag[0];
|
||||
// if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
||||
// $theseflags[]=$thisflag[0];
|
||||
// }
|
||||
// }
|
||||
// $flagslist=mysqli_query($db,"select * from flags");
|
||||
// while ($flagsymbol=mysqli_fetch_assoc($flagslist)) {
|
||||
// if ($theseflags[0]=="") $theseflags=[];
|
||||
// if (in_array($flagsymbol["flagid"],$theseflags)) {
|
||||
// echo $flagsymbol['flagsym']." ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// create an array called theseflags of flagids set for this maintformid
|
||||
$allflags = mysqli_query($db, "select flagid from flags");
|
||||
unset($theseflags);
|
||||
$theseflags = [];
|
||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
|
||||
$theseflags[] = $thisflag[0];
|
||||
}
|
||||
}
|
||||
// display flag symbols for set flags
|
||||
$flagslist = mysqli_query($db, "select * from flags");
|
||||
while ($flagsymbol = mysqli_fetch_assoc($flagslist)) {
|
||||
if ($theseflags[0] == "") $theseflags = [];
|
||||
if (!empty($theseflags) && in_array($flagsymbol["flagid"], $theseflags)) {
|
||||
echo $flagsymbol['flagsym'] . " ";
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</table><hr>
|
||||
<b><u>Maintenance Actions</u></b><br>
|
||||
";
|
||||
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
|
||||
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
|
||||
$actiondate=$actiontable["actiondate"];
|
||||
$actiontime=$actiontable["actiontime"];
|
||||
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
|
||||
$actiontext=convertweblinks($actiontable["action"]);
|
||||
$maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
|
||||
while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
|
||||
$actiondate = $actiontable["actiondate"];
|
||||
$actiontime = $actiontable["actiontime"];
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
|
||||
$actiontext = convertweblinks($actiontable["action"]);
|
||||
// print the actions
|
||||
echo "<table border=\"0\" cellpadding=\"5\">
|
||||
<tr>
|
||||
@@ -469,41 +475,50 @@ if ($printfmt) {
|
||||
<tr><td><textarea rows=\"4\" cols=\"65\" name=\"mfmalfunction\" wrap=\"soft\">$mfmalfunction</textarea></td></tr>
|
||||
<tr><td>
|
||||
";
|
||||
// get an array of flagids set for this maintformid
|
||||
$allflags=mysqli_query($db,"select flagid from flags");
|
||||
// create an array called theseflags of flagids set for this maintformid
|
||||
$allflags = mysqli_query($db, "select flagid from flags");
|
||||
unset($theseflags);
|
||||
$theseflags=[];
|
||||
while ($thisflag=mysqli_fetch_row($allflags)) {
|
||||
$thisflagtbl="flag_".$thisflag[0];
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from $thisflagtbl where target=\"maintforms\" and id=\"$maintformid\""))) {
|
||||
$theseflags[]=$thisflag[0];
|
||||
$theseflags = [];
|
||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
|
||||
$theseflags[] = $thisflag[0];
|
||||
}
|
||||
}
|
||||
if ($mfadd) {
|
||||
$flagslist=mysqli_query($db,"select * from flags where status=1");
|
||||
$flagslist = mysqli_query($db, "select * from flags where status=1");
|
||||
} else {
|
||||
$flagslist=mysqli_query($db,"select * from flags");
|
||||
$flagslist = mysqli_query($db, "select * from flags");
|
||||
}
|
||||
$flagsperline=8;
|
||||
$flagcount=1;
|
||||
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
||||
if ($theseflags[0]=="") $theseflags=[];
|
||||
if (in_array($flagcheckbox["flagid"],$theseflags)) {
|
||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
$flagsperline = 8;
|
||||
$flagcount = 1;
|
||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||
//if ($theseflags[0]=="") $theseflags=[];
|
||||
if (in_array($flagcheckbox["flagid"], $theseflags)) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],
|
||||
$flagcheckbox["flagcolor"],
|
||||
$flagcheckbox["flagname"],
|
||||
$flagcheckbox["flagsym"]
|
||||
);
|
||||
} else {
|
||||
$flagid=$flagcheckbox["flagid"];
|
||||
if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
$flagid = $flagcheckbox["flagid"];
|
||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],
|
||||
$flagcheckbox["flagcolor"],
|
||||
$flagcheckbox["flagname"],
|
||||
$flagcheckbox["flagsym"]
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($flagcount<$flagsperline) {
|
||||
if ($flagcount < $flagsperline) {
|
||||
echo " ";
|
||||
$flagcount++;
|
||||
} else {
|
||||
echo "<br>";
|
||||
$flagcount=1;
|
||||
$flagcount = 1;
|
||||
}
|
||||
}
|
||||
echo "
|
||||
@@ -550,7 +565,7 @@ if ($printfmt) {
|
||||
</td></tr></table>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
echo "
|
||||
</form>
|
||||
<hr>
|
||||
@@ -558,16 +573,16 @@ if ($printfmt) {
|
||||
if ($actionadd || $actionedit) {
|
||||
// show the action form
|
||||
if ($actionadd) {
|
||||
$matime=$now;
|
||||
$actiontext="";
|
||||
$actiontech=$loggedinas;
|
||||
$matime = $now;
|
||||
$actiontext = "";
|
||||
$actiontech = $loggedinas;
|
||||
} else if ($actionedit) {
|
||||
$actiontext=$actiontoedit['action'];
|
||||
$actiontech=$actiontoedit['actiontech'];
|
||||
$actiondate=$actiontoedit['actiondate'];
|
||||
$actiontime=$actiontoedit['actiontime'];
|
||||
$actiontext = $actiontoedit['action'];
|
||||
$actiontech = $actiontoedit['actiontech'];
|
||||
$actiondate = $actiontoedit['actiondate'];
|
||||
$actiontime = $actiontoedit['actiontime'];
|
||||
}
|
||||
$tname=dblookup($db,"techs","techid","techname",$actiontech);
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $actiontech);
|
||||
echo "<table width=\"70\" border=\"0\" cellpadding=\"5\">
|
||||
<tr>
|
||||
<td>Tech: $tname
|
||||
@@ -605,25 +620,25 @@ if ($printfmt) {
|
||||
<br><br>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
echo "<b>Maintenance Actions</b> ";
|
||||
if ($_SESSION['login'] && $maintformid) echo "<input type=\"submit\" name=\"actionadd\" value=\"Add New Action\">";
|
||||
echo "<br><br>";
|
||||
|
||||
|
||||
$maintactionqry=mysqli_query($db,"select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
|
||||
while ($actiontable=mysqli_fetch_assoc($maintactionqry)) {
|
||||
$maintactionid=$actiontable["maintactionid"];
|
||||
$actiondate=$actiontable["actiondate"];
|
||||
$actiontime=$actiontable["actiontime"];
|
||||
$maintformnum=$actiontable["maintformnum"];
|
||||
$tname=dblookup($db,"techs","techid","techname",$actiontable["actiontech"]);
|
||||
$actiontext=convertweblinks($actiontable["action"]);
|
||||
|
||||
|
||||
$maintactionqry = mysqli_query($db, "select * from maintactions where maintformnum=\"$maintformid\" order by actiondate asc, actiontime asc");
|
||||
while ($actiontable = mysqli_fetch_assoc($maintactionqry)) {
|
||||
$maintactionid = $actiontable["maintactionid"];
|
||||
$actiondate = $actiontable["actiondate"];
|
||||
$actiontime = $actiontable["actiontime"];
|
||||
$maintformnum = $actiontable["maintformnum"];
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $actiontable["actiontech"]);
|
||||
$actiontext = convertweblinks($actiontable["action"]);
|
||||
// print the table
|
||||
echo "<table width=\"100%\" border=\"1\" cellpadding=\"5\">
|
||||
<tr><td>
|
||||
";
|
||||
if (($loggedinas==$actiontable["actiontech"]) || $isadmin) {
|
||||
if (($loggedinas == $actiontable["actiontech"]) || $isadmin) {
|
||||
echo "
|
||||
<a href=\"maintformentry.php?maintformid=$maintformid&actionedit=1&maintactionid=$maintactionid\"><img src=\"icons/notebook--pencil.png\" border=\"0\" title=\"Edit this action\" alt=\"Edit this action\"></a>
|
||||
<a href=\"maintformentry.php?maintformid=$maintformid&actiondelete=1&maintactionid=$maintactionid\"><img src=\"icons/minus-button.png\" border=\"0\" title=\"Delete this action\" alt=\"Delete this action\"></a>
|
||||
@@ -646,16 +661,14 @@ if ($printfmt) {
|
||||
</table><br>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
echo "
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -11,39 +11,39 @@ include("functions.php");
|
||||
|
||||
|
||||
if (!isset($_SESSION['login'])) {
|
||||
header ("Location: login.php");
|
||||
header("Location: login.php");
|
||||
}
|
||||
|
||||
$loggedinas=$_SESSION['login'];
|
||||
$isadmin=dblookup($db,"techs","techid","admin",$loggedinas);
|
||||
$loggedinas = $_SESSION['login'];
|
||||
$isadmin = dblookup($db, "techs", "techid", "admin", $loggedinas);
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$add=$_REQUEST['add'];
|
||||
$edit=$_REQUEST['edit'];
|
||||
$delete=$_REQUEST['delete'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$add = $_REQUEST['add'] ?? NULL;
|
||||
$edit = $_REQUEST['edit'] ?? NULL;
|
||||
$delete = $_REQUEST['delete'] ?? NULL;
|
||||
|
||||
$partid=$_REQUEST['partid'];
|
||||
$uid=$_REQUEST['uid'];
|
||||
$partnum=$_REQUEST['partnum'];
|
||||
$sernum=$_REQUEST['sernum'];
|
||||
$partname=$_REQUEST['partname'];
|
||||
$submit=$_REQUEST['submit'];
|
||||
$partid = $_REQUEST['partid'] ?? NULL;
|
||||
$uid = $_REQUEST['uid'] ?? NULL;
|
||||
$partnum = $_REQUEST['partnum'] ?? NULL;
|
||||
$sernum = $_REQUEST['sernum'] ?? NULL;
|
||||
$partname = $_REQUEST['partname'] ?? NULL;
|
||||
$submit = $_REQUEST['submit'] ?? NULL;
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$uidtext=UID_TEXT;
|
||||
$logname = LOG_NAME;
|
||||
$uidtext = UID_TEXT;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
if ($edit || $delete) {
|
||||
framework("begin","$logname","Part Edit",$print);
|
||||
framework("begin", "$logname", "Part Edit", $print);
|
||||
} else {
|
||||
$add=1;
|
||||
framework("begin","$logname","Part Entry",$print);
|
||||
$add = 1;
|
||||
framework("begin", "$logname", "Part Entry", $print);
|
||||
}
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
@@ -53,11 +53,11 @@ if ($add) {
|
||||
if ($submit) {
|
||||
// add the entry if submit is pressed
|
||||
if ($uid || ($partnum && $sernum)) {
|
||||
$partexists=mysqli_num_rows(mysqli_query($db,"select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")"));
|
||||
$partexists = mysqli_num_rows(mysqli_query($db, "select partid from parts where uid=\"$uid\" or (partnum=\"$partnum\" and sernum=\"$sernum\")"));
|
||||
if (! $partexists) {
|
||||
// add to parts table
|
||||
mysqli_query($db,"insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
||||
$partid=mysqli_insert_id($db);
|
||||
mysqli_query($db, "insert into parts(uid,partnum,sernum,partname) values(\"$uid\",\"$partnum\",\"$sernum\",\"$partname\")");
|
||||
$partid = mysqli_insert_id($db);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,18 +66,18 @@ if ($edit) {
|
||||
if ($submit) {
|
||||
if ($uid || ($partnum && $sernum)) {
|
||||
// update parts table
|
||||
mysqli_query($db,"update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\"");
|
||||
mysqli_query($db, "update parts set uid=\"$uid\", partnum=\"$partnum\", sernum=\"$sernum\", partname=\"$partname\" where partid=\"$partid\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($delete) {
|
||||
// check for occurrence in logparts table
|
||||
$inlogparts=mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where partid=\"$partid\""));
|
||||
$inlogparts = mysqli_num_rows(mysqli_query($db, "select logpartid from logparts where partid=\"$partid\""));
|
||||
// check for occurrence in maintforms table
|
||||
$inmaintforms=mysqli_num_rows(mysqli_query($db,"select maintformid from maintforms where mfpart=\"$partid\""));
|
||||
$inmaintforms = mysqli_num_rows(mysqli_query($db, "select maintformid from maintforms where mfpart=\"$partid\""));
|
||||
// delete from parts table
|
||||
if(!$inlogparts && !$inmaintforms) {
|
||||
mysqli_query($db,"delete from parts where partid=\"$partid\"");
|
||||
if (!$inlogparts && !$inmaintforms) {
|
||||
mysqli_query($db, "delete from parts where partid=\"$partid\"");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,24 +85,24 @@ if ($delete) {
|
||||
|
||||
pagetable("begin");
|
||||
if (!$print) {
|
||||
pageblock("left","begin");
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
// display the form
|
||||
$partdatainput=array();
|
||||
$partdatainput['partid']=$partid;
|
||||
$partinfo=get_part_data($partdatainput);
|
||||
if ($partinfo['result']==2) {
|
||||
$pdatamismatch=1;
|
||||
$partdatainput = array();
|
||||
$partdatainput['partid'] = $partid;
|
||||
$partinfo = get_part_data($partdatainput);
|
||||
if ($partinfo['result'] == 2) {
|
||||
$pdatamismatch = TRUE;
|
||||
} else {
|
||||
unset($pdatamismatch);
|
||||
if ($partinfo['uid']) $uid=$partinfo['uid'];
|
||||
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
|
||||
if ($partinfo['sernum']) $sernum=$partinfo['sernum'];
|
||||
if ($partinfo['partname']) $partname=$partinfo['partname'];
|
||||
$pdatamismatch = FALSE;
|
||||
$uid = (array_key_exists('uid', $partinfo)) ? $partinfo['uid'] : NULL;
|
||||
$partnum = (array_key_exists('partnum', $partinfo)) ? $partinfo['partnum'] : NULL;
|
||||
$sernum = (array_key_exists('sernum', $partinfo)) ? $partinfo['sernum'] : NULL;
|
||||
$partname = (array_key_exists('partname', $partinfo)) ? $partinfo['partname'] : NULL;
|
||||
}
|
||||
if ($delete) {
|
||||
if ($inmaintforms) {
|
||||
@@ -168,9 +168,7 @@ echo "
|
||||
</form>
|
||||
";
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -10,50 +10,50 @@
|
||||
include("functions.php");
|
||||
|
||||
if (isset($_SESSION['login'])) {
|
||||
$loggedin=1;
|
||||
$loggedin = TRUE;
|
||||
} else {
|
||||
unset($loggedin);
|
||||
$loggedin = FALSE;
|
||||
}
|
||||
|
||||
$print=$_REQUEST['print'];
|
||||
$add=$_REQUEST['add'];
|
||||
$sort=$_REQUEST['sort'];
|
||||
$order=$_REQUEST['order'];
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$add = $_REQUEST['add'] ?? NULL;
|
||||
$sort = $_REQUEST['sort'] ?? NULL;
|
||||
$order = $_REQUEST['order'] ?? NULL;
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$uidtext=UID_TEXT;
|
||||
$logname = LOG_NAME;
|
||||
$uidtext = UID_TEXT;
|
||||
|
||||
if ($add) {
|
||||
header ("Location: partentry.php?add=1");
|
||||
header("Location: partentry.php?add=1");
|
||||
}
|
||||
|
||||
if (! $sort) $sort="uid";
|
||||
if (! $sort) $sort = "uid";
|
||||
if ($order == "asc") {
|
||||
$order="desc";
|
||||
$order = "desc";
|
||||
} else if ($order == "desc") {
|
||||
$order="asc";
|
||||
$order = "asc";
|
||||
} else {
|
||||
$order="asc";
|
||||
$order = "asc";
|
||||
}
|
||||
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
framework("begin","$logname","Parts",$print);
|
||||
framework("begin", "$logname", "Parts", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print) {
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
if ($loggedin) {
|
||||
echo "
|
||||
@@ -71,15 +71,16 @@ echo "
|
||||
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
|
||||
</tr>
|
||||
";
|
||||
$partqry=mysqli_query($db,"select * from parts order by $sort $order");
|
||||
while ($partline=mysqli_fetch_assoc($partqry)) {
|
||||
$partqry = mysqli_query($db, "select * from parts order by $sort $order");
|
||||
while ($partline = mysqli_fetch_assoc($partqry)) {
|
||||
if (!$partline['uid']) {
|
||||
$pluidtxt="none";
|
||||
$pluidtxt = "none";
|
||||
} else {
|
||||
$pluidtxt=$partline['uid'];
|
||||
$pluidtxt = $partline['uid'];
|
||||
}
|
||||
if ($loggedin) {
|
||||
printf("
|
||||
printf(
|
||||
"
|
||||
<tr>
|
||||
<td>
|
||||
<a href=\"partentry.php?edit=1&partid=%s\" title=\"Edit this part\">%s</a>
|
||||
@@ -87,22 +88,24 @@ while ($partline=mysqli_fetch_assoc($partqry)) {
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
<td>%s</td>",
|
||||
$partline['partid'],$pluidtxt,
|
||||
$partline['partnum'],
|
||||
$partline['sernum'],
|
||||
$partline['partname']
|
||||
$partline['partid'],
|
||||
$pluidtxt,
|
||||
$partline['partnum'],
|
||||
$partline['sernum'],
|
||||
$partline['partname']
|
||||
);
|
||||
} else {
|
||||
printf("
|
||||
printf(
|
||||
"
|
||||
<tr>
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
<td>%s</td>",
|
||||
$pluidtxt,
|
||||
$partline['partnum'],
|
||||
$partline['sernum'],
|
||||
$partline['partname']
|
||||
$pluidtxt,
|
||||
$partline['partnum'],
|
||||
$partline['sernum'],
|
||||
$partline['partname']
|
||||
);
|
||||
}
|
||||
echo "
|
||||
@@ -115,9 +118,7 @@ echo "
|
||||
|
||||
echo "<br><br>";
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -10,133 +10,138 @@
|
||||
include("functions.php");
|
||||
|
||||
if (!isset($_SESSION['login'])) {
|
||||
header ("Location: login.php");
|
||||
header("Location: login.php");
|
||||
}
|
||||
$techid=$_SESSION['login'] ?? NULL;
|
||||
$print=$_REQUEST['print'] ?? NULL;
|
||||
$table=$_REQUEST['table'] ?? NULL;
|
||||
$updateinfo=$_REQUEST['updateinfo'] ?? NULL;
|
||||
$updatedisplay=$_REQUEST['updatedisplay'] ?? NULL;
|
||||
$setcolor=$_REQUEST['setcolor'] ?? NULL;
|
||||
$name=$_REQUEST['name'] ?? NULL;
|
||||
$pass=$_REQUEST['pass'] ?? NULL;
|
||||
$passconf=$_REQUEST['passconf'] ?? NULL;
|
||||
$shift=$_REQUEST['shift'] ?? NULL;
|
||||
$display_urlchunk=$_REQUEST['display_urlchunk'] ?? NULL;
|
||||
$display_showts=$_REQUEST['display_showts'] ?? NULL;
|
||||
$display_techalpha=$_REQUEST['display_techalpha'] ?? NULL;
|
||||
$display_subjalpha=$_REQUEST['display_subjalpha'] ?? NULL;
|
||||
$display_logstyle=$_REQUEST['display_logstyle'] ?? NULL;
|
||||
$modcolor=$_REQUEST['modcolor'] ?? NULL;
|
||||
$hexcolor=$_REQUEST['hexcolor'] ?? NULL;
|
||||
$resetcustom=$_REQUEST["resetcustom"] ?? NULL;
|
||||
$techid = $_SESSION['login'] ?? NULL;
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$table = $_REQUEST['table'] ?? NULL;
|
||||
$updateinfo = $_REQUEST['updateinfo'] ?? NULL;
|
||||
$updatedisplay = $_REQUEST['updatedisplay'] ?? NULL;
|
||||
$setcolor = $_REQUEST['setcolor'] ?? NULL;
|
||||
$name = $_REQUEST['name'] ?? NULL;
|
||||
$pass = $_REQUEST['pass'] ?? NULL;
|
||||
$passconf = $_REQUEST['passconf'] ?? NULL;
|
||||
$shift = $_REQUEST['shift'] ?? NULL;
|
||||
$display_urlchunk = $_REQUEST['display_urlchunk'] ?? NULL;
|
||||
$display_showts = $_REQUEST['display_showts'] ?? NULL;
|
||||
$display_techalpha = $_REQUEST['display_techalpha'] ?? NULL;
|
||||
$display_subjalpha = $_REQUEST['display_subjalpha'] ?? NULL;
|
||||
$display_logstyle = $_REQUEST['display_logstyle'] ?? NULL;
|
||||
$modcolor = $_REQUEST['modcolor'] ?? NULL;
|
||||
$hexcolor = $_REQUEST['hexcolor'] ?? NULL;
|
||||
$resetcustom = $_REQUEST["resetcustom"] ?? NULL;
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$logname = LOG_NAME;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
|
||||
framework("begin","$logname","My Profile",$print);
|
||||
framework("begin", "$logname", "My Profile", $print);
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print){
|
||||
pageblock("left","begin");
|
||||
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
if ($updateinfo) {
|
||||
// name shift password settings
|
||||
// do error checking
|
||||
// test for name supplied
|
||||
if (strlen(trim($name))) {
|
||||
$namesuppld=1;
|
||||
$namesuppld = TRUE;
|
||||
} else {
|
||||
$namesuppld=0;
|
||||
$namesuppld = FALSE;
|
||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name cannot be blank.<br>";
|
||||
}
|
||||
// test for name unique
|
||||
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select techid from techs where techname=\"$name\""))) {
|
||||
$nameunique=0;
|
||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\" and techid!=\"$techid\""))) {
|
||||
if (mysqli_num_rows(mysqli_query($db, "select techid from techs where techname=\"$name\""))) {
|
||||
$nameunique = FALSE;
|
||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> Tech name already exists.<br>";
|
||||
} else {
|
||||
$nameunique=1;
|
||||
$nameunique = TRUE;
|
||||
}
|
||||
} else {
|
||||
$nameunique=1;
|
||||
$nameunique = TRUE;
|
||||
}
|
||||
// test for matching passwords
|
||||
if ($pass!="password_is_unchanged") {
|
||||
if ($pass==$passconf) {
|
||||
$passmatch=1;
|
||||
$passhash=password_hash($pass,PASSWORD_DEFAULT);
|
||||
$namepassupdqry=("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
|
||||
if ($pass != "password_is_unchanged") {
|
||||
if ($pass == $passconf) {
|
||||
$passmatch = TRUE;
|
||||
$passhash = password_hash($pass, PASSWORD_DEFAULT);
|
||||
$namepassupdqry = ("update techs set techname=\"$name\",techpass=\"$passhash\" where techid=\"$techid\"");
|
||||
} else {
|
||||
$passmatch=0;
|
||||
$passmatch = FALSE;
|
||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> The passwords you supplied don't match.<br>";
|
||||
}
|
||||
} else {
|
||||
$passmatch=1;
|
||||
$namepassupdqry="update techs set techname=\"$name\" where techid=\"$techid\"";
|
||||
$passmatch = TRUE;
|
||||
$namepassupdqry = "update techs set techname=\"$name\" where techid=\"$techid\"";
|
||||
}
|
||||
if ($namesuppld && $nameunique && $passmatch) {
|
||||
mysqli_query($db,$namepassupdqry);
|
||||
mysqli_query($db,"update techs set shift=\"$shift\" where techid=\"$techid\"");
|
||||
mysqli_query($db, $namepassupdqry);
|
||||
mysqli_query($db, "update techs set shift=\"$shift\" where techid=\"$techid\"");
|
||||
}
|
||||
}
|
||||
if ($updatedisplay) {
|
||||
// display settings
|
||||
if ($display_showts) $display_showts=1; else $display_showts=0;
|
||||
if ($display_techalpha=="a") $display_techalpha=1; else $display_techalpha=0;
|
||||
if ($display_subjalpha=="a") $display_subjalpha=1; else $display_subjalpha=0;
|
||||
if ($display_showts) $display_showts = 1;
|
||||
else $display_showts = 0;
|
||||
if ($display_techalpha == "a") $display_techalpha = 1;
|
||||
else $display_techalpha = 0;
|
||||
if ($display_subjalpha == "a") $display_subjalpha = 1;
|
||||
else $display_subjalpha = 0;
|
||||
// test for urlchunk supplied
|
||||
if (strlen(trim($display_urlchunk))) {
|
||||
$chunksuppld=1;
|
||||
$chunksuppld = TRUE;
|
||||
} else {
|
||||
$chunksuppld=0;
|
||||
$chunksuppld = FALSE;
|
||||
echo "<img src=\"icons/exclamation-red.png\" border=\"0\"> URL chunk size cannot be blank.<br>";
|
||||
}
|
||||
if ($chunksuppld) {
|
||||
putsetting('url_chunk_size',$display_urlchunk,$techid);
|
||||
putsetting('show_ts',$display_showts,$techid);
|
||||
putsetting('tech_alpha',$display_techalpha,$techid);
|
||||
putsetting('subj_alpha',$display_subjalpha,$techid);
|
||||
putsetting('log_style',$display_logstyle,$techid);
|
||||
putsetting('url_chunk_size', $display_urlchunk, $techid);
|
||||
putsetting('show_ts', $display_showts, $techid);
|
||||
putsetting('tech_alpha', $display_techalpha, $techid);
|
||||
putsetting('subj_alpha', $display_subjalpha, $techid);
|
||||
putsetting('log_style', $display_logstyle, $techid);
|
||||
}
|
||||
}
|
||||
if ($setcolor) {
|
||||
// color settings
|
||||
$hexcolor="#".ltrim($hexcolor);
|
||||
putsetting($modcolor,$hexcolor,$techid);
|
||||
$hexcolor = "#" . ltrim($hexcolor);
|
||||
putsetting($modcolor, $hexcolor, $techid);
|
||||
$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\"");
|
||||
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
// pull my current data from tables
|
||||
$curname=dblookup($db,"techs","techid","techname",$techid);
|
||||
$curshift=dblookup($db,"techs","techid","shift",$techid);
|
||||
$pass=$passconf="password_is_unchanged";
|
||||
$curname = dblookup($db, "techs", "techid", "techname", $techid);
|
||||
$curshift = dblookup($db, "techs", "techid", "shift", $techid);
|
||||
$pass = $passconf = "password_is_unchanged";
|
||||
// other values from customs
|
||||
$curlchunk=getsetting('url_chunk_size',$techid)["value"];
|
||||
$curts=getsetting('show_ts',$techid)["value"];
|
||||
$curtdo=getsetting('tech_alpha',$techid)["value"];
|
||||
$cursdo=getsetting('subj_alpha',$techid)["value"];
|
||||
$curbgc=getsetting('background_color',$techid)["value"];
|
||||
$cursbc=getsetting('sidebar_color',$techid)["value"];
|
||||
$curmbgc=getsetting('menubg_color',$techid)["value"];
|
||||
$curtc=getsetting('text_color',$techid)["value"];
|
||||
$curlc=getsetting('link_color',$techid)["value"];
|
||||
$curvlc=getsetting('vlink_color',$techid)["value"];
|
||||
$curhc=getsetting('heading_color',$techid)["value"];
|
||||
$curlogstyle=getsetting('log_style',$techid)["value"];
|
||||
$curlchunk = getsetting('url_chunk_size', $techid)["value"];
|
||||
$curts = getsetting('show_ts', $techid)["value"];
|
||||
$curtdo = getsetting('tech_alpha', $techid)["value"];
|
||||
$cursdo = getsetting('subj_alpha', $techid)["value"];
|
||||
$curbgc = getsetting('background_color', $techid)["value"];
|
||||
$cursbc = getsetting('sidebar_color', $techid)["value"];
|
||||
$curmbgc = getsetting('menubg_color', $techid)["value"];
|
||||
$curtc = getsetting('text_color', $techid)["value"];
|
||||
$curlc = getsetting('link_color', $techid)["value"];
|
||||
$curvlc = getsetting('vlink_color', $techid)["value"];
|
||||
$curhc = getsetting('heading_color', $techid)["value"];
|
||||
$curlogstyle = getsetting('log_style', $techid)["value"];
|
||||
|
||||
// show the form
|
||||
echo "
|
||||
@@ -149,19 +154,19 @@ Password: <input type=\"password\" name=\"pass\" size=\"40\" value=\"$pass
|
||||
Repeat Password: <input type=\"password\" name=\"passconf\" size=\"40\" value=\"$passconf\"><br><br>
|
||||
<font size=\"-1\">Need a random password? </font>
|
||||
";
|
||||
$rpw=substr(str_shuffle(password_hash(microtime(),PASSWORD_DEFAULT)), 10, 12);
|
||||
$rpw = substr(str_shuffle(password_hash(microtime(), PASSWORD_DEFAULT)), 10, 12);
|
||||
echo "
|
||||
$rpw<br><br>
|
||||
<b>Shift: </b>
|
||||
<select name=\"shift\">
|
||||
";
|
||||
$shiftrow=mysqli_query($db,"select * from shifts");
|
||||
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
|
||||
$shiftrow = mysqli_query($db, "select * from shifts");
|
||||
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
|
||||
if ($shiftitem["status"] == 1) {
|
||||
if ($shiftitem["shiftid"]==$curshift) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
||||
if ($shiftitem["shiftid"] == $curshift) {
|
||||
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
||||
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,12 +181,12 @@ echo "
|
||||
<b>My Display Preferences</b><br><br>
|
||||
Log style (the look of the log notes display): <select name=\"display_logstyle\">
|
||||
";
|
||||
$logstyleqry=mysqli_query($db,"select styleid,stylename from styles where styletype=\"logdisplay\"");
|
||||
while ($logstylerow=mysqli_fetch_assoc($logstyleqry)) {
|
||||
if ($logstylerow["styleid"]==$curlogstyle) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
|
||||
$logstyleqry = mysqli_query($db, "select styleid,stylename from styles where styletype=\"logdisplay\"");
|
||||
while ($logstylerow = mysqli_fetch_assoc($logstyleqry)) {
|
||||
if ($logstylerow["styleid"] == $curlogstyle) {
|
||||
printf("<option value=\"%s\" selected>%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$logstylerow["styleid"],$logstylerow["stylename"]);
|
||||
printf("<option value=\"%s\">%s</option>", $logstylerow["styleid"], $logstylerow["stylename"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
@@ -236,7 +241,7 @@ echo "
|
||||
<hr>
|
||||
<b>My Color Preferences</b><br><br>
|
||||
";
|
||||
switch($modcolor) {
|
||||
switch ($modcolor) {
|
||||
case "background_color":
|
||||
echo "<table border=\"0\"><tr><td>Page background color</td><td>";
|
||||
colorpicker("profile.php?setcolor=1&modcolor=background_color&hexcolor=");
|
||||
@@ -290,9 +295,7 @@ echo "
|
||||
</form>
|
||||
";
|
||||
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -9,69 +9,70 @@
|
||||
|
||||
include("functions.php");
|
||||
|
||||
$print=$_REQUEST['print'] ?? "";
|
||||
$chainnote=$_REQUEST['chainnote'];
|
||||
$print = $_REQUEST['print'] ?? "";
|
||||
$chainnote = $_REQUEST['chainnote'] ?? NULL;
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$logname = LOG_NAME;
|
||||
|
||||
if ($print) {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
|
||||
framework("begin","$logname","Reference Chain Display",$print);
|
||||
framework("begin", "$logname", "Reference Chain Display", $print);
|
||||
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
$master=generate_chain($chainnote);
|
||||
$master = generate_chain($chainnote);
|
||||
|
||||
// ******** end database manipulation ********
|
||||
|
||||
pagetable("begin");
|
||||
if(!$print){
|
||||
pageblock("left","begin");
|
||||
if (!$print) {
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
// display the chain
|
||||
$mptr=0;
|
||||
$mptr = 0;
|
||||
echo "<br><br><table border=\"1\" width=\"100%\">";
|
||||
echo "<tr><th>Note ID</th><th>Date / Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>";
|
||||
while($mptr<count($master)) {
|
||||
if(mysqli_num_rows(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"))) {
|
||||
$tablerow = mysqli_fetch_assoc(mysqli_query($db,"select * from lognotes where lognoteid=$master[$mptr]"));
|
||||
$noteid=$tablerow["lognoteid"];
|
||||
$urldatestr="y=".date("Y",strtotime($tablerow["date"]))."&m=".date("m",strtotime($tablerow["date"]))."&d=".date("d",strtotime($tablerow["date"]));
|
||||
$refs=" <a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a> <a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>";
|
||||
while ($mptr < count($master)) {
|
||||
if (mysqli_num_rows(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"))) {
|
||||
$tablerow = mysqli_fetch_assoc(mysqli_query($db, "select * from lognotes where lognoteid=$master[$mptr]"));
|
||||
$noteid = $tablerow["lognoteid"];
|
||||
$urldatestr = "y=" . date("Y", strtotime($tablerow["date"])) . "&m=" . date("m", strtotime($tablerow["date"])) . "&d=" . date("d", strtotime($tablerow["date"]));
|
||||
$refs = " <a href=\"logentry.php?add=1&refto=$noteid\"><img src=\"icons/plus.png\" border=\"0\" alt=\"Add referring note\" title=\"Add referring note\"></a> <a href=\"lognotes.php?$urldatestr\" title=\"View note in log\"><img src=\"icons/magnifier--arrow.png\"></a>";
|
||||
// convert the shift number to a name
|
||||
$shname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
|
||||
$shname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
|
||||
// convert tech number to name
|
||||
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
|
||||
$tname = dblookup($db, "techs", "techid", "techname", $tablerow["tech"]);
|
||||
//convert subject number to name
|
||||
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
|
||||
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
|
||||
// create links of urls in note
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$flagmapqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$noteid");
|
||||
$flagstring = "";
|
||||
$flagmapqry = mysqli_query($db, "select flagid from flagmap where lognoteid=$noteid");
|
||||
if (mysqli_num_rows($flagmapqry)) {
|
||||
while ($flagids=mysqli_fetch_row($flagmapqry)) {
|
||||
$flagid=$flagids[0];
|
||||
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
|
||||
$flagcolor=$flagparam["flagcolor"];
|
||||
$flagsym=$flagparam["flagsym"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font> ";
|
||||
while ($flagids = mysqli_fetch_row($flagmapqry)) {
|
||||
$flagid = $flagids[0];
|
||||
$flagparam = mysqli_fetch_assoc(mysqli_query($db, "select * from flags where flagid=\"$flagid\""));
|
||||
$flagcolor = $flagparam["flagcolor"];
|
||||
$flagsym = $flagparam["flagsym"];
|
||||
$flagstring = $flagstring . "<font color=\"$flagcolor\">$flagsym</font> ";
|
||||
}
|
||||
}
|
||||
|
||||
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
|
||||
printf("
|
||||
|
||||
if ($flagstring) $fmtnote = $fmtnote . "<br>" . $flagstring;
|
||||
printf(
|
||||
"
|
||||
<tr>
|
||||
<td><a href=\"logentry.php?edit=1¬eid=%s\">%s</a></td>
|
||||
<td>%s / %s</td>
|
||||
@@ -81,23 +82,24 @@ while($mptr<count($master)) {
|
||||
<td>%s</td>
|
||||
<td>%s</td>
|
||||
</tr>",
|
||||
$tablerow["lognoteid"],$tablerow["lognoteid"],
|
||||
$tablerow["date"],$tablerow["time"],
|
||||
$shname,
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs);
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["lognoteid"],
|
||||
$tablerow["date"],
|
||||
$tablerow["time"],
|
||||
$shname,
|
||||
$tname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refs
|
||||
);
|
||||
} else {
|
||||
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n",$master[$mptr]);
|
||||
printf("<tr><td colspan=\"7\"><font color=\"red\">Note Id <b> %s</b> has been deleted and cannot be displayed.</font></td></tr>\n", $master[$mptr]);
|
||||
}
|
||||
$mptr=$mptr+1;
|
||||
$mptr = $mptr + 1;
|
||||
}
|
||||
echo "</table><br><br>";
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -11,55 +11,53 @@
|
||||
$today = date("Y-m-d");
|
||||
$now = date("H:i:s");
|
||||
|
||||
$sttl=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"session_ttl_days\""))[0];
|
||||
$ostype=strtoupper(substr(php_uname('s'), 0, 3));
|
||||
$sttl = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"session_ttl_days\""))[0];
|
||||
$ostype = strtoupper(substr(php_uname('s'), 0, 3));
|
||||
if ($ostype == 'WIN') {
|
||||
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"win_server_session_dir\""))[0];
|
||||
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"win_server_session_dir\""))[0];
|
||||
} else {
|
||||
$sdir=mysqli_fetch_row(mysqli_query($db,"select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
|
||||
$sdir = mysqli_fetch_row(mysqli_query($db, "select confvalue from configs where confname=\"unix_server_session_dir\""))[0];
|
||||
}
|
||||
$lifetime=60 * 60 * 24 * $sttl;
|
||||
$lifetime = 60 * 60 * 24 * $sttl;
|
||||
if (!is_dir($sdir)) mkdir($sdir, 0700, true);
|
||||
ini_set('session.cookie_lifetime', $lifetime);
|
||||
ini_set('session.gc_maxlifetime', $lifetime);
|
||||
ini_set('session.save_path', $sdir);
|
||||
|
||||
$ss=session_status();
|
||||
if ($ss==PHP_SESSION_NONE) session_start();
|
||||
$ss = session_status();
|
||||
if ($ss == PHP_SESSION_NONE) session_start();
|
||||
|
||||
// get config options from database and assign them to constants
|
||||
unset($techid);
|
||||
if (isset($_SESSION['login']) && $_SESSION['login'] != '') {
|
||||
$techid=$_SESSION['login'];
|
||||
$techid = $_SESSION['login'];
|
||||
}
|
||||
|
||||
$configqry=mysqli_query($db,"select confname,confvalue,confid from configs");
|
||||
$configqry = mysqli_query($db, "select confname,confvalue,confid from configs");
|
||||
while ($configrow = mysqli_fetch_assoc($configqry)) {
|
||||
$constname=strtoupper($configrow["confname"]);
|
||||
$constname = strtoupper($configrow["confname"]);
|
||||
if (isset($techid)) {
|
||||
$confid=$configrow["confid"];
|
||||
$custqry=mysqli_query($db,"select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
|
||||
$confid = $configrow["confid"];
|
||||
$custqry = mysqli_query($db, "select customconfvalue from customs where customconfnum=\"$confid\" and customtech=\"$techid\"");
|
||||
if (mysqli_num_rows($custqry)) {
|
||||
$custrow=mysqli_fetch_row($custqry);
|
||||
$custval=$custrow[0];
|
||||
$custrow = mysqli_fetch_row($custqry);
|
||||
$custval = $custrow[0];
|
||||
} else {
|
||||
unset($custval);
|
||||
}
|
||||
}
|
||||
if (isset($custval)) {
|
||||
$constvalue=$custval;
|
||||
$constvalue = $custval;
|
||||
} else {
|
||||
$constvalue=$configrow["confvalue"];
|
||||
$constvalue = $configrow["confvalue"];
|
||||
}
|
||||
define("$constname","$constvalue");
|
||||
define("$constname", "$constvalue");
|
||||
}
|
||||
|
||||
// error reporting
|
||||
$logerrors=LOG_ERRORS;
|
||||
if ($logerrors==1) {
|
||||
$logerrors = LOG_ERRORS;
|
||||
if ($logerrors == 1) {
|
||||
error_reporting(E_ALL);
|
||||
} else {
|
||||
error_reporting(0);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -10,72 +10,73 @@
|
||||
include("functions.php");
|
||||
|
||||
if (!$_SESSION['login'] && !$_REQUEST['partview']) {
|
||||
header ("Location: login.php");
|
||||
header("Location: login.php");
|
||||
}
|
||||
|
||||
$techid=$_SESSION['login'] ?? NULL;
|
||||
$isadmin=dblookup($db,"techs","techid","admin",$techid);
|
||||
$print=$_REQUEST['print'] ?? NULL;
|
||||
$efftechid=$_REQUEST['efftechid'] ?? NULL;
|
||||
$shift=$_REQUEST['shift'] ?? NULL;
|
||||
$subject=$_REQUEST['subject'] ?? NULL;
|
||||
$note=$_REQUEST['note'] ?? NULL;
|
||||
$flags=$_POST['flags'] ?? [];
|
||||
$refstring=$_REQUEST['refstring'] ?? NULL;
|
||||
$submit=$_REQUEST['submit'] ?? NULL;
|
||||
$operation=$_REQUEST['operation'] ?? NULL;
|
||||
$templateid=$_REQUEST['templateid'] ?? NULL;
|
||||
$templatename=$_REQUEST['templatename'] ?? NULL;
|
||||
$usertemplateid=$_REQUEST['usertemplateid'] ?? NULL;
|
||||
$globaltemplateid=$_REQUEST['globaltemplateid'] ?? NULL;
|
||||
$loadtemplate=$_REQUEST['loadtemplate'] ?? NULL;
|
||||
$techid = $_SESSION['login'] ?? NULL;
|
||||
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
|
||||
$print = $_REQUEST['print'] ?? NULL;
|
||||
$efftechid = $_REQUEST['efftechid'] ?? NULL;
|
||||
$shift = $_REQUEST['shift'] ?? NULL;
|
||||
$subject = $_REQUEST['subject'] ?? NULL;
|
||||
$note = $_REQUEST['note'] ?? NULL;
|
||||
$flags = $_POST['flags'] ?? [];
|
||||
$refstring = $_REQUEST['refstring'] ?? NULL;
|
||||
$submit = $_REQUEST['submit'] ?? NULL;
|
||||
$operation = $_REQUEST['operation'] ?? NULL;
|
||||
$templateid = $_REQUEST['templateid'] ?? NULL;
|
||||
$templatename = $_REQUEST['templatename'] ?? NULL;
|
||||
$usertemplateid = $_REQUEST['usertemplateid'] ?? NULL;
|
||||
$globaltemplateid = $_REQUEST['globaltemplateid'] ?? NULL;
|
||||
$loadtemplate = $_REQUEST['loadtemplate'] ?? NULL;
|
||||
|
||||
|
||||
$logname=LOG_NAME;
|
||||
$techalpha=TECH_ALPHA;
|
||||
$subjalpha=SUBJ_ALPHA;
|
||||
$logname = LOG_NAME;
|
||||
$techalpha = TECH_ALPHA;
|
||||
$subjalpha = SUBJ_ALPHA;
|
||||
|
||||
$defaultshift=dblookup($db,"techs","techid","shift",$techid);
|
||||
$defaultshift = dblookup($db, "techs", "techid", "shift", $techid);
|
||||
|
||||
if ($print=="Printer Friendly") {
|
||||
$sbcolor=P_SIDEBAR_COLOR;
|
||||
$mbgcolor=P_MENUBG_COLOR;
|
||||
if ($print == "Printer Friendly") {
|
||||
$sbcolor = P_SIDEBAR_COLOR;
|
||||
$mbgcolor = P_MENUBG_COLOR;
|
||||
} else {
|
||||
$sbcolor=SIDEBAR_COLOR;
|
||||
$mbgcolor=MENUBG_COLOR;
|
||||
$sbcolor = SIDEBAR_COLOR;
|
||||
$mbgcolor = MENUBG_COLOR;
|
||||
}
|
||||
|
||||
framework("begin","$logname","Note Templates",$print);
|
||||
framework("begin", "$logname", "Note Templates", $print);
|
||||
|
||||
// make basic determination about authorization
|
||||
if ($isadmin) {
|
||||
$authorized=TRUE;
|
||||
} else if ($efftechid==$techid) {
|
||||
$authorized=TRUE;
|
||||
$authorized = TRUE;
|
||||
} else if ($efftechid == $techid) {
|
||||
$authorized = TRUE;
|
||||
} else {
|
||||
$authorized=FALSE;
|
||||
$authorized = FALSE;
|
||||
}
|
||||
|
||||
// var_dump($_REQUEST);
|
||||
|
||||
function templatetable($db,$techid,$user) {
|
||||
function templatetable($db, $techid, $user)
|
||||
{
|
||||
// Show template table
|
||||
$isadmin=dblookup($db,"techs","techid","admin",$techid);
|
||||
$templatequery=mysqli_query($db,"select * from notetemplates where tech=\"$user\" order by templatename asc");
|
||||
$tblusername=dblookup($db,"techs","techid","techname",$user);
|
||||
$isadmin = dblookup($db, "techs", "techid", "admin", $techid);
|
||||
$templatequery = mysqli_query($db, "select * from notetemplates where tech=\"$user\" order by templatename asc");
|
||||
$tblusername = dblookup($db, "techs", "techid", "techname", $user);
|
||||
if (mysqli_num_rows($templatequery)) {
|
||||
$hastemplates=TRUE;
|
||||
$hastemplates = TRUE;
|
||||
} else {
|
||||
$hastemplates=FALSE;
|
||||
$hastemplates = FALSE;
|
||||
}
|
||||
|
||||
|
||||
echo "<b><font size=\"+1\">";
|
||||
if ($hastemplates) {
|
||||
// print the user header
|
||||
if ($user=="0") {
|
||||
if ($user == "0") {
|
||||
echo "Global Templates</font></b>";
|
||||
} else {
|
||||
if ($user==$techid) {
|
||||
if ($user == $techid) {
|
||||
echo "My templates</font></b>";
|
||||
} else {
|
||||
echo "Templates for $tblusername</font></b>";
|
||||
@@ -85,62 +86,62 @@ function templatetable($db,$techid,$user) {
|
||||
echo "<br><table border=\"1\" width=\"100%\">";
|
||||
echo "<tr><th width=\"70\">Template Name</th><th width=\"100\">Shift</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>";
|
||||
while ($tablerow = mysqli_fetch_assoc($templatequery)) {
|
||||
$templateid=$tablerow["templateid"];
|
||||
$templatename=$tablerow["templatename"];
|
||||
$templateid = $tablerow["templateid"];
|
||||
$templatename = $tablerow["templatename"];
|
||||
// convert shift number to name
|
||||
$shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
|
||||
$shiftname = dblookup($db, "shifts", "shiftid", "shiftname", $tablerow["shift"]);
|
||||
// convert subject number to name
|
||||
$subjname=dblookup($db,"subjects","subjectid","subjectname",$tablerow["subject"]);
|
||||
$subjname = dblookup($db, "subjects", "subjectid", "subjectname", $tablerow["subject"]);
|
||||
// create links of urls in note
|
||||
$fmtnote=convertweblinks($tablerow["lognote"]);
|
||||
$fmtnote = convertweblinks($tablerow["lognote"]);
|
||||
// generate the flags string
|
||||
$flagstring="";
|
||||
$flagqry=mysqli_query($db,"select flagid from flagmap where notetemplateid=$templateid");
|
||||
while ($flagid=mysqli_fetch_row($flagqry)) {
|
||||
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
|
||||
$flagcolor=$flagparams["flagcolor"];
|
||||
$flagsym=$flagparams["flagsym"];
|
||||
$flagname=$flagparams["flagname"];
|
||||
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font> ";
|
||||
$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>";
|
||||
$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];
|
||||
$refstring = NULL;
|
||||
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
|
||||
while ($tgt = mysqli_fetch_row($refstringqry)) {
|
||||
$refstring = $refstring . " " . $tgt[0];
|
||||
}
|
||||
// now print the line in the table
|
||||
if (!$isadmin && $user=="0") {
|
||||
$nameblock="$templatename</a>";
|
||||
if (!$isadmin && $user == "0") {
|
||||
$nameblock = "$templatename</a>";
|
||||
} else {
|
||||
$nameblock="<a href=\"templates.php?operation=edit&templateid=$templateid\">$templatename</a>";
|
||||
$nameblock = "<a href=\"templates.php?operation=edit&templateid=$templateid\">$templatename</a>";
|
||||
}
|
||||
printf(
|
||||
"<tr>
|
||||
"<tr>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\"> %s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
<td valign=\"top\">%s</td>
|
||||
</tr>\n",
|
||||
$nameblock,
|
||||
$shiftname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refstring
|
||||
$nameblock,
|
||||
$shiftname,
|
||||
$subjname,
|
||||
$fmtnote,
|
||||
$refstring
|
||||
);
|
||||
};
|
||||
echo "</table><br><hr><br>";
|
||||
} else {
|
||||
if ($user=="0") {
|
||||
if ($user == "0") {
|
||||
echo "There are no global templates</font></b>";
|
||||
} else {
|
||||
if ($user==$techid) {
|
||||
if ($user == $techid) {
|
||||
echo "You have no templates</font></b>";
|
||||
} else {
|
||||
echo "$tblusername has no templates</font></b>";
|
||||
@@ -154,108 +155,114 @@ function templatetable($db,$techid,$user) {
|
||||
// ******** begin database manipulation ********
|
||||
|
||||
if ($usertemplateid) {
|
||||
$templateid=$usertemplateid;
|
||||
$templateid = $usertemplateid;
|
||||
} else if ($globaltemplateid) {
|
||||
$templateid=$globaltemplateid;
|
||||
$templateid = $globaltemplateid;
|
||||
} else {
|
||||
$loadtemplate=NULL;
|
||||
$loadtemplate = NULL;
|
||||
}
|
||||
|
||||
if ($operation=="add") {
|
||||
if ($submit) {
|
||||
// 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);
|
||||
|
||||
$note = strip_tags($note, "<a>");
|
||||
$note = mysqli_real_escape_string($db, $note);
|
||||
|
||||
if ($authorized) {
|
||||
// check if name supplied
|
||||
if ($templatename) {
|
||||
$namesupplied=TRUE;
|
||||
$namesupplied = TRUE;
|
||||
// check if supplied name already exists
|
||||
if (! mysqli_num_rows(mysqli_query($db,"select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) {
|
||||
if (! mysqli_num_rows(mysqli_query($db, "select templateid from notetemplates where tech=\"$efftechid\" and templatename=\"$templatename\""))) {
|
||||
// add the record to notetemplates
|
||||
mysqli_query($db,"insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")");
|
||||
$newtemplateid=mysqli_insert_id($db);
|
||||
|
||||
mysqli_query($db, "insert into notetemplates(templatename,shift,tech,subject,lognote) values (\"$templatename\", \"$shift\",\"$efftechid\",\"$subject\",\"$note\")");
|
||||
$newtemplateid = mysqli_insert_id($db);
|
||||
|
||||
// update the flagmap table
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")");
|
||||
mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$newtemplateid\")");
|
||||
}
|
||||
|
||||
|
||||
// add references to the reflinks table
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refarray=explode(" ",$refstring);
|
||||
$refstring = trim($refstring);
|
||||
$refarray = explode(" ", $refstring);
|
||||
foreach ($refarray as $target) {
|
||||
mysqli_query($db,"insert into reflinks(templateid,target) values($newtemplateid,$target)");
|
||||
mysqli_query($db, "insert into reflinks(templateid,target) values($newtemplateid,$target)");
|
||||
}
|
||||
}
|
||||
$templateid=$newtemplateid;
|
||||
$templateid = $newtemplateid;
|
||||
} else {
|
||||
$nameexists=TRUE;
|
||||
$nameexists = TRUE;
|
||||
}
|
||||
} else {
|
||||
$namesupplied=FALSE;
|
||||
$namesupplied = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($operation=="edit" || $operation=="delete") {
|
||||
if ($operation == "edit" || $operation == "delete") {
|
||||
// test to see if this templateid is owned by techid to prevent hijacking
|
||||
$owner=dblookup($db,"notetemplates","templateid","tech",$templateid);
|
||||
if (!$isadmin && ($owner!=$techid)) $authorized=FALSE;
|
||||
|
||||
if ($submit) {
|
||||
$owner = dblookup($db, "notetemplates", "templateid", "tech", $templateid);
|
||||
if (!$isadmin && ($owner != $techid)) $authorized = FALSE;
|
||||
|
||||
if ($submit) {
|
||||
if ($note) {
|
||||
// remove cruft from note text
|
||||
$note=strip_tags($note,"<a>");
|
||||
$note=mysqli_real_escape_string($db,$note);
|
||||
|
||||
$note = strip_tags($note, "<a>");
|
||||
$note = mysqli_real_escape_string($db, $note);
|
||||
|
||||
if ($templatename) {
|
||||
$namesupplied=TRUE;
|
||||
$namesupplied = TRUE;
|
||||
} else {
|
||||
$namesupplied=FALSE;
|
||||
$namesupplied = FALSE;
|
||||
}
|
||||
|
||||
|
||||
if ($authorized) {
|
||||
// check if name was supplied
|
||||
if ($templatename) {
|
||||
// update notetemplates
|
||||
mysqli_query($db,"update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\"");
|
||||
|
||||
mysqli_query($db, "update notetemplates set templatename=\"$templatename\", shift=\"$shift\", tech=\"$efftechid\", subject=\"$subject\", lognote=\"$note\" where templateid=\"$templateid\"");
|
||||
|
||||
// update the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\"");
|
||||
mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\"");
|
||||
foreach ($flags as $thisflag) {
|
||||
// set flag for this note
|
||||
mysqli_query($db,"insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")");
|
||||
mysqli_query($db, "insert into flagmap(flagid,notetemplateid) values(\"$thisflag\",\"$templateid\")");
|
||||
}
|
||||
|
||||
|
||||
// update the reflinks table
|
||||
mysqli_query($db,"delete from reflinks where templateid=\"$templateid\"");
|
||||
mysqli_query($db, "delete from reflinks where templateid=\"$templateid\"");
|
||||
if (strlen($refstring)) {
|
||||
$refstring=trim($refstring);
|
||||
$refarray=explode(" ",$refstring);
|
||||
$refstring = trim($refstring);
|
||||
$refarray = explode(" ", $refstring);
|
||||
foreach ($refarray as $target) {
|
||||
mysqli_query($db,"insert into reflinks(templateid,target) values($templateid,$target)");
|
||||
mysqli_query($db, "insert into reflinks(templateid,target) values($templateid,$target)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($operation=="delete") {
|
||||
if ($operation == "delete") {
|
||||
if ($authorized) {
|
||||
// update notetemplates
|
||||
mysqli_query($db,"delete from notetemplates where templateid=\"$templateid\"");
|
||||
mysqli_query($db, "delete from notetemplates where templateid=\"$templateid\"");
|
||||
// update the flagmap table
|
||||
mysqli_query($db,"delete from flagmap where notetemplateid=\"$templateid\"");
|
||||
mysqli_query($db, "delete from flagmap where notetemplateid=\"$templateid\"");
|
||||
// update the reflinks table
|
||||
mysqli_query($db,"delete from reflinks where templateid=\"$templateid\"");
|
||||
$templateid=NULL;
|
||||
$note=NULL;
|
||||
mysqli_query($db, "delete from reflinks where templateid=\"$templateid\"");
|
||||
$templateid = NULL;
|
||||
$note = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,118 +271,118 @@ if ($operation=="edit" || $operation=="delete") {
|
||||
|
||||
pagetable("begin");
|
||||
if (!$print) {
|
||||
pageblock("left","begin");
|
||||
pageblock("left", "begin");
|
||||
sidemenu();
|
||||
pageblock("left","end");
|
||||
pageblock("left", "end");
|
||||
}
|
||||
pageblock("right","begin");
|
||||
pageblock("right", "begin");
|
||||
banner($print);
|
||||
|
||||
|
||||
if ($submit || $operation=="delete") {
|
||||
if ($submit || $operation == "delete") {
|
||||
// show success/failure messages
|
||||
$nameexists=$nameexists ?? NULL;
|
||||
$namesupplied=$namesupplied ?? NULL;
|
||||
|
||||
if ($operation=="add") {
|
||||
$addfail=FALSE;
|
||||
$nameexists = $nameexists ?? NULL;
|
||||
$namesupplied = $namesupplied ?? NULL;
|
||||
|
||||
if ($operation == "add") {
|
||||
$addfail = FALSE;
|
||||
if ($nameexists) {
|
||||
format_message(1,"Template creation failed because the name you supplied already exists. Please try again.");
|
||||
$addfail=TRUE;
|
||||
format_message(1, "Template creation failed because the name you supplied already exists. Please try again.");
|
||||
$addfail = TRUE;
|
||||
}
|
||||
if (!$namesupplied) {
|
||||
format_message(1,"Template creation failed because you didn't supply a name. Please try again.");
|
||||
$addfail=TRUE;
|
||||
format_message(1, "Template creation failed because you didn't supply a name. Please try again.");
|
||||
$addfail = TRUE;
|
||||
}
|
||||
if (!$note) {
|
||||
format_message(1,"Template creation failed because you didn't enter any note text. Please try again.");
|
||||
$addfail=TRUE;
|
||||
format_message(1, "Template creation failed because you didn't enter any note text. Please try again.");
|
||||
$addfail = TRUE;
|
||||
}
|
||||
if (!$authorized) {
|
||||
format_message(1,"Template creation failed because you are not authorized to do so.");
|
||||
$addfail=TRUE;
|
||||
format_message(1, "Template creation failed because you are not authorized to do so.");
|
||||
$addfail = TRUE;
|
||||
}
|
||||
if (!$addfail) format_message(0,"<strong>Template created.</strong>");
|
||||
if (!$addfail) format_message(0, "<strong>Template created.</strong>");
|
||||
}
|
||||
if ($operation=="edit") {
|
||||
$editfail=FALSE;
|
||||
if ($operation == "edit") {
|
||||
$editfail = FALSE;
|
||||
if (!$namesupplied) {
|
||||
format_message(1,"Template save failed because you didn't supply a name. Please try again.");
|
||||
$editfail=TRUE;
|
||||
format_message(1, "Template save failed because you didn't supply a name. Please try again.");
|
||||
$editfail = TRUE;
|
||||
}
|
||||
if (!$note) {
|
||||
format_message(1,"Template save failed because you didn't enter any note text. Please try again.");
|
||||
$editfail=TRUE;
|
||||
format_message(1, "Template save failed because you didn't enter any note text. Please try again.");
|
||||
$editfail = TRUE;
|
||||
}
|
||||
if (!$authorized) {
|
||||
format_message(1,"Template save failed because you are not authorized to do so.");
|
||||
$editfail=TRUE;
|
||||
format_message(1, "Template save failed because you are not authorized to do so.");
|
||||
$editfail = TRUE;
|
||||
}
|
||||
if (!$editfail) format_message(0,"<strong>Template modified.</strong>");
|
||||
if (!$editfail) format_message(0, "<strong>Template modified.</strong>");
|
||||
}
|
||||
if ($operation=="delete") {
|
||||
$deletefail=FALSE;
|
||||
if ($operation == "delete") {
|
||||
$deletefail = FALSE;
|
||||
if (!$authorized) {
|
||||
format_message(1,"Template delete failed because you are not authorized to do so.");
|
||||
$deletefail=TRUE;
|
||||
format_message(1, "Template delete failed because you are not authorized to do so.");
|
||||
$deletefail = TRUE;
|
||||
}
|
||||
if (!$deletefail) format_message(0,"<strong>Template deleted.</strong>");
|
||||
if (!$deletefail) format_message(0, "<strong>Template deleted.</strong>");
|
||||
}
|
||||
}
|
||||
|
||||
if ($operation=="delete") {
|
||||
if ($operation == "delete") {
|
||||
// just show the link back to the templates page
|
||||
echo "
|
||||
<br><a href=\"templates.php\">Manage templates</a><br><br><br><br>
|
||||
";
|
||||
} else if ($operation=="add" || $operation=="edit") {
|
||||
} else if ($operation == "add" || $operation == "edit") {
|
||||
// Display the input form
|
||||
if ($loadtemplate) {
|
||||
// make templateid the selected template
|
||||
if ($usertemplateid) {
|
||||
$templateid=$usertemplateid;
|
||||
$templateid = $usertemplateid;
|
||||
} else if ($globaltemplateid) {
|
||||
$templateid=$globaltemplateid;
|
||||
$templateid = $globaltemplateid;
|
||||
} else {
|
||||
$templateid=NULL;
|
||||
$templateid = NULL;
|
||||
}
|
||||
}
|
||||
if ($operation=="edit" || $loadtemplate) {
|
||||
if ($operation == "edit" || $loadtemplate) {
|
||||
// use values from the templateid supplied with a defined tech id
|
||||
$loadeddata=mysqli_fetch_assoc(mysqli_query($db,"select * from notetemplates where templateid=\"$templateid\""));
|
||||
$filltemplatename=$loadeddata["templatename"];
|
||||
$loadeddata = mysqli_fetch_assoc(mysqli_query($db, "select * from notetemplates where templateid=\"$templateid\""));
|
||||
$filltemplatename = $loadeddata["templatename"];
|
||||
if ($efftechid) {
|
||||
$filltech=$efftechid;
|
||||
} else if ($isadmin && $loadeddata["tech"]=="0") {
|
||||
$filltech="0";
|
||||
$filltech = $efftechid;
|
||||
} else if ($isadmin && $loadeddata["tech"] == "0") {
|
||||
$filltech = "0";
|
||||
} else {
|
||||
$filltech=$techid;
|
||||
$filltech = $techid;
|
||||
}
|
||||
$fillshift=$loadeddata["shift"];
|
||||
$fillsubject=$loadeddata["subject"];
|
||||
$fillnote=$loadeddata["lognote"];
|
||||
$fillshift = $loadeddata["shift"];
|
||||
$fillsubject = $loadeddata["subject"];
|
||||
$fillnote = $loadeddata["lognote"];
|
||||
} else {
|
||||
// use empty values with a defined tech id
|
||||
$filltemplatename=NULL;
|
||||
$filltemplatename = NULL;
|
||||
if ($efftechid) {
|
||||
$filltech=$efftechid;
|
||||
$filltech = $efftechid;
|
||||
} else {
|
||||
$filltech=$techid;
|
||||
$filltech = $techid;
|
||||
}
|
||||
$fillshift=$defaultshift;
|
||||
$fillsubject=NULL;
|
||||
$fillnote=NULL;
|
||||
$fillshift = $defaultshift;
|
||||
$fillsubject = NULL;
|
||||
$fillnote = NULL;
|
||||
}
|
||||
|
||||
if ($operation=="add") $optext="Creating new";
|
||||
if ($operation=="edit") $optext="Editing";
|
||||
|
||||
if ($operation == "add") $optext = "Creating new";
|
||||
if ($operation == "edit") $optext = "Editing";
|
||||
echo "
|
||||
<br><b>$optext template</b><br><hr>
|
||||
";
|
||||
|
||||
|
||||
// show the template selection line
|
||||
templateselect($techid,$operation);
|
||||
|
||||
templateselect($techid, $operation);
|
||||
|
||||
// start template entry section
|
||||
echo "
|
||||
<form method=\"post\" action=\"templates.php\">
|
||||
@@ -388,25 +395,26 @@ if ($operation=="delete") {
|
||||
<tr><td colspan=\"2\"><b>Tech: </b>
|
||||
<select name=\"efftechid\">
|
||||
";
|
||||
if ($filltech=="0") {
|
||||
if ($filltech == "0") {
|
||||
echo "<option value=\"0\" selected>--Global Template--</option>";
|
||||
} else {
|
||||
echo "<option value=\"0\">--Global Template--</option>";
|
||||
}
|
||||
if ($techalpha) $torder="techname"; else $torder="techid";
|
||||
$techrow=mysqli_query($db,"select * from techs order by $torder asc");
|
||||
while ($techitem=mysqli_fetch_assoc($techrow)) {
|
||||
if ($techitem["techid"]==$filltech) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$techitem["techid"],$techitem["techname"]);
|
||||
if ($techalpha) $torder = "techname";
|
||||
else $torder = "techid";
|
||||
$techrow = mysqli_query($db, "select * from techs order by $torder asc");
|
||||
while ($techitem = mysqli_fetch_assoc($techrow)) {
|
||||
if ($techitem["techid"] == $filltech) {
|
||||
printf("<option value=\"%s\" selected>%s</option>", $techitem["techid"], $techitem["techname"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$techitem["techid"],$techitem["techname"]);
|
||||
printf("<option value=\"%s\">%s</option>", $techitem["techid"], $techitem["techname"]);
|
||||
}
|
||||
}
|
||||
echo "
|
||||
</select></td></tr>
|
||||
";
|
||||
} else {
|
||||
$authorized=TRUE;
|
||||
$authorized = TRUE;
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"efftechid\" value=\"$techid\">
|
||||
";
|
||||
@@ -416,13 +424,13 @@ if ($operation=="delete") {
|
||||
<td><b>Shift: </b>
|
||||
<select name=\"shift\">
|
||||
";
|
||||
$shiftrow=mysqli_query($db,"select * from shifts");
|
||||
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
|
||||
$shiftrow = mysqli_query($db, "select * from shifts");
|
||||
while ($shiftitem = mysqli_fetch_assoc($shiftrow)) {
|
||||
if ($shiftitem["status"] == 1) {
|
||||
if ($shiftitem["shiftid"]==$fillshift) {
|
||||
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
||||
if ($shiftitem["shiftid"] == $fillshift) {
|
||||
printf("<option value=\"%s\" selected>%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
|
||||
printf("<option value=\"%s\">%s</option>", $shiftitem["shiftid"], $shiftitem["shiftname"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,18 +439,19 @@ if ($operation=="delete") {
|
||||
<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"]);
|
||||
if ($subjalpha) $sorder = "subjectname";
|
||||
else $sorder = "subjectid";
|
||||
$subjrow = mysqli_query($db, "select * from subjects order by $sorder asc");
|
||||
while ($subjitem = mysqli_fetch_assoc($subjrow)) {
|
||||
if ($subjitem["status"] == 1) {
|
||||
if ($subjitem["subjectid"] == $fillsubject) {
|
||||
printf("<option value=\"%s\" selected>%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
|
||||
} else {
|
||||
printf("<option value=\"%s\">%s</option>",$subjitem["subjectid"],$subjitem["subjectname"]);
|
||||
printf("<option value=\"%s\">%s</option>", $subjitem["subjectid"], $subjitem["subjectname"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "
|
||||
</select></td>
|
||||
</tr></table>
|
||||
@@ -454,50 +463,60 @@ if ($operation=="delete") {
|
||||
<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=[];
|
||||
$theseflags = [];
|
||||
if ($templateid) {
|
||||
$allflags=mysqli_query($db,"select flagid from flags");
|
||||
while ($thisflag=mysqli_fetch_row($allflags)) {
|
||||
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) {
|
||||
$theseflags[]=$thisflag[0];
|
||||
$allflags = mysqli_query($db, "select flagid from flags");
|
||||
while ($thisflag = mysqli_fetch_row($allflags)) {
|
||||
if (mysqli_num_rows(mysqli_query($db, "select id from flagmap where flagid=\"$thisflag[0]\" and notetemplateid=\"$templateid\""))) {
|
||||
$theseflags[] = $thisflag[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$flagslist=mysqli_query($db,"select * from flags where status=1");
|
||||
$flagsperline=8;
|
||||
$flagcount=1;
|
||||
|
||||
|
||||
$flagslist = mysqli_query($db, "select * from flags where status=1");
|
||||
$flagsperline = 8;
|
||||
$flagcount = 1;
|
||||
|
||||
// display checkboxes for all the flags, selecting the ones that are set for this template
|
||||
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
|
||||
if ($operation=="edit" && in_array($flagcheckbox["flagid"],$theseflags)) {
|
||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
|
||||
if ($operation == "edit" && in_array($flagcheckbox["flagid"], $theseflags)) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\" checked><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],
|
||||
$flagcheckbox["flagcolor"],
|
||||
$flagcheckbox["flagname"],
|
||||
$flagcheckbox["flagsym"]
|
||||
);
|
||||
} else {
|
||||
$flagid=$flagcheckbox["flagid"];
|
||||
if (mysqli_num_rows(mysqli_query($db,"select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||
printf("<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
|
||||
$flagid = $flagcheckbox["flagid"];
|
||||
if (mysqli_num_rows(mysqli_query($db, "select flagid from flags where flagid=\"$flagid\" and status=1"))) {
|
||||
printf(
|
||||
"<input type=\"checkbox\" name=\"flags[]\" value=\"%s\"><font color=\"%s\" title=\"%s\">%s</font>",
|
||||
$flagcheckbox["flagid"],
|
||||
$flagcheckbox["flagcolor"],
|
||||
$flagcheckbox["flagname"],
|
||||
$flagcheckbox["flagsym"]
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($flagcount<$flagsperline) {
|
||||
if ($flagcount < $flagsperline) {
|
||||
echo " ";
|
||||
$flagcount++;
|
||||
} else {
|
||||
echo "<br>";
|
||||
$flagcount=1;
|
||||
$flagcount = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($operation=="edit" || $loadtemplate) {
|
||||
|
||||
if ($operation == "edit" || $loadtemplate) {
|
||||
// generate a reference string
|
||||
$refstring=NULL;
|
||||
$refstringqry=mysqli_query($db,"select target from reflinks where templateid=\"$templateid\"");
|
||||
while ($tgt=mysqli_fetch_row($refstringqry)) {
|
||||
$refstring=$refstring." ".$tgt[0];
|
||||
$refstring = NULL;
|
||||
$refstringqry = mysqli_query($db, "select target from reflinks where templateid=\"$templateid\"");
|
||||
while ($tgt = mysqli_fetch_row($refstringqry)) {
|
||||
$refstring = $refstring . " " . $tgt[0];
|
||||
}
|
||||
}
|
||||
echo "
|
||||
@@ -505,14 +524,14 @@ if ($operation=="delete") {
|
||||
<input type=\"text\" name=\"refstring\" size=\"20\" value=\"$refstring\" title=\"One or more Note ID numbers separated by spaces\">
|
||||
|
||||
";
|
||||
|
||||
if ($operation=="add" && $authorized) {
|
||||
|
||||
if ($operation == "add" && $authorized) {
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"operation\" value=\"add\">
|
||||
<input type=\"submit\" name=\"submit\" value=\"Save Template\">
|
||||
";
|
||||
}
|
||||
if ($operation=="edit" && $authorized) {
|
||||
if ($operation == "edit" && $authorized) {
|
||||
echo "
|
||||
<input type=\"hidden\" name=\"operation\" value=\"edit\">
|
||||
<input type=\"hidden\" name=\"templateid\" value=\"$templateid\">
|
||||
@@ -521,34 +540,32 @@ if ($operation=="delete") {
|
||||
<button type=\"submit\" name=\"operation\" value=\"delete\">Delete this template</button><font color=\"#FF0000\"><b>Deleted templates are irretrievable!</b></font>
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
echo "
|
||||
</form>
|
||||
<br>
|
||||
";
|
||||
} else {
|
||||
echo "<br><font size= \"+1\"><b><a href=\"templates.php?operation=add\">Create or copy a template</a></b></font><br><hr>";
|
||||
|
||||
|
||||
// Show my user template table
|
||||
templatetable($db,$techid,$techid);
|
||||
|
||||
templatetable($db, $techid, $techid);
|
||||
|
||||
// Show global template table
|
||||
templatetable($db,$techid,"0");
|
||||
|
||||
templatetable($db, $techid, "0");
|
||||
|
||||
if ($isadmin) {
|
||||
// Show template tables for other users
|
||||
$techqry=mysqli_query($db,"select techid from techs where techid != $techid and techid != 0");
|
||||
while ($techtblrow=(mysqli_fetch_row($techqry))) {
|
||||
templatetable($db,$techid,$techtblrow[0]);
|
||||
$techqry = mysqli_query($db, "select techid from techs where techid != $techid and techid != 0");
|
||||
while ($techtblrow = (mysqli_fetch_row($techqry))) {
|
||||
templatetable($db, $techid, $techtblrow[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
banner($print);
|
||||
pageblock("right","end");
|
||||
pageblock("right", "end");
|
||||
pagetable("end");
|
||||
|
||||
framework("end","","",$print);
|
||||
|
||||
?>
|
||||
framework("end", "", "", $print);
|
||||
|
||||
@@ -41,3 +41,15 @@ fi
|
||||
# ---------- version 5.2.4.4 -----------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.2.5 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.3.0 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
|
||||
# ---------- version 5.3.1 -------------
|
||||
# No changes
|
||||
# --------------------------------------
|
||||
144
install.sh
144
install.sh
@@ -2,13 +2,13 @@
|
||||
|
||||
# install.sh
|
||||
# OpenLog Online Logbook
|
||||
# Copyright (C) 2025 Rod Wright
|
||||
# Copyright (C) 2026 Rod Wright
|
||||
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
APP_NAME="OpenLog"
|
||||
DEFAULT_DB_NAME="openlog"
|
||||
APP_VERSION="5.3.0"
|
||||
APP_VERSION="5.3.1"
|
||||
DOC_ROOT="/var/www"
|
||||
INSTALL_LOC="openlog"
|
||||
APACHE_CONF_DIR="/etc/apache2/conf-available"
|
||||
@@ -21,7 +21,7 @@ CONFIG_DEFAULT_COLUMN=""
|
||||
|
||||
function privilege_check() {
|
||||
# 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"
|
||||
exit 1
|
||||
fi
|
||||
@@ -36,11 +36,11 @@ function get_new_password() {
|
||||
echo ""
|
||||
read -p "Re-type new password: " -s -r rnewpw
|
||||
echo ""
|
||||
if [ "$newpassword" = "" -o "$rnewpw" = "" ]
|
||||
if [[ "$newpassword" == "" || "$rnewpw" == "" ]]
|
||||
then
|
||||
echo "Password cannot be blank. Please try again."
|
||||
echo ""
|
||||
elif [ "$newpassword" != "$rnewpw" ]
|
||||
elif [[ "$newpassword" != "$rnewpw" ]]
|
||||
then
|
||||
echo "Passwords do not match. Please try again."
|
||||
echo ""
|
||||
@@ -63,7 +63,7 @@ function install_required_packages() {
|
||||
gpattern=""
|
||||
for pkg_option in $(echo $prereq)
|
||||
do
|
||||
if [ "$pkg_option" != "or" ]
|
||||
if [[ "$pkg_option" != "or" ]]
|
||||
then
|
||||
gpattern+=" -e $pkg_option"
|
||||
preferred_pkg=$pkg_option
|
||||
@@ -76,7 +76,7 @@ function install_required_packages() {
|
||||
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
|
||||
echo -n "Install $preferred_pkg now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]]
|
||||
then
|
||||
echo "$APP_NAME requires $prereq, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
@@ -172,20 +172,20 @@ echo ""
|
||||
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
|
||||
read install_loc_in
|
||||
echo ""
|
||||
if [ "$doc_root_in" = "" ]
|
||||
if [[ "$doc_root_in" == "" ]]
|
||||
then
|
||||
doc_root_in=$DOC_ROOT
|
||||
fi
|
||||
if [ "$install_loc_in" = "" ]
|
||||
if [[ "$install_loc_in" == "" ]]
|
||||
then
|
||||
install_loc_in=$INSTALL_LOC
|
||||
fi
|
||||
install_path="$doc_root_in/$install_loc_in"
|
||||
if [ -d "$install_path" ]
|
||||
if [[ -d "$install_path" ]]
|
||||
then
|
||||
echo "The installation path you chose already exists."
|
||||
# Install path exists.
|
||||
if [ -e "$install_path/db.php" ]
|
||||
if [[ -e "$install_path/db.php" ]]
|
||||
then
|
||||
# A db.php file was found in the install path
|
||||
if grep -q -e "$APP_NAME" $install_path/db.php
|
||||
@@ -195,12 +195,44 @@ then
|
||||
echo "and restart the install using a new installation location."
|
||||
echo -n "[U]pgrade or [C]ancel? [U] :"
|
||||
read upgrade_choice
|
||||
if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen
|
||||
if [[ "$upgrade_choice" == "C" || "$upgrade_choice" == "c" ]] # Cancel chosen
|
||||
then
|
||||
echo "Cancelling installation"
|
||||
abort_exit
|
||||
else
|
||||
# proceed with upgrade
|
||||
# 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
|
||||
@@ -226,19 +258,15 @@ then
|
||||
echo "Backing up current installation to the package directory."
|
||||
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
|
||||
|
||||
# delete all existing installation files except db.php
|
||||
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
|
||||
# delete all existing installation files except db.php and maintenancemode.php
|
||||
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
|
||||
(mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
mysql --defaults-extra-file=$mysql_opt_file --force < database-update.sql >/dev/null 2>&1
|
||||
|
||||
# apply database updates via script
|
||||
(bash ./database-update.sh $mysql_opt_file) &
|
||||
task_pid=$!
|
||||
spinner $task_pid
|
||||
bash ./database-update.sh $mysql_opt_file
|
||||
|
||||
echo "... finished with database updates."
|
||||
rm -f $mysql_opt_file
|
||||
@@ -250,12 +278,12 @@ then
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
# set symlink for jquery-ui
|
||||
if [ ! -L "$install_path/jquery-ui" ]
|
||||
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||
then
|
||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||
fi
|
||||
# set symlink for index.php
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
if [[ ! -L "$install_path/index.php" ]]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
@@ -270,6 +298,17 @@ then
|
||||
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
|
||||
else
|
||||
# This was a mistake. Exit now to avoid clobbering another app.
|
||||
@@ -287,11 +326,11 @@ then
|
||||
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."
|
||||
proceed=""
|
||||
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
|
||||
while [[ "$proceed" != "P" && "$proceed" != "p" && "$proceed" != "Q" && "$proceed" != "q" ]]
|
||||
do
|
||||
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
||||
done
|
||||
if [[ $proceed == "Q" || $proceed == "q" ]]
|
||||
if [[ "$proceed" == "Q" || "$proceed" == "q" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
@@ -306,7 +345,7 @@ else
|
||||
echo "This can be changed later in the application itself."
|
||||
echo -n "Installation name [$APP_NAME]: "
|
||||
read new_inst_name
|
||||
if [ "$new_inst_name" = "" ]
|
||||
if [[ "$new_inst_name" == "" ]]
|
||||
then
|
||||
new_inst_name="$APP_NAME"
|
||||
fi
|
||||
@@ -323,7 +362,7 @@ else
|
||||
echo "distinctive name."
|
||||
echo -n "database name [$DEFAULT_DB_NAME]: "
|
||||
read new_db_name
|
||||
if [ "$new_db_name" = "" ]
|
||||
if [[ "$new_db_name" == "" ]]
|
||||
then
|
||||
new_db_name=$DEFAULT_DB_NAME
|
||||
fi
|
||||
@@ -336,7 +375,7 @@ else
|
||||
echo "This probably means the database already exists."
|
||||
echo -n "Try again with a different database name? [Y/N]: "
|
||||
read dbcreatetry
|
||||
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
|
||||
if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
@@ -356,7 +395,7 @@ else
|
||||
# Set the installation name
|
||||
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\""
|
||||
if [ "$CONFIG_DEFAULT_COLUMN" != "" ]
|
||||
if [[ "$CONFIG_DEFAULT_COLUMN" != "" ]]
|
||||
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\""
|
||||
fi
|
||||
@@ -365,23 +404,29 @@ else
|
||||
mkdir $install_path
|
||||
|
||||
# Create db.php if it doesn't exist
|
||||
if [ ! -f "$install_path/db.php" ]
|
||||
if [[ ! -f "$install_path/db.php" ]]
|
||||
then
|
||||
cp db.php.template $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/DBPASS/$db_pass/g" $install_path/db.php
|
||||
sed -i "s/APPNAME/$APP_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|DBPASS|$db_pass|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
|
||||
|
||||
# copy distribution to install location
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
if [ ! -L "$install_path/jquery-ui" ]
|
||||
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||
then
|
||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||
fi
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
if [[ ! -L "$install_path/index.php" ]]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
@@ -404,23 +449,24 @@ echo ""
|
||||
echo ""
|
||||
echo "$APP_NAME has been $operation."
|
||||
base_url=$install_loc_in
|
||||
if [ "$operation" = "installed" ]
|
||||
if [[ "$operation" == "upgraded" ]]
|
||||
then
|
||||
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "Alias /$base_url $doc_root_in/$base_url" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "<Directory $doc_root_in/$base_url>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " AllowOverride Options" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " Options FollowSymLinks" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo " DirectoryIndex index.php" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
a2enconf -q $base_url
|
||||
systemctl reload apache2
|
||||
fi
|
||||
if [[ "$operation" == "installed" ]]
|
||||
then
|
||||
cp -f default-apache.conf $APACHE_CONF_DIR/$base_url.conf
|
||||
sed -i "s|_APPNAME_|$APP_NAME|g" $APACHE_CONF_DIR/$base_url.conf
|
||||
sed -i "s|_BASEURL_|$base_url|g" $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] :"
|
||||
read enconf
|
||||
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
|
||||
if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
|
||||
then
|
||||
a2enconf $base_url.conf >/dev/null
|
||||
service apache2 reload
|
||||
a2enconf -q $base_url.conf >/dev/null
|
||||
systemctl reload apache2
|
||||
echo "You can now point a web browser to $base_url on your web server "
|
||||
echo "to set up and configure $APP_NAME."
|
||||
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