18 Commits

Author SHA1 Message Date
5e1856f1dc Cleanups to avoid php undefined variable warnings. Changed boolean variables from 1/0 to TRUE/FALSE. Converted flag handling code to the new scheme. 2026-02-18 12:48:29 -05:00
262bd6dcdc Minor cleanups to prevent php undefined variables warnings. 2026-02-18 12:42:03 -05:00
ff71083b49 fixes to get_part_data to prevent php undefined variable warnings 2026-02-18 12:40:40 -05:00
1a4c9a9c2a Fixed bug where the shifts weren't being shown in the existing techs table. 2026-02-18 12:37:45 -05:00
5396f3367b Various cleanups to avoid php undefined variable warnings 2026-02-18 12:33:25 -05:00
557af4db04 Set REQUEST variables to default to NULL if not passed to avoid php warnings 2026-02-18 12:31:44 -05:00
cc2b638a6a Removed useless hyperlinks from headers of parts results table. 2026-02-18 12:29:58 -05:00
63bb7a3445 More work on flags 2026-02-17 14:43:46 -05:00
35173f6faa Update LICENSE
Added license info for the Fugue icon set
2026-02-14 10:57:37 -05:00
71f60d353f got lognote multi flag search working 2026-02-13 21:15:52 -05:00
f74385d8f3 flag fixes in work 2026-02-12 21:56:45 -05:00
9e392faa4d restored the flagmap and reflinks table creations that somehow got deleted 2026-02-12 20:40:56 -05:00
d2cb1851d0 restored the flag table and reference chain modifiactions that somehow got deleted 2026-02-12 20:40:05 -05:00
07a6d352b0 changed path of backup directory inside the package directory to avoid cluttering up package directory. 2026-02-12 20:38:40 -05:00
0547e97479 Moved templateselect function from templates.php to functions.php for use in other pages. 2026-02-12 19:42:36 -05:00
a79f73a8ca Continued work on templates.php 2026-02-11 22:28:02 -05:00
78ee18f03b Created a useful README.md file 2026-02-11 15:48:46 -05:00
c11ef1ad8c Updated various files where the version number exists.
Continued work on templates.php.
2026-02-10 22:18:42 -05:00
30 changed files with 1642 additions and 484 deletions

View File

@@ -1,6 +1,6 @@
CHANGELOG
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
@@ -240,7 +240,3 @@
treating the $today variable as global.
- In install.php, if a previous installation was found, make upgrade
the default choice.
5.2.5 - 2026-02-10
This is just a version number bump to get on a major-minor-patch
scheme. There are no code changes for this release.

View File

@@ -1,6 +1,6 @@
INSTALL
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0

323
LICENSE
View File

@@ -1,5 +1,5 @@
The following license applies to all OpenLog code
Copyright (C) 2016 by Rod Wright :
Copyright (C) 2026 by Rod Wright :
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
@@ -382,3 +382,324 @@ The following license applies to jquery code :
CC0: http://creativecommons.org/publicdomain/zero/1.0/
The following license applies to the Fugue icon set :
Creative Commons Legal Code
Attribution 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
h. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
i. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(b), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4 (b) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at https://creativecommons.org/.

View File

@@ -0,0 +1,52 @@
# OpenLog #
OpenLog is an online logbook application. It allows anyone with a web browser to read, enter, and search for notes on any subject.
The available shifts, employees, and subjects are easily configured. Notes can be referred to other notes and the entire chain of referenced notes can be displayed in a single page. This makes it convenient to track ongoing projects or actions on a particular piece of equipment over a long period of time.
Version 5.0 adds parts tracking functionality. Notes can have parts change information associated with them and maintenance/repair forms can be generated for parts. Parts related functions can be disabled to reduce clutter if they are not needed.
Version 5.1 adds scheduled maintenance functionality, which can also be disabled if not needed. Notes, parts, and maintenance forms can be searched for based on a number of criteria.
The look and feel of the OpenLog pages are easily changed. Settings that affect all users can be changed in the Administration menu. Each user can personalize his or her own settings in the My Profile menu.
No browser specific HTML is used in OpenLog, so it should be useable in any browser, and it has been tested using Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, and Edge.
## Prerequisites ##
- Linux - The installer is written to automate installation on Debian based Linux servers, but OpenLog itself should run on any current Linux distribution, albeit installation will need to be accomplished manually.
- Apache2 - Current development is using version 2.4.65
- MySQL or MariaDB - Current development is using MariaDB version 11.8.3
- php - Current development is using version 8.4.11
## Installation ##
> [!NOTE]
> These instructions are used to either install a new instance of OpenLog or upgrade an existing one.
1. Unzip the OpenLog-x.x.x.tar.gz file you've downloaded into a convenient place.
2. `cd OpenLog-x.x.x`
3. `sudo ./install.sh`
* The installer will check for installation of the required packages and prompt for their installation if not found.
* You'll then be prompted for the webserver's install location. The default should work for standard installations.
* You'll then be prompted for the installation location of this instance of OpenLog. You should come up with a unique name.
* If this directory already exists and contains an instance of OpenLog, you will be prompted to cancel the process or upgrade this instance.
* If you choose to upgrade, your OpenLog instance will be upgraded and you're done.
* If this directory does not exist, it will be created and a new instance will be installed. You can have multiple instances of OpenLog running under different names in different directories. For example, if you wanted to create an Operations Log, you could enter `opslog`.
* In the Operations Log example referred to above, you could enter `OpsLog` or `Operations Log`.
* You'll br prompted for the name of the database to be created. You should choose something appropriate, like `opslog` for the example given.
* Next, you'll be prompted to enable the apache2 configuration for this instance.
*The new instance will now be installed and accessible. You will be given some important information.
> [!IMPORTANT]
> The default login credentials for the initial admin user are:
> login: `OpenLogAdmin`
> password: `OpenLog-1`
> Make note of these credentials, otherwise you will not be able to login and configure your new installation.
>
> It is highly recommended that you change the OpenLogAdmin user password and/or create your own admin user (with a secure password) and disable this default account after logging in for the first time.
## History ##
OpenLog was written to replace a creaky old inefficient error prone Access database which had in turn replaced stacks of paper logbooks. Now, with some improvements and over 15 years and 44000 notes later in a production environment, it's still going strong.

View File

@@ -1 +1 @@
5.2.5
5.3.0

View File

@@ -69,7 +69,7 @@ CREATE TABLE `configs` (
LOCK TABLES `configs` WRITE;
/*!40000 ALTER TABLE `configs` DISABLE KEYS */;
INSERT INTO `configs` VALUES
(1,'ol_version','5.2.5'),
(1,'ol_version','5.2.4'),
(2,'log_name','OpenLog'),
(3,'banner','1'),
(4,'background_color','#003333'),
@@ -232,6 +232,32 @@ LOCK TABLES `flags` WRITE;
/*!40000 ALTER TABLE `flags` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `flagmap`
--
DROP TABLE IF EXISTS `flagmap`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `flagmap` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`flagid` int(11) NOT NULL,
`lognoteid` int(11) DEFAULT NULL,
`maintformid` int(11) DEFAULT NULL,
`notetemplateid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `flagmap`
--
LOCK TABLES `flagmap` WRITE;
/*!40000 ALTER TABLE `flagmap` DISABLE KEYS */;
/*!40000 ALTER TABLE `flagmap` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `links`
--
@@ -273,7 +299,6 @@ CREATE TABLE `lognotes` (
`tech` int(11) NOT NULL,
`subject` int(11) NOT NULL,
`lognote` text DEFAULT NULL,
`refs` tinytext DEFAULT NULL,
PRIMARY KEY (`lognoteid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -287,6 +312,31 @@ LOCK TABLES `lognotes` WRITE;
/*!40000 ALTER TABLE `lognotes` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `reflinks`
--
DROP TABLE IF EXISTS `reflinks`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `reflinks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`noteid` int(11) DEFAULT NULL,
`templateid` int(11) DEFAULT NULL,
`target` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `reflinks`
--
LOCK TABLES `reflinks` WRITE;
/*!40000 ALTER TABLE `reflinks` DISABLE KEYS */;
/*!40000 ALTER TABLE `reflinks` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `logpartactions`
--

View File

@@ -37,3 +37,82 @@ margs="--defaults-extra-file=$mysql_opt_file"
# ---------- version 5.2.5 ------------
# Nothing to do
# -------------------------------------
# ---------- version 5.3.0 ------------
#
echo "Started database updates for OpenLog version 5.3.0..."
# Import old flag data from old scheme to new flagmap table
if [[ $(mysql $margs -e "select count(*) from flagmap") == 0 ]]
then
echo "Importing flag data from old scheme to new flagmap table..."
for flagnumber in $(mysql $margs -e "select flagid from flags")
do
flag_x=$(mysql $margs -s -e "show tables like 'flag_$flagnumber'")
if [[ -n "$flag_x" ]]
then
for tgtid in $(mysql $margs -e "select id from flag_$flagnumber")
do
target=$(mysql $margs -e "select target from flag_$flagnumber where id=$tgtid")
if [[ $target == "lognotes" ]]
then
mysql $margs -e "insert into flagmap(flagid,lognoteid) values($flagnumber,$tgtid)"
elif [[ $target == "maintforms" ]]
then
mysql $margs -e "insert into flagmap(flagid,maintformid) values($flagnumber,$tgtid)"
elif [[ $target == "notetemplates" ]]
then
mysql $margs -e "insert into flagmap(flagid,notetemplateid) values($flagnumber,$tgtid)"
fi
done
mysql $margs -e "drop table flag_$flagnumber"
fi
done
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..."
for note in $(mysql $margs -e "select lognoteid from lognotes where refs!=''")
do
refstring=$(mysql $margs -e "select refs from lognotes where lognoteid=$note")
oldifs=$IFS
IFS=', '
for target in $refstring
do
target=$(echo "$target" | xargs)
mysql $margs -e "insert into reflinks(noteid,target) values($note,$target)"
done
IFS=$oldifs
done
echo "...done."
echo "Importing template reference chain data into new reflinks table..."
for template in $(mysql $margs -e "select templateid from notetemplates where refs!=''")
do
refstring=$(mysql $margs -e "select refs from notetemplates where templateid=$template")
oldifs=$IFS
IFS=', '
for target in $refstring
do
target=$(echo "$target" | xargs)
mysql $margs -e "insert into reflinks(templateid,target) values($template,$target)"
done
IFS=$oldifs
done
echo "...done."
mysql $margs -e "alter table lognotes drop column refs" >/dev/null 2>&1
mysql $margs -e "alter table notetemplates drop column refs" >/dev/null 2>&1
fi
# Convert database to utf8mb4/utf8mb4_unicode_ci
echo "Converting database to utf8mb4 encoding..."
mysql $margs -e "ALTER DATABASE CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"
for table in $(mysql $margs -e "show tables")
do
mysql $margs -e "ALTER TABLE $table CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
done
echo "...done."
# -------------------------------------

View File

@@ -55,3 +55,28 @@ UPDATE configs SET confvalue="5.2.4.4" WHERE confname="ol_version";
-- Update version number
UPDATE configs SET confvalue="5.2.5" WHERE confname="ol_version";
-- --------------------------------------
-- ---------- version 5.3.0 -------------
-- Update version number
UPDATE configs SET confvalue="5.3.0" WHERE confname="ol_version";
-- Create the flagmap table
CREATE TABLE IF NOT EXISTS `flagmap` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`flagid` int(11) NOT NULL,
`lognoteid` int(11) DEFAULT NULL,
`maintformid` int(11) DEFAULT NULL,
`notetemplateid` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Create the reflinks table
CREATE TABLE IF NOT EXISTS `reflinks` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`noteid` int(11) DEFAULT NULL,
`templateid` int(11) DEFAULT NULL,
`target` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --------------------------------------

View File

@@ -3,7 +3,7 @@
/*
db.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -1,6 +1,6 @@
CHANGELOG
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
@@ -240,8 +240,3 @@
treating the $today variable as global.
- In install.php, if a previous installation was found, make upgrade
the default choice.
5.2.5 - 2026-02-10
This is just a version number bump to get on a major-minor-patch
scheme. There are no code changes for this release.

View File

@@ -1,6 +1,6 @@
INSTALL
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0

View File

@@ -2,7 +2,7 @@
/*
about.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -2,7 +2,7 @@
/*
admin.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -794,7 +794,7 @@ switch($table) {
$shiftrow=mysqli_query($db,"select * from shifts");
while ($shiftitem=mysqli_fetch_assoc($shiftrow)) {
if ($shiftitem["status"] == 1) {
if ($shiftitem["shiftid"]==$customshiftnum) {
if ($shiftitem["shiftid"]==$shift) {
printf("<option value=\"%s\" selected>%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
} else {
printf("<option value=\"%s\">%s</option>",$shiftitem["shiftid"],$shiftitem["shiftname"]);
@@ -830,7 +830,7 @@ switch($table) {
} else {
$statdef="<img src=\"icons/cross.png\" title=\"inactive\" alt=\"inactive\">";
}
$shiftname=dblookup($db,"shifts","shiftname","shiftid",$shift);
$shiftname=dblookup($db,"shifts","shiftid","shiftname",$tablerow["shift"]);
printf("
<tr>
<td><a href=\"admin.php?table=$table&edit=1&id=%s\">%s</a></td>

View File

@@ -2,7 +2,7 @@
/*
functions.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -181,17 +181,28 @@ function framework($option,$htmltitle,$pagetitle,$print) {
}
}).datepicker(\"setDate\", defdate);
function insertUrlAtCaret(outputAreaId, inputAreaId) {
var rawlinktext=document.getElementById(inputAreaId).value;
var url='<a href=\"' + rawlinktext.replace(/ /g,'\%20') + '\">' + rawlinktext + '</a>';
function insertUrlAtCaret(outputAreaId, inputTextAreaId, inputUrlAreaId) {
var linktext=document.getElementById(inputTextAreaId).value;
var rawurltext=document.getElementById(inputUrlAreaId).value;
if (rawurltext=='') return;
var lastslashindex=rawurltext.lastIndexOf('/');
if (lastslashindex==rawurltext.length-1) {
rawurltext=rawurltext.slice(0, -1);
}
if (linktext=='' && rawurltext!= '') {
lastslashindex=rawurltext.lastIndexOf('/');
var lastpartofurl=rawurltext.substring(lastslashindex+1);
linktext=lastpartofurl;
}
var link='<a href=\"' + rawurltext.replace(/ /g,'\%20') + '\" target=\"_blank\">' + linktext + '</a>';
var txtarea = document.getElementById(outputAreaId);
var scrollPos = txtarea.scrollTop;
var caretPos = txtarea.selectionStart;
var front = (txtarea.value).substring(0, caretPos);
var back = (txtarea.value).substring(txtarea.selectionEnd, txtarea.value.length);
txtarea.value = front + url + back;
caretPos = caretPos + url.length;
txtarea.value = front + link + back;
caretPos = caretPos + link.length;
txtarea.selectionStart = caretPos;
txtarea.selectionEnd = caretPos;
txtarea.focus();
@@ -311,6 +322,7 @@ function sidemenu($noprint=false) {
<table bgcolor=\"$mbgcolor\" border=\"1\" width=\"100%\">
<tr><td align=\"center\"><a href=\"admin.php\" title=\"Control global settings. Must be an administrator.\"><b>Administration</b></a></td></tr>
<tr><td align=\"center\"><a href=\"profile.php\">My Profile</a></td></tr>
<tr><td align=\"center\"><a href=\"templates.php\">Manage Templates</a></td></tr>
</table>
";
if (!isset($_SESSION['login'])) {
@@ -375,8 +387,13 @@ function banner($print) {
function dblookup($dbhandle,$table,$in_field,$out_field,$in_data) {
// look up a single field in a database given a value for a single field
$out_data=mysqli_fetch_row(mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\""));
return($out_data[0]);
$dbqry=mysqli_query($dbhandle,"select $out_field from $table where $in_field=\"$in_data\"");
if (mysqli_num_rows($dbqry)) {
$out_data=mysqli_fetch_row($dbqry)[0];
} else {
$out_data=NULL;
}
return($out_data);
}
function calendar($year,$month,$day,$link_url) {
@@ -625,63 +642,53 @@ function islink($il_note) {
// determines if the argument is a link in a reference chain
// returns 1 if note is a link, 0 if not
global $db;
$il_pq=mysqli_fetch_row(mysqli_query($db,"select refs from lognotes where lognoteid=\"$il_note\""));
if ($il_pq[0]=="") {
$il_hasprev=0;
} else {
$il_hasprev=1;
}
$il_sq=mysqli_num_rows(mysqli_query($db,"select lognoteid from lognotes where refs like \"%$il_note%\""));
if ($il_sq) {
$il_hassubs=1;
} else {
$il_hassubs=0;
}
if($il_hassubs || $il_hasprev) {
$refqry=mysqli_query($db,"select id from reflinks where noteid is not null and (noteid='$il_note' or target='$il_note')");
if (mysqli_num_rows($refqry)) {
return 1;
} else {
return 0;
}
}
function generate_chain($chainlink) {
// generate a reference chain
// takes a single parameter, a noteid
// finds all notes that are members of a chain containing the supplied noteid
// returns a sorted array of all notes in chain
// returns a sorted array (chainarray) of all notes in chain
global $db;
$refsqry=mysqli_query($db,"select lognoteid,refs from lognotes where refs!=\"\"");
$nanote=array();
$narefs=array();
while ($allrefs=mysqli_fetch_row($refsqry)) {
$spltrefs=explode(",",$allrefs[1]);
$iptr=0;
while ($iptr<count($spltrefs)) {
array_push($nanote,$allrefs[0]);
array_push($narefs,$spltrefs[$iptr]);
$iptr=$iptr+1;
}
// create notes and refs arrays from the reflinks table
$notes=[];
$targets=[];
$linkqry=mysqli_query($db,"select noteid,target from reflinks where noteid is not null");
while ($link=mysqli_fetch_assoc($linkqry)) {
$notes[]=$link['noteid'];
$targets[]=$link['target'];
}
$chainarray=array($chainlink);
$results=array();
$mptr=0;
while($mptr<count($chainarray)) {
$nptr=0;
while($nptr<count($nanote)) {
if(($nanote[$nptr]==$chainarray[$mptr]) && ( ! in_array($narefs[$nptr],$chainarray))) {
array_push($chainarray,$narefs[$nptr]);
$chainarray=array(); // create the chainarray
$chainarray[]=$chainlink; // add the incoming noteid for which the chain should be generated
$captr=0; // chainarray pointer
while($captr<count($chainarray)) { // as long as the chainarray is growing
$nptr=0; // note pointer
// run through the notes array, adding all targets for this note to the chainarray
while($nptr<count($notes)) {
if(($notes[$nptr]==$chainarray[$captr]) && ( ! in_array($targets[$nptr],$chainarray))) {
$chainarray[]=$targets[$nptr];
}
$nptr=$nptr+1;
}
$rptr=0;
while($rptr<count($narefs)) {
if(($narefs[$rptr]==$chainarray[$mptr]) && ( ! in_array($nanote[$rptr],$chainarray))) {
array_push($chainarray,$nanote[$rptr]);
// run through the targets array, adding all notes for this target to the chainarray
$tptr=0; //target pointer
while($tptr<count($targets)) {
if(($targets[$tptr]==$chainarray[$captr]) && ( ! in_array($notes[$tptr],$chainarray))) {
$chainarray[]=$notes[$tptr];
}
$rptr=$rptr+1;
$tptr=$tptr+1;
}
$mptr=$mptr+1;
$captr=$captr+1;
}
// sort and return the output array
sort($chainarray);
return($chainarray);
}
@@ -750,43 +757,45 @@ function get_part_data($partinputdata) {
// 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 (mysqli_num_rows($partqry)) {
@@ -800,9 +809,6 @@ function get_part_data($partinputdata) {
if ($checkmm) {
if (mysqli_num_rows($mismatchqry)) {
$result=2;
//while ($mmdata=mysqli_fetch_assoc($mismatchqry)) {
//var_dump($mmdata);
//}
}
}
@@ -924,4 +930,54 @@ function format_message($msgtype,$msgtxt) {
";
}
function templateselect($techid,$operation) {
// Displays a line enabling selection of a user or global template
// $techid is the id number of the current tech
// $operation is one of "add" "edit" "delete"
global $db;
echo "
<form method=\"post\" action=\"templates.php\">
";
// generate template selection line
echo "
<table border=\"0\" cellpadding=\"10\"><tr>
";
// list user templates
echo "
<td>
<select name=\"usertemplateid\" title=\"Select the user template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"$techid\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select user template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
}
echo "
</select>&nbsp;or&nbsp;
";
// list global templates
echo "
<select name=\"globaltemplateid\" title=\"Select the global template you'd like to load and click the Load Template button. User template selection takes precedence.\">
";
$templaterow=mysqli_query($db,"select * from notetemplates where tech=\"0\" order by templatename asc");
printf("<option value=\"%s\" selected>%s</option>","0","Select global template");
while ($templateitem=mysqli_fetch_assoc($templaterow)) {
printf("<option value=\"%s\">%s</option>",$templateitem["templateid"],$templateitem["templatename"]);
}
echo "
</select>&nbsp;&nbsp;
";
// show load button
echo "
<input type=\"hidden\" name=\"operation\" value=\"$operation\">
<input type=\"submit\" name=\"loadtemplate\" value=\"Load Template\">
</td>
<td>
<a href=\"templates.php\">Manage templates</a>
</td>
</tr></table>
<hr>
</form>
";
}
?>

View File

@@ -2,7 +2,7 @@
/*
gpl.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

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

View File

@@ -2,7 +2,7 @@
/*
login.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -2,7 +2,7 @@
/*
lognotes.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -42,14 +42,14 @@ function shifttable_classic($shift, $tgt_date, $db) {
if ($dshdr) {
// print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
echo "<br><table border=\"1\" width=\"100%\">\n";
echo "<tr><th width=\"70\">Note ID</th><th width=\"70\">Tech</th><th width=\"100\">Subject</th><th>Note</th><th width=\"70\">References</th></tr>\n";
while ($tablerow = mysqli_fetch_assoc($note)) {
$reftonote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($tablerow["lognoteid"])) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
$thisnote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($thisnote)) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
}
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
@@ -59,27 +59,24 @@ function shifttable_classic($shift, $tgt_date, $db) {
$fmtnote=convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$allflagqry=mysqli_query($db,"select flagid from flags");
while ($allflagids=mysqli_fetch_row($allflagqry)) {
$flagid=$allflagids[0];
$flag_tbl="flag_".$flagid;
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagname=$flagparam["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$fmtnote=$fmtnote."<br>";
}
if ($doparts) {
// turn on the parts indicator if parts were entered with the note
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1&noteid=$reftonote\">PARTS</a>";
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?partview=1&noteid=$thisnote\">PARTS</a>";
}
}
// now print the line in the table
@@ -134,14 +131,14 @@ function shifttable_clean($shift, $tgt_date, $db) {
if ($dshdr) {
// print the shift header
printf("<b><font size=\"+1\">%s</font></b>\n",$shname);
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,refs,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
$note=mysqli_query($db,"select lognoteid,tech,subject,lognote,time from lognotes where date=\"$tgt_date\" and shift=\"$shift\" order by time asc");
echo "<br><br>";
echo "<table border=\"0\" width=\"100%\"><tr><td>\n";
while ($tablerow = mysqli_fetch_assoc($note)) {
$reftonote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$reftonote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
$thisnote=$tablerow["lognoteid"];
$refs="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"logentry.php?add=1&refto=$thisnote\"><img src=\"icons/plus.png\" border=\"0\" title=\"Add referring note\" alt=\"Add referring note\"></a>";
if (islink($tablerow["lognoteid"])) {
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$reftonote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
$refs=$refs."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"refchain.php?chainnote=$thisnote\"><img src=\"icons/magnifier--arrow.png\" border=\"0\" title=\"View reference chain\" alt=\"View reference chain\"></a>";
}
// convert tech number to name
$tname=dblookup($db,"techs","techid","techname",$tablerow["tech"]);
@@ -151,17 +148,13 @@ function shifttable_clean($shift, $tgt_date, $db) {
$fmtnote=convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$allflagqry=mysqli_query($db,"select flagid from flags");
while ($allflagids=mysqli_fetch_row($allflagqry)) {
$flagid=$allflagids[0];
$flag_tbl="flag_".$flagid;
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$reftonote\""))) {
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagname=$flagparam["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$thisnote");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) {
$fmtnote=$fmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
@@ -170,8 +163,8 @@ function shifttable_clean($shift, $tgt_date, $db) {
}
if ($doparts) {
// turn on the parts indicator if parts were entered with the note
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$reftonote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1&noteid=$reftonote\" title=\"Click here to see note and parts data.\">PARTS</a>";
if (mysqli_num_rows(mysqli_query($db,"select logpartid from logparts where lognoteid=\"$thisnote\""))) {
$fmtnote=$fmtnote."<a href=\"logentry.php?edit=1&noteid=$thisnote\" title=\"Click here to see note and parts data.\">PARTS</a>";
}
}
// now print the line in the table

View File

@@ -2,7 +2,7 @@
/*
maintform.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -11,8 +11,9 @@ include("functions.php");
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;

View File

@@ -2,7 +2,7 @@
/*
maintformentry.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -31,38 +31,38 @@ function getactiondata($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;
@@ -78,48 +78,49 @@ if ($printfmt) {
framework("begin","","",$print);
} else if ($mfedit) {
framework("begin","$logname","Maintenance Form Edit",$print);
if ($loggedinas) $mfauthorized=1;
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;
if (($loggedinas==$mfowner) || $isadmin) $mfauthorized=TRUE;
} else if ($actionadd) {
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;
if ($loggedinas) $mfauthorized=TRUE;
$actionowner=dblookup($db,"maintactions","maintactionid","actiontech",$maintactionid);
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=1;
if (($loggedinas==$actionowner) || $isadmin) $actionauthorized=TRUE;
} else {
$mfadd=1;
$mfadd=TRUE;
framework("begin","$logname","Maintenance Form Entry",$print);
$mftech=$loggedinas;
$mfauthorized=1;
$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();
$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=1;
$pdatamismatch=TRUE;
} else {
unset($pdatamismatch);
$pdatamismatch=FALSE;
if ($partinfo['partid']) $mfpart=$partinfo['partid'];
if ($partinfo['uid']) $uid=$partinfo['uid'];
if ($partinfo['partnum']) $partnum=$partinfo['partnum'];
@@ -157,9 +158,10 @@ if ($mfadd) {
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;
$pdatamismatch=TRUE;
} else {
// if it is in parts table, get partid for this record
$pdatamismatch=FALSE;
$mfpart=$partinfo['partid'];
}
if ($uid =="" || $partnum == "" || $sernum == "") {
@@ -176,10 +178,10 @@ if ($mfadd) {
$newmaintformid=mysqli_insert_id($db);
$mfidtoprint=$newmaintformid;
// add this maintformid to the appropriate flag_tables
foreach ($flags as $flagtblnum) {
$flagtblname="flag_".$flagtblnum;
mysqli_query($db,"insert into $flagtblname(target,id) values(\"maintforms\",\"$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\")");
}
}
}
@@ -209,20 +211,12 @@ if ($mfedit) {
if (! $pdatamismatch) {
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 appropriate flag_tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$thisflag_tbl="flag_".$thisflagid[0];
if ($flags[0]=="") $flags=[];
if (in_array($thisflagid[0],$flags)) {
if(!mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"insert into $thisflag_tbl(target,id) values(\"maintforms\",\"$maintformid\")");
}
} else {
if(mysqli_num_rows(mysqli_query($db,"select id from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\""))) {
mysqli_query($db,"delete from $thisflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
}
// update the flagmap table
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\")");
}
}
}
@@ -233,12 +227,8 @@ if ($mfedit) {
if ($mfdelete && $mfauthorized) {
// delete from maintforms table
mysqli_query($db,"delete from maintforms where maintformid=\"$maintformid\"");
// delete occurances from the flag_ tables
$flagids=mysqli_query($db,"select flagid from flags");
while ($thisflagid=mysqli_fetch_row($flagids)) {
$delflag_tbl="flag_".$thisflagid[0];
mysqli_query($db,"delete from $delflag_tbl where target=\"maintforms\" and id=\"$maintformid\"");
}
// delete occurances from the flagmap table
mysqli_query($db,"delete from flagmap where maintformid=\"$maintformid\"");
}
if ($actionadd) {
@@ -324,7 +314,7 @@ if (($mfedit || $actionadd || $actionedit) && ! ($mfsubmit || $actionaddsubmit |
$sernum=$partinfo['sernum'];
$partname=$partinfo['partname'];
$pluresult=$partinfo['result'];
if ($pluresult==2) $pdatamismatch=1; else unset($pdatamismatch);
if ($pluresult==2) $pdatamismatch=TRUE; else $pdatamismatch=FALSE;
}
$techname=dblookup($db,"techs","techid","techname",$mftech);
@@ -384,19 +374,21 @@ if ($printfmt) {
<b><u>Flags</u></b><br>
<table width=\"100%\" border=\"0\">
";
// get an array of flagids set for this maintformid
// create an array called theseflags of flagids set for this maintformid
$allflags=mysqli_query($db,"select flagid from flags");
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\""))) {
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 (in_array($flagsymbol["flagid"],$theseflags)) {
if (!empty($theseflags) && in_array($flagsymbol["flagid"],$theseflags)) {
echo $flagsymbol['flagsym']."&nbsp;&nbsp;";
}
}
@@ -470,13 +462,12 @@ 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
// 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\""))) {
if (mysqli_num_rows(mysqli_query($db,"select id from flagmap where flagid=\"$thisflag[0]\" and maintformid=\"$maintformid\""))) {
$theseflags[]=$thisflag[0];
}
}
@@ -488,7 +479,7 @@ if ($printfmt) {
$flagsperline=8;
$flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if ($theseflags[0]=="") $theseflags=[];
//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"]);

View File

@@ -2,7 +2,7 @@
/*
partentry.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -17,17 +17,17 @@ if (!isset($_SESSION['login'])) {
$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;
@@ -96,13 +96,13 @@ $partdatainput=array();
$partdatainput['partid']=$partid;
$partinfo=get_part_data($partdatainput);
if ($partinfo['result']==2) {
$pdatamismatch=1;
$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) {

View File

@@ -2,7 +2,7 @@
/*
parts.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -15,10 +15,10 @@ if (isset($_SESSION['login'])) {
unset($loggedin);
}
$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;

View File

@@ -2,7 +2,7 @@
/*
profile.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -2,14 +2,14 @@
/*
refchain.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
include("functions.php");
$print=$_REQUEST['print'];
$print=$_REQUEST['print'] ?? "";
$chainnote=$_REQUEST['chainnote'];
$logname=LOG_NAME;
@@ -59,17 +59,17 @@ while($mptr<count($master)) {
$fmtnote=convertweblinks($tablerow["lognote"]);
// generate the flags string
$flagstring="";
$allflagqry=mysqli_query($db,"select flagid from flags");
while ($allflagids=mysqli_fetch_row($allflagqry)) {
$flagid=$allflagids[0];
$flag_tbl="flag_".$flagid;
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$noteid\""))) {
$flagmapqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$noteid");
if (mysqli_num_rows($flagmapqry)) {
while ($flagids=mysqli_fetch_row($flagmapqry)) {
$flagid=$flagids[0];
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
}
}
if ($flagstring) $fmtnote=$fmtnote."<br>".$flagstring;
printf("
<tr>

View File

@@ -2,7 +2,7 @@
/*
blankpage.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

View File

@@ -2,7 +2,7 @@
/*
search.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/
@@ -34,7 +34,7 @@ $srchpname=$_REQUEST['srchpname'] ?? NULL;
$srchploc=$_REQUEST['srchploc'] ?? NULL;
$srchnha=$_REQUEST['srchnha'] ?? NULL;
$srchrepord=$_REQUEST['srchrepord'] ?? NULL;
$srchflags=$_REQUEST['srchflags'] ?? NULL;
$srchflags=$_POST['srchflags'] ?? [];
$target=$_REQUEST['target'] ?? NULL;
$doparts=PARTS_FUNCTIONS;
@@ -54,9 +54,20 @@ if ($print) {
framework("begin","$logname Search","Search",$print);
//var_dump($_REQUEST);
// echo "REQUEST variables: <br>";
// var_dump($_REQUEST);
// ******** begin database manipulation ********
// define the arrays
$logfromtables=[];
$mffromtables=[];
$pfromtables=[];
$logconstraints=[];
$mfconstraints=[];
$pconstraints=[];
// get the date range of lognotes
$logdateqry=mysqli_query($db,"select min(date), max(date) from lognotes");
$logdateresults=mysqli_fetch_row($logdateqry);
@@ -75,8 +86,6 @@ if ($mfmaxdate == "") $mfmaxdate = $today;
$mindate=min($logmindate, $mfmindate);
$maxdate=max($logmaxdate, $mfmaxdate);
if ($search) {
// strip whitespace from beginning and end of text fields
$srchtext=trim($srchtext);
@@ -123,13 +132,21 @@ if ($search) {
$logconstraints[]="lognotes.lognote like \"%$srchtext%\"";
}
// flags
if ($srchflags != NULL) {
foreach ($srchflags as $flagtblnum) {
$flagtblname="flag_{$flagtblnum}";
$logfromtables[]="lognotes";
$logfromtables[]=$flagtblname;
$logconstraints[]="lognotes.lognoteid={$flagtblname}.id and {$flagtblname}.target=\"lognotes\"";
if (!empty($srchflags)) {
unset($flagconstraints);
$flagcount=count($srchflags);
$logfromtables[]="lognotes";
$logfromtables[]="flagmap";
$flagconstraints[]="flagmap.lognoteid=lognotes.lognoteid and flagmap.flagid in (";
foreach ($srchflags as $flagid) {
$flagconstraints[]="\"$flagid\"";
$flagconstraints[]=",";
}
// remove final comma
array_splice($flagconstraints, -1, 1);
$flagconstraints[]=") group by flagmap.lognoteid having count(distinct flagmap.flagid)=$flagcount";
// make flagconstraints a single string so that the final implode doesn't split it
$logconstraints[]=join('', $flagconstraints);
}
// uid
if ($srchuid != "any" && $srchuid != "") {
@@ -232,11 +249,21 @@ if ($search) {
$mfconstraints[]="maintforms.mfmalfunction like \"%$srchtext%\" or (maintactions.action like \"%$srchtext%\" and maintforms.maintformid=maintactions.maintformnum)";
}
// flags
foreach ($srchflags as $flagtblnum) {
$flagtblname="flag_{$flagtblnum}";
if (!empty($srchflags)) {
unset($flagconstraints);
$flagcount=count($srchflags);
$mffromtables[]="maintforms";
$mffromtables[]=$flagtblname;
$mfconstraints[]="maintforms.maintformid={$flagtblname}.id and {$flagtblname}.target=\"maintforms\"";
$mffromtables[]="flagmap";
$flagconstraints[]="flagmap.maintformid=maintforms.maintformid and flagmap.flagid in (";
foreach ($srchflags as $thisflagid) {
$flagconstraints[]="\"$thisflagid\"";
$flagconstraints[]=",";
}
// remove final comma
array_splice($flagconstraints, -1, 1);
$flagconstraints[]=") group by flagmap.maintformid having count(distinct flagmap.flagid)=$flagcount";
// make flagconstraints a single string so that the final implode doesn't split it
$mfconstraints[]=join('', $flagconstraints);
}
// uid
if ($srchuid != "any" && $srchuid != "") {
@@ -463,27 +490,37 @@ if (!$print) {
<br><br>
<b>Flags:</b>
";
$flagslist=mysqli_query($db,"select * from flags");
$flagsperline=8;
$flagcount=1;
while ($flagcheckbox=mysqli_fetch_assoc($flagslist)) {
if ($srchflags[0]=="") $srchflags=[];
if (in_array($flagcheckbox["flagid"],$srchflags)) {
printf("<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
$flagslist = mysqli_query($db, "select * from flags");
$flagsperline = 8;
$flagcount = 1;
while ($flagcheckbox = mysqli_fetch_assoc($flagslist)) {
//if ($srchflags[0] == "") $srchflags = [];
if (in_array($flagcheckbox["flagid"], $srchflags)) {
printf(
"<input type=\"checkbox\" name=\"srchflags[]\" value=\"%s\" checked title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
$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=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],$flagcheckbox["flagcolor"],$flagcheckbox["flagname"],$flagcheckbox["flagsym"]);
$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=\"srchflags[]\" value=\"%s\" title=\"When checked, only results with this flag set will be shown\"><font color=\"%s\" title=\"%s\">%s</font>",
$flagcheckbox["flagid"],
$flagcheckbox["flagcolor"],
$flagcheckbox["flagname"],
$flagcheckbox["flagsym"]
);
}
}
if ($flagcount<$flagsperline) {
if ($flagcount < $flagsperline) {
echo "&nbsp;&nbsp;&nbsp;";
$flagcount++;
} else {
echo "<br>";
$flagcount=1;
$flagcount = 1;
}
}
echo "
@@ -637,9 +674,10 @@ if ($search) {
if ($target[0]=="") $target=[];
if (in_array("log",$target)) {
// run lognotes query and show results
if(mysqli_num_rows($logrowqry)) {
$log_num_results=mysqli_num_rows($logrowqry);
if($log_num_results) {
echo "
<b>Results from Logbook</b><br><br>
<b>Results from Logbook: $log_num_results</b><br><br>
<table border=\"1\" width=\"100%\">
<tr><th>Note ID</th><th>Date/Time</th><th>Shift</th><th>Tech</th><th>Subject</th><th>Note</th><th>References</th></tr>
";
@@ -656,20 +694,23 @@ if ($search) {
$logsubjname=dblookup($db,"subjects","subjectid","subjectname",$logtablerow['subject']);
// create links of urls in note
$logfmtnote=convertweblinks($logtablerow['lognote']);
// generate the flags string
$flagstring="";
$allflagqry=mysqli_query($db,"select flagid from flags");
while ($allflagids=mysqli_fetch_row($allflagqry)) {
$flagid=$allflagids[0];
$flag_tbl="flag_".$flagid;
if (mysqli_num_rows(mysqli_query($db,"select id from $flag_tbl where target=\"lognotes\" and id=\"$logtablerow[lognoteid]\""))) {
$flagparam=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid\""));
$flagcolor=$flagparam["flagcolor"];
$flagsym=$flagparam["flagsym"];
$flagstring=$flagstring."<font color=\"$flagcolor\">$flagsym</font>&nbsp;&nbsp;";
}
$flagqry=mysqli_query($db,"select flagid from flagmap where lognoteid=$logtablerow[lognoteid]");
while ($flagid=mysqli_fetch_row($flagqry)) {
$flagparams=mysqli_fetch_assoc(mysqli_query($db,"select * from flags where flagid=\"$flagid[0]\""));
$flagcolor=$flagparams["flagcolor"];
$flagsym=$flagparams["flagsym"];
$flagname=$flagparams["flagname"];
$flagstring=$flagstring."<font color=\"$flagcolor\" title=\"$flagname\">$flagsym</font>&nbsp;&nbsp;";
}
if ($flagstring) $logfmtnote=$logfmtnote."<br>".$flagstring;
if ($flagstring) {
$logfmtnote=$logfmtnote."<br>".$flagstring."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
} else {
$logfmtnote=$logfmtnote."<br>";
}
printf("<tr>
<td valign=\"top\"><a href=logentry.php?edit=1&noteid=%s>%s</a></td>
<td valign=\"top\">%s&nbsp;&#047;&nbsp;%s</td>
@@ -695,9 +736,10 @@ if ($search) {
if ($target[0]=="") $target=[];
if (in_array("maintform",$target)) {
// run maintforms query and show results
if(mysqli_num_rows($mfrowqry)) {
$mf_num_results=mysqli_num_rows($mfrowqry);
if($mf_num_results) {
echo "
<b>Results from Maintenance Forms</b><br><br>
<b>Results from Maintenance Forms: $mf_num_results</b><br><br>
<br><table border=\"1\" width=\"100%\">
<tr>
<th>ID</th>
@@ -758,16 +800,17 @@ if ($search) {
if ($target[0]=="") $target=[];
if (in_array("part",$target)) {
// run parts query and show results
if(mysqli_num_rows($prowqry)) {
$p_num_results=mysqli_num_rows($prowqry);
if($p_num_results) {
echo "
<b>Results from Parts</b><br><br>
<b>Results from Parts: $p_num_results</b><br><br>
<table width=\"100%\" border=\"1\" cellpadding=\"5\">
<tr>
<th>Action</th>
<th><a href=\"parts.php?sort=uid&order=$order\" title=\"Sort by $uidtext\">$uidtext</a></th>
<th><a href=\"parts.php?sort=partnum&order=$order\" title=\"Sort by Part Number\">Part Number</a></th>
<th><a href=\"parts.php?sort=sernum&order=$order\" title=\"Sort by Serial Number\">Serial Number</a></th>
<th><a href=\"parts.php?sort=partname&order=$order\" title=\"Sort by Part Name\">Part Name</a></th>
<th>$uidtext</th>
<th>Part Number</th>
<th>Serial Number</th>
<th>Part Name</th>
</tr>
";
while ($partrow=mysqli_fetch_assoc($prowqry)) {

View File

@@ -2,7 +2,7 @@
/*
settings.php
OpenLog Online Logbook
Copyright (C) 2025 Rod Wright
Copyright (C) 2026 Rod Wright
SPDX-License-Identifier: GPL-2.0
*/

554
distfiles/templates.php Normal file
View File

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

View File

@@ -41,8 +41,3 @@ fi
# ---------- version 5.2.4.4 -----------
# No changes
# --------------------------------------
# ---------- version 5.2.5 -------------
# No changes
# --------------------------------------

View File

@@ -8,11 +8,10 @@
APP_NAME="OpenLog"
DEFAULT_DB_NAME="openlog"
APP_VERSION="5.2.5"
APP_VERSION="5.3.0"
DOC_ROOT="/var/www"
INSTALL_LOC="openlog"
APACHE_CONF_DIR="/etc/apache2/conf-available"
BACKUP_DIR="openlog-previous-installation"
LANDING_PAGE="lognotes.php"
CONFIG_TABLE="configs"
CONFIG_NAME_COLUMN="confname"
@@ -202,7 +201,9 @@ then
abort_exit
else
# proceed with upgrade
mkdir -p backups
datestamp=$(date +%Y-%m-%d_%H:%M:%S)
backupdir=backups/$datestamp
mkdir -p $backupdir
operation="upgraded"
curr_dbname=$(grep dbname $install_path/db.php | head -1 | cut -d\" -f2)
@@ -216,14 +217,14 @@ then
echo "database = $curr_dbname" >> $mysql_opt_file
echo "batch" >> $mysql_opt_file
echo "disable-column-names" >> $mysql_opt_file
# back up existing database
echo "Backing up the current database to the package directory."
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > backups/$curr_dbname-$(date +%Y-%m-%d_%H:%M:%S)-backup.sql
mysqldump --defaults-extra-file=$mysql_opt_file --no-tablespaces $curr_dbname > $backupdir/$curr_dbname-$datestamp-backup.sql
# back up existing installation
echo "Backing up current installation to the package directory."
cp -R $install_path backups/$install_loc_in-`date +%Y-%m-%d_%H:%M:%S`-backup
cp -R $install_path $backupdir/$install_loc_in-$datestamp-backup
# delete all existing installation files except db.php
find $install_path/ -mindepth 1 -not -name 'db.php' -delete
@@ -267,6 +268,8 @@ then
echo ""
echo "Setting file ownership . . ."
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."
fi
else
# This was a mistake. Exit now to avoid clobbering another app.